Skip to content

Commit

Permalink
chore: create mock gtag function for dev env
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Sales committed Nov 2, 2022
1 parent d3ee8a8 commit 8f237ce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
20 changes: 8 additions & 12 deletions app/components/share-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ export default function ShareSection() {
});
}

if (gtag) {
gtag('event', 'images_generated', {
player: stickerData.player.id,
phrase: stickerData.phrase.id,
});
}
gtag('event', 'images_generated', {
player: stickerData.player.id,
phrase: stickerData.phrase.id,
});

setFiles(files);
setLoading(false);
Expand Down Expand Up @@ -104,12 +102,10 @@ export default function ShareSection() {
link.click();
link.remove();

if (gtag) {
gtag('event', 'shared_image', {
device: 'desktop',
type,
});
}
gtag('event', 'shared_image', {
device: 'desktop',
type,
});
}
}

Expand Down
12 changes: 4 additions & 8 deletions app/components/social-media-buttons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ export default function SocialMediaAuth() {

setStickerData((prevValue) => ({ ...prevValue, user }));

if (gtag) {
gtag('event', 'login', {
method: result.providerId,
});
}
gtag('event', 'login', {
method: result.providerId,
});
}
})
.catch((e) => {
if (gtag) {
gtag('event', 'login_error', e);
}
gtag('event', 'login_error', e);
});
}, [setStickerData]);

Expand Down
12 changes: 12 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ export default function RootLayout({
/>
</>
)}
{process.env.NODE_ENV !== 'production' && (
<>
{/* eslint-disable-next-line @next/next/no-before-interactive-script-outside-document */}
<Script
id="analytics-provider-init"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `function gtag(){}`,
}}
/>
</>
)}
</head>
<body className="overflow-x-hidden">
<Header />
Expand Down

1 comment on commit 8f237ce

@vercel
Copy link

@vercel vercel bot commented on 8f237ce Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.