first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
32
apps/web/modules/analytics/provider/umami/index.tsx
Normal file
32
apps/web/modules/analytics/provider/umami/index.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"use client";
|
||||
|
||||
import Script from "next/script";
|
||||
|
||||
const umamiTrackingId = process.env.NEXT_PUBLIC_UMAMI_TRACKING_ID as string;
|
||||
|
||||
export function AnalyticsScript() {
|
||||
return (
|
||||
<Script
|
||||
async
|
||||
type="text/javascript"
|
||||
data-website-id={umamiTrackingId}
|
||||
src="https://analytics.eu.umami.is/script.js"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = (event: string, data?: Record<string, unknown>) => {
|
||||
if (typeof window === "undefined" || !(window as any).umami) {
|
||||
return;
|
||||
}
|
||||
|
||||
(window as any).umami.track(event, {
|
||||
props: data,
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue