Skip to content

Migrate from Segment to PostHog analytics#1481

Draft
samseely wants to merge 2 commits into
mainfrom
cursor/posthog-analytics-migration-2415
Draft

Migrate from Segment to PostHog analytics#1481
samseely wants to merge 2 commits into
mainfrom
cursor/posthog-analytics-migration-2415

Conversation

@samseely

Copy link
Copy Markdown
Contributor

Description

This PR migrates the docs site analytics from Segment to PostHog, as part of the Posthog project initiative.

Changes:

  • Replaced @segment/snippet package with posthog-js
  • Created new lib/posthog.ts module with PostHog analytics functions:
    • init() - Initialize PostHog client
    • track() - Track custom events
    • page() - Track page views
    • identify() - Identify users
    • reset() - Reset user identity
  • Updated pages/_app.tsx to initialize PostHog on mount and track page views on route changes
  • Removed old lib/analytics.js Segment integration

Environment variables required:

  • NEXT_PUBLIC_POSTHOG_KEY - PostHog project API key (required)
  • NEXT_PUBLIC_POSTHOG_HOST - PostHog API host (optional, defaults to https://us.i.posthog.com)

Todos

  • Add NEXT_PUBLIC_POSTHOG_KEY environment variable in production deployment

Screenshots

The docs site loads successfully with the new PostHog integration:

Docs site loaded successfully

Console output showing no errors (PostHog shows as undefined since no API key is set in development):

Console output showing no errors

To show artifacts inline, enable in settings.

Linear Issue: KNO-13710

Open in Web Open in Cursor 

- Replace @segment/snippet package with posthog-js
- Create new lib/posthog.ts module with PostHog analytics functions
- Update pages/_app.tsx to initialize PostHog and track page views
- Remove old lib/analytics.js Segment integration

Environment variables:
- NEXT_PUBLIC_POSTHOG_KEY: PostHog project API key
- NEXT_PUBLIC_POSTHOG_HOST: PostHog API host (optional, defaults to us.i.posthog.com)

Resolves KNO-13710

Co-authored-by: Sam Seely <samseely@gmail.com>
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 12, 2026 9:12pm

Request Review

Co-authored-by: Sam Seely <samseely@gmail.com>
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.

2 participants