The best way to control Claude Code, Codex and more from any computer or phone

main
astro 30 lines 2.91 KB
Raw
1 ---
2 /**
3 * PostHog Cloud (US region) browser SDK loader, fronted by our reverse-proxy
4 * Worker at `analytics.alchemy.run` (see `stacks/src/otel/Ingester.ts`). Routing
5 * the SDK through a first-party domain hides the PostHog hostname from
6 * clients, defeats most ad-blocker rules, and keeps event traffic on
7 * `alchemy.run`.
8 *
9 * The project API key is a public `phc_…` value provisioned by `stacks/src/otel.ts`
10 * and exposed to the build via `PUBLIC_POSTHOG_KEY`. Astro auto-inlines any
11 * `PUBLIC_*` env var into `import.meta.env`. We render nothing when the key is
12 * missing or in dev so PR previews / local builds don't ship events.
13 */
14 const projectKey = import.meta.env.PUBLIC_POSTHOG_KEY as string | undefined;
15 const enabled = import.meta.env.PROD && Boolean(projectKey);
16 ---
17
18 {enabled && (
19 <script is:inline define:vars={{ projectKey }}>
20 // oxlint-disable-next-line no-unused-expressions, number-arg-out-of-range -- PostHog's vendor snippet; its stub `toString` takes a flag, not a radix
21 !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug getPageViewId captureTraceFeedback captureTraceMetric".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
22 posthog.init(projectKey, {
23 api_host: "https://analytics.alchemy.run",
24 ui_host: "https://us.posthog.com",
25 defaults: "2025-05-24",
26 person_profiles: "identified_only",
27 capture_pageview: "history_change"
28 });
29 </script>
30 )}