feat: opt-in tracking-param stripping (utm_*/fbclid/gclid/etc.)#29
Merged
Conversation
Add a stripTrackingParams option to @gitmarks/core's normalizeUrl that removes well-known tracking parameters (utm_*, fbclid, gclid, msclkid, mc_*) when the user enables it. Default off — spec.md §'Open questions' deliberately specified this as opt-in to preserve legitimate uses. Wiring: - core/src/url.ts: NormalizeUrlOptions param; case-insensitive match - core/test/url.test.ts: 6 new tests - extension settings.ts: stripTrackingParams: boolean (z default false) - bookmark-factory: pipes the option through to normalizeUrl - save-flow: SaveOptions param the popup passes from settings - popup.ts: reads settings.stripTrackingParams when saving - listeners.ts: ListenerDeps.getStripTrackingParams; applyBatch pipes through to normalizeUrl on both create and url-change update - reconcile.ts: stripTrackingParams param on local-only push - background.ts: provides getStripTrackingParams in ListenerDeps; passes the flag to reconcile() - options.html: checkbox UI for the setting - options.ts: read/write the form field - test/bookmark-factory.test.ts: 2 new tests (strip + preserve) - test/settings.test.ts: legacy-data default test + fixture updates TDD: started with core/test/url.test.ts (RED: 5 failing tests against the new option). Implemented in core. Extended bookmark-factory, then all the wiring. Full suite: core 65/65 (+6), extension 97/97 (+3). Closes #6
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.
Adds a
stripTrackingParamsoption tonormalizeUrlin@gitmarks/coreand wires it through settings, popup, listener push, and reconcile so all bookmark-creation paths respect the same toggle.Default is OFF — spec.md §'Open questions' explicitly specified this as opt-in because some sites use utm_* for non-tracking purposes.
Stripped params
Case-insensitive:
utm_*fbclid,gclid,msclkid,mc_cid,mc_eidWiring path
core/src/url.ts: newNormalizeUrlOptions { stripTrackingParams?: boolean }argextension settings.ts: newstripTrackingParams: booleanfield (Zod.default(false)— legacy stored settings without the field parse fine)bookmark-factory: pipes through to normalizeUrlsave-flow: newSaveOptionsarg the popup passespopup.ts: readssettings.stripTrackingParamslisteners.ts:ListenerDeps.getStripTrackingParams(optional getter, defaults false in tests);applyBatchpipes through to both create and url-change update normalize callsreconcile.ts: newstripTrackingParamsparam on the local-only push pathbackground.ts: providesgetStripTrackingParamsto listeners + passes to reconcileoptions.html/options.ts: checkbox UITDD
core/test/url.test.tsagainst{ stripTrackingParams: true }(option didn't exist).core/src/url.tsextension.bookmark-factorystrip+preserve,settingslegacy-default).Settingsshape (fixtures gainedstripTrackingParams: false).Test plan
pnpm testcore 65/65 (+6), extension 97/97 (+3)pnpm typecheckcleanpnpm buildcleanCloses #6