Skip to content

refactor(docs): migrate @vercel/analytics to posthog - #6643

Open
wingkwong wants to merge 2 commits into
v3from
refactor/vercel-analytics
Open

refactor(docs): migrate @vercel/analytics to posthog#6643
wingkwong wants to merge 2 commits into
v3from
refactor/vercel-analytics

Conversation

@wingkwong

@wingkwong wingkwong commented Jun 13, 2026

Copy link
Copy Markdown
Member

Closes #

📝 Description

This pull request migrates the analytics provider for the apps/docs app from Vercel Analytics to PostHog, enabling more flexible and production-aware analytics tracking. It introduces a new PostHog integration with environment-based enablement, updates analytics event handling, and configures asset routing for PostHog. The changes are grouped below by theme.

Analytics Provider Migration and Integration

  • Replaces Vercel Analytics with a new PostHog integration by removing all @vercel/analytics dependencies and related code, and introducing posthog-js and supporting logic. (apps/docs/package.json, pnpm-lock.yaml, apps/docs/src/app/[lang]/layout.tsx, apps/docs/src/app/[lang]/layout.tsxL4-R10, apps/docs/src/app/[lang]/layout.tsxL61-R62, [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

  • Adds a new PostHogProvider React component and supporting files to initialize and provide PostHog analytics, capturing page views and wrapping the app's layout. (apps/docs/src/lib/analytics/posthog-provider.tsx, apps/docs/src/lib/analytics/posthog.ts, apps/docs/src/lib/analytics/index.ts, [1] [2] [3]

Environment-based Analytics Enablement

  • Introduces an isAnalyticsEnabled helper to ensure analytics are only sent in production and when required environment variables are set. Integrates this check into both client and server analytics logic. (apps/docs/src/lib/analytics/enabled.ts, apps/docs/src/libs/posthog.ts, [1] [2] [3]

Routing and Asset Configuration

  • Updates Next.js rewrites to proxy PostHog API and static asset requests through the /ingest path, supporting self-hosted or custom PostHog domains. (apps/docs/next.config.ts, [1] [2]

These changes ensure that analytics are robust, production-safe, and compatible with PostHog's requirements.

⛳️ Current behavior (updates)

🚀 New behavior

💣 Is this a breaking change (Yes/No):

📝 Additional Information

@wingkwong
wingkwong requested a review from jrgarciadev as a code owner June 13, 2026 10:25
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
heroui Ready Ready Preview, Comment Jun 13, 2026 10:41am
heroui-sb Ready Ready Preview, Comment Jun 13, 2026 10:41am

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Jun 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@heroui/react@6643
npm i https://pkg.pr.new/@heroui/styles@6643

commit: e754c05

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