Skip to content

Commit

Permalink
fix: posthog capture app info
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Aug 2, 2024
1 parent 9933463 commit 8cf7ae2
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/renderer/src/initialize/posthog.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { env } from "@env"
import { getMe } from "@renderer/atoms/user"
import type { CaptureOptions, Properties } from "posthog-js"

declare global {
interface Window {

posthog?: typeof import("posthog-js").default
}
}
Expand All @@ -16,7 +16,27 @@ export const initPostHog = async () => {
person_profiles: "identified_only",
})

window.posthog = posthog
const { capture } = posthog
// @ts-expect-error
window.posthog = {
...posthog,
capture(
event_name: string,
properties?: Properties | null,
options?: CaptureOptions,
) {
return capture.apply(posthog, [
event_name,
{
...properties,
build: ELECTRON ? "electron" : "web",
version: APP_VERSION,
hash: GIT_COMMIT_SHA,
},
options,
] as const)
},
}

const user = getMe()
if (user) {
Expand Down

0 comments on commit 8cf7ae2

Please sign in to comment.