-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update posthog configuration (janhq#1258)
feat: update posthog configuration
- Loading branch information
Showing
1 changed file
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
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', | ||
} | ||
|
||
// 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 = { | ||
appVersion: VERSION, | ||
userOperatingSystem: getOperatingSystem(), | ||
} | ||
posthog.capture(AnalyticsEvent.Ping, properties) | ||
} | ||
|
||
export enum AnalyticsEvent {} | ||
captureAppVersionAndOS() |