@codefast/tracking 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +67 -84
- package/dist/core/consent-receipt.d.ts +1 -1
- package/dist/core/cookie.d.ts.map +1 -1
- package/dist/core/cookie.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/core/consent-receipt.ts +1 -1
- package/src/core/cookie.ts +1 -1
- package/src/index.ts +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @codefast/tracking
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
## 0.6.0
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#690](https://github.com/codefastlabs/codefast/pull/690) [`f4b1aa6`](https://github.com/codefastlabs/codefast/commit/f4b1aa6335f535574eae5cf559b81a568f5a7a30) Thanks [@thevuong](https://github.com/thevuong)! - Report the failures that were being swallowed or mislabelled, and derive the types the build emits.
|
|
10
|
+
|
|
11
|
+
`@codefast/di`:
|
|
12
|
+
|
|
13
|
+
- `@inject`, `@postConstruct` and `@preDestroy` on a static member now throw `StaticMemberDecoratorError` instead of
|
|
14
|
+
`InternalError`. All three act on one instance, so this is caller misuse — and `InternalError` means the library
|
|
15
|
+
broke, which sent anyone catching it to file a bug against their own mistake. SPEC §10 already recorded that mistake
|
|
16
|
+
for predicate ambiguity.
|
|
17
|
+
- `AsyncResolutionError` names the token the caller asked for and the token whose factory is async, which is what SPEC
|
|
18
|
+
has always specified. Every throw site passed the same token twice, so the message read "Token 'X' requires async
|
|
19
|
+
resolution because 'X' in its dependency chain has an async factory"; a `resolve(App)` that fails on an async
|
|
20
|
+
`Database` now says so. `asyncSourceToken` defaults to `tokenName` for the case where the requested binding is itself
|
|
21
|
+
the source.
|
|
22
|
+
- A `MetadataReader` that names a `@postConstruct`/`@preDestroy` method the instance does not have raises
|
|
23
|
+
`InvalidMetadataError` instead of skipping the hook — a hook that silently never runs is the failure a caller cannot
|
|
24
|
+
see. `InvalidMetadataError`'s message no longer says "constructor", since it now covers both answers; the specifics
|
|
25
|
+
moved into `reason`.
|
|
26
|
+
- `MissingScopeContextError` from `ScopeManager` names its token instead of `"(unknown)"`, and the scoped read takes one
|
|
27
|
+
map lookup where it took two.
|
|
28
|
+
- `Token`, `Constructor` and `InjectionDescriptor` declare `out Value`, so the compiler checks the covariance the engine
|
|
29
|
+
already relied on.
|
|
30
|
+
|
|
31
|
+
Repo-wide: `isolatedDeclarations` is on for every package that emits declarations, so a public type can always be
|
|
32
|
+
written down from the source file alone. `allowJs` is gone from the shared base config — no package has JavaScript
|
|
33
|
+
sources. `@codefast/theme` and `@codefast/tracking` gained explicit annotations on four exported constants to satisfy
|
|
34
|
+
it; the emitted types are unchanged. `@codefast/ui` and `@codefast/benchmark-viewer` opt out for reasons recorded in
|
|
35
|
+
their configs.
|
|
36
|
+
|
|
3
37
|
## 0.5.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -5,23 +5,21 @@ Consent-gated, type-safe event tracking for TanStack Start apps.
|
|
|
5
5
|
[](https://www.npmjs.com/package/@codefast/tracking)
|
|
6
6
|
[](https://github.com/codefastlabs/codefast/blob/main/LICENSE)
|
|
7
7
|
|
|
8
|
-
- **One catalog, typed end to end** — apps define their events over any
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
the region-correct default arrives per visitor over a private server-function lane.
|
|
8
|
+
- **One catalog, typed end to end** — apps define their events over any [Standard Schema](https://standardschema.dev)
|
|
9
|
+
library (zod, `zod/mini`, valibot, ...); `track()` validates properties at the call site and at runtime, and the
|
|
10
|
+
client bundle only pays for the schema library the app already ships.
|
|
11
|
+
- **One consent config, every surface** — `ConsentConfig` is the single bag for the storage key, policy version, and
|
|
12
|
+
requested purposes; the React hooks, the tracker gate, and the pre-hydration gtag bootstrap all take the same object,
|
|
13
|
+
so nothing drifts.
|
|
14
|
+
- **ISR-safe by design** — shared/CDN-cached HTML bakes the strictest consent default; the region-correct default
|
|
15
|
+
arrives per visitor over a private server-function lane.
|
|
17
16
|
|
|
18
17
|
## Status
|
|
19
18
|
|
|
20
|
-
Pre-1.0 (canary). The surface is deliberately small: it covers exactly what a consented
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
them — git history has them if a real need returns.
|
|
19
|
+
Pre-1.0 (canary). The surface is deliberately small: it covers exactly what a consented gtag + Vercel Analytics setup on
|
|
20
|
+
TanStack Start needs, and nothing speculative. Lanes that shipped here before (offline queue, beacon relay, server-side
|
|
21
|
+
tracker, GTM, Segment-style `identify`/`group`/`alias`/`page`) were removed because no consumer called them — git
|
|
22
|
+
history has them if a real need returns.
|
|
25
23
|
|
|
26
24
|
## Installation
|
|
27
25
|
|
|
@@ -29,9 +27,8 @@ them — git history has them if a real need returns.
|
|
|
29
27
|
pnpm add @codefast/tracking
|
|
30
28
|
```
|
|
31
29
|
|
|
32
|
-
Every peer is optional and only needed by the surface that uses it: `react`/`react-dom`
|
|
33
|
-
|
|
34
|
-
`@vercel/analytics` for the Vercel destination.
|
|
30
|
+
Every peer is optional and only needed by the surface that uses it: `react`/`react-dom` (>= 19) for `/react`,
|
|
31
|
+
`@tanstack/react-start` (>= 1.168) for `/adapters/tanstack-start`, and `@vercel/analytics` for the Vercel destination.
|
|
35
32
|
|
|
36
33
|
## Quick Start
|
|
37
34
|
|
|
@@ -88,102 +85,89 @@ export const tracker = createClientTracker({
|
|
|
88
85
|
tracker.track("copy_code", { name: "button" }); // typed + runtime-validated
|
|
89
86
|
```
|
|
90
87
|
|
|
91
|
-
Destinations own their transport (gtag.js and Vercel both batch in-page), so `track()`
|
|
92
|
-
|
|
88
|
+
Destinations own their transport (gtag.js and Vercel both batch in-page), so `track()` is fire-and-forget — a failing
|
|
89
|
+
destination can never break the interaction.
|
|
93
90
|
|
|
94
91
|
## Event catalog
|
|
95
92
|
|
|
96
|
-
The package ships no events and no schema library — every app builds its own catalog
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
by design — tracking sits on synchronous call paths.
|
|
93
|
+
The package ships no events and no schema library — every app builds its own catalog with `defineEventCatalog` over
|
|
94
|
+
whatever Standard Schema validator it already uses. `track()` infers both the event name and its properties from the
|
|
95
|
+
catalog, then validates the properties at runtime; a mismatch throws at the call site. Async schemas are rejected by
|
|
96
|
+
design — tracking sits on synchronous call paths.
|
|
101
97
|
|
|
102
98
|
## Subpaths
|
|
103
99
|
|
|
104
|
-
The root `@codefast/tracking` is the **client entry**: it re-exports the isomorphic core
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
are their own subpaths and are never re-exported from the root:
|
|
100
|
+
The root `@codefast/tracking` is the **client entry**: it re-exports the isomorphic core (catalog types, `Destination`,
|
|
101
|
+
consent model + config) plus the whole browser-side surface (tracker, consent runtime, React bindings, and the client
|
|
102
|
+
destinations). Server-only lanes are their own subpaths and are never re-exported from the root:
|
|
108
103
|
|
|
109
|
-
- `@codefast/tracking` — client entry: core + `createClientTracker`, `createConsentRuntime`,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
`@vercel/analytics` peer is only pulled in when used.
|
|
104
|
+
- `@codefast/tracking` — client entry: core + `createClientTracker`, `createConsentRuntime`, the
|
|
105
|
+
`useConsent`/`ConsentBanner`/`GtagConsentBootstrap` React bindings, the gtag + ad-network destinations.
|
|
106
|
+
- `@codefast/tracking/destinations/vercel-analytics` — its own subpath so its `@vercel/analytics` peer is only pulled in
|
|
107
|
+
when used.
|
|
114
108
|
- `@codefast/tracking/server/*` — request-scoped, **server-only**: `server/initial-consent`,
|
|
115
|
-
`server/consent-receipt-store`, `server/measurement-protocol`, … (server code imports the
|
|
116
|
-
|
|
117
|
-
- `@codefast/tracking/adapters/tanstack-start` — request/response glue over Start's server
|
|
118
|
-
|
|
119
|
-
- `@codefast/tracking/tooling/import-protection` — `SERVER_ONLY_SUBPATHS` deny-list for
|
|
120
|
-
client bundles.
|
|
109
|
+
`server/consent-receipt-store`, `server/measurement-protocol`, … (server code imports the core it needs from
|
|
110
|
+
`@codefast/tracking/core/*`, never from the client root).
|
|
111
|
+
- `@codefast/tracking/adapters/tanstack-start` — request/response glue over Start's server context, **server-only**.
|
|
112
|
+
- `@codefast/tracking/tooling/import-protection` — `SERVER_ONLY_SUBPATHS` deny-list for client bundles.
|
|
121
113
|
- `@codefast/tracking/css/consent.css` — optional plain-CSS theme for the consent banner.
|
|
122
114
|
|
|
123
|
-
Every built module is also its own subpath (e.g. `@codefast/tracking/client/gpc`) for
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
the package is consent resolution plus cookie persistence.
|
|
115
|
+
Every built module is also its own subpath (e.g. `@codefast/tracking/client/gpc`) for granular imports. Server-only
|
|
116
|
+
lanes (`server/*`, `adapters/*`) must never enter a client bundle — feed `SERVER_ONLY_SUBPATHS` to the framework's
|
|
117
|
+
import-protection (see below). There is deliberately no server-side tracker: destinations batch in-page, and the server
|
|
118
|
+
half of the package is consent resolution plus cookie persistence.
|
|
128
119
|
|
|
129
120
|
## Consent (region-based, per-category)
|
|
130
121
|
|
|
131
|
-
`ConsentDecision` is per-purpose (`{ ads, analytics }`), mirroring Google Consent Mode
|
|
132
|
-
|
|
133
|
-
get **opt-
|
|
134
|
-
|
|
135
|
-
a malformed or legacy-shaped record re-prompts instead of silently deciding.
|
|
122
|
+
`ConsentDecision` is per-purpose (`{ ads, analytics }`), mirroring Google Consent Mode v2. Region resolves the mode:
|
|
123
|
+
GDPR (EU, plus UK/EEA-EFTA equivalents) and Vietnam's PDPL get **opt-in**; the US (CCPA/CPRA) and unrecognized regions
|
|
124
|
+
get **opt-out**, with GPC honored as an ads-only opt-out. Stored records are policy-versioned and shape-checked — a
|
|
125
|
+
malformed or legacy-shaped record re-prompts instead of silently deciding.
|
|
136
126
|
|
|
137
|
-
- `useConsent({ config, mode, storage })` — `useSyncExternalStore` bridge over the stored
|
|
138
|
-
|
|
127
|
+
- `useConsent({ config, mode, storage })` — `useSyncExternalStore` bridge over the stored decision; cross-tab saves sync
|
|
128
|
+
through the `storage` event.
|
|
139
129
|
- `ConsentBanner` + parts (`Title`/`Description`/`Actions`/`Accept`/`Reject`/`Customize`/
|
|
140
|
-
`Preferences`/`Category`/`Save`) — headless, `data-slot`-styleable; optional plain-CSS
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
wire to `onDecision` so a denial clears first-party identifiers.
|
|
130
|
+
`Preferences`/`Category`/`Save`) — headless, `data-slot`-styleable; optional plain-CSS theme at
|
|
131
|
+
`@codefast/tracking/css/consent.css`. `ConsentToggle` is the persistent opt-out control CCPA requires.
|
|
132
|
+
- `useGoogleConsentSync(consent, { loadGtagScript? })` — pushes Consent Mode `update` signals, including privacy-page
|
|
133
|
+
and cross-tab decisions.
|
|
134
|
+
- `createConsentWithdrawalHandler({ clearAnonymousId?, clearGoogleAnalyticsCookies? })` — wire to `onDecision` so a
|
|
135
|
+
denial clears first-party identifiers.
|
|
147
136
|
|
|
148
137
|
### The ISR lane
|
|
149
138
|
|
|
150
|
-
ISR/CDN-cached HTML is shared across visitors, so no render may read geo. Bake
|
|
151
|
-
|
|
152
|
-
|
|
139
|
+
ISR/CDN-cached HTML is shared across visitors, so no render may read geo. Bake `STRICTEST_INITIAL_CONSENT` into the
|
|
140
|
+
shared render (and into `<GtagConsentBootstrap />`), then resolve the region-correct default per visitor after
|
|
141
|
+
hydration:
|
|
153
142
|
|
|
154
143
|
1. **Server function** — `resolveInitialConsentFromRequest({ requestedCategories })`
|
|
155
144
|
(`@codefast/tracking/adapters/tanstack-start`) reads the geo header and `sec-gpc`, stamps
|
|
156
145
|
`cache-control: private, no-store`, and fails closed when geo is missing.
|
|
157
|
-
2. **Client** — `createConsentRuntime` owns the rest: strictest default until the server
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
the round trip overlaps hydration; read it reactively via
|
|
146
|
+
2. **Client** — `createConsentRuntime` owns the rest: strictest default until the server answers, single-flight resolve,
|
|
147
|
+
per-session cache, fail-closed-but-retryable errors. Kick `runtime.ensureInitialConsentResolved()` at router creation
|
|
148
|
+
(window-guarded) so the round trip overlaps hydration; read it reactively via
|
|
161
149
|
`useInitialConsent(runtime.initialConsentStore)` (`@codefast/tracking/react/use-initial-consent`).
|
|
162
150
|
|
|
163
151
|
## Durable anonymous id ("client mints, server persists")
|
|
164
152
|
|
|
165
153
|
`createServerPersistedAnonymousId` (`@codefast/tracking/client/server-persisted-anonymous-id`) mints a UUID cookie
|
|
166
|
-
lazily — only once an event is actually allowed to send — and asks the server to re-issue
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
id is exactly UUID-shaped, so a public endpoint can never echo attacker input into a
|
|
171
|
-
response header.
|
|
154
|
+
lazily — only once an event is actually allowed to send — and asks the server to re-issue it via `Set-Cookie`, which
|
|
155
|
+
escapes Safari ITP's 7-day cap on script-written cookies. The server half is one line per endpoint with
|
|
156
|
+
`setAnonymousIdResponseCookie` / `clearAnonymousIdResponseCookie` (`@codefast/tracking/adapters/tanstack-start`); both
|
|
157
|
+
validate the id is exactly UUID-shaped, so a public endpoint can never echo attacker input into a response header.
|
|
172
158
|
|
|
173
159
|
## Google tag (advanced Consent Mode)
|
|
174
160
|
|
|
175
161
|
`<GtagConsentBootstrap config={consentConfig} defaultConsent={...} gaMeasurementId="G-…" />`
|
|
176
|
-
(`@codefast/tracking/react/use-initial-consent`) renders the pre-hydration inline script: Consent Mode v2
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
catalog events. Runtime changes go through `useGoogleConsentSync`/`updateGoogleConsent`.
|
|
162
|
+
(`@codefast/tracking/react/use-initial-consent`) renders the pre-hydration inline script: Consent Mode v2 `default`
|
|
163
|
+
first (stored decision wins over the baked fallback), then gtag.js always loads so cookieless pings and consent modeling
|
|
164
|
+
can run even when storage is denied. Page views are gtag's own job (`config` + Enhanced Measurement) — the destination
|
|
165
|
+
only forwards catalog events. Runtime changes go through `useGoogleConsentSync`/`updateGoogleConsent`.
|
|
181
166
|
|
|
182
167
|
## Keeping server-only subpaths out of client bundles
|
|
183
168
|
|
|
184
|
-
`./server` and `./adapters/tanstack-start` must never enter a client bundle. On TanStack Start,
|
|
185
|
-
|
|
186
|
-
with the package instead of going stale in your config:
|
|
169
|
+
`./server` and `./adapters/tanstack-start` must never enter a client bundle. On TanStack Start, spread the package's own
|
|
170
|
+
deny-list into the plugin's import-protection so it versions with the package instead of going stale in your config:
|
|
187
171
|
|
|
188
172
|
```ts
|
|
189
173
|
import { SERVER_ONLY_SUBPATHS } from "@codefast/tracking/tooling/import-protection";
|
|
@@ -195,15 +179,14 @@ tanstackStart({
|
|
|
195
179
|
});
|
|
196
180
|
```
|
|
197
181
|
|
|
198
|
-
A violation is mocked with a console diagnostic in dev and fails the build in prod, with
|
|
199
|
-
|
|
182
|
+
A violation is mocked with a console diagnostic in dev and fails the build in prod, with a trace of the offending import
|
|
183
|
+
chain.
|
|
200
184
|
|
|
201
185
|
## Reference consumer
|
|
202
186
|
|
|
203
187
|
[`apps/ui` (`src/features/tracking/`)](https://github.com/codefastlabs/codefast/tree/main/apps/ui/src/features/tracking)
|
|
204
|
-
in this repo wires everything above on a real ISR-deployed TanStack Start site — consent
|
|
205
|
-
|
|
206
|
-
the private server-function consent lane.
|
|
188
|
+
in this repo wires everything above on a real ISR-deployed TanStack Start site — consent config + runtime, banner +
|
|
189
|
+
persistent toggle, gtag bootstrap, durable anonymous id, and the private server-function consent lane.
|
|
207
190
|
|
|
208
191
|
## License
|
|
209
192
|
|
|
@@ -8,7 +8,7 @@ import type { ConsentDecision } from "#/core/consent";
|
|
|
8
8
|
export type ConsentReceiptEventType = "give" | "update" | "withdraw";
|
|
9
9
|
/**
|
|
10
10
|
* How the decision was expressed — the "how" dimension a demonstrable-consent record must
|
|
11
|
-
* capture (GDPR Art. 7(1); EDPB 05/2020 §5.1).
|
|
11
|
+
* capture (GDPR Art. 7(1); EDPB 05/2020 §5.1).
|
|
12
12
|
*
|
|
13
13
|
* @since 1.0.0-canary.7
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/core/cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/core/cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAA2B,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAc/G"}
|
package/dist/core/cookie.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../src/core/cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../src/core/cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAW,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,YAAuC,EAAE,UAAkB;IACzF,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEzC,IAAI,cAAc,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,IAAI,EAAE,KAAK,UAAU,EAAE,CAAC;YACjF,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* browser-side surface (tracker, consent runtime, React bindings, client destinations).
|
|
10
10
|
* Server-only lanes are their own subpaths and never belong here — `@codefast/tracking/server/*`
|
|
11
11
|
* and `@codefast/tracking/adapters/*` (deny them in the client environment via
|
|
12
|
-
* `SERVER_ONLY_SUBPATHS`). The Vercel destination stays on
|
|
13
|
-
* vercel-analytics` so its `@vercel/analytics` peer is only
|
|
12
|
+
* `SERVER_ONLY_SUBPATHS`). The Vercel destination stays on
|
|
13
|
+
* `@codefast/tracking/destinations/vercel-analytics` so its `@vercel/analytics` peer is only
|
|
14
|
+
* pulled in when used.
|
|
14
15
|
*/
|
|
15
16
|
export type { ConsentCategory, ConsentDecision, ConsentMode, ConsentRecord, ConsentRegion, ConsentStorage, InitialConsent, ResolveDefaultConsentOptions, ResolveEffectiveConsentOptions, } from "#/core/consent";
|
|
16
17
|
export { CONSENT_CATEGORIES, CONSENT_REGIONS, createConsentDecision, isConsentDecision, isConsentRecord, isConsentRegion, isInitialConsent, normalizeConsentDecision, readStoredDecision, resolveConsentMode, resolveDefaultConsent, resolveEffectiveConsent, STRICTEST_INITIAL_CONSENT, } from "#/core/consent";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,YAAY,EACV,eAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AACrH,OAAO,EAAE,SAAS,EAAE,SAAS,EAA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AAC;AACzG,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* browser-side surface (tracker, consent runtime, React bindings, client destinations).
|
|
10
10
|
* Server-only lanes are their own subpaths and never belong here — `@codefast/tracking/server/*`
|
|
11
11
|
* and `@codefast/tracking/adapters/*` (deny them in the client environment via
|
|
12
|
-
* `SERVER_ONLY_SUBPATHS`). The Vercel destination stays on
|
|
13
|
-
* vercel-analytics` so its `@vercel/analytics` peer is only
|
|
12
|
+
* `SERVER_ONLY_SUBPATHS`). The Vercel destination stays on
|
|
13
|
+
* `@codefast/tracking/destinations/vercel-analytics` so its `@vercel/analytics` peer is only
|
|
14
|
+
* pulled in when used.
|
|
14
15
|
*/
|
|
15
16
|
export { CONSENT_CATEGORIES, CONSENT_REGIONS, createConsentDecision, isConsentDecision, isConsentRecord, isConsentRegion, isInitialConsent, normalizeConsentDecision, readStoredDecision, resolveConsentMode, resolveDefaultConsent, resolveEffectiveConsent, STRICTEST_INITIAL_CONSENT, } from "#/core/consent";
|
|
16
17
|
export { defineConsentConfig } from "#/core/consent-config";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAS5D,OA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AC;AAS7D,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,gCAAgC,EAChC,UAAU,EACV,cAAc,EACd,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAOzF,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGpG,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/tracking",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Consent-gated, type-safe event tracking for TanStack Start — client tracker and server consent helpers over a per-app Standard Schema event catalog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -275,12 +275,12 @@
|
|
|
275
275
|
"@standard-schema/spec": "^1.1.0"
|
|
276
276
|
},
|
|
277
277
|
"devDependencies": {
|
|
278
|
-
"@tanstack/react-start": "^1.168.
|
|
278
|
+
"@tanstack/react-start": "^1.168.44",
|
|
279
279
|
"@testing-library/dom": "^10.4.1",
|
|
280
|
-
"@testing-library/jest-dom": "^7.0.
|
|
280
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
281
281
|
"@testing-library/react": "^16.3.2",
|
|
282
|
-
"@testing-library/user-event": "^14.6.
|
|
283
|
-
"@types/node": "^26.
|
|
282
|
+
"@testing-library/user-event": "^14.6.4",
|
|
283
|
+
"@types/node": "^26.2.0",
|
|
284
284
|
"@types/react": "^19.2.18",
|
|
285
285
|
"@types/react-dom": "^19.2.4",
|
|
286
286
|
"@vercel/analytics": "^2.0.1",
|
|
@@ -293,7 +293,7 @@
|
|
|
293
293
|
"typescript": "^7.0.2",
|
|
294
294
|
"vitest": "^4.1.10",
|
|
295
295
|
"zod": "^4.4.3",
|
|
296
|
-
"@codefast/typescript-config": "0.
|
|
296
|
+
"@codefast/typescript-config": "0.6.1"
|
|
297
297
|
},
|
|
298
298
|
"peerDependencies": {
|
|
299
299
|
"@tanstack/react-start": ">=1.168.0",
|
|
@@ -11,7 +11,7 @@ export type ConsentReceiptEventType = "give" | "update" | "withdraw";
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* How the decision was expressed — the "how" dimension a demonstrable-consent record must
|
|
14
|
-
* capture (GDPR Art. 7(1); EDPB 05/2020 §5.1).
|
|
14
|
+
* capture (GDPR Art. 7(1); EDPB 05/2020 §5.1).
|
|
15
15
|
*
|
|
16
16
|
* @since 1.0.0-canary.7
|
|
17
17
|
*/
|
package/src/core/cookie.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* browser-side surface (tracker, consent runtime, React bindings, client destinations).
|
|
10
10
|
* Server-only lanes are their own subpaths and never belong here — `@codefast/tracking/server/*`
|
|
11
11
|
* and `@codefast/tracking/adapters/*` (deny them in the client environment via
|
|
12
|
-
* `SERVER_ONLY_SUBPATHS`). The Vercel destination stays on
|
|
13
|
-
* vercel-analytics` so its `@vercel/analytics` peer is only
|
|
12
|
+
* `SERVER_ONLY_SUBPATHS`). The Vercel destination stays on
|
|
13
|
+
* `@codefast/tracking/destinations/vercel-analytics` so its `@vercel/analytics` peer is only
|
|
14
|
+
* pulled in when used.
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
|
-
// ── Core (isomorphic)
|
|
17
|
+
// ── Core (isomorphic) ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
17
18
|
export type {
|
|
18
19
|
ConsentCategory,
|
|
19
20
|
ConsentDecision,
|
|
@@ -64,7 +65,7 @@ export { generateEventId } from "#/core/event-id";
|
|
|
64
65
|
|
|
65
66
|
export type { TrackedEvent } from "#/core/tracked-event";
|
|
66
67
|
|
|
67
|
-
// ── Client
|
|
68
|
+
// ── Client ───────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
68
69
|
export type { CmpConsentSignal, CmpStatus, ReconcileAdFrameworkConsentOptions } from "#/client/ad-framework-consent";
|
|
69
70
|
export { hasGppApi, hasTcfApi, reconcileAdFrameworkConsent } from "#/client/ad-framework-consent";
|
|
70
71
|
|
|
@@ -97,7 +98,7 @@ export { createIsAnalyticsAllowed } from "#/client/is-analytics-allowed";
|
|
|
97
98
|
export type { ServerPersistedAnonymousIdOptions } from "#/client/server-persisted-anonymous-id";
|
|
98
99
|
export { createServerPersistedAnonymousId } from "#/client/server-persisted-anonymous-id";
|
|
99
100
|
|
|
100
|
-
// ── React
|
|
101
|
+
// ── React ────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
101
102
|
export type {
|
|
102
103
|
ConsentBannerAcceptProps,
|
|
103
104
|
ConsentBannerActionsProps,
|
|
@@ -136,7 +137,7 @@ export { useGoogleConsentSync } from "#/react/use-google-consent-sync";
|
|
|
136
137
|
|
|
137
138
|
export { useInitialConsent } from "#/react/use-initial-consent";
|
|
138
139
|
|
|
139
|
-
// ── Destinations (client-lane; Vercel stays on its own subpath)
|
|
140
|
+
// ── Destinations (client-lane; Vercel stays on its own subpath) ──────────────────────────────────────────────────────
|
|
140
141
|
export type { AdConsentState } from "#/destinations/ad-consent";
|
|
141
142
|
export { toAdConsentState } from "#/destinations/ad-consent";
|
|
142
143
|
|