From 234aa68cb92545c51598af9a31a0b48e4df95714 Mon Sep 17 00:00:00 2001 From: Ho Duc Hieu <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 29 Dec 2023 20:41:25 +0700 Subject: [PATCH 1/3] feat: update posthog configuration --- web/utils/posthog.ts | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) 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() From 22f6caa8cd0b3a059444634b6d157c1188b610f9 Mon Sep 17 00:00:00 2001 From: Ho Duc Hieu <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 29 Dec 2023 20:52:24 +0700 Subject: [PATCH 2/3] feat: update posthog configuration --- web/utils/posthog.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/web/utils/posthog.ts b/web/utils/posthog.ts index 93b461d18..2010825da 100644 --- a/web/utils/posthog.ts +++ b/web/utils/posthog.ts @@ -33,5 +33,4 @@ function captureAppVersionAndOS() { posthog.capture(AnalyticsEvent.Ping, properties) } -// Example usage captureAppVersionAndOS() From 7d9b3e26a60fe884916207029da26769a8f01563 Mon Sep 17 00:00:00 2001 From: Ho Duc Hieu <150573299+hieu-jan@users.noreply.github.com> Date: Fri, 29 Dec 2023 21:32:16 +0700 Subject: [PATCH 3/3] fix: change properties name --- web/utils/posthog.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/utils/posthog.ts b/web/utils/posthog.ts index 2010825da..c334decbe 100644 --- a/web/utils/posthog.ts +++ b/web/utils/posthog.ts @@ -27,7 +27,7 @@ function getOperatingSystem(): string { // Function to capture app version and operating system function captureAppVersionAndOS() { const properties: Properties = { - JanVersion: VERSION, + appVersion: VERSION, userOperatingSystem: getOperatingSystem(), } posthog.capture(AnalyticsEvent.Ping, properties)