diff --git a/README.md b/README.md index 3ae19848..dd575e1c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ pnpm fix:format # auto-format ``` Each app also works on its own: `cd apps/docs && pnpm dev`. Copy `apps//.env.example` to -`apps//.env` for Algolia / PostHog keys (both are optional — search falls back to local search). +`apps//.env` to configure optional Algolia credentials; without them, search falls back to local search. ## Repository layout diff --git a/apps/developer-docs/.env.example b/apps/developer-docs/.env.example index 16aa059b..87ff492a 100644 --- a/apps/developer-docs/.env.example +++ b/apps/developer-docs/.env.example @@ -1,6 +1,3 @@ -# PostHog Analytics -VITE_POSTHOG_KEY= - # Algolia Search VITE_ALGOLIA_APP_ID= VITE_ALGOLIA_API_KEY= diff --git a/apps/developer-docs/docs/.vitepress/config.mts b/apps/developer-docs/docs/.vitepress/config.mts index 3b162af7..5a74acc0 100644 --- a/apps/developer-docs/docs/.vitepress/config.mts +++ b/apps/developer-docs/docs/.vitepress/config.mts @@ -20,7 +20,6 @@ function loadEnvVar(key: string): string | undefined { } } -const posthogKey = loadEnvVar("VITE_POSTHOG_KEY"); const algoliaAppId = loadEnvVar("VITE_ALGOLIA_APP_ID"); const algoliaApiKey = loadEnvVar("VITE_ALGOLIA_API_KEY"); const algoliaIndexName = loadEnvVar("VITE_ALGOLIA_INDEX_NAME"); @@ -38,19 +37,6 @@ const searchConfig = } : { provider: "local" as const }; -const posthogHead: HeadConfig[] = posthogKey - ? [ - [ - "script", - {}, - ` - !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.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 void; - posthog?: { - opt_in_capturing?: () => void; - opt_out_capturing?: () => void; - }; } } @@ -31,22 +27,6 @@ function grantConsent() { analytics_storage: "granted", }); } - - // PostHog (may not be loaded if VITE_POSTHOG_KEY is unset) - if (window.posthog?.opt_in_capturing) { - window.posthog.opt_in_capturing(); - } -} - -function denyConsent() { - if (typeof window === "undefined") return; - - // Google Analytics — consent stays denied by default, no update needed - - // PostHog (may not be loaded if VITE_POSTHOG_KEY is unset) - if (window.posthog?.opt_out_capturing) { - window.posthog.opt_out_capturing(); - } } function accept() { @@ -61,7 +41,6 @@ function decline() { try { localStorage.setItem(STORAGE_KEY, "denied"); } catch {} - denyConsent(); showBanner.value = false; } @@ -69,9 +48,7 @@ onMounted(() => { const consent = getConsent(); if (consent === "granted") { grantConsent(); - } else if (consent === "denied") { - denyConsent(); - } else { + } else if (consent !== "denied") { showBanner.value = true; } });