first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
29
apps/web/modules/analytics/provider/mixpanel/index.tsx
Normal file
29
apps/web/modules/analytics/provider/mixpanel/index.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"use client";
|
||||
|
||||
// @ts-expect-error package is not installed per default
|
||||
import mixpanel from "mixpanel-browser";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const mixpanelToken = process.env.NEXT_PUBLIC_MIXPANEL_TOKEN as string;
|
||||
|
||||
export function AnalyticsScript() {
|
||||
useEffect(() => {
|
||||
mixpanel.init(mixpanelToken, {
|
||||
debug: true,
|
||||
track_pageview: true,
|
||||
persistence: "localStorage",
|
||||
});
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = (event: string, data?: Record<string, unknown>) => {
|
||||
mixpanel.track(event, data);
|
||||
};
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue