GDPR-compliant product analytics, feature flags, and user identification fully bridged to your web layer. Track events, identify users, run experiments, and manage consent from your web app usingDocumentation Index
Fetch the complete documentation index at: https://setup.despia.com/llms.txt
Use this file to discover all available pages before exploring further.
despia(), with no native code and no native SDK to configure.
Installation
- Bundle
- CDN
PostHog and Despia setup
Create a PostHog project, then connect it to Despia. The steps go in order, each one feeds the next.Create a PostHog account
Go to app.posthog.com and sign up, or sign in with an existing account. PostHog is free up to 1 million events per month, so account creation does not block early development.
Get your API key
In PostHog, go to Project Settings > Project API keys and copy the project API key. It starts with
phc_. This is the only credential Despia needs.Enable PostHog in the Despia Editor
Open the Despia Editor and go to App > Settings > Integrations > PostHog. Toggle the integration on, then paste in:
- API Key - the
phc_...key from the previous step - Host - leave blank to use
https://app.posthog.com, or set a custom host for self-hosted PostHog instances
How it works
Despia initializes the native PostHog SDK at app start using your API key. Your web app does not loadposthog-js - the native layer owns the SDK entirely. You interact through three things.
posthog:// commands (JS → native): fire events, identify users, manage consent using despia("posthog://...").
despia.postHog* globals (native → JS): four variables injected before your code runs and kept live by the native layer. Read them synchronously at any point - no scheme call, no callback, no await.
window.onPostHogEvent(evt) (native → JS, optional): lifecycle pushes when identity, flags, or opt-out status changes. Define it to react to these changes without polling the globals.
Reference
All schemes, parameters, globals, callback payloads, and encoding rules.
PostHog Dashboard
Configure feature flags, funnels, and session recordings.
Platform gating
Theposthog:// schemes and the despia.postHog* globals only exist inside the Despia runtime. Gate every call and every global read.
Capture an event
$current_url and $pathname from the WebView’s current route to every capture and screen call. Your own properties win on any key conflict.
Identify a user
Callposthog://identify as soon as a user logs in. All subsequent events link to their identity until posthog://reset is called on logout. After identify fires, despia.postHogDistinctId and despia.postHogSessionId update in place and window.onPostHogEvent fires with { type: "identity", distinctId, sessionId }.
Feature flags
All evaluated flag values are available synchronously indespia.postHogFlags. No scheme call needed.
GDPR consent
PostHog tracking requires explicit user consent under GDPR. Callposthog://opt_out when the user declines and posthog://opt_in when they accept. PostHog enforces the cutoff at the SDK level - events fired after opt_out are dropped before they reach PostHog servers. despia.postHogOptedOut updates in place when either scheme fires.
Resources
NPM Package
despia-native
PostHog Dashboard
Configure feature flags, funnels, and session recordings
PostHog Docs
Feature flags, person properties, and group analytics