diff --git a/web/utils/posthog.ts b/web/utils/posthog.ts index 7d958166f..93b461d18 100644 --- a/web/utils/posthog.ts +++ b/web/utils/posthog.ts @@ -1,15 +1,37 @@ import posthog, { Properties } from 'posthog-js' +// Initialize PostHog posthog.init(ANALYTICS_ID, { api_host: ANALYTICS_HOST, autocapture: false, + capture_pageview: false, + capture_pageleave: false, + rageclick: false, }) - +// Export the PostHog instance export const instance = posthog -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const trackEvent = (name: string, properties?: Properties) => { - posthog.capture(name, properties) +// Enum for Analytics Events +export enum AnalyticsEvent { + Ping = 'Ping', } -export enum AnalyticsEvent {} +// Function to determine the operating system +function getOperatingSystem(): string { + if (isMac) return 'MacOS' + if (isWindows) return 'Windows' + if (isLinux) return 'Linux' + return 'Unknown' +} + +// Function to capture app version and operating system +function captureAppVersionAndOS() { + const properties: Properties = { + JanVersion: VERSION, + userOperatingSystem: getOperatingSystem(), + } + posthog.capture(AnalyticsEvent.Ping, properties) +} + +// Example usage +captureAppVersionAndOS()