Summary
Review and improve PostHog telemetry for the Authsome library/daemon so registered principals and identities are reliably tracked, then create an equivalent analytics dashboard in PostHog.
Current state
Client: src/authsome/server/analytics.py
- Initialized in
src/authsome/server/app.py lifespan when settings.analytics_enabled is true.
- Enabled when:
AUTHSOME_ENV=prod + AUTHSOME_POSTHOG_API_KEY set + AUTHSOME_DO_NOT_TRACK is false.
- Compose defaults
AUTHSOME_DO_NOT_TRACK=1 — telemetry off in Docker quick start.
Events captured today (grep capture_event):
| Event |
Source |
distinct_id |
account_registered |
routes/ui.py |
session email |
account_logged_in |
routes/ui.py |
session email |
account_logged_out |
routes/ui.py |
session email |
identity_claimed |
routes/ui.py |
pending identity handle |
identity registered |
routes/identities.py |
identity handle |
auth session completed / auth session failed |
routes/auth.py |
session identity or principal_id |
provider registered / provider deleted / provider configuration updated |
routes/providers.py |
identity handle |
connection logout / connection revoked / connection made global / global connection removed / credentials exported |
routes/connections.py |
identity or principal |
credentials resolved |
routes/proxy.py |
identity handle |
Gaps
- No explicit "principal registered" lifecycle event beyond
account_registered (email-based distinct_id).
- Identity registration fires
identity registered but properties may not include stable principal linkage in all paths.
- distinct_id inconsistency: mix of email, identity handle, and fallback
"account-ui" — hard to build unified principal/identity funnels.
- No PostHog dashboard documented or checked into the repo for monitoring adoption (registered principals, claimed identities, active connections).
- Library/CLI usage (proxy runs, credential resolves) may be under-represented vs UI events.
Proposed work
Relevant files
src/authsome/server/analytics.py
src/authsome/server/config.py — analytics_enabled, posthog_api_key, posthog_host
src/authsome/server/routes/ui.py, identities.py, auth.py, connections.py, providers.py, proxy.py
docs/guides/self-hosting.md
Acceptance criteria
- Principal and identity registration/claim events are queryable in PostHog with stable properties.
- A PostHog dashboard exists (link or export config in repo/docs).
- Event naming and distinct_id conventions are documented.
- No PII beyond what is necessary (email as distinct_id — evaluate privacy implications).
Summary
Review and improve PostHog telemetry for the Authsome library/daemon so registered principals and identities are reliably tracked, then create an equivalent analytics dashboard in PostHog.
Current state
Client:
src/authsome/server/analytics.pysrc/authsome/server/app.pylifespan whensettings.analytics_enabledis true.AUTHSOME_ENV=prod+AUTHSOME_POSTHOG_API_KEYset +AUTHSOME_DO_NOT_TRACKis false.AUTHSOME_DO_NOT_TRACK=1— telemetry off in Docker quick start.Events captured today (grep
capture_event):account_registeredroutes/ui.pyaccount_logged_inroutes/ui.pyaccount_logged_outroutes/ui.pyidentity_claimedroutes/ui.pyidentity registeredroutes/identities.pyauth session completed/auth session failedroutes/auth.pyprovider registered/provider deleted/provider configuration updatedroutes/providers.pyconnection logout/connection revoked/connection made global/global connection removed/credentials exportedroutes/connections.pycredentials resolvedroutes/proxy.pyGaps
account_registered(email-based distinct_id).identity registeredbut properties may not include stable principal linkage in all paths."account-ui"— hard to build unified principal/identity funnels.Proposed work
capture_eventcall sites; normalize event names (snake_case vs spaces inconsistency today).principal_id,identity_handle, anddidwhere available.distinct_idstrategy (e.g. principal_id for account events, handle for agent events) and use PostHogidentifyproperties for cross-linking.AUTHSOME_POSTHOG_API_KEY,AUTHSOME_DO_NOT_TRACK=0).Relevant files
src/authsome/server/analytics.pysrc/authsome/server/config.py—analytics_enabled,posthog_api_key,posthog_hostsrc/authsome/server/routes/ui.py,identities.py,auth.py,connections.py,providers.py,proxy.pydocs/guides/self-hosting.mdAcceptance criteria