@codefast/tracking 0.7.2 → 0.8.0

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/LICENSE +1 -1
  3. package/README.md +6 -5
  4. package/dist/adapters/tanstack-start.d.ts +4 -4
  5. package/dist/adapters/tanstack-start.js +4 -4
  6. package/dist/client/ad-framework-consent.d.ts +1 -1
  7. package/dist/client/consent-runtime.d.ts +3 -3
  8. package/dist/client/consent-runtime.js +4 -4
  9. package/dist/client/consent-storage.d.ts +1 -1
  10. package/dist/client/consent-storage.js +1 -1
  11. package/dist/client/consent-withdrawal.d.ts +1 -1
  12. package/dist/client/cookie-anonymous-id.js +2 -2
  13. package/dist/client/create-client-tracker.d.ts +3 -3
  14. package/dist/client/create-client-tracker.js +2 -2
  15. package/dist/client/initial-consent-store.d.ts +1 -1
  16. package/dist/client/initial-consent-store.js +1 -1
  17. package/dist/client/is-analytics-allowed.d.ts +2 -2
  18. package/dist/client/is-analytics-allowed.js +1 -1
  19. package/dist/client/server-persisted-anonymous-id.d.ts +1 -1
  20. package/dist/client/server-persisted-anonymous-id.js +2 -2
  21. package/dist/core/consent-config.d.ts +1 -1
  22. package/dist/core/consent-receipt.d.ts +1 -1
  23. package/dist/core/consent-receipt.js +1 -1
  24. package/dist/core/destination.d.ts +1 -1
  25. package/dist/destinations/ad-consent.d.ts +1 -1
  26. package/dist/destinations/google-analytics.d.ts +5 -5
  27. package/dist/destinations/google-analytics.js +2 -2
  28. package/dist/destinations/google-consent.d.ts +1 -1
  29. package/dist/destinations/google-consent.js +1 -1
  30. package/dist/destinations/meta.d.ts +3 -3
  31. package/dist/destinations/meta.js +2 -2
  32. package/dist/destinations/microsoft-uet.d.ts +3 -3
  33. package/dist/destinations/microsoft-uet.js +2 -2
  34. package/dist/destinations/tiktok.d.ts +3 -3
  35. package/dist/destinations/tiktok.js +2 -2
  36. package/dist/destinations/vercel-analytics.d.ts +1 -1
  37. package/dist/destinations/vercel-analytics.js +1 -1
  38. package/dist/index.d.ts +49 -49
  39. package/dist/index.js +26 -26
  40. package/dist/react/consent-banner.d.ts +2 -2
  41. package/dist/react/gtag-consent-bootstrap.d.ts +1 -1
  42. package/dist/react/gtag-consent-bootstrap.js +1 -1
  43. package/dist/react/use-consent.d.ts +2 -2
  44. package/dist/react/use-consent.js +1 -1
  45. package/dist/react/use-google-consent-sync.d.ts +1 -1
  46. package/dist/react/use-google-consent-sync.js +1 -1
  47. package/dist/react/use-initial-consent.d.ts +1 -1
  48. package/dist/server/anonymous-id-cookie.js +1 -1
  49. package/dist/server/consent-receipt-store.d.ts +1 -1
  50. package/dist/server/consent-receipt.d.ts +1 -1
  51. package/dist/server/initial-consent.d.ts +1 -1
  52. package/dist/server/initial-consent.js +2 -2
  53. package/dist/server/measurement-protocol.d.ts +1 -1
  54. package/dist/server/region.d.ts +1 -1
  55. package/dist/tooling/import-protection.d.ts +1 -1
  56. package/dist/tooling/import-protection.js +1 -1
  57. package/package.json +4 -42
  58. package/src/css/consent.css +119 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @codefast/tracking
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#976](https://github.com/codefastlabs/codefast/pull/976) `engines.node` is now `>=24.0.0`, up from `>=22.12.0`, and Node 22 is no longer supported. Node 24.0.0 is the first
8
+ release with explicit resource management built in (`using`, `await using`, `DisposableStack`, `AsyncDisposableStack`,
9
+ `SuppressedError`) and all of ES2025, so the packages use both as the platform ships them instead of shimming them for
10
+ an older line, and the CI matrix runs the unit suite on 24.0.0 itself. Move to Node 24, or stay on the current minor
11
+ while a deployment still runs Node 22.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#977](https://github.com/codefastlabs/codefast/pull/977) The README states the browser floor: Chrome and Edge 136, Firefox 136, and Safari 18.4 or later, the first releases that
16
+ ship every ES2025 builtin. `@codefast/di`'s README also says what a browser program without explicit resource management
17
+ does: it keeps `skipLibCheck` on and calls `dispose()` instead of `await using`.
18
+
19
+ - [#965](https://github.com/codefastlabs/codefast/pull/965) `README.md` now states TypeScript 7 or later as the floor for the package's types — the one compiler every `@codefast/*`
20
+ package is built and checked with. No code or declaration changed.
21
+
22
+ ## 0.7.3
23
+
24
+ ### Patch Changes
25
+
26
+ - [#892](https://github.com/codefastlabs/codefast/pull/892) [`4c97c5b`](https://github.com/codefastlabs/codefast/commit/4c97c5b8c2314f25ee9df7eac5a4b5dd723d6d90) Thanks [@thevuong](https://github.com/thevuong)! - Lower the monorepo's Node floor from 24 to 22.12, so the packages install and run on the active Node 22 LTS line.
27
+
28
+ `engines.node` becomes `>=22.12.0` across every package — the floor the shared toolchain (oxlint, Vite, Vitest, TanStack
29
+ Start) already requires. Development stays on the latest Node (`.node-version`) for speed, and a CI matrix exercises the
30
+ floor and the active LTS directly, so the floor is a contract CI proves rather than one everyone has to run.
31
+ `@types/node` is pinned to the floor's major (`^22`), with a workspace override holding the whole tree there so a dev
32
+ tool's `@types/node: "*"` peer can no longer pull a newer major and mask an API the floor lacks. The floor stays
33
+ mechanical, not advisory: `@codefast/di` keeps its own `Map` upsert helpers rather than the ES2025
34
+ `Map.prototype.getOrInsert` (which would raise the floor to 26) and its `lib` stays `ES2024`. `@codefast/cli`'s mirror
35
+ step now calls the `node:path` functions directly instead of aliasing them, which the floor's types correctly flag as
36
+ unbound methods.
37
+
38
+ The shared `@codefast/typescript-config` presets pin `lib` and `target` to `ES2024` (was `ESNext`) so the compiler's
39
+ ECMAScript surface matches the Node floor: an ES2025 builtin such as `Map.prototype.getOrInsert` now fails to type-check
40
+ rather than compiling and crashing on Node 22.12. `@codefast/di` and `@codefast/di-testing` already pinned `lib` and are
41
+ unchanged.
42
+
43
+ Internal subpath imports move from a `#/` prefix to a bare `#` (`#core/token`, not `#/core/token`), and the
44
+ `package.json#imports` keys become `#*`/`#tests/*`/`#examples/*` to match. Node's native ESM resolver rejects a
45
+ `#/`-prefixed specifier with `ERR_INVALID_MODULE_SPECIFIER` on the whole Node 22 line (and on Node 24 before 24.14), and
46
+ each package ships those specifiers verbatim inside its published `dist/*.js` for a consumer's Node to resolve — so this
47
+ rename is what actually lets the packages import on the new floor. Purely internal: a consumer's own import paths are
48
+ unchanged.
49
+
50
+ - [#892](https://github.com/codefastlabs/codefast/pull/892) [`4c97c5b`](https://github.com/codefastlabs/codefast/commit/4c97c5b8c2314f25ee9df7eac5a4b5dd723d6d90) Thanks [@thevuong](https://github.com/thevuong)! - Fix `pack-slim` stripping the stylesheet source of packages that export CSS.
51
+
52
+ `codefast pack-slim` removed the whole `src` directory from a package's published `files`, but `@codefast/ui` and
53
+ `@codefast/tracking` ship Tailwind source through `./css/*` → `./src/css/*`, so their published tarballs went out with
54
+ no CSS at all and the `./css/*` export resolved to nothing. pack-slim now keeps the `src` subtrees a surviving
55
+ `exports`/`imports` target still points into (e.g. `src/css`) and drops the rest of `src`, so the stylesheets ship while
56
+ the TypeScript source stays out. Surfaced and now guarded by the new `codefast audit publish` check.
57
+
3
58
  ## 0.7.2
4
59
 
5
60
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 CodeFast Labs
3
+ Copyright (c) 2024 Codefast Labs
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -33,10 +33,11 @@ resolves the region-correct default per visitor over a private server-function l
33
33
  pnpm add @codefast/tracking
34
34
  ```
35
35
 
36
- `@codefast/tracking` requires Node.js 24 or later. Its one runtime dependency is `@standard-schema/spec`. Every peer is
37
- optional, needed only by the surface that uses it: `react` and `react-dom` (19 or later) for the `react/*` subpaths,
38
- `@tanstack/react-start` (1.168 or later) for `adapters/tanstack-start`, and `@vercel/analytics` for
39
- `destinations/vercel-analytics`.
36
+ `@codefast/tracking` requires Node.js 24 or later on the server, Chrome and Edge 136, Firefox 136, or Safari 18.4 or
37
+ later in the browser ([support policy](../../SUPPORT.md#browsers)), and TypeScript 7 or later for its types. Its one
38
+ runtime dependency is `@standard-schema/spec`. Every peer is optional, needed only by the surface that uses it: `react`
39
+ and `react-dom` (19 or later) for the `react/*` subpaths, `@tanstack/react-start` (1.168 or later) for
40
+ `adapters/tanstack-start`, and `@vercel/analytics` for `destinations/vercel-analytics`.
40
41
 
41
42
  The package is published on 0.x and versioned on its own track: breaking changes ship as minor versions, so pin the
42
43
  minor version when you need stability.
@@ -302,7 +303,7 @@ tanstackStart({
302
303
 
303
304
  ## Reference consumer
304
305
 
305
- [`apps/ui/src/features/tracking`](../../apps/ui/src/features/tracking/) wires everything above on a real ISR-deployed
306
+ [`apps/web/src/features/tracking`](../../apps/web/src/features/tracking/) wires everything above on a real ISR-deployed
306
307
  TanStack Start site: the consent config and runtime, the banner and the persistent toggle, the gtag bootstrap, the
307
308
  durable anonymous id, and the private server-function consent lane.
308
309
 
@@ -1,7 +1,7 @@
1
- import type { ConsentCategory, InitialConsent } from "#/core/consent";
2
- import type { ConsentReceipt, ConsentReceiptInput } from "#/core/consent-receipt";
3
- import type { AnonymousIdCookieOptions } from "#/server/anonymous-id-cookie";
4
- import type { ReceiptStore } from "#/server/consent-receipt-store";
1
+ import type { ConsentCategory, InitialConsent } from "#core/consent";
2
+ import type { ConsentReceipt, ConsentReceiptInput } from "#core/consent-receipt";
3
+ import type { AnonymousIdCookieOptions } from "#server/anonymous-id-cookie";
4
+ import type { ReceiptStore } from "#server/consent-receipt-store";
5
5
  /**
6
6
  * Options for `resolveInitialConsentFromRequest`.
7
7
  *
@@ -1,8 +1,8 @@
1
1
  import { deleteCookie, getRequestHeader, getRequestIP, setCookie, setResponseHeader, } from "@tanstack/react-start/server";
2
- import { isConsentReceiptInput } from "#/core/consent-receipt";
3
- import { resolveAnonymousIdCookie, resolveClearAnonymousIdCookie } from "#/server/anonymous-id-cookie";
4
- import { buildConsentReceipt } from "#/server/consent-receipt";
5
- import { resolveInitialConsent } from "#/server/initial-consent";
2
+ import { isConsentReceiptInput } from "#core/consent-receipt";
3
+ import { resolveAnonymousIdCookie, resolveClearAnonymousIdCookie } from "#server/anonymous-id-cookie";
4
+ import { buildConsentReceipt } from "#server/consent-receipt";
5
+ import { resolveInitialConsent } from "#server/initial-consent";
6
6
  /**
7
7
  * Region-correct `InitialConsent` for the current request: reads the platform geo header
8
8
  * and `sec-gpc`, fails closed when geo is missing, and stamps
@@ -1,4 +1,4 @@
1
- import type { ConsentCategory, ConsentDecision } from "#/core/consent";
1
+ import type { ConsentCategory, ConsentDecision } from "#core/consent";
2
2
  /**
3
3
  * TCF/GPP interop reconciler (spec-ad-consent-frameworks): the system **reads** an external
4
4
  * CMP and reconciles it with the native `{ ads, analytics }` decision — it never becomes a
@@ -1,6 +1,6 @@
1
- import type { InitialConsentStore } from "#/client/initial-consent-store";
2
- import type { ConsentStorage, InitialConsent } from "#/core/consent";
3
- import type { ConsentConfig } from "#/core/consent-config";
1
+ import type { InitialConsentStore } from "#client/initial-consent-store";
2
+ import type { ConsentStorage, InitialConsent } from "#core/consent";
3
+ import type { ConsentConfig } from "#core/consent-config";
4
4
  /**
5
5
  * Options for `createConsentRuntime`.
6
6
  *
@@ -1,7 +1,7 @@
1
- import { createLocalStorageConsentStorage } from "#/client/consent-storage";
2
- import { hasGlobalPrivacyControlSignal } from "#/client/gpc";
3
- import { createInitialConsentStore } from "#/client/initial-consent-store";
4
- import { createIsAnalyticsAllowed } from "#/client/is-analytics-allowed";
1
+ import { createLocalStorageConsentStorage } from "#client/consent-storage";
2
+ import { hasGlobalPrivacyControlSignal } from "#client/gpc";
3
+ import { createInitialConsentStore } from "#client/initial-consent-store";
4
+ import { createIsAnalyticsAllowed } from "#client/is-analytics-allowed";
5
5
  /**
6
6
  * Composes the client half of the consent lane from a single `ConsentConfig`:
7
7
  * `localStorage`-backed decision storage, the initial-consent store over the app's
@@ -1,4 +1,4 @@
1
- import type { ConsentStorage } from "#/core/consent";
1
+ import type { ConsentStorage } from "#core/consent";
2
2
  /**
3
3
  * `localStorage`-backed consent storage. Corrupt state, a private-mode/quota error, or no
4
4
  * `window` (SSR) degrades to an in-memory record — the visitor's decision still applies
@@ -1,4 +1,4 @@
1
- import { isConsentRecord } from "#/core/consent";
1
+ import { isConsentRecord } from "#core/consent";
2
2
  /**
3
3
  * `localStorage`-backed consent storage. Corrupt state, a private-mode/quota error, or no
4
4
  * `window` (SSR) degrades to an in-memory record — the visitor's decision still applies
@@ -1,4 +1,4 @@
1
- import type { ConsentDecision } from "#/core/consent";
1
+ import type { ConsentDecision } from "#core/consent";
2
2
  /**
3
3
  * Options for `createConsentWithdrawalHandler`.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { writeBrowserCookie } from "#/client/browser-cookie";
2
- import { ONE_YEAR_IN_SECONDS, readCookieValue } from "#/core/cookie";
1
+ import { writeBrowserCookie } from "#client/browser-cookie";
2
+ import { ONE_YEAR_IN_SECONDS, readCookieValue } from "#core/cookie";
3
3
  /**
4
4
  * A `document.cookie`-backed anonymous id — not `localStorage`-only, so a server-owned
5
5
  * event can read the same id from the request and correlate to this visitor. Pass
@@ -1,7 +1,7 @@
1
1
  import type { StandardSchemaV1 } from "@standard-schema/spec";
2
- import type { Destination } from "#/core/destination";
3
- import type { EventCatalog } from "#/core/event-catalog";
4
- import type { TrackedEvent } from "#/core/tracked-event";
2
+ import type { Destination } from "#core/destination";
3
+ import type { EventCatalog } from "#core/event-catalog";
4
+ import type { TrackedEvent } from "#core/tracked-event";
5
5
  /**
6
6
  * Context handed to {@link ClientTrackerOptions.onDeliveryError} for one failed delivery.
7
7
  *
@@ -1,5 +1,5 @@
1
- import { assertValidEventProperties } from "#/core/event-catalog";
2
- import { generateEventId } from "#/core/event-id";
1
+ import { assertValidEventProperties } from "#core/event-catalog";
2
+ import { generateEventId } from "#core/event-id";
3
3
  /**
4
4
  * `Destination.send` is typed to always return a `Promise`, but that's unenforceable at
5
5
  * runtime for a third-party/plain-JS destination — one that ignores the contract and
@@ -1,4 +1,4 @@
1
- import type { InitialConsent } from "#/core/consent";
1
+ import type { InitialConsent } from "#core/consent";
2
2
  /**
3
3
  * External-store view of the visitor's region default — the strictest value until the
4
4
  * server lane answers, then the resolved one.
@@ -1,4 +1,4 @@
1
- import { isInitialConsent, STRICTEST_INITIAL_CONSENT } from "#/core/consent";
1
+ import { isInitialConsent, STRICTEST_INITIAL_CONSENT } from "#core/consent";
2
2
  const SERVER_SNAPSHOT = {
3
3
  initialConsent: STRICTEST_INITIAL_CONSENT,
4
4
  isResolved: false,
@@ -1,5 +1,5 @@
1
- import type { ConsentMode, ConsentStorage } from "#/core/consent";
2
- import type { ConsentConfig } from "#/core/consent-config";
1
+ import type { ConsentMode, ConsentStorage } from "#core/consent";
2
+ import type { ConsentConfig } from "#core/consent-config";
3
3
  /**
4
4
  * Options for `createIsAnalyticsAllowed`.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { resolveEffectiveConsent } from "#/core/consent";
1
+ import { resolveEffectiveConsent } from "#core/consent";
2
2
  /**
3
3
  * Non-React mirror of `useConsent`'s `isAnalyticsAllowed` — pass the returned function as
4
4
  * `createClientTracker({ isAnalyticsAllowed })` so the pipeline and the banner share one rule.
@@ -1,4 +1,4 @@
1
- import type { CookieAnonymousId } from "#/client/cookie-anonymous-id";
1
+ import type { CookieAnonymousId } from "#client/cookie-anonymous-id";
2
2
  /**
3
3
  * Options for `createServerPersistedAnonymousId`.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { createCookieAnonymousId } from "#/client/cookie-anonymous-id";
2
- import { readCookieValue } from "#/core/cookie";
1
+ import { createCookieAnonymousId } from "#client/cookie-anonymous-id";
2
+ import { readCookieValue } from "#core/cookie";
3
3
  /**
4
4
  * `createCookieAnonymousId` plus server persistence: the client still mints the id
5
5
  * (lazily, only once an event is allowed to send — consent stays client-owned), then
@@ -1,4 +1,4 @@
1
- import type { ConsentCategory } from "#/core/consent";
1
+ import type { ConsentCategory } from "#core/consent";
2
2
  /**
3
3
  * The consent constants every surface must agree on. The React hooks, the client
4
4
  * tracker gate, and the pre-hydration tag bootstrap all accept this object, so the
@@ -1,4 +1,4 @@
1
- import type { ConsentDecision } from "#/core/consent";
1
+ import type { ConsentDecision } from "#core/consent";
2
2
  /**
3
3
  * Which consent event a receipt records. Receipts are append-only: an `update` or
4
4
  * `withdraw` is a new receipt referencing the prior one, never a mutation.
@@ -1,4 +1,4 @@
1
- import { isConsentDecision } from "#/core/consent";
1
+ import { isConsentDecision } from "#core/consent";
2
2
  function isString(value) {
3
3
  return typeof value === "string";
4
4
  }
@@ -1,4 +1,4 @@
1
- import type { TrackedEvent } from "#/core/tracked-event";
1
+ import type { TrackedEvent } from "#core/tracked-event";
2
2
  /**
3
3
  * Fan-out target for tracked events. The tracker depends only on this interface, never
4
4
  * on a specific provider SDK — destinations own their transport (gtag.js and Vercel both
@@ -1,4 +1,4 @@
1
- import type { ConsentDecision } from "#/core/consent";
1
+ import type { ConsentDecision } from "#core/consent";
2
2
  /**
3
3
  * The normalized two-lever ad-platform consent state derived from one `{ ads, analytics }`
4
4
  * decision (spec-destinations §5): `analytics` drives whether events transmit at all, and
@@ -1,8 +1,8 @@
1
- import type { ConsentDecision } from "#/core/consent";
2
- import type { ConsentConfig } from "#/core/consent-config";
3
- import type { Destination } from "#/core/destination";
4
- import type { GoogleConsentParams } from "#/destinations/google-consent";
5
- import type { FlatPropertyValue } from "#/destinations/shared";
1
+ import type { ConsentDecision } from "#core/consent";
2
+ import type { ConsentConfig } from "#core/consent-config";
3
+ import type { Destination } from "#core/destination";
4
+ import type { GoogleConsentParams } from "#destinations/google-consent";
5
+ import type { FlatPropertyValue } from "#destinations/shared";
6
6
  type GtagPropertyValue = FlatPropertyValue;
7
7
  /**
8
8
  * All signatures share one `gtag` global, so they must live in a single overloaded type —
@@ -1,5 +1,5 @@
1
- import { buildGoogleConsentBootstrapPreamble, DEFAULT_DATA_LAYER_NAME, ensureDataLayer, toGoogleConsentParams, warnUnlessGa4EventName, } from "#/destinations/google-consent";
2
- import { flattenEventProps } from "#/destinations/shared";
1
+ import { buildGoogleConsentBootstrapPreamble, DEFAULT_DATA_LAYER_NAME, ensureDataLayer, toGoogleConsentParams, warnUnlessGa4EventName, } from "#destinations/google-consent";
2
+ import { flattenEventProps } from "#destinations/shared";
3
3
  const GTAG_SCRIPT_BASE_URL = "https://www.googletagmanager.com/gtag/js";
4
4
  function gtagScriptSrc(gaMeasurementId, dataLayerName) {
5
5
  const url = new URL(GTAG_SCRIPT_BASE_URL);
@@ -1,4 +1,4 @@
1
- import type { ConsentDecision } from "#/core/consent";
1
+ import type { ConsentDecision } from "#core/consent";
2
2
  /**
3
3
  * gtag.js/gtm.js's default queue-array name — shared so the gtag and GTM helpers cannot disagree.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { CONSENT_CATEGORIES } from "#/core/consent";
1
+ import { CONSENT_CATEGORIES } from "#core/consent";
2
2
  /**
3
3
  * gtag.js/gtm.js's default queue-array name — shared so the gtag and GTM helpers cannot disagree.
4
4
  *
@@ -1,6 +1,6 @@
1
- import type { ConsentDecision } from "#/core/consent";
2
- import type { Destination } from "#/core/destination";
3
- import type { FlatPropertyValue } from "#/destinations/shared";
1
+ import type { ConsentDecision } from "#core/consent";
2
+ import type { Destination } from "#core/destination";
3
+ import type { FlatPropertyValue } from "#destinations/shared";
4
4
  /**
5
5
  * Meta's `dataProcessingOptions` restriction. `['LDU'], 0, 0` turns on Limited Data Use and
6
6
  * lets Meta geolocate the user — the recommended default beyond California, where only
@@ -1,5 +1,5 @@
1
- import { toAdConsentState } from "#/destinations/ad-consent";
2
- import { flattenEventProps } from "#/destinations/shared";
1
+ import { toAdConsentState } from "#destinations/ad-consent";
2
+ import { flattenEventProps } from "#destinations/shared";
3
3
  /**
4
4
  * Maps a `ConsentDecision` to Meta's `dataProcessingOptions`: LDU when `ads` is denied.
5
5
  *
@@ -1,6 +1,6 @@
1
- import type { ConsentDecision } from "#/core/consent";
2
- import type { Destination } from "#/core/destination";
3
- import type { FlatPropertyValue } from "#/destinations/shared";
1
+ import type { ConsentDecision } from "#core/consent";
2
+ import type { Destination } from "#core/destination";
3
+ import type { FlatPropertyValue } from "#destinations/shared";
4
4
  /**
5
5
  * Microsoft UET consent. UET enforces **only** `ad_storage` — it has no `analytics_storage`,
6
6
  * and its `ad_user_data`/`ad_personalization` fields have no documented behavior, so this
@@ -1,5 +1,5 @@
1
- import { toAdConsentState } from "#/destinations/ad-consent";
2
- import { flattenEventProps } from "#/destinations/shared";
1
+ import { toAdConsentState } from "#destinations/ad-consent";
2
+ import { flattenEventProps } from "#destinations/shared";
3
3
  /**
4
4
  * Maps a `ConsentDecision` to UET's enforced `ad_storage` signal via the shared ad lever, so
5
5
  * it can't drift from Meta/TikTok — `ad_storage` is the inverse of Limited Data Use.
@@ -1,6 +1,6 @@
1
- import type { ConsentDecision } from "#/core/consent";
2
- import type { Destination } from "#/core/destination";
3
- import type { FlatPropertyValue } from "#/destinations/shared";
1
+ import type { ConsentDecision } from "#core/consent";
2
+ import type { Destination } from "#core/destination";
3
+ import type { FlatPropertyValue } from "#destinations/shared";
4
4
  /**
5
5
  * TikTok consent. TikTok uses a **single Limited Data Use boolean**, not Meta's
6
6
  * `dataProcessingOptions` structure and no signal object (spec-destinations §5). Its
@@ -1,5 +1,5 @@
1
- import { toAdConsentState } from "#/destinations/ad-consent";
2
- import { flattenEventProps } from "#/destinations/shared";
1
+ import { toAdConsentState } from "#destinations/ad-consent";
2
+ import { flattenEventProps } from "#destinations/shared";
3
3
  /**
4
4
  * Maps a `ConsentDecision` to TikTok's LDU boolean — on when `ads` is denied.
5
5
  *
@@ -1,4 +1,4 @@
1
- import type { Destination } from "#/core/destination";
1
+ import type { Destination } from "#core/destination";
2
2
  /**
3
3
  * Options for `createVercelAnalyticsDestination`.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { track } from "@vercel/analytics";
2
- import { flattenEventProps } from "#/destinations/shared";
2
+ import { flattenEventProps } from "#destinations/shared";
3
3
  /**
4
4
  * `track()` only pushes onto Vercel's own in-page queue (`window.va`/`window.vaq`), which
5
5
  * handles batching and unload delivery itself. Requires the Vercel Analytics script to be
package/dist/index.d.ts CHANGED
@@ -13,52 +13,52 @@
13
13
  * `@codefast/tracking/destinations/vercel-analytics` so its `@vercel/analytics` peer is only
14
14
  * pulled in when used.
15
15
  */
16
- export type { ConsentCategory, ConsentDecision, ConsentMode, ConsentRecord, ConsentRegion, ConsentStorage, InitialConsent, ResolveDefaultConsentOptions, ResolveEffectiveConsentOptions, } from "#/core/consent";
17
- export { CONSENT_CATEGORIES, CONSENT_REGIONS, createConsentDecision, isConsentDecision, isConsentRecord, isConsentRegion, isInitialConsent, normalizeConsentDecision, readStoredDecision, resolveConsentMode, resolveDefaultConsent, resolveEffectiveConsent, STRICTEST_INITIAL_CONSENT, } from "#/core/consent";
18
- export type { ConsentConfig } from "#/core/consent-config";
19
- export { defineConsentConfig } from "#/core/consent-config";
20
- export type { ConsentReceipt, ConsentReceiptEventType, ConsentReceiptInput, ConsentReceiptMethod, ConsentReceiptSubjectIdType, } from "#/core/consent-receipt";
21
- export { isConsentReceiptInput } from "#/core/consent-receipt";
22
- export { readCookieValue } from "#/core/cookie";
23
- export type { Destination } from "#/core/destination";
24
- export type { EventCatalog, EventDefinition } from "#/core/event-catalog";
25
- export { assertValidEventProperties, defineEventCatalog } from "#/core/event-catalog";
26
- export { generateEventId } from "#/core/event-id";
27
- export type { TrackedEvent } from "#/core/tracked-event";
28
- export type { CmpConsentSignal, CmpStatus, ReconcileAdFrameworkConsentOptions } from "#/client/ad-framework-consent";
29
- export { hasGppApi, hasTcfApi, reconcileAdFrameworkConsent } from "#/client/ad-framework-consent";
30
- export type { ConsentRuntime, ConsentRuntimeOptions } from "#/client/consent-runtime";
31
- export { createConsentRuntime } from "#/client/consent-runtime";
32
- export { createLocalStorageConsentStorage } from "#/client/consent-storage";
33
- export type { ConsentWithdrawalHandlerOptions } from "#/client/consent-withdrawal";
34
- export { createConsentWithdrawalHandler } from "#/client/consent-withdrawal";
35
- export type { CookieAnonymousId, CookieAnonymousIdOptions } from "#/client/cookie-anonymous-id";
36
- export { createCookieAnonymousId } from "#/client/cookie-anonymous-id";
37
- export type { ClientTracker, ClientTrackerOptions, DeliveryErrorContext } from "#/client/create-client-tracker";
38
- export { createClientTracker } from "#/client/create-client-tracker";
39
- export { hasGlobalPrivacyControlSignal } from "#/client/gpc";
40
- export type { InitialConsentSnapshot, InitialConsentStore, InitialConsentStoreOptions, } from "#/client/initial-consent-store";
41
- export { createInitialConsentStore } from "#/client/initial-consent-store";
42
- export type { IsAnalyticsAllowedOptions } from "#/client/is-analytics-allowed";
43
- export { createIsAnalyticsAllowed } from "#/client/is-analytics-allowed";
44
- export type { ServerPersistedAnonymousIdOptions } from "#/client/server-persisted-anonymous-id";
45
- export { createServerPersistedAnonymousId } from "#/client/server-persisted-anonymous-id";
46
- export type { ConsentBannerAcceptProps, ConsentBannerActionsProps, ConsentBannerCategoryProps, ConsentBannerCustomizeProps, ConsentBannerDescriptionProps, ConsentBannerPreferencesProps, ConsentBannerProps, ConsentBannerRejectProps, ConsentBannerSaveProps, ConsentBannerTitleProps, ConsentToggleProps, } from "#/react/consent-banner";
47
- export { ConsentBanner, ConsentBannerAccept, ConsentBannerActions, ConsentBannerCategory, ConsentBannerCustomize, ConsentBannerDescription, ConsentBannerPreferences, ConsentBannerReject, ConsentBannerSave, ConsentBannerTitle, ConsentToggle, } from "#/react/consent-banner";
48
- export type { GtagConsentBootstrapProps } from "#/react/gtag-consent-bootstrap";
49
- export { GtagConsentBootstrap } from "#/react/gtag-consent-bootstrap";
50
- export type { UseConsentOptions, UseConsentResult } from "#/react/use-consent";
51
- export { useConsent } from "#/react/use-consent";
52
- export type { UseGoogleConsentSyncOptions } from "#/react/use-google-consent-sync";
53
- export { useGoogleConsentSync } from "#/react/use-google-consent-sync";
54
- export { useInitialConsent } from "#/react/use-initial-consent";
55
- export type { AdConsentState } from "#/destinations/ad-consent";
56
- export { toAdConsentState } from "#/destinations/ad-consent";
57
- export type { EnsureGtagOptions, GoogleAnalyticsDestinationOptions, GtagConsentBootstrapOptions, GtagFunction, LoadGtagScriptOptions, } from "#/destinations/google-analytics";
58
- export { buildGtagConsentBootstrapScript, clearGoogleAnalyticsCookies, createGoogleAnalyticsDestination, ensureGtag, loadGtagScript, updateGoogleConsent, } from "#/destinations/google-analytics";
59
- export type { MetaDataProcessingOptions, MetaDestinationOptions, MetaEventPayload } from "#/destinations/meta";
60
- export { createMetaDestination, toMetaDataProcessingOptions } from "#/destinations/meta";
61
- export type { MicrosoftUetConsent, MicrosoftUetDestinationOptions, MicrosoftUetEventPayload, } from "#/destinations/microsoft-uet";
62
- export { createMicrosoftUetDestination, toMicrosoftUetConsent } from "#/destinations/microsoft-uet";
63
- export type { TiktokConsent, TiktokDestinationOptions, TiktokEventPayload } from "#/destinations/tiktok";
64
- export { createTiktokDestination, toTiktokConsent } from "#/destinations/tiktok";
16
+ export type { ConsentCategory, ConsentDecision, ConsentMode, ConsentRecord, ConsentRegion, ConsentStorage, InitialConsent, ResolveDefaultConsentOptions, ResolveEffectiveConsentOptions, } from "#core/consent";
17
+ export { CONSENT_CATEGORIES, CONSENT_REGIONS, createConsentDecision, isConsentDecision, isConsentRecord, isConsentRegion, isInitialConsent, normalizeConsentDecision, readStoredDecision, resolveConsentMode, resolveDefaultConsent, resolveEffectiveConsent, STRICTEST_INITIAL_CONSENT, } from "#core/consent";
18
+ export type { ConsentConfig } from "#core/consent-config";
19
+ export { defineConsentConfig } from "#core/consent-config";
20
+ export type { ConsentReceipt, ConsentReceiptEventType, ConsentReceiptInput, ConsentReceiptMethod, ConsentReceiptSubjectIdType, } from "#core/consent-receipt";
21
+ export { isConsentReceiptInput } from "#core/consent-receipt";
22
+ export { readCookieValue } from "#core/cookie";
23
+ export type { Destination } from "#core/destination";
24
+ export type { EventCatalog, EventDefinition } from "#core/event-catalog";
25
+ export { assertValidEventProperties, defineEventCatalog } from "#core/event-catalog";
26
+ export { generateEventId } from "#core/event-id";
27
+ export type { TrackedEvent } from "#core/tracked-event";
28
+ export type { CmpConsentSignal, CmpStatus, ReconcileAdFrameworkConsentOptions } from "#client/ad-framework-consent";
29
+ export { hasGppApi, hasTcfApi, reconcileAdFrameworkConsent } from "#client/ad-framework-consent";
30
+ export type { ConsentRuntime, ConsentRuntimeOptions } from "#client/consent-runtime";
31
+ export { createConsentRuntime } from "#client/consent-runtime";
32
+ export { createLocalStorageConsentStorage } from "#client/consent-storage";
33
+ export type { ConsentWithdrawalHandlerOptions } from "#client/consent-withdrawal";
34
+ export { createConsentWithdrawalHandler } from "#client/consent-withdrawal";
35
+ export type { CookieAnonymousId, CookieAnonymousIdOptions } from "#client/cookie-anonymous-id";
36
+ export { createCookieAnonymousId } from "#client/cookie-anonymous-id";
37
+ export type { ClientTracker, ClientTrackerOptions, DeliveryErrorContext } from "#client/create-client-tracker";
38
+ export { createClientTracker } from "#client/create-client-tracker";
39
+ export { hasGlobalPrivacyControlSignal } from "#client/gpc";
40
+ export type { InitialConsentSnapshot, InitialConsentStore, InitialConsentStoreOptions, } from "#client/initial-consent-store";
41
+ export { createInitialConsentStore } from "#client/initial-consent-store";
42
+ export type { IsAnalyticsAllowedOptions } from "#client/is-analytics-allowed";
43
+ export { createIsAnalyticsAllowed } from "#client/is-analytics-allowed";
44
+ export type { ServerPersistedAnonymousIdOptions } from "#client/server-persisted-anonymous-id";
45
+ export { createServerPersistedAnonymousId } from "#client/server-persisted-anonymous-id";
46
+ export type { ConsentBannerAcceptProps, ConsentBannerActionsProps, ConsentBannerCategoryProps, ConsentBannerCustomizeProps, ConsentBannerDescriptionProps, ConsentBannerPreferencesProps, ConsentBannerProps, ConsentBannerRejectProps, ConsentBannerSaveProps, ConsentBannerTitleProps, ConsentToggleProps, } from "#react/consent-banner";
47
+ export { ConsentBanner, ConsentBannerAccept, ConsentBannerActions, ConsentBannerCategory, ConsentBannerCustomize, ConsentBannerDescription, ConsentBannerPreferences, ConsentBannerReject, ConsentBannerSave, ConsentBannerTitle, ConsentToggle, } from "#react/consent-banner";
48
+ export type { GtagConsentBootstrapProps } from "#react/gtag-consent-bootstrap";
49
+ export { GtagConsentBootstrap } from "#react/gtag-consent-bootstrap";
50
+ export type { UseConsentOptions, UseConsentResult } from "#react/use-consent";
51
+ export { useConsent } from "#react/use-consent";
52
+ export type { UseGoogleConsentSyncOptions } from "#react/use-google-consent-sync";
53
+ export { useGoogleConsentSync } from "#react/use-google-consent-sync";
54
+ export { useInitialConsent } from "#react/use-initial-consent";
55
+ export type { AdConsentState } from "#destinations/ad-consent";
56
+ export { toAdConsentState } from "#destinations/ad-consent";
57
+ export type { EnsureGtagOptions, GoogleAnalyticsDestinationOptions, GtagConsentBootstrapOptions, GtagFunction, LoadGtagScriptOptions, } from "#destinations/google-analytics";
58
+ export { buildGtagConsentBootstrapScript, clearGoogleAnalyticsCookies, createGoogleAnalyticsDestination, ensureGtag, loadGtagScript, updateGoogleConsent, } from "#destinations/google-analytics";
59
+ export type { MetaDataProcessingOptions, MetaDestinationOptions, MetaEventPayload } from "#destinations/meta";
60
+ export { createMetaDestination, toMetaDataProcessingOptions } from "#destinations/meta";
61
+ export type { MicrosoftUetConsent, MicrosoftUetDestinationOptions, MicrosoftUetEventPayload, } from "#destinations/microsoft-uet";
62
+ export { createMicrosoftUetDestination, toMicrosoftUetConsent } from "#destinations/microsoft-uet";
63
+ export type { TiktokConsent, TiktokDestinationOptions, TiktokEventPayload } from "#destinations/tiktok";
64
+ export { createTiktokDestination, toTiktokConsent } from "#destinations/tiktok";
package/dist/index.js CHANGED
@@ -13,29 +13,29 @@
13
13
  * `@codefast/tracking/destinations/vercel-analytics` so its `@vercel/analytics` peer is only
14
14
  * pulled in when used.
15
15
  */
16
- export { CONSENT_CATEGORIES, CONSENT_REGIONS, createConsentDecision, isConsentDecision, isConsentRecord, isConsentRegion, isInitialConsent, normalizeConsentDecision, readStoredDecision, resolveConsentMode, resolveDefaultConsent, resolveEffectiveConsent, STRICTEST_INITIAL_CONSENT, } from "#/core/consent";
17
- export { defineConsentConfig } from "#/core/consent-config";
18
- export { isConsentReceiptInput } from "#/core/consent-receipt";
19
- export { readCookieValue } from "#/core/cookie";
20
- export { assertValidEventProperties, defineEventCatalog } from "#/core/event-catalog";
21
- export { generateEventId } from "#/core/event-id";
22
- export { hasGppApi, hasTcfApi, reconcileAdFrameworkConsent } from "#/client/ad-framework-consent";
23
- export { createConsentRuntime } from "#/client/consent-runtime";
24
- export { createLocalStorageConsentStorage } from "#/client/consent-storage";
25
- export { createConsentWithdrawalHandler } from "#/client/consent-withdrawal";
26
- export { createCookieAnonymousId } from "#/client/cookie-anonymous-id";
27
- export { createClientTracker } from "#/client/create-client-tracker";
28
- export { hasGlobalPrivacyControlSignal } from "#/client/gpc";
29
- export { createInitialConsentStore } from "#/client/initial-consent-store";
30
- export { createIsAnalyticsAllowed } from "#/client/is-analytics-allowed";
31
- export { createServerPersistedAnonymousId } from "#/client/server-persisted-anonymous-id";
32
- export { ConsentBanner, ConsentBannerAccept, ConsentBannerActions, ConsentBannerCategory, ConsentBannerCustomize, ConsentBannerDescription, ConsentBannerPreferences, ConsentBannerReject, ConsentBannerSave, ConsentBannerTitle, ConsentToggle, } from "#/react/consent-banner";
33
- export { GtagConsentBootstrap } from "#/react/gtag-consent-bootstrap";
34
- export { useConsent } from "#/react/use-consent";
35
- export { useGoogleConsentSync } from "#/react/use-google-consent-sync";
36
- export { useInitialConsent } from "#/react/use-initial-consent";
37
- export { toAdConsentState } from "#/destinations/ad-consent";
38
- export { buildGtagConsentBootstrapScript, clearGoogleAnalyticsCookies, createGoogleAnalyticsDestination, ensureGtag, loadGtagScript, updateGoogleConsent, } from "#/destinations/google-analytics";
39
- export { createMetaDestination, toMetaDataProcessingOptions } from "#/destinations/meta";
40
- export { createMicrosoftUetDestination, toMicrosoftUetConsent } from "#/destinations/microsoft-uet";
41
- export { createTiktokDestination, toTiktokConsent } from "#/destinations/tiktok";
16
+ export { CONSENT_CATEGORIES, CONSENT_REGIONS, createConsentDecision, isConsentDecision, isConsentRecord, isConsentRegion, isInitialConsent, normalizeConsentDecision, readStoredDecision, resolveConsentMode, resolveDefaultConsent, resolveEffectiveConsent, STRICTEST_INITIAL_CONSENT, } from "#core/consent";
17
+ export { defineConsentConfig } from "#core/consent-config";
18
+ export { isConsentReceiptInput } from "#core/consent-receipt";
19
+ export { readCookieValue } from "#core/cookie";
20
+ export { assertValidEventProperties, defineEventCatalog } from "#core/event-catalog";
21
+ export { generateEventId } from "#core/event-id";
22
+ export { hasGppApi, hasTcfApi, reconcileAdFrameworkConsent } from "#client/ad-framework-consent";
23
+ export { createConsentRuntime } from "#client/consent-runtime";
24
+ export { createLocalStorageConsentStorage } from "#client/consent-storage";
25
+ export { createConsentWithdrawalHandler } from "#client/consent-withdrawal";
26
+ export { createCookieAnonymousId } from "#client/cookie-anonymous-id";
27
+ export { createClientTracker } from "#client/create-client-tracker";
28
+ export { hasGlobalPrivacyControlSignal } from "#client/gpc";
29
+ export { createInitialConsentStore } from "#client/initial-consent-store";
30
+ export { createIsAnalyticsAllowed } from "#client/is-analytics-allowed";
31
+ export { createServerPersistedAnonymousId } from "#client/server-persisted-anonymous-id";
32
+ export { ConsentBanner, ConsentBannerAccept, ConsentBannerActions, ConsentBannerCategory, ConsentBannerCustomize, ConsentBannerDescription, ConsentBannerPreferences, ConsentBannerReject, ConsentBannerSave, ConsentBannerTitle, ConsentToggle, } from "#react/consent-banner";
33
+ export { GtagConsentBootstrap } from "#react/gtag-consent-bootstrap";
34
+ export { useConsent } from "#react/use-consent";
35
+ export { useGoogleConsentSync } from "#react/use-google-consent-sync";
36
+ export { useInitialConsent } from "#react/use-initial-consent";
37
+ export { toAdConsentState } from "#destinations/ad-consent";
38
+ export { buildGtagConsentBootstrapScript, clearGoogleAnalyticsCookies, createGoogleAnalyticsDestination, ensureGtag, loadGtagScript, updateGoogleConsent, } from "#destinations/google-analytics";
39
+ export { createMetaDestination, toMetaDataProcessingOptions } from "#destinations/meta";
40
+ export { createMicrosoftUetDestination, toMicrosoftUetConsent } from "#destinations/microsoft-uet";
41
+ export { createTiktokDestination, toTiktokConsent } from "#destinations/tiktok";
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps, ReactNode } from "react";
2
- import type { ConsentCategory } from "#/core/consent";
3
- import type { UseConsentResult } from "#/react/use-consent";
2
+ import type { ConsentCategory } from "#core/consent";
3
+ import type { UseConsentResult } from "#react/use-consent";
4
4
  /**
5
5
  * Props for {@link ConsentBanner}.
6
6
  *
@@ -1,5 +1,5 @@
1
1
  import type { ComponentProps, ReactNode } from "react";
2
- import type { GtagConsentBootstrapOptions } from "#/destinations/google-analytics";
2
+ import type { GtagConsentBootstrapOptions } from "#destinations/google-analytics";
3
3
  /**
4
4
  * Props for {@link GtagConsentBootstrap}.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { buildGtagConsentBootstrapScript } from "#/destinations/google-analytics";
2
+ import { buildGtagConsentBootstrapScript } from "#destinations/google-analytics";
3
3
  /**
4
4
  * Framework-agnostic inline `<script>` that runs `buildGtagConsentBootstrapScript` before
5
5
  * hydration. Pass the same `nonce` here and in `loadGtagScript` for CSP; this component
@@ -1,5 +1,5 @@
1
- import type { ConsentDecision, ConsentMode, ConsentStorage } from "#/core/consent";
2
- import type { ConsentConfig } from "#/core/consent-config";
1
+ import type { ConsentDecision, ConsentMode, ConsentStorage } from "#core/consent";
2
+ import type { ConsentConfig } from "#core/consent-config";
3
3
  /**
4
4
  * Options for `useConsent`.
5
5
  *
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useCallback, useMemo, useRef, useSyncExternalStore } from "react";
3
- import { CONSENT_CATEGORIES, createConsentDecision, readStoredDecision, resolveDefaultConsent } from "#/core/consent";
3
+ import { CONSENT_CATEGORIES, createConsentDecision, readStoredDecision, resolveDefaultConsent } from "#core/consent";
4
4
  /**
5
5
  * Bridges `resolveConsentMode`/`resolveDefaultConsent` (core, region-aware) to React via
6
6
  * `useSyncExternalStore`: the stored record is the single source of truth, hydration is
@@ -1,4 +1,4 @@
1
- import type { UseConsentResult } from "#/react/use-consent";
1
+ import type { UseConsentResult } from "#react/use-consent";
2
2
  /**
3
3
  * Options for `useGoogleConsentSync`.
4
4
  *
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useEffect } from "react";
3
- import { updateGoogleConsent } from "#/destinations/google-analytics";
3
+ import { updateGoogleConsent } from "#destinations/google-analytics";
4
4
  /**
5
5
  * Keeps Google Consent Mode v2 in sync with `useConsent`: emits `update` when a stored
6
6
  * decision exists (including cross-tab / privacy-page saves), and optionally loads gtag
@@ -1,4 +1,4 @@
1
- import type { InitialConsentSnapshot, InitialConsentStore } from "#/client/initial-consent-store";
1
+ import type { InitialConsentSnapshot, InitialConsentStore } from "#client/initial-consent-store";
2
2
  /**
3
3
  * Reactive view of a `createInitialConsentStore` — kicks off resolution on mount (a no-op
4
4
  * when the app already did so at router creation) and re-renders once the server lane
@@ -1,4 +1,4 @@
1
- import { ONE_YEAR_IN_SECONDS } from "#/core/cookie";
1
+ import { ONE_YEAR_IN_SECONDS } from "#core/cookie";
2
2
  // The only shape the client ever mints (crypto.randomUUID) — anything else is rejected.
3
3
  const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4
4
  // Conservative subset of the RFC 6265 cookie-name token.
@@ -1,4 +1,4 @@
1
- import type { ConsentReceipt } from "#/core/consent-receipt";
1
+ import type { ConsentReceipt } from "#core/consent-receipt";
2
2
  /**
3
3
  * Persistence backend for consent receipts — the durable store is the consumer's to supply
4
4
  * (a database, an append-only log). The store is **append-only**: `append` never overwrites,
@@ -1,4 +1,4 @@
1
- import type { ConsentReceipt, ConsentReceiptInput } from "#/core/consent-receipt";
1
+ import type { ConsentReceipt, ConsentReceiptInput } from "#core/consent-receipt";
2
2
  /**
3
3
  * The receipt information-structure version this builder emits (ISO/IEC TS 27560-shaped).
4
4
  * Bump when the receipt field set changes; stored receipts carry it so a reader can migrate.
@@ -1,4 +1,4 @@
1
- import type { ConsentCategory, InitialConsent } from "#/core/consent";
1
+ import type { ConsentCategory, InitialConsent } from "#core/consent";
2
2
  /**
3
3
  * Options for `resolveInitialConsent`.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { resolveConsentMode, resolveDefaultConsent, STRICTEST_INITIAL_CONSENT } from "#/core/consent";
2
- import { resolveRegionFromCountryCode } from "#/server/region";
1
+ import { resolveConsentMode, resolveDefaultConsent, STRICTEST_INITIAL_CONSENT } from "#core/consent";
2
+ import { resolveRegionFromCountryCode } from "#server/region";
3
3
  /**
4
4
  * Pure region → mode → default-consent resolution for server functions (or a fail-closed
5
5
  * bake when country is unknown). Named with the `resolve*` family it composes.
@@ -1,4 +1,4 @@
1
- import type { ConsentDecision } from "#/core/consent";
1
+ import type { ConsentDecision } from "#core/consent";
2
2
  /**
3
3
  * A GA4 event for the Measurement Protocol. `params` are flat scalars — GA4 rejects nested values and booleans.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { ConsentRegion } from "#/core/consent";
1
+ import type { ConsentRegion } from "#core/consent";
2
2
  /**
3
3
  * EU member states — GDPR opt-in via `resolveConsentMode("eu")`.
4
4
  *
@@ -3,7 +3,7 @@
3
3
  * framework-neutral data each build tool maps to its own guard: TanStack Start's
4
4
  * `importProtection.client.specifiers`, Next's `server-only`, Remix's `.server` convention.
5
5
  * Ships and versions with the package instead of going stale in each consumer's config.
6
- * Nothing in this package imports it — its consumers are app build configs (see apps/ui
6
+ * Nothing in this package imports it — its consumers are app build configs (see apps/web
7
7
  * vite.config.ts).
8
8
  *
9
9
  * @example
@@ -3,7 +3,7 @@
3
3
  * framework-neutral data each build tool maps to its own guard: TanStack Start's
4
4
  * `importProtection.client.specifiers`, Next's `server-only`, Remix's `.server` convention.
5
5
  * Ships and versions with the package instead of going stale in each consumer's config.
6
- * Nothing in this package imports it — its consumers are app build configs (see apps/ui
6
+ * Nothing in this package imports it — its consumers are app build configs (see apps/web
7
7
  * vite.config.ts).
8
8
  *
9
9
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefast/tracking",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
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",
@@ -16,7 +16,7 @@
16
16
  "url": "https://github.com/codefastlabs/codefast/issues"
17
17
  },
18
18
  "license": "MIT",
19
- "author": "Vuong Phan <mr.thevuong@gmail.com>",
19
+ "author": "Vuong Phan <mr.thevuong@gmail.com> (https://github.com/thevuong)",
20
20
  "repository": {
21
21
  "type": "git",
22
22
  "url": "git+https://github.com/codefastlabs/codefast.git",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "files": [
26
26
  "dist",
27
+ "src/css",
27
28
  "CHANGELOG.md",
28
29
  "README.md",
29
30
  "LICENSE"
@@ -34,14 +35,7 @@
34
35
  "module": "./dist/index.js",
35
36
  "types": "./dist/index.d.ts",
36
37
  "imports": {
37
- "#/tests/*": [
38
- "./tests/*",
39
- "./tests/*.ts",
40
- "./tests/*.tsx",
41
- "./tests/*/index.ts",
42
- "./tests/*/index.tsx"
43
- ],
44
- "#/*": {
38
+ "#*": {
45
39
  "types": "./dist/*.d.ts",
46
40
  "default": "./dist/*.js"
47
41
  }
@@ -224,26 +218,6 @@
224
218
  "dependencies": {
225
219
  "@standard-schema/spec": "^1.1.0"
226
220
  },
227
- "devDependencies": {
228
- "@tanstack/react-start": "^1.168.49",
229
- "@testing-library/dom": "^10.4.1",
230
- "@testing-library/jest-dom": "^7.0.1",
231
- "@testing-library/react": "^16.3.3",
232
- "@testing-library/user-event": "^14.6.7",
233
- "@types/node": "^26.4.1",
234
- "@types/react": "^19.2.18",
235
- "@types/react-dom": "^19.2.7",
236
- "@vercel/analytics": "^2.0.1",
237
- "@vitejs/plugin-react": "^6.1.1",
238
- "@vitest/coverage-v8": "^5.0.0",
239
- "jsdom": "^30.0.1",
240
- "react": "^19.2.8",
241
- "react-dom": "^19.2.8",
242
- "typescript": "^7.0.2",
243
- "vitest": "^5.0.0",
244
- "zod": "^4.5.4",
245
- "@codefast/typescript-config": "0.9.0"
246
- },
247
221
  "peerDependencies": {
248
222
  "@tanstack/react-start": ">=1.168.0",
249
223
  "@types/react": ">=19.0.0",
@@ -274,17 +248,5 @@
274
248
  },
275
249
  "engines": {
276
250
  "node": ">=24.0.0"
277
- },
278
- "scripts": {
279
- "build": "rm -rf dist && tsc -p tsconfig.build.json",
280
- "check-types": "tsc --noEmit",
281
- "clean": "rm -rf dist",
282
- "test": "vitest run",
283
- "test:coverage": "vitest run --coverage",
284
- "test:e2e": "vitest run tests/e2e",
285
- "test:integration": "vitest run tests/integration",
286
- "test:type": "vitest run tests/types",
287
- "test:unit": "vitest run tests/unit",
288
- "test:watch": "vitest"
289
251
  }
290
252
  }
@@ -0,0 +1,119 @@
1
+ /* -------------------------------------------------------------------------
2
+ * Optional consent UI theme
3
+ *
4
+ * Plain CSS over the components' data-slot attributes — no Tailwind, no
5
+ * design-system dependency. Import it for a sensible default look:
6
+ *
7
+ * @import "@codefast/tracking/css/consent.css";
8
+ *
9
+ * Every color routes through a `--consent-*` custom property with a
10
+ * `light-dark()` fallback, so a host app can retheme by defining those
11
+ * properties (or skip this file entirely and style the slots itself).
12
+ * ------------------------------------------------------------------------- */
13
+
14
+ [data-slot="consent-banner"] {
15
+ position: fixed;
16
+ inset-inline: 1rem;
17
+ bottom: 1rem;
18
+ z-index: 50;
19
+ margin-inline: auto;
20
+ max-width: 24rem;
21
+ padding: 1.25rem;
22
+ border: 1px solid var(--consent-border, light-dark(rgb(0 0 0 / 12%), rgb(255 255 255 / 14%)));
23
+ border-radius: 1rem;
24
+ background: var(--consent-surface, light-dark(#fff, #1c1c1e));
25
+ color: var(--consent-fg, light-dark(#1c1c1e, #f2f2f7));
26
+ box-shadow: 0 12px 32px rgb(0 0 0 / 18%);
27
+ font-size: 0.875rem;
28
+ line-height: 1.5;
29
+ animation: consent-banner-in 220ms ease-out;
30
+ }
31
+
32
+ @media (min-width: 640px) {
33
+ [data-slot="consent-banner"] {
34
+ inset-inline: auto 1rem;
35
+ }
36
+ }
37
+
38
+ @keyframes consent-banner-in {
39
+ from {
40
+ opacity: 0;
41
+ transform: translateY(1rem);
42
+ }
43
+ }
44
+
45
+ @media (prefers-reduced-motion: reduce) {
46
+ [data-slot="consent-banner"] {
47
+ animation: none;
48
+ }
49
+ }
50
+
51
+ [data-slot="consent-title"] {
52
+ margin: 0 0 0.375rem;
53
+ font-size: 0.875rem;
54
+ font-weight: 600;
55
+ }
56
+
57
+ [data-slot="consent-description"] {
58
+ margin: 0 0 1rem;
59
+ color: var(--consent-muted, light-dark(rgb(28 28 30 / 65%), rgb(242 242 247 / 65%)));
60
+ }
61
+
62
+ [data-slot="consent-description"] a {
63
+ color: inherit;
64
+ text-decoration: underline;
65
+ text-underline-offset: 0.2em;
66
+ }
67
+
68
+ [data-slot="consent-preferences"] {
69
+ display: flex;
70
+ flex-direction: column;
71
+ gap: 0.5rem;
72
+ margin-bottom: 1rem;
73
+ }
74
+
75
+ [data-slot="consent-category"] {
76
+ display: flex;
77
+ gap: 0.5rem;
78
+ align-items: baseline;
79
+ }
80
+
81
+ [data-slot="consent-actions"] {
82
+ display: flex;
83
+ gap: 0.5rem;
84
+ }
85
+
86
+ [data-slot="consent-action"] {
87
+ flex: 1;
88
+ padding: 0.5rem 0.75rem;
89
+ border: 1px solid var(--consent-border, light-dark(rgb(0 0 0 / 12%), rgb(255 255 255 / 14%)));
90
+ border-radius: 0.5rem;
91
+ background: transparent;
92
+ color: inherit;
93
+ font: inherit;
94
+ font-weight: 500;
95
+ cursor: pointer;
96
+ }
97
+
98
+ /* The affirmative actions carry the accent; Reject stays equally prominent, just outlined. */
99
+ [data-slot="consent-action"][data-action="accept"],
100
+ [data-slot="consent-action"][data-action="save"] {
101
+ border-color: transparent;
102
+ background: var(--consent-accent, light-dark(#1c1c1e, #f2f2f7));
103
+ color: var(--consent-accent-fg, light-dark(#fff, #1c1c1e));
104
+ }
105
+
106
+ [data-slot="consent-toggle"] {
107
+ position: fixed;
108
+ inset-inline-start: 1rem;
109
+ bottom: 1rem;
110
+ z-index: 50;
111
+ padding: 0.375rem 0.75rem;
112
+ border: 1px solid var(--consent-border, light-dark(rgb(0 0 0 / 12%), rgb(255 255 255 / 14%)));
113
+ border-radius: 9999px;
114
+ background: var(--consent-surface, light-dark(#fff, #1c1c1e));
115
+ color: var(--consent-muted, light-dark(rgb(28 28 30 / 65%), rgb(242 242 247 / 65%)));
116
+ font: inherit;
117
+ font-size: 0.75rem;
118
+ cursor: pointer;
119
+ }