Merge pull request #828 from elammertsma/dev

Added PostHog metrics
This commit is contained in:
Rohan Verma 2026-02-20 12:23:15 -08:00 committed by GitHub
commit dc19b43967
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View file

@ -26,12 +26,12 @@ export function PostHogIdentify() {
// Only identify if this is a new user or different from previous
if (previousUserIdRef.current !== userId) {
identifyUser(userId, {
email: user.email,
// Add any other user properties you want to track
is_superuser: user.is_superuser,
is_verified: user.is_verified,
});
identifyUser(userId, {
email: user.email,
name: user.display_name,
is_superuser: user.is_superuser,
is_verified: user.is_verified,
});
previousUserIdRef.current = userId;
}
}

View file

@ -12,6 +12,15 @@ if (process.env.NEXT_PUBLIC_POSTHOG_KEY) {
capture_pageview: "history_change",
// Enable session recording
capture_pageleave: true,
before_send: (event) => {
if (event.properties) {
event.properties.$set = {
...event.properties.$set,
last_seen_at: new Date().toISOString(),
};
}
return event;
},
loaded: (posthog) => {
// Expose PostHog to window for console access and toolbar
if (typeof window !== "undefined") {