refactor(docs): migrate @vercel/analytics to posthog - #6643
Open
wingkwong wants to merge 2 commits into
Open
Conversation
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #
📝 Description
This pull request migrates the analytics provider for the
apps/docsapp 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/analyticsdependencies and related code, and introducingposthog-jsand 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
PostHogProviderReact 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
isAnalyticsEnabledhelper 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
/ingestpath, 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