@codefast/tracking 0.7.0 → 0.7.2

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 (214) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +235 -105
  3. package/dist/adapters/tanstack-start.d.ts +12 -9
  4. package/dist/adapters/tanstack-start.js +5 -6
  5. package/dist/client/ad-framework-consent.d.ts +9 -8
  6. package/dist/client/ad-framework-consent.js +4 -5
  7. package/dist/client/browser-cookie.d.ts +2 -3
  8. package/dist/client/browser-cookie.js +2 -3
  9. package/dist/client/consent-runtime.d.ts +6 -5
  10. package/dist/client/consent-runtime.js +2 -3
  11. package/dist/client/consent-storage.d.ts +1 -2
  12. package/dist/client/consent-storage.js +1 -2
  13. package/dist/client/consent-withdrawal.d.ts +5 -4
  14. package/dist/client/consent-withdrawal.js +2 -3
  15. package/dist/client/cookie-anonymous-id.d.ts +8 -5
  16. package/dist/client/cookie-anonymous-id.js +2 -3
  17. package/dist/client/create-client-tracker.d.ts +8 -3
  18. package/dist/client/create-client-tracker.js +3 -2
  19. package/dist/client/gpc.d.ts +1 -2
  20. package/dist/client/gpc.js +1 -2
  21. package/dist/client/initial-consent-store.d.ts +7 -6
  22. package/dist/client/initial-consent-store.js +2 -3
  23. package/dist/client/is-analytics-allowed.d.ts +5 -4
  24. package/dist/client/is-analytics-allowed.js +2 -3
  25. package/dist/client/server-persisted-anonymous-id.d.ts +5 -4
  26. package/dist/client/server-persisted-anonymous-id.js +2 -3
  27. package/dist/core/consent-config.d.ts +3 -4
  28. package/dist/core/consent-config.js +2 -3
  29. package/dist/core/consent-receipt.d.ts +7 -8
  30. package/dist/core/consent-receipt.js +2 -3
  31. package/dist/core/consent.d.ts +24 -13
  32. package/dist/core/consent.js +13 -10
  33. package/dist/core/cookie.d.ts +3 -4
  34. package/dist/core/cookie.js +3 -4
  35. package/dist/core/destination.d.ts +1 -2
  36. package/dist/core/destination.js +1 -2
  37. package/dist/core/event-catalog.d.ts +2 -3
  38. package/dist/core/event-catalog.js +2 -3
  39. package/dist/core/event-id.d.ts +1 -2
  40. package/dist/core/event-id.js +1 -2
  41. package/dist/core/tracked-event.d.ts +1 -2
  42. package/dist/core/tracked-event.js +1 -2
  43. package/dist/destinations/ad-consent.d.ts +3 -4
  44. package/dist/destinations/ad-consent.js +2 -3
  45. package/dist/destinations/google-analytics.d.ts +17 -10
  46. package/dist/destinations/google-analytics.js +5 -6
  47. package/dist/destinations/google-consent.d.ts +10 -9
  48. package/dist/destinations/google-consent.js +6 -7
  49. package/dist/destinations/meta.d.ts +8 -7
  50. package/dist/destinations/meta.js +3 -4
  51. package/dist/destinations/microsoft-uet.d.ts +8 -7
  52. package/dist/destinations/microsoft-uet.js +3 -4
  53. package/dist/destinations/shared.d.ts +8 -5
  54. package/dist/destinations/shared.js +4 -3
  55. package/dist/destinations/tiktok.d.ts +8 -7
  56. package/dist/destinations/tiktok.js +3 -4
  57. package/dist/destinations/vercel-analytics.d.ts +4 -3
  58. package/dist/destinations/vercel-analytics.js +1 -2
  59. package/dist/index.d.ts +1 -2
  60. package/dist/index.js +1 -2
  61. package/dist/react/consent-banner.d.ts +29 -2
  62. package/dist/react/consent-banner.js +12 -9
  63. package/dist/react/gtag-consent-bootstrap.d.ts +5 -4
  64. package/dist/react/gtag-consent-bootstrap.js +2 -3
  65. package/dist/react/use-consent.d.ts +5 -2
  66. package/dist/react/use-consent.js +1 -2
  67. package/dist/react/use-google-consent-sync.d.ts +5 -4
  68. package/dist/react/use-google-consent-sync.js +2 -3
  69. package/dist/react/use-initial-consent.d.ts +2 -3
  70. package/dist/react/use-initial-consent.js +2 -3
  71. package/dist/server/anonymous-id-cookie.d.ts +8 -7
  72. package/dist/server/anonymous-id-cookie.js +5 -6
  73. package/dist/server/consent-receipt-store.d.ts +5 -6
  74. package/dist/server/consent-receipt-store.js +3 -4
  75. package/dist/server/consent-receipt.d.ts +5 -6
  76. package/dist/server/consent-receipt.js +4 -5
  77. package/dist/server/initial-consent.d.ts +5 -4
  78. package/dist/server/initial-consent.js +2 -3
  79. package/dist/server/measurement-protocol.d.ts +10 -9
  80. package/dist/server/measurement-protocol.js +4 -5
  81. package/dist/server/region.d.ts +3 -4
  82. package/dist/server/region.js +3 -4
  83. package/dist/server/user-deletion.d.ts +10 -7
  84. package/dist/server/user-deletion.js +3 -4
  85. package/dist/tooling/import-protection.d.ts +2 -3
  86. package/dist/tooling/import-protection.js +2 -3
  87. package/package.json +11 -62
  88. package/dist/adapters/tanstack-start.d.ts.map +0 -1
  89. package/dist/adapters/tanstack-start.js.map +0 -1
  90. package/dist/client/ad-framework-consent.d.ts.map +0 -1
  91. package/dist/client/ad-framework-consent.js.map +0 -1
  92. package/dist/client/browser-cookie.d.ts.map +0 -1
  93. package/dist/client/browser-cookie.js.map +0 -1
  94. package/dist/client/consent-runtime.d.ts.map +0 -1
  95. package/dist/client/consent-runtime.js.map +0 -1
  96. package/dist/client/consent-storage.d.ts.map +0 -1
  97. package/dist/client/consent-storage.js.map +0 -1
  98. package/dist/client/consent-withdrawal.d.ts.map +0 -1
  99. package/dist/client/consent-withdrawal.js.map +0 -1
  100. package/dist/client/cookie-anonymous-id.d.ts.map +0 -1
  101. package/dist/client/cookie-anonymous-id.js.map +0 -1
  102. package/dist/client/create-client-tracker.d.ts.map +0 -1
  103. package/dist/client/create-client-tracker.js.map +0 -1
  104. package/dist/client/gpc.d.ts.map +0 -1
  105. package/dist/client/gpc.js.map +0 -1
  106. package/dist/client/initial-consent-store.d.ts.map +0 -1
  107. package/dist/client/initial-consent-store.js.map +0 -1
  108. package/dist/client/is-analytics-allowed.d.ts.map +0 -1
  109. package/dist/client/is-analytics-allowed.js.map +0 -1
  110. package/dist/client/server-persisted-anonymous-id.d.ts.map +0 -1
  111. package/dist/client/server-persisted-anonymous-id.js.map +0 -1
  112. package/dist/core/consent-config.d.ts.map +0 -1
  113. package/dist/core/consent-config.js.map +0 -1
  114. package/dist/core/consent-receipt.d.ts.map +0 -1
  115. package/dist/core/consent-receipt.js.map +0 -1
  116. package/dist/core/consent.d.ts.map +0 -1
  117. package/dist/core/consent.js.map +0 -1
  118. package/dist/core/cookie.d.ts.map +0 -1
  119. package/dist/core/cookie.js.map +0 -1
  120. package/dist/core/destination.d.ts.map +0 -1
  121. package/dist/core/destination.js.map +0 -1
  122. package/dist/core/event-catalog.d.ts.map +0 -1
  123. package/dist/core/event-catalog.js.map +0 -1
  124. package/dist/core/event-id.d.ts.map +0 -1
  125. package/dist/core/event-id.js.map +0 -1
  126. package/dist/core/tracked-event.d.ts.map +0 -1
  127. package/dist/core/tracked-event.js.map +0 -1
  128. package/dist/destinations/ad-consent.d.ts.map +0 -1
  129. package/dist/destinations/ad-consent.js.map +0 -1
  130. package/dist/destinations/google-analytics.d.ts.map +0 -1
  131. package/dist/destinations/google-analytics.js.map +0 -1
  132. package/dist/destinations/google-consent.d.ts.map +0 -1
  133. package/dist/destinations/google-consent.js.map +0 -1
  134. package/dist/destinations/meta.d.ts.map +0 -1
  135. package/dist/destinations/meta.js.map +0 -1
  136. package/dist/destinations/microsoft-uet.d.ts.map +0 -1
  137. package/dist/destinations/microsoft-uet.js.map +0 -1
  138. package/dist/destinations/shared.d.ts.map +0 -1
  139. package/dist/destinations/shared.js.map +0 -1
  140. package/dist/destinations/tiktok.d.ts.map +0 -1
  141. package/dist/destinations/tiktok.js.map +0 -1
  142. package/dist/destinations/vercel-analytics.d.ts.map +0 -1
  143. package/dist/destinations/vercel-analytics.js.map +0 -1
  144. package/dist/index.d.ts.map +0 -1
  145. package/dist/index.js.map +0 -1
  146. package/dist/react/consent-banner.d.ts.map +0 -1
  147. package/dist/react/consent-banner.js.map +0 -1
  148. package/dist/react/gtag-consent-bootstrap.d.ts.map +0 -1
  149. package/dist/react/gtag-consent-bootstrap.js.map +0 -1
  150. package/dist/react/use-consent.d.ts.map +0 -1
  151. package/dist/react/use-consent.js.map +0 -1
  152. package/dist/react/use-google-consent-sync.d.ts.map +0 -1
  153. package/dist/react/use-google-consent-sync.js.map +0 -1
  154. package/dist/react/use-initial-consent.d.ts.map +0 -1
  155. package/dist/react/use-initial-consent.js.map +0 -1
  156. package/dist/server/anonymous-id-cookie.d.ts.map +0 -1
  157. package/dist/server/anonymous-id-cookie.js.map +0 -1
  158. package/dist/server/consent-receipt-store.d.ts.map +0 -1
  159. package/dist/server/consent-receipt-store.js.map +0 -1
  160. package/dist/server/consent-receipt.d.ts.map +0 -1
  161. package/dist/server/consent-receipt.js.map +0 -1
  162. package/dist/server/initial-consent.d.ts.map +0 -1
  163. package/dist/server/initial-consent.js.map +0 -1
  164. package/dist/server/measurement-protocol.d.ts.map +0 -1
  165. package/dist/server/measurement-protocol.js.map +0 -1
  166. package/dist/server/region.d.ts.map +0 -1
  167. package/dist/server/region.js.map +0 -1
  168. package/dist/server/user-deletion.d.ts.map +0 -1
  169. package/dist/server/user-deletion.js.map +0 -1
  170. package/dist/tooling/import-protection.d.ts.map +0 -1
  171. package/dist/tooling/import-protection.js.map +0 -1
  172. package/src/adapters/tanstack-start.ts +0 -135
  173. package/src/client/ad-framework-consent.ts +0 -86
  174. package/src/client/browser-cookie.ts +0 -16
  175. package/src/client/consent-runtime.ts +0 -80
  176. package/src/client/consent-storage.ts +0 -125
  177. package/src/client/consent-withdrawal.ts +0 -32
  178. package/src/client/cookie-anonymous-id.ts +0 -112
  179. package/src/client/create-client-tracker.ts +0 -168
  180. package/src/client/gpc.ts +0 -15
  181. package/src/client/initial-consent-store.ts +0 -218
  182. package/src/client/is-analytics-allowed.ts +0 -43
  183. package/src/client/server-persisted-anonymous-id.ts +0 -102
  184. package/src/core/consent-config.ts +0 -27
  185. package/src/core/consent-receipt.ts +0 -115
  186. package/src/core/consent.ts +0 -286
  187. package/src/core/cookie.ts +0 -29
  188. package/src/core/destination.ts +0 -29
  189. package/src/core/event-catalog.ts +0 -54
  190. package/src/core/event-id.ts +0 -8
  191. package/src/core/tracked-event.ts +0 -14
  192. package/src/css/consent.css +0 -119
  193. package/src/destinations/ad-consent.ts +0 -29
  194. package/src/destinations/google-analytics.ts +0 -296
  195. package/src/destinations/google-consent.ts +0 -164
  196. package/src/destinations/meta.ts +0 -96
  197. package/src/destinations/microsoft-uet.ts +0 -86
  198. package/src/destinations/shared.ts +0 -45
  199. package/src/destinations/tiktok.ts +0 -85
  200. package/src/destinations/vercel-analytics.ts +0 -39
  201. package/src/index.ts +0 -171
  202. package/src/react/consent-banner.tsx +0 -360
  203. package/src/react/gtag-consent-bootstrap.tsx +0 -48
  204. package/src/react/use-consent.ts +0 -119
  205. package/src/react/use-google-consent-sync.ts +0 -38
  206. package/src/react/use-initial-consent.ts +0 -22
  207. package/src/server/anonymous-id-cookie.ts +0 -103
  208. package/src/server/consent-receipt-store.ts +0 -79
  209. package/src/server/consent-receipt.ts +0 -89
  210. package/src/server/initial-consent.ts +0 -46
  211. package/src/server/measurement-protocol.ts +0 -114
  212. package/src/server/region.ts +0 -77
  213. package/src/server/user-deletion.ts +0 -93
  214. package/src/tooling/import-protection.ts +0 -22
@@ -3,7 +3,6 @@
3
3
  * mirror): Secure on HTTPS so values never ride plain HTTP, SameSite=Lax, never HttpOnly —
4
4
  * the client must read its own cookies back. A no-op without a `document` (SSR).
5
5
  *
6
- * @since 1.0.0-canary.6
6
+ * @since 0.5.0-canary.6
7
7
  */
8
- export declare function writeBrowserCookie(cookieName: string, value: string, maxAgeSeconds: number): void;
9
- //# sourceMappingURL=browser-cookie.d.ts.map
8
+ export declare function writeBrowserCookie(cookieName: string, value: string, maxAgeSeconds: number): void;
@@ -3,7 +3,7 @@
3
3
  * mirror): Secure on HTTPS so values never ride plain HTTP, SameSite=Lax, never HttpOnly —
4
4
  * the client must read its own cookies back. A no-op without a `document` (SSR).
5
5
  *
6
- * @since 1.0.0-canary.6
6
+ * @since 0.5.0-canary.6
7
7
  */
8
8
  export function writeBrowserCookie(cookieName, value, maxAgeSeconds) {
9
9
  if (typeof document === "undefined") {
@@ -11,5 +11,4 @@ export function writeBrowserCookie(cookieName, value, maxAgeSeconds) {
11
11
  }
12
12
  const secure = globalThis.location.protocol === "https:" ? "; secure" : "";
13
13
  document.cookie = `${cookieName}=${value}; path=/; max-age=${String(maxAgeSeconds)}; samesite=lax${secure}`;
14
- }
15
- //# sourceMappingURL=browser-cookie.js.map
14
+ }
@@ -2,7 +2,9 @@ import type { InitialConsentStore } from "#/client/initial-consent-store";
2
2
  import type { ConsentStorage, InitialConsent } from "#/core/consent";
3
3
  import type { ConsentConfig } from "#/core/consent-config";
4
4
  /**
5
- * @since 1.0.0-canary.6
5
+ * Options for `createConsentRuntime`.
6
+ *
7
+ * @since 0.5.0-canary.6
6
8
  */
7
9
  export interface ConsentRuntimeOptions {
8
10
  config: ConsentConfig;
@@ -25,7 +27,7 @@ export interface ConsentRuntimeOptions {
25
27
  * it once at module scope and every surface (banner hook, tracker gate, privacy page)
26
28
  * shares the same storage and region resolution by construction.
27
29
  *
28
- * @since 1.0.0-canary.6
30
+ * @since 0.5.0-canary.6
29
31
  */
30
32
  export interface ConsentRuntime {
31
33
  config: ConsentConfig;
@@ -47,7 +49,6 @@ export interface ConsentRuntime {
47
49
  * `localStorage`-backed decision storage, the initial-consent store over the app's
48
50
  * server lane, and the non-React analytics gate wired to that store's resolved mode.
49
51
  *
50
- * @since 1.0.0-canary.6
52
+ * @since 0.5.0-canary.6
51
53
  */
52
- export declare function createConsentRuntime(options: ConsentRuntimeOptions): ConsentRuntime;
53
- //# sourceMappingURL=consent-runtime.d.ts.map
54
+ export declare function createConsentRuntime(options: ConsentRuntimeOptions): ConsentRuntime;
@@ -7,7 +7,7 @@ import { createIsAnalyticsAllowed } from "#/client/is-analytics-allowed";
7
7
  * `localStorage`-backed decision storage, the initial-consent store over the app's
8
8
  * server lane, and the non-React analytics gate wired to that store's resolved mode.
9
9
  *
10
- * @since 1.0.0-canary.6
10
+ * @since 0.5.0-canary.6
11
11
  */
12
12
  export function createConsentRuntime(options) {
13
13
  const { config } = options;
@@ -29,5 +29,4 @@ export function createConsentRuntime(options) {
29
29
  isAnalyticsAllowed,
30
30
  storage,
31
31
  };
32
- }
33
- //# sourceMappingURL=consent-runtime.js.map
32
+ }
@@ -17,5 +17,4 @@ import type { ConsentStorage } from "#/core/consent";
17
17
  *
18
18
  * @since 0.5.0-canary.4
19
19
  */
20
- export declare function createLocalStorageConsentStorage(storageKey: string): ConsentStorage;
21
- //# sourceMappingURL=consent-storage.d.ts.map
20
+ export declare function createLocalStorageConsentStorage(storageKey: string): ConsentStorage;
@@ -105,5 +105,4 @@ export function createLocalStorageConsentStorage(storageKey) {
105
105
  };
106
106
  },
107
107
  };
108
- }
109
- //# sourceMappingURL=consent-storage.js.map
108
+ }
@@ -1,6 +1,8 @@
1
1
  import type { ConsentDecision } from "#/core/consent";
