Skip to content

feat: opt-in tracking-param stripping (utm_*/fbclid/gclid/etc.)#29

Merged
paperhurts merged 2 commits into
mainfrom
feat/utm-stripping
May 24, 2026
Merged

feat: opt-in tracking-param stripping (utm_*/fbclid/gclid/etc.)#29
paperhurts merged 2 commits into
mainfrom
feat/utm-stripping

Conversation

@paperhurts
Copy link
Copy Markdown
Owner

Adds a stripTrackingParams option to normalizeUrl in @gitmarks/core and 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:

  • Prefixes: utm_*
  • Exact: fbclid, gclid, msclkid, mc_cid, mc_eid

Wiring path

  • core/src/url.ts: new NormalizeUrlOptions { stripTrackingParams?: boolean } arg
  • extension settings.ts: new stripTrackingParams: boolean field (Zod .default(false) — legacy stored settings without the field parse fine)
  • bookmark-factory: pipes through to normalizeUrl
  • save-flow: new SaveOptions arg the popup passes
  • popup.ts: reads settings.stripTrackingParams
  • listeners.ts: ListenerDeps.getStripTrackingParams (optional getter, defaults false in tests); applyBatch pipes through to both create and url-change update normalize calls
  • reconcile.ts: new stripTrackingParams param on the local-only push path
  • background.ts: provides getStripTrackingParams to listeners + passes to reconcile
  • options.html / options.ts: checkbox UI

TDD

  • RED: 6 failing tests in core/test/url.test.ts against { stripTrackingParams: true } (option didn't exist).
  • GREEN: core/src/url.ts extension.
  • Then wired through with extension tests added (bookmark-factory strip+preserve, settings legacy-default).
  • Existing tests adjusted for the new Settings shape (fixtures gained stripTrackingParams: false).

Test plan

  • pnpm test core 65/65 (+6), extension 97/97 (+3)
  • pnpm typecheck clean
  • pnpm build clean
  • CI green

Closes #6

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
@paperhurts paperhurts merged commit 5fa7fca into main May 24, 2026
1 check passed
@paperhurts paperhurts deleted the feat/utm-stripping branch May 24, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL normalization: strip tracking params (utm_*, fbclid, etc.) as configurable setting

1 participant