first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
17
apps/web/modules/analytics/provider/custom/index.tsx
Normal file
17
apps/web/modules/analytics/provider/custom/index.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use client";
|
||||
|
||||
export function AnalyticsScript() {
|
||||
// return your script here
|
||||
return null;
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = (event: string, data: Record<string, unknown>) => {
|
||||
// call your analytics service to track a custom event here
|
||||
console.info("tracking event", event, data);
|
||||
};
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
17
apps/web/modules/analytics/provider/google/index.tsx
Normal file
17
apps/web/modules/analytics/provider/google/index.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use client";
|
||||
|
||||
import { GoogleAnalytics, sendGAEvent } from "@next/third-parties/google";
|
||||
|
||||
const googleTagId = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID as string;
|
||||
|
||||
export function AnalyticsScript() {
|
||||
return <GoogleAnalytics gaId={googleTagId} />;
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = sendGAEvent;
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
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,
|
||||
};
|
||||
}
|
||||
33
apps/web/modules/analytics/provider/pirsch/index.tsx
Normal file
33
apps/web/modules/analytics/provider/pirsch/index.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
"use client";
|
||||
|
||||
import Script from "next/script";
|
||||
|
||||
const pirschCode = process.env.NEXT_PUBLIC_PIRSCH_CODE as string;
|
||||
|
||||
export function AnalyticsScript() {
|
||||
return (
|
||||
<Script
|
||||
defer
|
||||
type="text/javascript"
|
||||
src="https://api.pirsch.io/pirsch-extended.js"
|
||||
id="pirschextendedjs"
|
||||
data-code={pirschCode}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = (event: string, data?: Record<string, unknown>) => {
|
||||
if (typeof window === "undefined" || !(window as any).pirsch) {
|
||||
return;
|
||||
}
|
||||
|
||||
(window as any).pirsch(event, {
|
||||
meta: data,
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
32
apps/web/modules/analytics/provider/plausible/index.tsx
Normal file
32
apps/web/modules/analytics/provider/plausible/index.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"use client";
|
||||
|
||||
import Script from "next/script";
|
||||
|
||||
const plausibleUrl = process.env.NEXT_PUBLIC_PLAUSIBLE_URL as string;
|
||||
|
||||
export function AnalyticsScript() {
|
||||
return (
|
||||
<Script
|
||||
defer
|
||||
type="text/javascript"
|
||||
data-domain={plausibleUrl}
|
||||
src="https://plausible.io/js/script.js"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = (event: string, data?: Record<string, unknown>) => {
|
||||
if (typeof window === "undefined" || !(window as any).plausible) {
|
||||
return;
|
||||
}
|
||||
|
||||
(window as any).plausible(event, {
|
||||
props: data,
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
35
apps/web/modules/analytics/provider/posthog/index.tsx
Normal file
35
apps/web/modules/analytics/provider/posthog/index.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"use client";
|
||||
|
||||
// @ts-expect-error package is not installed per default
|
||||
import posthog from "posthog-js";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const posthogKey = process.env.NEXT_PUBLIC_POSTHOG_KEY as string;
|
||||
|
||||
export function AnalyticsScript() {
|
||||
useEffect(() => {
|
||||
if (!posthogKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
posthog.init(posthogKey, {
|
||||
// use eu.i.posthog.com for european users
|
||||
api_host: "https://i.posthog.com",
|
||||
person_profiles: "identified_only", // or 'always' to create profiles for anonymous users as well
|
||||
});
|
||||
}, []);
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = (event: string, data?: Record<string, unknown>) => {
|
||||
if (!posthogKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
posthog.capture(event, data);
|
||||
};
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
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,
|
||||
};
|
||||
}
|
||||
20
apps/web/modules/analytics/provider/vercel/index.tsx
Normal file
20
apps/web/modules/analytics/provider/vercel/index.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
"use client";
|
||||
|
||||
// @ts-expect-error package is not installed per default
|
||||
import { track } from "@vercel/analytics";
|
||||
// @ts-expect-error package is not installed per default
|
||||
import { Analytics } from "@vercel/analytics/react";
|
||||
|
||||
export function AnalyticsScript() {
|
||||
return <Analytics />;
|
||||
}
|
||||
|
||||
export function useAnalytics() {
|
||||
const trackEvent = (event: string, data?: Record<string, unknown>) => {
|
||||
track(event, data);
|
||||
};
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue