Skip to content

Commit 7ce635f

Browse files
authored
VAP10-38: PostHog - Enable cross domain tracking
1 parent 04d0ef4 commit 7ce635f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

fern/custom.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,33 @@ function initializeReo() {
7070
document.head.appendChild(reoScript);
7171
}
7272

73+
function configurePostHog() {
74+
if (isLocalhost) {
75+
console.log('[custom.js] Skipping PostHog configuration on localhost');
76+
return;
77+
}
78+
79+
// Wait for PostHog to be initialized by Fern
80+
const checkPostHog = setInterval(() => {
81+
if (typeof window.posthog !== 'undefined') {
82+
clearInterval(checkPostHog);
83+
84+
// Configure cross-domain tracking
85+
window.posthog.set_config({
86+
cross_subdomain_cookie: true,
87+
cross_domain: '.vapi.ai',
88+
persistence: 'localStorage+cookie'
89+
});
90+
91+
}
92+
}, 100);
93+
94+
}
95+
7396
function initializeAll() {
7497
initializeHockeyStack();
7598
initializeReo();
99+
configurePostHog();
76100
if (ENABLE_VOICE_WIDGET) {
77101
injectVapiWidget();
78102
}

0 commit comments

Comments
 (0)