@codefast/tracking 0.5.0-canary.5 → 0.5.0-canary.6

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 (276) hide show
  1. package/CHANGELOG.md +467 -0
  2. package/README.md +176 -126
  3. package/dist/adapters/tanstack-start.d.ts +80 -0
  4. package/dist/adapters/tanstack-start.d.ts.map +1 -0
  5. package/dist/adapters/tanstack-start.js +74 -0
  6. package/dist/adapters/tanstack-start.js.map +1 -0
  7. package/dist/client/ad-framework-consent.d.ts +62 -0
  8. package/dist/client/ad-framework-consent.d.ts.map +1 -0
  9. package/dist/client/ad-framework-consent.js +40 -0
  10. package/dist/client/ad-framework-consent.js.map +1 -0
  11. package/dist/client/browser-cookie.d.ts +9 -0
  12. package/dist/client/browser-cookie.d.ts.map +1 -0
  13. package/dist/client/browser-cookie.js +15 -0
  14. package/dist/client/browser-cookie.js.map +1 -0
  15. package/dist/client/consent-runtime.d.ts +53 -0
  16. package/dist/client/consent-runtime.d.ts.map +1 -0
  17. package/dist/client/consent-runtime.js +33 -0
  18. package/dist/client/consent-runtime.js.map +1 -0
  19. package/dist/client/{consent-storage.d.mts → consent-storage.d.ts} +8 -6
  20. package/dist/client/consent-storage.d.ts.map +1 -0
  21. package/dist/client/consent-storage.js +109 -0
  22. package/dist/client/consent-storage.js.map +1 -0
  23. package/dist/client/consent-withdrawal.d.ts +18 -0
  24. package/dist/client/consent-withdrawal.d.ts.map +1 -0
  25. package/dist/client/consent-withdrawal.js +17 -0
  26. package/dist/client/consent-withdrawal.js.map +1 -0
  27. package/dist/client/cookie-anonymous-id.d.ts +41 -0
  28. package/dist/client/cookie-anonymous-id.d.ts.map +1 -0
  29. package/dist/client/cookie-anonymous-id.js +65 -0
  30. package/dist/client/cookie-anonymous-id.js.map +1 -0
  31. package/dist/client/create-client-tracker.d.ts +60 -0
  32. package/dist/client/create-client-tracker.d.ts.map +1 -0
  33. package/dist/client/create-client-tracker.js +91 -0
  34. package/dist/client/create-client-tracker.js.map +1 -0
  35. package/dist/client/gpc.d.ts +10 -0
  36. package/dist/client/gpc.d.ts.map +1 -0
  37. package/dist/client/gpc.js +12 -0
  38. package/dist/client/gpc.js.map +1 -0
  39. package/dist/client/initial-consent-store.d.ts +63 -0
  40. package/dist/client/initial-consent-store.d.ts.map +1 -0
  41. package/dist/client/initial-consent-store.js +138 -0
  42. package/dist/client/initial-consent-store.js.map +1 -0
  43. package/dist/client/is-analytics-allowed.d.ts +26 -0
  44. package/dist/client/is-analytics-allowed.d.ts.map +1 -0
  45. package/dist/client/is-analytics-allowed.js +22 -0
  46. package/dist/client/is-analytics-allowed.js.map +1 -0
  47. package/dist/client/server-persisted-anonymous-id.d.ts +30 -0
  48. package/dist/client/server-persisted-anonymous-id.d.ts.map +1 -0
  49. package/dist/client/server-persisted-anonymous-id.js +72 -0
  50. package/dist/client/server-persisted-anonymous-id.js.map +1 -0
  51. package/dist/core/consent-config.d.ts +24 -0
  52. package/dist/core/consent-config.d.ts.map +1 -0
  53. package/dist/core/consent-config.js +9 -0
  54. package/dist/core/consent-config.js.map +1 -0
  55. package/dist/core/consent-receipt.d.ts +71 -0
  56. package/dist/core/consent-receipt.d.ts.map +1 -0
  57. package/dist/core/consent-receipt.js +39 -0
  58. package/dist/core/consent-receipt.js.map +1 -0
  59. package/dist/core/consent.d.ts +182 -0
  60. package/dist/core/consent.d.ts.map +1 -0
  61. package/dist/core/consent.js +159 -0
  62. package/dist/core/consent.js.map +1 -0
  63. package/dist/core/cookie.d.ts +15 -0
  64. package/dist/core/cookie.d.ts.map +1 -0
  65. package/dist/core/cookie.js +26 -0
  66. package/dist/core/cookie.js.map +1 -0
  67. package/dist/core/destination.d.ts +29 -0
  68. package/dist/core/destination.d.ts.map +1 -0
  69. package/dist/core/destination.js +2 -0
  70. package/dist/core/destination.js.map +1 -0
  71. package/dist/core/event-catalog.d.ts +35 -0
  72. package/dist/core/event-catalog.d.ts.map +1 -0
  73. package/dist/core/event-catalog.js +30 -0
  74. package/dist/core/event-catalog.js.map +1 -0
  75. package/dist/core/event-id.d.ts +7 -0
  76. package/dist/core/event-id.d.ts.map +1 -0
  77. package/dist/core/event-id.js +9 -0
  78. package/dist/core/event-id.js.map +1 -0
  79. package/dist/core/tracked-event.d.ts +15 -0
  80. package/dist/core/tracked-event.d.ts.map +1 -0
  81. package/dist/core/tracked-event.js +2 -0
  82. package/dist/core/tracked-event.js.map +1 -0
  83. package/dist/destinations/ad-consent.d.ts +23 -0
  84. package/dist/destinations/ad-consent.d.ts.map +1 -0
  85. package/dist/destinations/ad-consent.js +12 -0
  86. package/dist/destinations/ad-consent.js.map +1 -0
  87. package/dist/destinations/google-analytics.d.ts +148 -0
  88. package/dist/destinations/google-analytics.d.ts.map +1 -0
  89. package/dist/destinations/google-analytics.js +156 -0
  90. package/dist/destinations/google-analytics.js.map +1 -0
  91. package/dist/destinations/google-consent.d.ts +62 -0
  92. package/dist/destinations/google-consent.d.ts.map +1 -0
  93. package/dist/destinations/google-consent.js +109 -0
  94. package/dist/destinations/google-consent.js.map +1 -0
  95. package/dist/destinations/meta.d.ts +63 -0
  96. package/dist/destinations/meta.d.ts.map +1 -0
  97. package/dist/destinations/meta.js +44 -0
  98. package/dist/destinations/meta.js.map +1 -0
  99. package/dist/destinations/microsoft-uet.d.ts +56 -0
  100. package/dist/destinations/microsoft-uet.d.ts.map +1 -0
  101. package/dist/destinations/microsoft-uet.js +41 -0
  102. package/dist/destinations/microsoft-uet.js.map +1 -0
  103. package/dist/destinations/shared.d.ts +18 -0
  104. package/dist/destinations/shared.d.ts.map +1 -0
  105. package/dist/destinations/shared.js +19 -0
  106. package/dist/destinations/shared.js.map +1 -0
  107. package/dist/destinations/tiktok.d.ts +55 -0
  108. package/dist/destinations/tiktok.d.ts.map +1 -0
  109. package/dist/destinations/tiktok.js +40 -0
  110. package/dist/destinations/tiktok.js.map +1 -0
  111. package/dist/destinations/vercel-analytics.d.ts +25 -0
  112. package/dist/destinations/vercel-analytics.d.ts.map +1 -0
  113. package/dist/destinations/vercel-analytics.js +23 -0
  114. package/dist/destinations/vercel-analytics.js.map +1 -0
  115. package/dist/index.d.ts +64 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +41 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/react/consent-banner.d.ts +155 -0
  120. package/dist/react/consent-banner.d.ts.map +1 -0
  121. package/dist/react/consent-banner.js +171 -0
  122. package/dist/react/consent-banner.js.map +1 -0
  123. package/dist/react/gtag-consent-bootstrap.d.ts +17 -0
  124. package/dist/react/gtag-consent-bootstrap.d.ts.map +1 -0
  125. package/dist/react/gtag-consent-bootstrap.js +22 -0
  126. package/dist/react/gtag-consent-bootstrap.js.map +1 -0
  127. package/dist/react/use-consent.d.ts +42 -0
  128. package/dist/react/use-consent.d.ts.map +1 -0
  129. package/dist/react/use-consent.js +60 -0
  130. package/dist/react/use-consent.js.map +1 -0
  131. package/dist/react/use-google-consent-sync.d.ts +20 -0
  132. package/dist/react/use-google-consent-sync.d.ts.map +1 -0
  133. package/dist/react/use-google-consent-sync.js +22 -0
  134. package/dist/react/use-google-consent-sync.js.map +1 -0
  135. package/dist/react/use-initial-consent.d.ts +11 -0
  136. package/dist/react/use-initial-consent.d.ts.map +1 -0
  137. package/dist/react/use-initial-consent.js +18 -0
  138. package/dist/react/use-initial-consent.js.map +1 -0
  139. package/dist/server/anonymous-id-cookie.d.ts +67 -0
  140. package/dist/server/anonymous-id-cookie.d.ts.map +1 -0
  141. package/dist/server/anonymous-id-cookie.js +71 -0
  142. package/dist/server/anonymous-id-cookie.js.map +1 -0
  143. package/dist/server/consent-receipt-store.d.ts +56 -0
  144. package/dist/server/consent-receipt-store.d.ts.map +1 -0
  145. package/dist/server/consent-receipt-store.js +44 -0
  146. package/dist/server/consent-receipt-store.js.map +1 -0
  147. package/dist/server/consent-receipt.d.ts +41 -0
  148. package/dist/server/consent-receipt.d.ts.map +1 -0
  149. package/dist/server/consent-receipt.js +60 -0
  150. package/dist/server/consent-receipt.js.map +1 -0
  151. package/dist/server/initial-consent.d.ts +26 -0
  152. package/dist/server/initial-consent.d.ts.map +1 -0
  153. package/dist/server/initial-consent.js +31 -0
  154. package/dist/server/initial-consent.js.map +1 -0
  155. package/dist/server/measurement-protocol.d.ts +69 -0
  156. package/dist/server/measurement-protocol.d.ts.map +1 -0
  157. package/dist/server/measurement-protocol.js +61 -0
  158. package/dist/server/measurement-protocol.js.map +1 -0
  159. package/dist/server/region.d.ts +27 -0
  160. package/dist/server/region.d.ts.map +1 -0
  161. package/dist/server/region.js +69 -0
  162. package/dist/server/region.js.map +1 -0
  163. package/dist/server/user-deletion.d.ts +64 -0
  164. package/dist/server/user-deletion.d.ts.map +1 -0
  165. package/dist/server/user-deletion.js +54 -0
  166. package/dist/server/user-deletion.js.map +1 -0
  167. package/dist/tooling/import-protection.d.ts +19 -0
  168. package/dist/tooling/import-protection.d.ts.map +1 -0
  169. package/dist/tooling/import-protection.js +23 -0
  170. package/dist/tooling/import-protection.js.map +1 -0
  171. package/package.json +201 -107
  172. package/src/adapters/tanstack-start.ts +135 -0
  173. package/src/client/ad-framework-consent.ts +86 -0
  174. package/src/client/browser-cookie.ts +16 -0
  175. package/src/client/consent-runtime.ts +80 -0
  176. package/src/client/consent-storage.ts +31 -1
  177. package/src/client/consent-withdrawal.ts +32 -0
  178. package/src/client/cookie-anonymous-id.ts +112 -0
  179. package/src/client/create-client-tracker.ts +128 -86
  180. package/src/client/gpc.ts +4 -2
  181. package/src/client/initial-consent-store.ts +218 -0
  182. package/src/client/is-analytics-allowed.ts +43 -0
  183. package/src/client/server-persisted-anonymous-id.ts +102 -0
  184. package/src/core/consent-config.ts +27 -0
  185. package/src/core/consent-receipt.ts +115 -0
  186. package/src/core/consent.ts +164 -10
  187. package/src/core/cookie.ts +29 -0
  188. package/src/core/destination.ts +17 -8
  189. package/src/core/event-catalog.ts +29 -15
  190. package/src/core/event-id.ts +1 -2
  191. package/src/core/tracked-event.ts +4 -4
  192. package/src/destinations/ad-consent.ts +29 -0
  193. package/src/destinations/google-analytics.ts +196 -133
  194. package/src/destinations/google-consent.ts +164 -0
  195. package/src/destinations/meta.ts +96 -0
  196. package/src/destinations/microsoft-uet.ts +86 -0
  197. package/src/destinations/shared.ts +45 -0
  198. package/src/destinations/tiktok.ts +85 -0
  199. package/src/destinations/vercel-analytics.ts +23 -24
  200. package/src/index.ts +165 -8
  201. package/src/react/consent-banner.tsx +40 -14
  202. package/src/react/gtag-consent-bootstrap.tsx +48 -0
  203. package/src/react/use-consent.ts +53 -45
  204. package/src/react/use-google-consent-sync.ts +38 -0
  205. package/src/react/use-initial-consent.ts +22 -0
  206. package/src/server/anonymous-id-cookie.ts +103 -0
  207. package/src/server/consent-receipt-store.ts +79 -0
  208. package/src/server/consent-receipt.ts +89 -0
  209. package/src/server/initial-consent.ts +46 -0
  210. package/src/server/measurement-protocol.ts +114 -0
  211. package/src/server/region.ts +22 -15
  212. package/src/server/user-deletion.ts +93 -0
  213. package/src/tooling/import-protection.ts +22 -0
  214. package/dist/client/consent-storage.mjs +0 -63
  215. package/dist/client/create-client-tracker.d.mts +0 -37
  216. package/dist/client/create-client-tracker.mjs +0 -66
  217. package/dist/client/gpc.d.mts +0 -10
  218. package/dist/client/gpc.mjs +0 -12
  219. package/dist/client/index.d.mts +0 -8
  220. package/dist/client/index.mjs +0 -8
  221. package/dist/client/lifecycle.d.mts +0 -23
  222. package/dist/client/lifecycle.mjs +0 -30
  223. package/dist/client/local-storage.d.mts +0 -13
  224. package/dist/client/local-storage.mjs +0 -31
  225. package/dist/client/queue.d.mts +0 -49
  226. package/dist/client/queue.mjs +0 -71
  227. package/dist/client/router.d.mts +0 -30
  228. package/dist/client/router.mjs +0 -17
  229. package/dist/core/consent.d.mts +0 -89
  230. package/dist/core/consent.mjs +0 -57
  231. package/dist/core/destination.d.mts +0 -23
  232. package/dist/core/destination.mjs +0 -1
  233. package/dist/core/event-catalog.d.mts +0 -36
  234. package/dist/core/event-catalog.mjs +0 -12
  235. package/dist/core/event-id.d.mts +0 -10
  236. package/dist/core/event-id.mjs +0 -12
  237. package/dist/core/index.d.mts +0 -6
  238. package/dist/core/index.mjs +0 -4
  239. package/dist/core/tracked-event.d.mts +0 -17
  240. package/dist/core/tracked-event.mjs +0 -1
  241. package/dist/destinations/ga4-measurement-protocol.d.mts +0 -54
  242. package/dist/destinations/ga4-measurement-protocol.mjs +0 -89
  243. package/dist/destinations/google-analytics.d.mts +0 -98
  244. package/dist/destinations/google-analytics.mjs +0 -126
  245. package/dist/destinations/http-destination.d.mts +0 -20
  246. package/dist/destinations/http-destination.mjs +0 -25
  247. package/dist/destinations/index.d.mts +0 -5
  248. package/dist/destinations/index.mjs +0 -5
  249. package/dist/destinations/vercel-analytics.d.mts +0 -13
  250. package/dist/destinations/vercel-analytics.mjs +0 -30
  251. package/dist/index.d.mts +0 -6
  252. package/dist/index.mjs +0 -4
  253. package/dist/react/consent-banner.d.mts +0 -163
  254. package/dist/react/consent-banner.mjs +0 -209
  255. package/dist/react/index.d.mts +0 -3
  256. package/dist/react/index.mjs +0 -3
  257. package/dist/react/use-consent.d.mts +0 -49
  258. package/dist/react/use-consent.mjs +0 -54
  259. package/dist/server/create-server-tracker.d.mts +0 -42
  260. package/dist/server/create-server-tracker.mjs +0 -67
  261. package/dist/server/index.d.mts +0 -3
  262. package/dist/server/index.mjs +0 -3
  263. package/dist/server/region.d.mts +0 -20
  264. package/dist/server/region.mjs +0 -56
  265. package/src/client/index.ts +0 -17
  266. package/src/client/lifecycle.ts +0 -50
  267. package/src/client/local-storage.ts +0 -44
  268. package/src/client/queue.ts +0 -117
  269. package/src/client/router.ts +0 -37
  270. package/src/core/index.ts +0 -24
  271. package/src/destinations/ga4-measurement-protocol.ts +0 -166
  272. package/src/destinations/http-destination.ts +0 -33
  273. package/src/destinations/index.ts +0 -20
  274. package/src/react/index.ts +0 -29
  275. package/src/server/create-server-tracker.ts +0 -128
  276. package/src/server/index.ts +0 -4
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The `@codefast/tracking` subpaths every client bundle must deny (picomatch patterns) —
3
+ * framework-neutral data each build tool maps to its own guard: TanStack Start's
4
+ * `importProtection.client.specifiers`, Next's `server-only`, Remix's `.server` convention.
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
7
+ * vite.config.ts).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * tanstackStart({
12
+ * importProtection: { client: { specifiers: [...SERVER_ONLY_SUBPATHS] } },
13
+ * });
14
+ * ```
15
+ *
16
+ * @since 1.0.0-canary.6
17
+ */
18
+ export const SERVER_ONLY_SUBPATHS = [
19
+ "@codefast/tracking/server",
20
+ "@codefast/tracking/server/**",
21
+ "@codefast/tracking/adapters/**",
22
+ ];
23
+ //# sourceMappingURL=import-protection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-protection.js","sourceRoot":"","sources":["../../src/tooling/import-protection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0B;IACzD,2BAA2B;IAC3B,8BAA8B;IAC9B,gCAAgC;CACjC,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@codefast/tracking",
3
- "version": "0.5.0-canary.5",
4
- "description": "Fullstack, type-safe event tracking for TanStack Start — isomorphic client/server trackers over a per-app Zod event catalog",
3
+ "version": "0.5.0-canary.6",
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",
7
7
  "codefast",
8
8
  "consent",
9
+ "standard-schema",
9
10
  "tanstack-start",
10
11
  "tracking",
11
- "typescript",
12
- "zod"
12
+ "typescript"
13
13
  ],
14
14
  "homepage": "https://github.com/codefastlabs/codefast/tree/main/packages/tracking#readme",
15
15
  "bugs": {
@@ -31,9 +31,9 @@
31
31
  ],
32
32
  "type": "module",
33
33
  "sideEffects": false,
34
- "main": "./dist/index.mjs",
35
- "module": "./dist/index.mjs",
36
- "types": "./dist/index.d.mts",
34
+ "main": "./dist/index.js",
35
+ "module": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
37
  "imports": {
38
38
  "#/tests/*": [
39
39
  "./tests/*",
@@ -42,144 +42,234 @@
42
42
  "./tests/*/index.ts",
43
43
  "./tests/*/index.tsx"
44
44
  ],
45
- "#/*": [
46
- "./src/*",
47
- "./src/*.ts",
48
- "./src/*.tsx",
49
- "./src/*/index.ts",
50
- "./src/*/index.tsx"
51
- ]
45
+ "#/*": {
46
+ "source": [
47
+ "./src/*",
48
+ "./src/*.ts",
49
+ "./src/*.tsx",
50
+ "./src/*/index.ts",
51
+ "./src/*/index.tsx"
52
+ ],
53
+ "types": [
54
+ "./dist/*.d.ts",
55
+ "./dist/*/index.d.ts"
56
+ ],
57
+ "default": [
58
+ "./dist/*.js",
59
+ "./dist/*/index.js"
60
+ ]
61
+ }
52
62
  },
53
63
  "exports": {
54
64
  ".": {
55
65
  "source": "./src/index.ts",
56
- "types": "./dist/index.d.mts",
57
- "import": "./dist/index.mjs"
66
+ "types": "./dist/index.d.ts",
67
+ "import": "./dist/index.js"
68
+ },
69
+ "./adapters/tanstack-start": {
70
+ "source": "./src/adapters/tanstack-start.ts",
71
+ "types": "./dist/adapters/tanstack-start.d.ts",
72
+ "import": "./dist/adapters/tanstack-start.js"
73
+ },
74
+ "./client/ad-framework-consent": {
75
+ "source": "./src/client/ad-framework-consent.ts",
76
+ "types": "./dist/client/ad-framework-consent.d.ts",
77
+ "import": "./dist/client/ad-framework-consent.js"
78
+ },
79
+ "./client/browser-cookie": {
80
+ "source": "./src/client/browser-cookie.ts",
81
+ "types": "./dist/client/browser-cookie.d.ts",
82
+ "import": "./dist/client/browser-cookie.js"
58
83
  },
59
- "./client": {
60
- "source": "./src/client/index.ts",
61
- "types": "./dist/client/index.d.mts",
62
- "import": "./dist/client/index.mjs"
84
+ "./client/consent-runtime": {
85
+ "source": "./src/client/consent-runtime.ts",
86
+ "types": "./dist/client/consent-runtime.d.ts",
87
+ "import": "./dist/client/consent-runtime.js"
63
88
  },
64
89
  "./client/consent-storage": {
65
90
  "source": "./src/client/consent-storage.ts",
66
- "types": "./dist/client/consent-storage.d.mts",
67
- "import": "./dist/client/consent-storage.mjs"
91
+ "types": "./dist/client/consent-storage.d.ts",
92
+ "import": "./dist/client/consent-storage.js"
93
+ },
94
+ "./client/consent-withdrawal": {
95
+ "source": "./src/client/consent-withdrawal.ts",
96
+ "types": "./dist/client/consent-withdrawal.d.ts",
97
+ "import": "./dist/client/consent-withdrawal.js"
98
+ },
99
+ "./client/cookie-anonymous-id": {
100
+ "source": "./src/client/cookie-anonymous-id.ts",
101
+ "types": "./dist/client/cookie-anonymous-id.d.ts",
102
+ "import": "./dist/client/cookie-anonymous-id.js"
68
103
  },
69
104
  "./client/create-client-tracker": {
70
105
  "source": "./src/client/create-client-tracker.ts",
71
- "types": "./dist/client/create-client-tracker.d.mts",
72
- "import": "./dist/client/create-client-tracker.mjs"
106
+ "types": "./dist/client/create-client-tracker.d.ts",
107
+ "import": "./dist/client/create-client-tracker.js"
73
108
  },
74
109
  "./client/gpc": {
75
110
  "source": "./src/client/gpc.ts",
76
- "types": "./dist/client/gpc.d.mts",
77
- "import": "./dist/client/gpc.mjs"
78
- },
79
- "./client/lifecycle": {
80
- "source": "./src/client/lifecycle.ts",
81
- "types": "./dist/client/lifecycle.d.mts",
82
- "import": "./dist/client/lifecycle.mjs"
83
- },
84
- "./client/local-storage": {
85
- "source": "./src/client/local-storage.ts",
86
- "types": "./dist/client/local-storage.d.mts",
87
- "import": "./dist/client/local-storage.mjs"
88
- },
89
- "./client/queue": {
90
- "source": "./src/client/queue.ts",
91
- "types": "./dist/client/queue.d.mts",
92
- "import": "./dist/client/queue.mjs"
93
- },
94
- "./client/router": {
95
- "source": "./src/client/router.ts",
96
- "types": "./dist/client/router.d.mts",
97
- "import": "./dist/client/router.mjs"
98
- },
99
- "./core": {
100
- "source": "./src/core/index.ts",
101
- "types": "./dist/core/index.d.mts",
102
- "import": "./dist/core/index.mjs"
111
+ "types": "./dist/client/gpc.d.ts",
112
+ "import": "./dist/client/gpc.js"
113
+ },
114
+ "./client/initial-consent-store": {
115
+ "source": "./src/client/initial-consent-store.ts",
116
+ "types": "./dist/client/initial-consent-store.d.ts",
117
+ "import": "./dist/client/initial-consent-store.js"
118
+ },
119
+ "./client/is-analytics-allowed": {
120
+ "source": "./src/client/is-analytics-allowed.ts",
121
+ "types": "./dist/client/is-analytics-allowed.d.ts",
122
+ "import": "./dist/client/is-analytics-allowed.js"
123
+ },
124
+ "./client/server-persisted-anonymous-id": {
125
+ "source": "./src/client/server-persisted-anonymous-id.ts",
126
+ "types": "./dist/client/server-persisted-anonymous-id.d.ts",
127
+ "import": "./dist/client/server-persisted-anonymous-id.js"
103
128
  },
104
129
  "./core/consent": {
105
130
  "source": "./src/core/consent.ts",
106
- "types": "./dist/core/consent.d.mts",
107
- "import": "./dist/core/consent.mjs"
131
+ "types": "./dist/core/consent.d.ts",
132
+ "import": "./dist/core/consent.js"
133
+ },
134
+ "./core/consent-config": {
135
+ "source": "./src/core/consent-config.ts",
136
+ "types": "./dist/core/consent-config.d.ts",
137
+ "import": "./dist/core/consent-config.js"
138
+ },
139
+ "./core/consent-receipt": {
140
+ "source": "./src/core/consent-receipt.ts",
141
+ "types": "./dist/core/consent-receipt.d.ts",
142
+ "import": "./dist/core/consent-receipt.js"
143
+ },
144
+ "./core/cookie": {
145
+ "source": "./src/core/cookie.ts",
146
+ "types": "./dist/core/cookie.d.ts",
147
+ "import": "./dist/core/cookie.js"
108
148
  },
109
149
  "./core/destination": {
110
150
  "source": "./src/core/destination.ts",
111
- "types": "./dist/core/destination.d.mts",
112
- "import": "./dist/core/destination.mjs"
151
+ "types": "./dist/core/destination.d.ts",
152
+ "import": "./dist/core/destination.js"
113
153
  },
114
154
  "./core/event-catalog": {
115
155
  "source": "./src/core/event-catalog.ts",
116
- "types": "./dist/core/event-catalog.d.mts",
117
- "import": "./dist/core/event-catalog.mjs"
156
+ "types": "./dist/core/event-catalog.d.ts",
157
+ "import": "./dist/core/event-catalog.js"
118
158
  },
119
159
  "./core/event-id": {
120
160
  "source": "./src/core/event-id.ts",
121
- "types": "./dist/core/event-id.d.mts",
122
- "import": "./dist/core/event-id.mjs"
161
+ "types": "./dist/core/event-id.d.ts",
162
+ "import": "./dist/core/event-id.js"
123
163
  },
124
164
  "./core/tracked-event": {
125
165
  "source": "./src/core/tracked-event.ts",
126
- "types": "./dist/core/tracked-event.d.mts",
127
- "import": "./dist/core/tracked-event.mjs"
128
- },
129
- "./destinations": {
130
- "source": "./src/destinations/index.ts",
131
- "types": "./dist/destinations/index.d.mts",
132
- "import": "./dist/destinations/index.mjs"
166
+ "types": "./dist/core/tracked-event.d.ts",
167
+ "import": "./dist/core/tracked-event.js"
133
168
  },
134
- "./destinations/ga4-measurement-protocol": {
135
- "source": "./src/destinations/ga4-measurement-protocol.ts",
136
- "types": "./dist/destinations/ga4-measurement-protocol.d.mts",
137
- "import": "./dist/destinations/ga4-measurement-protocol.mjs"
169
+ "./destinations/ad-consent": {
170
+ "source": "./src/destinations/ad-consent.ts",
171
+ "types": "./dist/destinations/ad-consent.d.ts",
172
+ "import": "./dist/destinations/ad-consent.js"
138
173
  },
139
174
  "./destinations/google-analytics": {
140
175
  "source": "./src/destinations/google-analytics.ts",
141
- "types": "./dist/destinations/google-analytics.d.mts",
142
- "import": "./dist/destinations/google-analytics.mjs"
176
+ "types": "./dist/destinations/google-analytics.d.ts",
177
+ "import": "./dist/destinations/google-analytics.js"
178
+ },
179
+ "./destinations/google-consent": {
180
+ "source": "./src/destinations/google-consent.ts",
181
+ "types": "./dist/destinations/google-consent.d.ts",
182
+ "import": "./dist/destinations/google-consent.js"
143
183
  },
144
- "./destinations/http-destination": {
145
- "source": "./src/destinations/http-destination.ts",
146
- "types": "./dist/destinations/http-destination.d.mts",
147
- "import": "./dist/destinations/http-destination.mjs"
184
+ "./destinations/meta": {
185
+ "source": "./src/destinations/meta.ts",
186
+ "types": "./dist/destinations/meta.d.ts",
187
+ "import": "./dist/destinations/meta.js"
188
+ },
189
+ "./destinations/microsoft-uet": {
190
+ "source": "./src/destinations/microsoft-uet.ts",
191
+ "types": "./dist/destinations/microsoft-uet.d.ts",
192
+ "import": "./dist/destinations/microsoft-uet.js"
193
+ },
194
+ "./destinations/shared": {
195
+ "source": "./src/destinations/shared.ts",
196
+ "types": "./dist/destinations/shared.d.ts",
197
+ "import": "./dist/destinations/shared.js"
198
+ },
199
+ "./destinations/tiktok": {
200
+ "source": "./src/destinations/tiktok.ts",
201
+ "types": "./dist/destinations/tiktok.d.ts",
202
+ "import": "./dist/destinations/tiktok.js"
148
203
  },
149
204
  "./destinations/vercel-analytics": {
150
205
  "source": "./src/destinations/vercel-analytics.ts",
151
- "types": "./dist/destinations/vercel-analytics.d.mts",
152
- "import": "./dist/destinations/vercel-analytics.mjs"
153
- },
154
- "./react": {
155
- "source": "./src/react/index.ts",
156
- "types": "./dist/react/index.d.mts",
157
- "import": "./dist/react/index.mjs"
206
+ "types": "./dist/destinations/vercel-analytics.d.ts",
207
+ "import": "./dist/destinations/vercel-analytics.js"
158
208
  },
159
209
  "./react/consent-banner": {
160
210
  "source": "./src/react/consent-banner.tsx",
161
- "types": "./dist/react/consent-banner.d.mts",
162
- "import": "./dist/react/consent-banner.mjs"
211
+ "types": "./dist/react/consent-banner.d.ts",
212
+ "import": "./dist/react/consent-banner.js"
213
+ },
214
+ "./react/gtag-consent-bootstrap": {
215
+ "source": "./src/react/gtag-consent-bootstrap.tsx",
216
+ "types": "./dist/react/gtag-consent-bootstrap.d.ts",
217
+ "import": "./dist/react/gtag-consent-bootstrap.js"
163
218
  },
164
219
  "./react/use-consent": {
165
220
  "source": "./src/react/use-consent.ts",
166
- "types": "./dist/react/use-consent.d.mts",
167
- "import": "./dist/react/use-consent.mjs"
221
+ "types": "./dist/react/use-consent.d.ts",
222
+ "import": "./dist/react/use-consent.js"
223
+ },
224
+ "./react/use-google-consent-sync": {
225
+ "source": "./src/react/use-google-consent-sync.ts",
226
+ "types": "./dist/react/use-google-consent-sync.d.ts",
227
+ "import": "./dist/react/use-google-consent-sync.js"
228
+ },
229
+ "./react/use-initial-consent": {
230
+ "source": "./src/react/use-initial-consent.ts",
231
+ "types": "./dist/react/use-initial-consent.d.ts",
232
+ "import": "./dist/react/use-initial-consent.js"
168
233
  },
169
- "./server": {
170
- "source": "./src/server/index.ts",
171
- "types": "./dist/server/index.d.mts",
172
- "import": "./dist/server/index.mjs"
234
+ "./server/anonymous-id-cookie": {
235
+ "source": "./src/server/anonymous-id-cookie.ts",
236
+ "types": "./dist/server/anonymous-id-cookie.d.ts",
237
+ "import": "./dist/server/anonymous-id-cookie.js"
173
238
  },
174
- "./server/create-server-tracker": {
175
- "source": "./src/server/create-server-tracker.ts",
176
- "types": "./dist/server/create-server-tracker.d.mts",
177
- "import": "./dist/server/create-server-tracker.mjs"
239
+ "./server/consent-receipt": {
240
+ "source": "./src/server/consent-receipt.ts",
241
+ "types": "./dist/server/consent-receipt.d.ts",
242
+ "import": "./dist/server/consent-receipt.js"
243
+ },
244
+ "./server/consent-receipt-store": {
245
+ "source": "./src/server/consent-receipt-store.ts",
246
+ "types": "./dist/server/consent-receipt-store.d.ts",
247
+ "import": "./dist/server/consent-receipt-store.js"
248
+ },
249
+ "./server/initial-consent": {
250
+ "source": "./src/server/initial-consent.ts",
251
+ "types": "./dist/server/initial-consent.d.ts",
252
+ "import": "./dist/server/initial-consent.js"
253
+ },
254
+ "./server/measurement-protocol": {
255
+ "source": "./src/server/measurement-protocol.ts",
256
+ "types": "./dist/server/measurement-protocol.d.ts",
257
+ "import": "./dist/server/measurement-protocol.js"
178
258
  },
179
259
  "./server/region": {
180
260
  "source": "./src/server/region.ts",
181
- "types": "./dist/server/region.d.mts",
182
- "import": "./dist/server/region.mjs"
261
+ "types": "./dist/server/region.d.ts",
262
+ "import": "./dist/server/region.js"
263
+ },
264
+ "./server/user-deletion": {
265
+ "source": "./src/server/user-deletion.ts",
266
+ "types": "./dist/server/user-deletion.d.ts",
267
+ "import": "./dist/server/user-deletion.js"
268
+ },
269
+ "./tooling/import-protection": {
270
+ "source": "./src/tooling/import-protection.ts",
271
+ "types": "./dist/tooling/import-protection.d.ts",
272
+ "import": "./dist/tooling/import-protection.js"
183
273
  },
184
274
  "./css/*": "./src/css/*",
185
275
  "./package.json": "./package.json"
@@ -188,30 +278,31 @@
188
278
  "access": "public"
189
279
  },
190
280
  "dependencies": {
191
- "zod": "^4.4.3"
281
+ "@standard-schema/spec": "^1.1.0"
192
282
  },
193
283
  "devDependencies": {
284
+ "@tanstack/react-start": "^1.168.32",
194
285
  "@testing-library/dom": "^10.4.1",
195
286
  "@testing-library/jest-dom": "^6.9.1",
196
287
  "@testing-library/react": "^16.3.2",
197
288
  "@testing-library/user-event": "^14.6.1",
198
- "@types/node": "^26.1.0",
289
+ "@types/node": "^26.1.1",
199
290
  "@types/react": "^19.2.17",
200
291
  "@types/react-dom": "^19.2.3",
201
- "@typescript/native-preview": "7.0.0-dev.20260704.1",
202
292
  "@vercel/analytics": "^2.0.1",
203
293
  "@vitejs/plugin-react": "^6.0.3",
204
- "@vitest/coverage-v8": "^4.1.9",
294
+ "@vitest/coverage-v8": "^4.1.10",
205
295
  "expect-type": "^1.4.0",
206
296
  "jsdom": "^29.1.1",
207
297
  "react": "^19.2.7",
208
298
  "react-dom": "^19.2.7",
209
- "tsdown": "^0.22.3",
210
- "typescript": "^6.0.3",
211
- "vitest": "^4.1.9",
212
- "@codefast/typescript-config": "0.5.0-canary.5"
299
+ "typescript": "^7.0.2",
300
+ "vitest": "^4.1.10",
301
+ "zod": "^4.4.3",
302
+ "@codefast/typescript-config": "0.5.0-canary.6"
213
303
  },
214
304
  "peerDependencies": {
305
+ "@tanstack/react-start": ">=1.168.0",
215
306
  "@types/react": ">=19.0.0",
216
307
  "@types/react-dom": ">=19.0.0",
217
308
  "@vercel/analytics": ">=1.0.0",
@@ -219,6 +310,9 @@
219
310
  "react-dom": ">=19.0.0"
220
311
  },
221
312
  "peerDependenciesMeta": {
313
+ "@tanstack/react-start": {
314
+ "optional": true
315
+ },
222
316
  "@types/react": {
223
317
  "optional": true
224
318
  },
@@ -239,8 +333,8 @@
239
333
  "node": ">=24.0.0"
240
334
  },
241
335
  "scripts": {
242
- "build": "tsdown",
243
- "check-types": "tsgo --noEmit",
336
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
337
+ "check-types": "tsc --noEmit",
244
338
  "clean": "rm -rf dist",
245
339
  "test": "vitest run",
246
340
  "test:coverage": "vitest run --coverage",
@@ -0,0 +1,135 @@
1
+ import {
2
+ deleteCookie,
3
+ getRequestHeader,
4
+ getRequestIP,
5
+ setCookie,
6
+ setResponseHeader,
7
+ } from "@tanstack/react-start/server";
8
+
9
+ import type { ConsentCategory, InitialConsent } from "#/core/consent";
10
+ import type { ConsentReceipt, ConsentReceiptInput } from "#/core/consent-receipt";
11
+ import { isConsentReceiptInput } from "#/core/consent-receipt";
12
+ import type { AnonymousIdCookieOptions } from "#/server/anonymous-id-cookie";
13
+ import { resolveAnonymousIdCookie, resolveClearAnonymousIdCookie } from "#/server/anonymous-id-cookie";
14
+ import { buildConsentReceipt } from "#/server/consent-receipt";
15
+ import type { ReceiptStore } from "#/server/consent-receipt-store";
16
+ import { resolveInitialConsent } from "#/server/initial-consent";
17
+
18
+ /**
19
+ * @since 1.0.0-canary.7
20
+ */
21
+ export interface InitialConsentFromRequestOptions {
22
+ /**
23
+ * Header carrying the ISO 3166-1 alpha-2 country code.
24
+ *
25
+ * @defaultValue "x-vercel-ip-country"
26
+ */
27
+ countryHeaderName?: string | undefined;
28
+ /** Categories the app's prompt asks about — opt-out regions grant exactly these by default. */
29
+ requestedCategories: ReadonlyArray<ConsentCategory>;
30
+ }
31
+
32
+ /**
33
+ * Region-correct `InitialConsent` for the current request: reads the platform geo header
34
+ * and `sec-gpc`, fails closed when geo is missing, and stamps
35
+ * `cache-control: private, no-store` — the value is per-visitor by definition, so no
36
+ * shared cache may ever store the response carrying it.
37
+ *
38
+ * Server-only: deny this subpath in the client environment via Start's `importProtection`
39
+ * — the compiler already strips it with stubbed handler bodies.
40
+ *
41
+ * @since 1.0.0-canary.6
42
+ */
43
+ export function resolveInitialConsentFromRequest(options: InitialConsentFromRequestOptions): InitialConsent {
44
+ setResponseHeader("cache-control", "private, no-store");
45
+
46
+ return resolveInitialConsent({
47
+ countryCode: getRequestHeader(options.countryHeaderName ?? "x-vercel-ip-country"),
48
+ hasGlobalPrivacyControlSignal: getRequestHeader("sec-gpc") === "1",
49
+ requestedCategories: options.requestedCategories,
50
+ });
51
+ }
52
+
53
+ /**
54
+ * Persists (or prolongs) a client-minted anonymous id via the framework's `setCookie` (which
55
+ * appends, so it never clobbers another `Set-Cookie` on the response) — the server re-issue
56
+ * that escapes Safari ITP's 7-day cap on script-written cookies. Validation lives in
57
+ * `resolveAnonymousIdCookie`: a non-UUID id throws, so this can safely back a public server
58
+ * function without echoing attacker input into a header.
59
+ *
60
+ * @since 1.0.0-canary.6
61
+ */
62
+ export function setAnonymousIdResponseCookie(options: AnonymousIdCookieOptions): void {
63
+ const { name, value, ...attributes } = resolveAnonymousIdCookie({
64
+ cookieName: options.cookieName,
65
+ id: options.id,
66
+ maxAgeSeconds: options.maxAgeSeconds,
67
+ });
68
+
69
+ setCookie(name, value, attributes);
70
+ }
71
+
72
+ /**
73
+ * Expires the anonymous-id cookie on the current response — the server half of a consent withdrawal.
74
+ *
75
+ * @since 1.0.0-canary.6
76
+ */
77
+ export function clearAnonymousIdResponseCookie(cookieName: string): void {
78
+ const { name, ...attributes } = resolveClearAnonymousIdCookie(cookieName);
79
+
80
+ deleteCookie(name, attributes);
81
+ }
82
+
83
+ /**
84
+ * The client-visible acknowledgement of a recorded receipt — deliberately minimal so the
85
+ * stored PII (`subjectId`, `ipCoarse`) is never echoed back over the wire.
86
+ *
87
+ * @since 1.0.0-canary.7
88
+ */
89
+ export interface ConsentReceiptAck {
90
+ receiptId: string;
91
+ timestamp: number;
92
+ }
93
+
94
+ /**
95
+ * @since 1.0.0-canary.7
96
+ */
97
+ export interface RecordConsentReceiptFromRequestOptions {
98
+ input: ConsentReceiptInput;
99
+ /**
100
+ * Optional tamper-evidence signer — supply an HMAC/signature over the receipt to stamp an
101
+ * `integrityKey`. Omit it and the stored receipt carries none.
102
+ */
103
+ sign?: ((receipt: Omit<ConsentReceipt, "integrityKey">) => string) | undefined;
104
+ store: ReceiptStore;
105
+ }
106
+
107
+ /**
108
+ * Records a consent receipt for the current request: rejects a body-supplied IP, derives a
109
+ * coarsened one from the connection, builds the server-stamped receipt, appends it to the
110
+ * store, and stamps `cache-control: no-store` — the response carries PII, so no cache
111
+ * (shared or private) may store it. Returns a minimal ack, never the stored record.
112
+ *
113
+ * @throws Error when `input` fails {@link isConsentReceiptInput} (including a body that
114
+ * carries an `ip`/`ipCoarse` field — the server owns IP derivation).
115
+ *
116
+ * @since 1.0.0-canary.7
117
+ */
118
+ export async function recordConsentReceiptFromRequest(
119
+ options: RecordConsentReceiptFromRequestOptions,
120
+ ): Promise<ConsentReceiptAck> {
121
+ setResponseHeader("cache-control", "no-store");
122
+
123
+ if (!isConsentReceiptInput(options.input)) {
124
+ throw new Error("Invalid consent receipt input");
125
+ }
126
+
127
+ // getRequestIP reads the platform/socket IP, trusting X-Forwarded-For's first hop — safe
128
+ // behind the CDN/proxy this app deploys to, and the maintained path over hand-parsing headers.
129
+ const rawIp = getRequestIP({ xForwardedFor: true });
130
+ const receipt = buildConsentReceipt({ input: options.input, rawIp, sign: options.sign });
131
+
132
+ await options.store.append(receipt);
133
+
134
+ return { receiptId: receipt.receiptId, timestamp: receipt.timestamp };
135
+ }