2
2
  /**
3
- * @since 1.0.0-canary.6
3
+ * Options for `createConsentWithdrawalHandler`.
4
+ *
5
+ * @since 0.5.0-canary.6
4
6
  */
5
7
  export interface ConsentWithdrawalHandlerOptions {
6
8
  /** Forget the cookie-backed visitor id when analytics is denied. */
@@ -12,7 +14,6 @@ export interface ConsentWithdrawalHandlerOptions {
12
14
  * `useConsent({ onDecision })` handler that clears first-party tracking state when the
13
15
  * visitor denies (or withdraws) analytics. Grant paths are a no-op.
14
16
  *
15
- * @since 1.0.0-canary.6
17
+ * @since 0.5.0-canary.6
16
18
  */
17
- export declare function createConsentWithdrawalHandler(options: ConsentWithdrawalHandlerOptions): (decision: ConsentDecision) => void;
18
- //# sourceMappingURL=consent-withdrawal.d.ts.map
19
+ export declare function createConsentWithdrawalHandler(options: ConsentWithdrawalHandlerOptions): (decision: ConsentDecision) => void;
@@ -2,7 +2,7 @@
2
2
  * `useConsent({ onDecision })` handler that clears first-party tracking state when the
3
3
  * visitor denies (or withdraws) analytics. Grant paths are a no-op.
4
4
  *
5
- * @since 1.0.0-canary.6
5
+ * @since 0.5.0-canary.6
6
6
  */
7
7
  export function createConsentWithdrawalHandler(options) {
8
8
  const { clearAnonymousId, clearGoogleAnalyticsCookies } = options;
@@ -13,5 +13,4 @@ export function createConsentWithdrawalHandler(options) {
13
13
  clearAnonymousId?.();
14
14
  clearGoogleAnalyticsCookies?.();
15
15
  };
16
- }
17
- //# sourceMappingURL=consent-withdrawal.js.map
16
+ }
@@ -1,5 +1,7 @@
1
1
  /**
2
- * @since 1.0.0-canary.6
2
+ * Options for `createCookieAnonymousId`.
3
+ *
4
+ * @since 0.5.0-canary.6
3
5
  */
4
6
  export interface CookieAnonymousIdOptions {
5
7
  /** Cookie name — must not collide with another cookie on the domain. */
@@ -8,7 +10,9 @@ export interface CookieAnonymousIdOptions {
8
10
  maxAgeSeconds?: number | undefined;
9
11
  }
10
12
  /**
11
- * @since 1.0.0-canary.6
13
+ * A cookie-backed anonymous id handle: lazy minting, expiry refresh, and clearing on withdrawal.
14
+ *
15
+ * @since 0.5.0-canary.6
12
16
  */
13
17
  export interface CookieAnonymousId {
14
18
  /** Expires the cookie — call when the visitor withdraws tracking consent. */
@@ -35,7 +39,6 @@ export interface CookieAnonymousId {
35
39
  * it's invoked lazily, so the cookie is minted only once an event is actually allowed to
36
40
  * send, never as an import-time side effect.
37
41
  *
38
- * @since 1.0.0-canary.6
42
+ * @since 0.5.0-canary.6
39
43
  */
40
- export declare function createCookieAnonymousId(options: CookieAnonymousIdOptions): CookieAnonymousId;
41
- //# sourceMappingURL=cookie-anonymous-id.d.ts.map
44
+ export declare function createCookieAnonymousId(options: CookieAnonymousIdOptions): CookieAnonymousId;
@@ -7,7 +7,7 @@ import { ONE_YEAR_IN_SECONDS, readCookieValue } from "#/core/cookie";
7
7
  * it's invoked lazily, so the cookie is minted only once an event is actually allowed to
8
8
  * send, never as an import-time side effect.
9
9
  *
10
- * @since 1.0.0-canary.6
10
+ * @since 0.5.0-canary.6
11
11
  */
12
12
  export function createCookieAnonymousId(options) {
13
13
  const { cookieName, maxAgeSeconds = ONE_YEAR_IN_SECONDS } = options;
@@ -61,5 +61,4 @@ export function createCookieAnonymousId(options) {
61
61
  }
62
62
  },
63
63
  };
64
- }
65
- //# sourceMappingURL=cookie-anonymous-id.js.map
64
+ }
@@ -5,7 +5,7 @@ import type { TrackedEvent } from "#/core/tracked-event";
5
5
  /**
6
6
  * Context handed to {@link ClientTrackerOptions.onDeliveryError} for one failed delivery.
7
7
  *
8
- * @since 1.0.0-canary.7
8
+ * @since 0.5.0-canary.6
9
9
  */
10
10
  export interface DeliveryErrorContext {
11
11
  destination: Destination;
@@ -13,6 +13,8 @@ export interface DeliveryErrorContext {
13
13
  event: TrackedEvent;
14
14
  }
15
15
  /**
16
+ * Options for `createClientTracker`.
17
+ *
16
18
  * @since 0.5.0-canary.4
17
19
  */
18
20
  export interface ClientTrackerOptions<Catalog extends EventCatalog> {
@@ -42,6 +44,8 @@ export interface ClientTrackerOptions<Catalog extends EventCatalog> {
42
44
  onDeliveryError?: ((context: DeliveryErrorContext) => void) | undefined;
43
45
  }
44
46
  /**
47
+ * A client-side tracker delivering catalog-validated events to destinations, plus erasure on withdrawal.
48
+ *
45
49
  * @since 0.5.0-canary.4
46
50
  */
47
51
  export interface ClientTracker<Catalog extends EventCatalog> {
@@ -54,7 +58,8 @@ export interface ClientTracker<Catalog extends EventCatalog> {
54
58
  track: <Name extends keyof Catalog & string>(name: Name, properties: StandardSchemaV1.InferOutput<Catalog[Name]["schema"]>) => void;
55
59
  }
56
60
  /**
61
+ * Creates a consent-gated tracker that validates each event against the catalog and fans it out to destinations.
62
+ *
57
63
  * @since 0.5.0-canary.4
58
64
  */
59
- export declare function createClientTracker<Catalog extends EventCatalog>(options: ClientTrackerOptions<Catalog>): ClientTracker<Catalog>;
60
- //# sourceMappingURL=create-client-tracker.d.ts.map
65
+ export declare function createClientTracker<Catalog extends EventCatalog>(options: ClientTrackerOptions<Catalog>): ClientTracker<Catalog>;
@@ -40,6 +40,8 @@ function eraseInDestination(destination, id) {
40
40
  }
41
41
  }
42
42
  /**
43
+ * Creates a consent-gated tracker that validates each event against the catalog and fans it out to destinations.
44
+ *
43
45
  * @since 0.5.0-canary.4
44
46
  */
45
47
  export function createClientTracker(options) {
@@ -87,5 +89,4 @@ export function createClientTracker(options) {
87
89
  }
88
90
  },
89
91
  };
90
- }
91
- //# sourceMappingURL=create-client-tracker.js.map
92
+ }
@@ -6,5 +6,4 @@
6
6
  *
