Skip to content

Commit

Permalink
Fix sendGAEvent function (for real?) (#62192)
Browse files Browse the repository at this point in the history
The recently merged PR - #62065,
doesn't seem to fix the issue. As per the comment this seems to be
related to `dataLayer` that does not like working with Arrays, but works
with [arguments
object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments).
Also, when using window.gtag(...) an Arguments() is pushed instead of
Array().

Fixes #61703
  • Loading branch information
asobirov authored Feb 17, 2024
1 parent da616e5 commit 4fa08de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/third-parties/src/google/ga.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export function GoogleAnalytics(props: GAParams) {
)
}

export const sendGAEvent = (...args: Object[]) => {
export function sendGAEvent(..._args: Object[]) {
if (currDataLayerName === undefined) {
console.warn(`@next/third-parties: GA has not been initialized`)
return
}

if (window[currDataLayerName]) {
window[currDataLayerName].push(args)
window[currDataLayerName].push(arguments)
} else {
console.warn(
`@next/third-parties: GA dataLayer ${currDataLayerName} does not exist`
Expand Down

0 comments on commit 4fa08de

Please sign in to comment.