2023-10-30 06:04:53 +00:00
|
|
|
import { dev } from '$app/environment';
|
|
|
|
|
import posthog from 'posthog-js';
|
|
|
|
|
|
2024-04-07 22:01:36 +01:00
|
|
|
export const capturePosthogEvent = (event: string, properties?: Record<string, unknown>): void => {
|
2023-10-30 06:04:53 +00:00
|
|
|
if (dev) return;
|
|
|
|
|
|
|
|
|
|
posthog.capture(event, properties);
|
|
|
|
|
};
|
|
|
|
|
|
2024-04-07 22:01:36 +01:00
|
|
|
export const identifyPosthogUser = (id: string, properties?: Record<string, unknown>): void => {
|
2023-10-30 06:04:53 +00:00
|
|
|
if (dev) return;
|
|
|
|
|
|
|
|
|
|
posthog.identify(id, properties);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const initPosthog = (): void => {
|
|
|
|
|
if (dev) return;
|
|
|
|
|
|
|
|
|
|
posthog.init('phc_JfdHOZ6v0cVlGELBYx1Tmoen2nxNOrAzvgvrPA6Ksov', {
|
|
|
|
|
api_host: 'https://eu.posthog.com'
|
|
|
|
|
});
|
|
|
|
|
};
|