7
7
  * @since 0.5.0-canary.4
8
8
  */
9
- export declare function hasGlobalPrivacyControlSignal(): boolean;
10
- //# sourceMappingURL=gpc.d.ts.map
9
+ export declare function hasGlobalPrivacyControlSignal(): boolean;
@@ -8,5 +8,4 @@
8
8
  */
9
9
  export function hasGlobalPrivacyControlSignal() {
10
10
  return typeof navigator !== "undefined" && navigator.globalPrivacyControl === true;
11
- }
12
- //# sourceMappingURL=gpc.js.map
11
+ }
@@ -3,7 +3,7 @@ import type { InitialConsent } from "#/core/consent";
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.
5
5
  *
6
- * @since 1.0.0-canary.6
6
+ * @since 0.5.0-canary.6
7
7
  */
8
8
  export interface InitialConsentSnapshot {
9
9
  /** The region-correct default once resolved; {@link STRICTEST_INITIAL_CONSENT} until then. */
@@ -16,7 +16,9 @@ export interface InitialConsentSnapshot {
16
16
  isResolved: boolean;
17
17
  }
18
18
  /**
19
- * @since 1.0.0-canary.6
19
+ * Options for `createInitialConsentStore`.
20
+ *
21
+ * @since 0.5.0-canary.6
20
22
  */
21
23
  export interface InitialConsentStoreOptions {
22
24
  /**
@@ -36,7 +38,7 @@ export interface InitialConsentStoreOptions {
36
38
  * `useSyncExternalStore`-shaped — pass `subscribe`/`getSnapshot`/`getServerSnapshot`
37
39
  * straight through, or use the `useInitialConsent` hook from `@codefast/tracking/react`.
38
40
  *
39
- * @since 1.0.0-canary.6
41
+ * @since 0.5.0-canary.6
40
42
  */
41
43
  export interface InitialConsentStore {
42
44
  /**
@@ -57,7 +59,6 @@ export interface InitialConsentStore {
57
59
  * (consent UI still renders, under the strictest default), and a retry the next time the
58
60
  * tab becomes visible — so one failed request never locks the whole SPA session.
59
61
  *
60
- * @since 1.0.0-canary.6
62
+ * @since 0.5.0-canary.6
61
63
  */
62
- export declare function createInitialConsentStore(options: InitialConsentStoreOptions): InitialConsentStore;
63
- //# sourceMappingURL=initial-consent-store.d.ts.map
64
+ export declare function createInitialConsentStore(options: InitialConsentStoreOptions): InitialConsentStore;
@@ -9,7 +9,7 @@ const SERVER_SNAPSHOT = {
9
9
  * (consent UI still renders, under the strictest default), and a retry the next time the
10
10
  * tab becomes visible — so one failed request never locks the whole SPA session.
11
11
  *
12
- * @since 1.0.0-canary.6
12
+ * @since 0.5.0-canary.6
13
13
  */
14
14
  export function createInitialConsentStore(options) {
15
15
  const listeners = new Set();
@@ -134,5 +134,4 @@ export function createInitialConsentStore(options) {
134
134
  };
135
135
  },
136
136
  };
137
- }
138
- //# sourceMappingURL=initial-consent-store.js.map
137
+ }
@@ -1,7 +1,9 @@
1
1
  import type { ConsentMode, ConsentStorage } from "#/core/consent";
2
2
  import type { ConsentConfig } from "#/core/consent-config";
3
3
  /**
4
- * @since 1.0.0-canary.6
4
+ * Options for `createIsAnalyticsAllowed`.
5
+ *
6
+ * @since 0.5.0-canary.6
5
7
  */
6
8
  export interface IsAnalyticsAllowedOptions {
7
9
  /** Must be the same object `useConsent` receives — one config, every surface. */
@@ -20,7 +22,6 @@ export interface IsAnalyticsAllowedOptions {
20
22
  * Non-React mirror of `useConsent`'s `isAnalyticsAllowed` — pass the returned function as
21
23
  * `createClientTracker({ isAnalyticsAllowed })` so the pipeline and the banner share one rule.
22
24
  *
23
- * @since 1.0.0-canary.6
25
+ * @since 0.5.0-canary.6
24
26
  */
25
- export declare function createIsAnalyticsAllowed(options: IsAnalyticsAllowedOptions): () => boolean;
26
- //# sourceMappingURL=is-analytics-allowed.d.ts.map
27
+ export declare function createIsAnalyticsAllowed(options: IsAnalyticsAllowedOptions): () => boolean;
@@ -3,7 +3,7 @@ import { resolveEffectiveConsent } from "#/core/consent";
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.
5
5
  *
6
- * @since 1.0.0-canary.6
6
+ * @since 0.5.0-canary.6
7
7
  */
8
8
  export function createIsAnalyticsAllowed(options) {
9
9
  const { config, getMode, storage } = options;
@@ -18,5 +18,4 @@ export function createIsAnalyticsAllowed(options) {
18
18
  });
19
19
  return effectiveConsent.analytics;
20
20
  };
21
- }
22
- //# sourceMappingURL=is-analytics-allowed.js.map
21
+ }
@@ -1,6 +1,8 @@
1
1
  import type { CookieAnonymousId } from "#/client/cookie-anonymous-id";
2
2
  /**
3
- * @since 1.0.0-canary.6
3
+ * Options for `createServerPersistedAnonymousId`.
4
+ *
5
+ * @since 0.5.0-canary.6
4
6
  */
5
7
  export interface ServerPersistedAnonymousIdOptions {
6
8
  /** Server round-trip that expires the cookie via `Set-Cookie` — the server half of `clear()`. */
@@ -24,7 +26,6 @@ export interface ServerPersistedAnonymousIdOptions {
24
26
  * its full max-age. Same optimistic `document.cookie` write first, so the current event
25
27
  * never waits on the round-trip and a failed `persist` degrades to today's behavior.
26
28
  *
27
- * @since 1.0.0-canary.6
29
+ * @since 0.5.0-canary.6
28
30
  */
29
- export declare function createServerPersistedAnonymousId(options: ServerPersistedAnonymousIdOptions): CookieAnonymousId;
30
- //# sourceMappingURL=server-persisted-anonymous-id.d.ts.map
31
+ export declare function createServerPersistedAnonymousId(options: ServerPersistedAnonymousIdOptions): CookieAnonymousId;
@@ -8,7 +8,7 @@ import { readCookieValue } from "#/core/cookie";
8
8
  * its full max-age. Same optimistic `document.cookie` write first, so the current event
9
9
  * never waits on the round-trip and a failed `persist` degrades to today's behavior.
10
10
  *
11
- * @since 1.0.0-canary.6
11
+ * @since 0.5.0-canary.6
12
12
  */
13
13
  export function createServerPersistedAnonymousId(options) {
14
14
  const { clearOnServer, cookieName, maxAgeSeconds, persist } = options;
@@ -68,5 +68,4 @@ export function createServerPersistedAnonymousId(options) {
68
68
  }
69
69
  },
70
70
  };
71
- }
72
- //# sourceMappingURL=server-persisted-anonymous-id.js.map
71
+ }
@@ -5,7 +5,7 @@ import type { ConsentCategory } from "#/core/consent";
5
5
  * cross-surface "must match" contracts hold by construction instead of by hand-threading
6
6
  * the same strings through every call site.
7
7
  *
8
- * @since 1.0.0-canary.6
8
+ * @since 0.5.0-canary.6
9
9
  */
10
10
  export interface ConsentConfig {
11
11
  /** Bumping re-prompts every visitor — a stored decision under any other version is ignored. */
@@ -18,7 +18,6 @@ export interface ConsentConfig {
18
18
  /**
19
19
  * Identity helper for declaring the config with inference — `defineEventCatalog`'s consent twin.
20
20
  *
21
- * @since 1.0.0-canary.6
21
+ * @since 0.5.0-canary.6
22
22
  */
23
- export declare function defineConsentConfig<Config extends ConsentConfig>(config: Config): Config;
24
- //# sourceMappingURL=consent-config.d.ts.map
23
+ export declare function defineConsentConfig<Config extends ConsentConfig>(config: Config): Config;
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Identity helper for declaring the config with inference — `defineEventCatalog`'s consent twin.
3
3
  *
4
- * @since 1.0.0-canary.6
4
+ * @since 0.5.0-canary.6
5
5
  */
6
6
  export function defineConsentConfig(config) {
7
7
  return config;
8
- }
9
- //# sourceMappingURL=consent-config.js.map
8
+ }
@@ -3,28 +3,28 @@ import type { ConsentDecision } from "#/core/consent";
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.
5
5
  *
6
- * @since 1.0.0-canary.7
6
+ * @since 0.5.0-canary.6
7
7
  */
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
11
  * capture (GDPR Art. 7(1); EDPB 05/2020 §5.1).
12
12
  *
13
- * @since 1.0.0-canary.7
13
+ * @since 0.5.0-canary.6
14
14
  */
15
15
  export type ConsentReceiptMethod = "banner-accept" | "banner-reject" | "granular" | "gpc-signal" | "withdrawal";
16
16
  /**
17
17
  * What kind of identifier links the receipt to a subject. A cookie-only visitor uses a
18
18
  * pseudonymous `cookie` id — the receipt is still valid proof.
19
19
  *
20
- * @since 1.0.0-canary.7
20
+ * @since 0.5.0-canary.6
21
21
  */
22
22
  export type ConsentReceiptSubjectIdType = "cookie" | "email-hash" | "userId";
23
23
  /**
24
24
  * The caller-supplied fields of a consent receipt. Deliberately carries **no IP** — the
25
25
  * server derives a coarsened one from the connection so a full IP never transits the body.
26
26
  *
27
- * @since 1.0.0-canary.7
27
+ * @since 0.5.0-canary.6
28
28
  */
29
29
  export interface ConsentReceiptInput {
30
30
  decision: ConsentDecision;
@@ -49,7 +49,7 @@ export interface ConsentReceiptInput {
49
49
  * The record is append-only; never mutate a stored receipt. `ipCoarse` is truncated at
50
50
  * write time and MUST NOT be a full IP.
51
51
  *
52
- * @since 1.0.0-canary.7
52
+ * @since 0.5.0-canary.6
53
53
  */
54
54
  export interface ConsentReceipt extends ConsentReceiptInput {
55
55
  /** Coarsened/pseudonymized IP, or absent — never a full address. */
@@ -65,7 +65,6 @@ export interface ConsentReceipt extends ConsentReceiptInput {
65
65
  * Guards a receipt input received from an untrusted client. Rejects a body carrying an
66
66
  * `ip`/`ipCoarse` field so a full address can never be persisted from caller input.
67
67
  *
68
- * @since 1.0.0-canary.7
68
+ * @since 0.5.0-canary.6
69
69
  */
70
- export declare function isConsentReceiptInput(value: unknown): value is ConsentReceiptInput;
71
- //# sourceMappingURL=consent-receipt.d.ts.map
70
+ export declare function isConsentReceiptInput(value: unknown): value is ConsentReceiptInput;
@@ -14,7 +14,7 @@ const RECEIPT_SUBJECT_ID_TYPES = new Set(["cookie", "email-hash", "userId"]);
14
14
  * Guards a receipt input received from an untrusted client. Rejects a body carrying an
15
15
  * `ip`/`ipCoarse` field so a full address can never be persisted from caller input.
16
16
  *
17
- * @since 1.0.0-canary.7
17
+ * @since 0.5.0-canary.6
18
18
  */
19
19
  export function isConsentReceiptInput(value) {
20
20
  if (typeof value !== "object" || value === null) {
@@ -35,5 +35,4 @@ export function isConsentReceiptInput(value) {
35
35
  isString(input.subjectId) &&
36
36
  isString(input.subjectIdType) &&
37
37
  RECEIPT_SUBJECT_ID_TYPES.has(input.subjectIdType));
38
- }
39
- //# sourceMappingURL=consent-receipt.js.map
38
+ }
@@ -1,18 +1,24 @@
1
1
  /**
2
+ * The privacy-law region a visitor's consent defaults are resolved for.
3
+ *
2
4
  * @since 0.5.0-canary.4
3
5
  */
4
6
  export type ConsentRegion = "eu" | "other" | "us" | "vn";
5
7
  /**
6
- * @since 1.0.0-canary.6
8
+ * Every consent region, in a stable order shared by guards and iteration.
9
+ *
10
+ * @since 0.5.0-canary.6
7
11
  */
8
12
  export declare const CONSENT_REGIONS: ReadonlyArray<ConsentRegion>;
9
13
  /**
10
14
  * Guards a region read from untrusted storage (a cached `InitialConsent`, a cookie).
11
15
  *
12
- * @since 1.0.0-canary.6
16
+ * @since 0.5.0-canary.6
13
17
  */
14
18
  export declare function isConsentRegion(value: unknown): value is ConsentRegion;
15
19
  /**
20
+ * Whether a region requires explicit opt-in before tracking or defaults to opt-out.
21
+ *
16
22
  * @since 0.5.0-canary.4
17
23
  */
18
24
  export type ConsentMode = "opt-in" | "opt-out";
@@ -33,6 +39,8 @@ export declare function resolveConsentMode(region: ConsentRegion): ConsentMode;
33
39
  */
34
40
  export type ConsentCategory = "ads" | "analytics";
35
41
  /**
42
+ * Every consent category, in a stable order shared by guards and iteration.
43
+ *
36
44
  * @since 0.5.0-canary.4
37
45
  */
38
46
  export declare const CONSENT_CATEGORIES: ReadonlyArray<ConsentCategory>;
@@ -60,17 +68,19 @@ export declare function isConsentDecision(value: unknown): value is ConsentDecis
60
68
  * dropped, every category becomes an explicit boolean. The one normalization rule every
61
69
  * reader of stored consent shares (e.g. `readStoredDecision`).
62
70
  *
63
- * @since 1.0.0-canary.6
71
+ * @since 0.5.0-canary.6
64
72
  */
65
73
  export declare function normalizeConsentDecision(decision: ConsentDecision): ConsentDecision;
66
74
  /**
67
75
  * Guards a persisted consent record read from untrusted storage (e.g. `localStorage`).
68
76
  *
69
- * @since 1.0.0-canary.6
77
+ * @since 0.5.0-canary.6
70
78
  */
71
79
  export declare function isConsentRecord(value: unknown): value is ConsentRecord;
72
80
  /**
73
- * @since 1.0.0-canary.6
81
+ * Options for `resolveDefaultConsent`.
82
+ *
83
+ * @since 0.5.0-canary.6
74
84
  */
75
85
  export interface ResolveDefaultConsentOptions {
76
86
  /** A "do not sell or share" opt-out — forces `ads` denied under opt-out regions. */
@@ -98,7 +108,7 @@ export declare function resolveDefaultConsent(options: ResolveDefaultConsentOpti
98
108
  * `defaultConsent` is the server snapshot — useful when you need request-time `sec-gpc`
99
109
  * as-is; analytics-only apps can ignore it because GPC only forces `ads` denied.
100
110
  *
101
- * @since 1.0.0-canary.6
111
+ * @since 0.5.0-canary.6
102
112
  */
103
113
  export interface InitialConsent {
104
114
  defaultConsent: ConsentDecision;
@@ -111,7 +121,7 @@ export interface InitialConsent {
111
121
  * Prerendered/CDN-cached markup must carry nothing region-specific, and a missing geo
112
122
  * header means "unknown visitor", never "known non-EU visitor".
113
123
  *
114
- * @since 1.0.0-canary.6
124
+ * @since 0.5.0-canary.6
115
125
  */
116
126
  export declare const STRICTEST_INITIAL_CONSENT: InitialConsent;
117
127
  /**
@@ -120,7 +130,7 @@ export declare const STRICTEST_INITIAL_CONSENT: InitialConsent;
120
130
  * {@link STRICTEST_INITIAL_CONSENT}'s own pairing — stricter than the region's usual
121
131
  * mode, never looser.
122
132
  *
123
- * @since 1.0.0-canary.6
133
+ * @since 0.5.0-canary.6
124
134
  */
125
135
  export declare function isInitialConsent(value: unknown): value is InitialConsent;
126
136
  /**
@@ -156,11 +166,13 @@ export interface ConsentStorage {
156
166
  * any tampered extra keys — `undefined` if there is none yet, the record is malformed, or
157
167
  * it was recorded under a superseded policy version.
158
168
  *
159
- * @since 1.0.0-canary.6
169
+ * @since 0.5.0-canary.6
160
170
  */
161
171
  export declare function readStoredDecision(storage: ConsentStorage, policyVersion: string): ConsentDecision | undefined;
162
172
  /**
163
- * @since 1.0.0-canary.6
173
+ * Options for `resolveEffectiveConsent`.
174
+ *
175
+ * @since 0.5.0-canary.6
164
176
  */
165
177
  export interface ResolveEffectiveConsentOptions {
166
178
  /** A "do not sell or share" opt-out — forces `ads` denied under opt-out regions. */
@@ -176,7 +188,6 @@ export interface ResolveEffectiveConsentOptions {
176
188
  * non-React gate (e.g. a tracker's `isAnalyticsAllowed` option) doesn't have to reimplement
177
189
  * "read storage, validate the policy version, fall back to `resolveDefaultConsent`" itself.
178
190
  *
179
- * @since 1.0.0-canary.6
191
+ * @since 0.5.0-canary.6
180
192
  */
181
- export declare function resolveEffectiveConsent(options: ResolveEffectiveConsentOptions): ConsentDecision;
182
- //# sourceMappingURL=consent.d.ts.map
193
+ export declare function resolveEffectiveConsent(options: ResolveEffectiveConsentOptions): ConsentDecision;