From 0f4e148aebbfea746f5eec502e313f7c16a7479d Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Wed, 16 Sep 2026 18:28:41 +0200 Subject: [PATCH] feat(track): gate TrackShopify on Shopify analytics consent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `dispatch()` now calls `window.Shopify.customerPrivacy.analyticsProcessingAllowed()` before every publish and publishes only when it returns `true`. `window.Shopify` is read fresh on each dispatch, so a consent change applies to the next event without a remount. Shopify's Web Pixels Manager gates App Pixels at load time, but it hands every published event to custom pixels, which are expected to apply their own consent logic. That gate is now the component's default instead of something each storefront repeats before each event. A dropped event is not queued and is never replayed. Each drop reports a diagnostic so a missing event is diagnosable: `track.shopify-consent-denied` when processing is refused, `track.shopify-privacy-unavailable` when the Customer Privacy API is absent — which is legitimate early in a page's life, since Shopify loads it asynchronously through `loadFeatures()`. The event-name check runs before the consent check. A declaration without an `event` name is wrong for every visitor, so it stays visible instead of being masked by a consent drop. The TrackShopify tests move out of `Track.spec.ts` into their own spec. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01LMSCm41fm3g7chxD728vAu --- CHANGELOG.md | 6 + packages/docs/.vitepress/reference/catalog.ts | 8 +- .../docs/reference/items/Track/anatomy.md | 12 +- .../docs/reference/items/Track/examples.md | 2 +- packages/docs/reference/items/Track/index.md | 10 +- packages/docs/reference/items/Track/js-api.md | 37 ++- packages/tests/Track/Track.spec.ts | 55 +--- packages/tests/Track/TrackShopify.spec.ts | 254 ++++++++++++++++++ packages/ui/src/Track/TrackShopify.ts | 44 ++- 9 files changed, 358 insertions(+), 70 deletions(-) create mode 100644 packages/tests/Track/TrackShopify.spec.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 49fca617..906937f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed + +- **TrackShopify:** publish only when Shopify analytics processing is allowed ([#654](https://github.com/studiometa/ui/pull/654)) + ## [v2.0.0-alpha.0](https://github.com/studiometa/ui/compare/1.11.1..2.0.0-alpha.0) (2026-09-03) This is the first release of the v2 line. It moves every package onto [`@studiometa/js-toolkit` v4](https://js-toolkit-v4.studiometa.dev/), removes six component families that a newer component already covers, renames three components, merges `LargeText` and `CircularMarquee` into `Marquee`, rewrites `Tabs` on the WAI-ARIA Tabs pattern, redesigns `Cursor` around published CSS hooks, completes the `Carousel` family and gives it an accessibility contract, and changes the shape of every event payload. There is no compatibility layer. diff --git a/packages/docs/.vitepress/reference/catalog.ts b/packages/docs/.vitepress/reference/catalog.ts index b62c9cc2..d5cde4ac 100644 --- a/packages/docs/.vitepress/reference/catalog.ts +++ b/packages/docs/.vitepress/reference/catalog.ts @@ -1105,7 +1105,13 @@ export const referenceCatalog = [ uiSymbol('TrackEvent', '/reference/items/Track/js-api', 'TrackEvent', 'primitive'), uiSymbol('TrackShopify', '/reference/items/Track/js-api'), ], - capabilities: ['click tracking', 'context', 'custom events', 'impression tracking'], + capabilities: [ + 'click tracking', + 'consent gating', + 'context', + 'custom events', + 'impression tracking', + ], }, { id: 'transition', diff --git a/packages/docs/reference/items/Track/anatomy.md b/packages/docs/reference/items/Track/anatomy.md index 4b07d85d..330ece92 100644 --- a/packages/docs/reference/items/Track/anatomy.md +++ b/packages/docs/reference/items/Track/anatomy.md @@ -17,12 +17,12 @@ TrackContext data-component="TrackContext" shared, i ## Parts -| Part | Selector | Required | Role | -| ----------------- | ------------------------------- | -------- | ------------------------------------------------------------------------------------------ | -| Tracker | `data-component="Track"` | Yes | Resolves each `data-track:` payload and pushes it to `window.dataLayer`. | -| Tracker (Shopify) | `data-component="TrackShopify"` | Yes\* | Same as `Track`, but publishes through `window.Shopify.analytics.publish`. | -| Context | `data-component="TrackContext"` | Optional | Provides data inherited by every descendant tracker, deep-merged up the ancestor chain. | -| Payload | `data-ref="payload"` | Optional | A `