-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
46 additions
and
40 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client'; | ||
|
||
import { usePathname } from 'lib/i18n/navigation'; | ||
import { init } from 'lib/utils/analytics'; | ||
import Script from 'next/script'; | ||
import { useEffect } from 'react'; | ||
|
||
const Analytics = () => { | ||
const path = usePathname(); | ||
|
||
// Mixpanel | ||
useEffect(() => { | ||
init(); | ||
// track('Viewed Page', { path }); | ||
}, []); | ||
|
||
// SimpleAnalytics | ||
return ( | ||
<> | ||
<Script> | ||
{ | ||
'window.sa_event=window.sa_event||function(){var a=[].slice.call(arguments);window.sa_event.q?window.sa_event.q.push(a):window.sa_event.q=[a]};' | ||
} | ||
</Script> | ||
<Script async defer src="/assets/js/sa-v11.js" /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Analytics; |
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
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 |
---|---|---|
@@ -1,17 +1,16 @@ | ||
import mixpanel from 'mixpanel-browser'; | ||
// import mixpanel from 'mixpanel'; | ||
|
||
export const init = () => { | ||
if (typeof window === 'undefined') return; | ||
|
||
if (process.env.NEXT_PUBLIC_MIXPANEL_API_KEY) { | ||
mixpanel?.init(process.env.NEXT_PUBLIC_MIXPANEL_API_KEY, { ip: false }); | ||
} | ||
// if (process.env.NEXT_PUBLIC_MIXPANEL_API_KEY) { | ||
// mixpanel.init(process.env.NEXT_PUBLIC_MIXPANEL_API_KEY, { geolocate: false }); | ||
// } | ||
}; | ||
|
||
export const track = (eventName: string, eventProperties: any) => { | ||
// if (process.env.NEXT_PUBLIC_MIXPANEL_API_KEY) { | ||
// mixpanel.track(eventName, eventProperties); | ||
// } | ||
if (typeof window === 'undefined') return; | ||
|
||
if (process.env.NEXT_PUBLIC_MIXPANEL_API_KEY) { | ||
mixpanel?.track(eventName, eventProperties); | ||
} | ||
(window as any)?.sa_event(eventName, eventProperties); | ||
}; |
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