USRSE / USRSE/usrse.github.io

feat(infra): integrate PostHog for feature flags and analytics

Open
#1,923 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
33
Forks
104
Avg merge
12h 3m
Merged PRs (30d)
10

Description

Summary

Add PostHog as the feature flag and product analytics platform. Enables gradual rollout of the membership system, instant kill switches for auth, user-targeted beta access, and usage analytics — all in one open-source tool.

Requirements

Integration
  • Install posthog-js and posthog-js/react
  • Initialize PostHog provider in App.tsx (wrap router)
  • Configure respect_dnt: true for Do Not Track compliance
  • Environment variable for PostHog project key (VITE_POSTHOG_KEY)
  • Disable in development by default
Feature Flags
  • membership_enabled — master switch for the entire auth/profile system
  • registration_open — controls whether new users can sign up
  • admin_dashboard — gates access to the admin panel
  • profile_public — controls whether member profiles are publicly visible
  • Create a useFlag(name) hook wrapping PostHog's useFeatureFlagEnabled
Analytics Events (initial set)
  • Page views (automatic via PostHog)
  • user_signed_up — new member registration
  • user_signed_in — sign-in event
  • profile_updated — member edited their profile
  • job_viewed — clicked a job listing
  • group_joined — joined a working/affinity group
Privacy
  • Add PostHog to the site's privacy/cookie notice
  • Respect Do Not Track browser setting
  • No PII in event properties (use anonymous IDs until user opts in)
  • Document self-hosting option for future institutional compliance needs

Context

Parent issue: #1916
Should be integrated alongside issue #1918 (auth) since feature flags are most valuable during the auth rollout. PostHog's free tier (1M events/month) is sufficient for a 4,000-member community.

Implementation Notes

  • Use PostHog Cloud initially; document self-hosting path for future if needed
  • PostHog React SDK provides PostHogProvider, useFeatureFlagEnabled, and usePostHog hooks
  • Feature flags evaluate on the client — wrap protected routes with flag checks
  • For SSR/prerender compatibility, flags should have sensible defaults (off) while loading
  • Consider PostHog session replay for debugging auth flows during beta

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with App.tsx and the existing router, auth flows, and profile or membership entry points; then review the PostHog React SDK integration requirements in the issue. Done means the listed flags and events work, development is disabled by default, Do Not Track and no-PII requirements are respected, and the privacy notice documents the integration and self-hosting path.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
analytics, authentication, documentation, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.