Repository navigation
Route browser analytics through first-party API #7484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9686abc
edfbdbe
946ce40
8574810
bfc8950
a89f129
be9c2bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,14 +4,21 @@ import posthog from "posthog-js"; | |
| import { PostHogProvider as PHProvider } from "posthog-js/react"; | ||
| import { usePathname, useSearchParams } from "next/navigation"; | ||
| import { useEffect, Suspense } from "react"; | ||
| import { captureAnalyticsClick } from "../lib/analytics"; | ||
|
|
||
| if (typeof window !== "undefined") { | ||
| posthog.init("phc_opOVu7oFzR9wD3I6ZahFGOV2h3mqGpl5EHyQvmHciDP", { | ||
| api_host: "https://r.cmux.com", | ||
| api_host: "/api/analytics/posthog-sdk-disabled", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing PostHog SDK stub routeMedium Severity
Reviewed by Cursor Bugbot for commit 9686abc. Configure here. |
||
| ui_host: "https://us.posthog.com", | ||
| autocapture: false, | ||
| person_profiles: "identified_only", | ||
| capture_pageview: false, | ||
| capture_pageleave: true, | ||
| capture_pageleave: false, | ||
| disable_session_recording: true, | ||
| disable_surveys: true, | ||
| disable_external_dependency_loading: true, | ||
| advanced_disable_flags: true, | ||
| advanced_disable_decide: true, | ||
| advanced_disable_feature_flags: true, | ||
| }); | ||
| } | ||
|
|
@@ -25,7 +32,7 @@ function PageviewTracker() { | |
| let url = window.origin + pathname; | ||
| const search = searchParams.toString(); | ||
| if (search) url += "?" + search; | ||
| posthog.capture("$pageview", { $current_url: url }); | ||
| captureAnalyticsClick("$pageview", { $current_url: url }); | ||
| } | ||
| }, [pathname, searchParams]); | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signup event now uses the email address as the forwarded
distinct_id, while pageviews and clicks still use the local anonymous PostHog ID fromgetAnalyticsDistinctId(). Because this path does not send an alias or$anon_distinct_id, a normal visitor who browses anonymously and then joins the waitlist can end up with the waitlist event on a separate email-keyed person, breaking attribution from the earlier pageviews and clicks.