Skip to content

Commit

Permalink
feat: update posthog configuration (janhq#1258)
Browse files Browse the repository at this point in the history
feat: update posthog configuration
  • Loading branch information
0xHieu01 authored Dec 29, 2023
2 parents c621024 + 7d9b3e2 commit 1e8e06f
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions web/utils/posthog.ts
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()

0 comments on commit 1e8e06f

Please sign in to comment.