fix(segment): drop $sdk_debug_* telemetry from enriched Segment events - #4707
Open
posthog[bot] wants to merge 3 commits into
Open
fix(segment): drop $sdk_debug_* telemetry from enriched Segment events#4707posthog[bot] wants to merge 3 commits into
posthog[bot] wants to merge 3 commits into
Conversation
The Segment integration registers as an enrichment plugin, so every property it adds becomes part of the Segment event that fans out to all destinations, not just PostHog. This leaked PostHog's internal $sdk_debug_* SDK telemetry onto every other destination for customers who set config.segment. Filter $sdk_debug_* keys out of the enrichment path. They only serve PostHog's own capture pipeline and are meaningless to other destinations. Generated-By: PostHog Desktop Task-Id: 90b4947c-5a03-43a3-b98d-a56def575fbb
Contributor
Contributor
posthog-js Compliance ReportDate: 2026-09-01 22:00:33 UTC ✅ All Tests Passed!26/26 tests passed Capture Tests✅ 26/26 tests passed View Details
|
Contributor
|
Size Change: +6.01 kB (+0.03%) Total Size: 20.8 MB 📦 View Changed
ℹ️ View Unchanged
|
turnipdabeets
requested review from
a team,
TueHaulund,
arnohillen,
fasyy612 and
ksvat
and removed request for
a team
August 31, 2026 18:57
dustinbyrne
marked this pull request as ready for review
September 1, 2026 21:31
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.
Problem
The browser SDK's Segment integration calls
calculateEventPropertiesdirectly and adds the resulting PostHog context to the shared Segment event before Segment fans it out to every destination. This includes internal properties such as$sdk_debug_*.Top-level
before_sendruns later in PostHog's direct capture pipeline, so it cannot filter this Segment enrichment. Existing options such asproperty_denylistalso affect direct PostHog captures and do not provide a Segment-only extension point.Customers need a supported way to control which PostHog-generated properties are added to Segment events without changing PostHog's direct capture behavior or automatically removing metadata for everyone.
Changes
Public API change:
PostHogConfig.segmentnow accepts aSegmentIntegrationConfigin addition to the existing Segment analytics object:filterPropertiesaccepts one filter or an ordered array of filters.Filters receive a fresh shallow property bag containing only non-colliding PostHog-generated enrichment properties.
Original Segment properties are not exposed to filters and are merged last, so they remain authoritative.
Returning
nullor throwing skips PostHog enrichment without canceling or mutating the shared Segment event.No properties are filtered by default, and the existing
segment: window.analyticsconfiguration remains supported.Direct PostHog capture and top-level
before_sendbehavior are unchanged.Export the new integration/filter types from
@posthog/typesandposthog-js.Validation
@posthog/typesJest suite: 3 suites and 3 tests passed@posthog/typesbuildposthog-jsbuildgit diff --checkRelease info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
@dustinbyrne; implementation and local validation used the Pi coding agent.