Skip to content

feat(frontend/analytics): add PostHog with session recording + typed events#69

Merged
LuD1161 merged 11 commits into
betterclever/auth-setupfrom
posthog_integration
Nov 7, 2025
Merged

feat(frontend/analytics): add PostHog with session recording + typed events#69
LuD1161 merged 11 commits into
betterclever/auth-setupfrom
posthog_integration

Conversation

@LuD1161
Copy link
Copy Markdown
Contributor

@LuD1161 LuD1161 commented Nov 5, 2025

This PR integrates PostHog analytics in the frontend and adds a small, typed event layer.

What’s included

  • PostHogProvider mounted with env guards (no-op without keys)
  • Session recording enabled (maskAllInputs=true, maskAllText=false)
  • SPA pageview capture via router listener
  • Clerk → PostHog bridge (identify + organization group; reset on sign-out)
  • Typed track() helper using zod + event map
    • Events instrumented: list viewed, builder loaded, workflow created/saved, run started, node added, secret created/deleted
  • Docs: docs/analytics.md and .env.example
  • Cleanup: remove duplicate wizard artifact (src/config/env.ts)

Environment

  • VITE_PUBLIC_POSTHOG_KEY
  • VITE_PUBLIC_POSTHOG_HOST

Privacy & safety

  • Respects Do Not Track (DNT)
  • Masks all form inputs; leaves text visible to make recordings useful
  • All analytics gated on env presence; local clones work without configuration

Validation steps

  • Set env vars and run frontend
  • Sign in via Clerk, navigate around
    • Live Events: $pageview and UI events show up
    • Session recordings appear, inputs masked
    • Identify shows distinct_id; organization grouped when applicable

Follow-ups (separate PR)

  • Expand event taxonomy for builder interactions and errors
  • Optional server-side analytics (posthog-node) for trusted events

…PA pageviews, and Clerk identify

- Mount PostHogProvider with guards in src/main.tsx
- Enable autocapture + exception capture; respect DNT
- Enable session recording (maskAllInputs=true, maskAllText=false)
- Capture SPA  via AnalyticsRouterListener
- Identify users and group by organization via PostHogClerkBridge; reset on sign-out
- Remove duplicate wizard artifact src/config/env.ts
- Add docs/analytics.md and frontend/.env.example

Env: VITE_PUBLIC_POSTHOG_KEY, VITE_PUBLIC_POSTHOG_HOST
…UI interactions

- Add zod-validated analytics helper (track) and event map
- Capture: list viewed, builder loaded, create/save, run started, node added
- Instrument Secrets Manager create/delete events
- Update analytics docs with taxonomy
@LuD1161
Copy link
Copy Markdown
Contributor Author

LuD1161 commented Nov 5, 2025

Solves for #68

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread frontend/src/config/env.ts
Comment thread frontend/src/features/analytics/events.ts
@LuD1161 LuD1161 merged commit cb72e2f into betterclever/auth-setup Nov 7, 2025
1 check failed
@LuD1161 LuD1161 deleted the posthog_integration branch November 7, 2025 05:22
@LuD1161 LuD1161 restored the posthog_integration branch November 7, 2025 05:26
LuD1161 added a commit that referenced this pull request Nov 7, 2025
Reverts #69 so we can land auth stack without the PostHog session recording changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant