Repository navigation
feat: sanitized manual $pageview for PostHog Web Analytics - #60
Merged
Merged
Conversation
Web Analytics needs $current_url/$pathname on $pageview events, but automatic capture stays off — the SDK would stamp raw location fields (query, hash, referrer) before the scrubber could clean them. - property_denylist still strips every URL/referrer-derived field; before_send re-attaches ONLY the sanitized set ($current_url, $pathname, $host, $referring_domain) recomputed from window.location at send time. - capturePageview() is the sole $pageview entry point — zero caller properties, pathname-only dedupe (StrictMode / hash / ?range= safe), and emits only on the public host or local dev. - Initial pageview fires after SDK init; useRoute's navigate/popstate cover client-side navigation and back/forward. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Summary
Enables PostHog Web Analytics (visitors/pageviews/sessions, page breakdowns) without weakening the privacy model. Automatic capture stays off — a manual
$pageviewis emitted with a deliberately sanitized property set.Mechanism:
property_denyliststrips every URL/referrer-derived field the SDK adds.before_sendthen re-attaches only the sanitized set —$current_url=origin + sanitized pathname,$pathname,$host,$referring_domain(bare domain only) — recomputed fromwindow.locationat send time.capturePageview()is the only entry point: zero caller properties, pathname-dedupe (StrictMode / hash /?range=history entries can't double-emit), gated todevledger.site+ localhost.Wiring: initial emit after SDK init in
main.tsx;useRoute'snavigate+popstatecover client-side nav and back/forward.Blog events/pageviews are emitted by the separate
dev-ledger-siteproject (same PostHog project, same model).Test plan
typecheck+build+ 455 tests green$pageviewnot caller-emittable, dedupe, denylist→sanitize ordering$pageviewobserved through/rlyGenerated with Devin