-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gtag): 🚀 add simple gtag based on env key (#78)
* feat(gtag): 🚀 add simple gtag based on env key CLOSES #74 * refactor(gtag): 🔍 add nprogress and updated gtag implementation * refactor(gtag): 🔍 removed initial track event Co-authored-by: Maren Osnabrug <[email protected]> Co-authored-by: MitchelvanBever <[email protected]>
- Loading branch information
1 parent
3936075
commit 6205b7f
Showing
10 changed files
with
305 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useEffect } from 'react'; | ||
|
||
/** | ||
* Detect user agent and add `data-ios` attribute to document if iOS. | ||
*/ | ||
export const UserAgent = () => { | ||
useEffect(() => { | ||
// Browser only | ||
if (typeof window !== 'undefined') { | ||
const ua = navigator?.userAgent?.toString(); | ||
if (/(iPhone|iPad)/.test(ua)) { | ||
document.documentElement.setAttribute('data-ios', ''); | ||
} | ||
} | ||
}, []); | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './common/Image'; | ||
export * from './common/Providers'; | ||
export * from './common/UserAgent'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
declare interface GtagWindow extends Window { | ||
gtag: any; | ||
} | ||
declare const window: GtagWindow; | ||
|
||
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages | ||
export const pageview = (url: string) => { | ||
window.gtag('config', process.env.NEXT_PUBLIC_GTM, { | ||
page_path: url, | ||
}); | ||
}; | ||
|
||
export const track = (data: any) => { | ||
try { | ||
window.gtag(data); | ||
} catch (e) {} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './test-utils'; | ||
export * from './sentry'; | ||
export * from './gtag'; | ||
export * from './modifyResponsiveValue'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6205b7f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: