-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathposthog.config.ts
More file actions
33 lines (27 loc) · 1.5 KB
/
Copy pathposthog.config.ts
File metadata and controls
33 lines (27 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/// <reference types="vite/client" />
import type { PostHogConfig } from 'posthog-js'
function isEnvFlagEnabled(value: string | undefined): boolean {
if (value == null)
return false
return /^(?:1|true|t|yes|y|on)$/i.test(value.trim())
}
// For Release workflows set `VITE_ENABLE_POSTHOG=true`.
export const POSTHOG_ENABLED = isEnvFlagEnabled(import.meta.env.VITE_ENABLE_POSTHOG)
// Single PostHog project for every AIRI surface (web / desktop / mobile).
// Platforms are told apart by the `app_surface` super property set at init, not
// by routing to separate per-platform projects.
export const POSTHOG_PROJECT_KEY
= import.meta.env.VITE_POSTHOG_PROJECT_KEY
?? 'phc_pzjziJjrVZpa9SqnQqq0QEKvkmuCPH7GDTA6TbRTEf9' // cspell:disable-line
export const DEFAULT_POSTHOG_CONFIG = {
api_host: 'https://t.airi.build',
person_profiles: 'identified_only', // or 'always' to create profiles for anonymous users as well
// Without this, posthog-js only fires `$pageview` on the initial page load.
// Every AIRI surface is an SPA (vue-router / VitePress client routing), so
// route changes would be invisible in PostHog. The '2025-05-24' defaults
// preset switches `capture_pageview` to 'history_change' — and because
// `capture_pageleave` defaults to 'if_capture_pageview', every surface
// that spreads this config also starts emitting `$pageleave`. That is
// intentional: pageleave is what makes route-level dwell time queryable.
defaults: '2025-05-24',
} as const satisfies Partial<PostHogConfig>