Skip to content

Commit

Permalink
Only do analytics in a browser environment
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed May 1, 2024
1 parent d70f892 commit 6350a53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/utils/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import mixpanel from 'mixpanel-browser';

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 });
}
};

export const track = (eventName: string, eventProperties: any) => {
if (typeof window === 'undefined') return;

if (process.env.NEXT_PUBLIC_MIXPANEL_API_KEY) {
mixpanel?.track(eventName, eventProperties);
}
Expand Down

0 comments on commit 6350a53

Please sign in to comment.