STRATCONN-6922 - [Mixpanel Web] harden session replay config + add masking controls - #3945
STRATCONN-6922 - [Mixpanel Web] harden session replay config + add masking controls#3945joe-ayoub-segment wants to merge 1 commit into
Conversation
…sking controls Build the Mixpanel init config explicitly instead of spreading unfiltered settings, so only correctly-typed, defined values reach mixpanel.init: - Replace `...remainingSettings` spread (which leaked Segment-internal keys like `subscriptions`/`versionSettings` into the SDK config) with an explicit config literal filtered by a `defined()` helper. - Add asString/asNumber/asBoolean coercers (settings arrive as strings from the CDN, e.g. record_min_ms, record_sessions_percent). Session replay masking: - Add record_mask_all_text / record_mask_all_inputs parent toggles (default true) plus mask/unmask selector fields, each depends_on-gated by its parent. Previously record_mask_text_selector was a no-op because record_mask_all_text (Mixpanel default true) was never exposed. - Fix record_mask_text_selectors -> record_mask_text_selector to match the Mixpanel SDK key; add api_host to the Config type. - Fix record_idle_timeout_ms default 180000 -> 1800000 (30 min, matches Mixpanel). Additive and non-breaking; safe default (mask all) preserved. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR hardens Mixpanel Web (device-mode) destination configuration passed to mixpanel.init by switching from a broad settings spread to an explicit, typed/coerced config object, and adds first-class session replay text/input masking controls.
Changes:
- Build
mixpanel.initconfig via explicit keys withasString/asNumber/asBooleancoercion and anundefinedfilter to prevent leaking Segment-internal settings into Mixpanel. - Add session replay masking toggles/selectors (mask/unmask for text and inputs) and align config keys with Mixpanel SDK (
record_mask_text_selector). - Update defaults/metadata (notably
record_idle_timeout_msto 30 minutes) and regenerate types/metadata.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/browser-destinations/destinations/mixpanel-web/src/types.ts | Extends Config with api_host and new session replay masking options/renames. |
| packages/browser-destinations/destinations/mixpanel-web/src/setting-fields.ts | Adds new masking settings with depends_on gating; updates replay idle timeout default. |
| packages/browser-destinations/destinations/mixpanel-web/src/index.ts | Replaces ...rest spread with explicit, coerced config construction to avoid leaking internal keys. |
| packages/browser-destinations/destinations/mixpanel-web/src/generated-types.ts | Regenerates settings types/docs for new masking controls. |
| packages/browser-destinations/destinations/mixpanel-web/metadata.json | Regenerates metadata (new fields, gating, updated defaults). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return undefined | ||
| } | ||
|
|
||
| const asBoolean = (value: unknown): boolean | undefined => (typeof value === 'boolean' ? value : undefined) |
| ...defined({ | ||
| api_host: asString(api_host), |
Summary
Hardens how the Mixpanel Web (device-mode) destination builds the config passed to
mixpanel.init, and adds first-class session-replay text/input masking controls. Motivated by STRATCONN-6922 (Farmers session-replay work).Config building
persistence: ..., ...remainingSettingsspread with an explicit config literal. The old spread pushed every non-destructured setting into the SDK config, including Segment-internal keys (subscriptions,versionSettings) that leaked into the livemixpanel.config.asString/asNumber/asBooleancoercers and adefined()filter so only correctly-typed, present values reachmixpanel.init. Settings arrive from the CDN as strings (e.g.record_min_ms: "8000",record_sessions_percent: "2"), so numeric coercion is retained.Session replay masking
record_mask_all_textandrecord_mask_all_inputsparent toggles (defaulttrue, matching the Mixpanel SDK default), plus mask/unmask selector fields, eachdepends_on-gated by its parent toggle. Previouslyrecord_mask_text_selectorwas effectively a no-op becauserecord_mask_all_text(SDK defaulttrue) was never exposed.record_mask_text_selectors→record_mask_text_selectorto match the Mixpanel SDK key.api_hostto theConfigtype.record_idle_timeout_msdefault180000→1800000(30 min, matches Mixpanel docs).Compatibility
Additive and non-breaking. The safe default (mask all text/inputs) is preserved. Regenerated
generated-types.tsandmetadata.json.Testing
yarn browser typecheckpasses.mixpanel.initwith correctly-typed values and no leaked Segment-internal keys.🤖 Generated with Claude Code