@10x-media/analytics 0.1.0-beta.5 → 1.0.0-beta.10

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 (515) hide show
  1. package/CHANGELOG.md +270 -0
  2. package/LICENSE +21 -21
  3. package/README.md +15 -4
  4. package/dist/adapters/ga4/disableKey.d.ts +9 -0
  5. package/dist/adapters/ga4/disableKey.js +21 -0
  6. package/dist/adapters/ga4/disableKey.js.map +1 -0
  7. package/dist/adapters/ga4/eventName.d.ts +15 -0
  8. package/dist/adapters/ga4/eventName.js +19 -0
  9. package/dist/adapters/ga4/eventName.js.map +1 -0
  10. package/dist/adapters/ga4/ga4.d.ts +5 -0
  11. package/dist/adapters/ga4/ga4.js +186 -58
  12. package/dist/adapters/ga4/ga4.js.map +1 -1
  13. package/dist/adapters/ga4/measurementId.js +15 -0
  14. package/dist/adapters/ga4/measurementId.js.map +1 -0
  15. package/dist/adapters/goalRead.js +126 -0
  16. package/dist/adapters/goalRead.js.map +1 -0
  17. package/dist/adapters/http/fetchJson.js +1 -1
  18. package/dist/adapters/plausible/plausible.d.ts +25 -0
  19. package/dist/adapters/plausible/plausible.js +159 -38
  20. package/dist/adapters/plausible/plausible.js.map +1 -1
  21. package/dist/adapters/posthog/posthog.d.ts +10 -1
  22. package/dist/adapters/posthog/posthog.js +130 -21
  23. package/dist/adapters/posthog/posthog.js.map +1 -1
  24. package/dist/adapters/series.js +11 -1
  25. package/dist/adapters/series.js.map +1 -1
  26. package/dist/adapters/umami/umami.d.ts +13 -1
  27. package/dist/adapters/umami/umami.js +278 -26
  28. package/dist/adapters/umami/umami.js.map +1 -1
  29. package/dist/binding/resolvePath.js +18 -2
  30. package/dist/binding/resolvePath.js.map +1 -1
  31. package/dist/capture/getTrackerConfig.d.ts +20 -0
  32. package/dist/capture/getTrackerConfig.js +31 -0
  33. package/dist/capture/getTrackerConfig.js.map +1 -0
  34. package/dist/capture/mountPath.js +14 -0
  35. package/dist/capture/mountPath.js.map +1 -0
  36. package/dist/capture/proxyEndpoint.js +127 -0
  37. package/dist/capture/proxyEndpoint.js.map +1 -0
  38. package/dist/capture/proxyRoutes.js +108 -0
  39. package/dist/capture/proxyRoutes.js.map +1 -0
  40. package/dist/capture/requestBody.js +68 -0
  41. package/dist/capture/requestBody.js.map +1 -0
  42. package/dist/capture/slots.d.ts +8 -0
  43. package/dist/capture/slots.js +54 -0
  44. package/dist/capture/slots.js.map +1 -0
  45. package/dist/capture/trackerConfig.d.ts +33 -0
  46. package/dist/capture/trackerConfig.js +95 -0
  47. package/dist/capture/trackerConfig.js.map +1 -0
  48. package/dist/capture/trackerEndpoint.js +35 -0
  49. package/dist/capture/trackerEndpoint.js.map +1 -0
  50. package/dist/charts/BarList.d.ts +16 -1
  51. package/dist/charts/BarList.js +41 -19
  52. package/dist/charts/BarList.js.map +1 -1
  53. package/dist/charts/TrendChart.d.ts +16 -3
  54. package/dist/charts/TrendChart.js +172 -106
  55. package/dist/charts/TrendChart.js.map +1 -1
  56. package/dist/charts/bars.d.ts +4 -0
  57. package/dist/charts/bars.js +3 -1
  58. package/dist/charts/bars.js.map +1 -1
  59. package/dist/charts/bucket.js +10 -1
  60. package/dist/charts/bucket.js.map +1 -1
  61. package/dist/charts/spline.js +2 -2
  62. package/dist/charts/spline.js.map +1 -1
  63. package/dist/charts/styles.js +18 -1
  64. package/dist/charts/styles.js.map +1 -1
  65. package/dist/core/cacheKey.js +26 -3
  66. package/dist/core/cacheKey.js.map +1 -1
  67. package/dist/core/capabilities.d.ts +5 -1
  68. package/dist/core/capabilities.js +11 -2
  69. package/dist/core/capabilities.js.map +1 -1
  70. package/dist/core/capture.d.ts +49 -0
  71. package/dist/core/contract.d.ts +74 -5
  72. package/dist/core/contract.js +30 -1
  73. package/dist/core/contract.js.map +1 -1
  74. package/dist/core/granularity.js +1 -1
  75. package/dist/core/options.d.ts +164 -6
  76. package/dist/core/options.js +126 -3
  77. package/dist/core/options.js.map +1 -1
  78. package/dist/core/registry.d.ts +1 -0
  79. package/dist/core/scopeList.js +32 -0
  80. package/dist/core/scopeList.js.map +1 -0
  81. package/dist/core/scopedRead.js +101 -30
  82. package/dist/core/scopedRead.js.map +1 -1
  83. package/dist/core/serverEvent.d.ts +60 -0
  84. package/dist/core/serverEvent.js +12 -0
  85. package/dist/core/serverEvent.js.map +1 -0
  86. package/dist/exports/adapters/ga4.d.ts +2 -1
  87. package/dist/exports/adapters/ga4.js +2 -1
  88. package/dist/exports/adapters/native.d.ts +3 -1
  89. package/dist/exports/adapters/native.js +2 -1
  90. package/dist/exports/client.d.ts +13 -3
  91. package/dist/exports/client.js +10 -1
  92. package/dist/exports/geo.d.ts +2 -2
  93. package/dist/exports/next.d.ts +2 -1
  94. package/dist/exports/next.js +2 -1
  95. package/dist/exports/react.d.ts +4 -0
  96. package/dist/exports/react.js +5 -0
  97. package/dist/exports/rsc.d.ts +11 -3
  98. package/dist/exports/rsc.js +7 -2
  99. package/dist/exports/tracker.d.ts +21 -0
  100. package/dist/exports/tracker.js +15 -0
  101. package/dist/exports/types.d.ts +16 -3
  102. package/dist/exports/types.js +4 -2
  103. package/dist/fields/AnalyticsPanelClient.js +2 -2
  104. package/dist/fields/AnalyticsPanelField.js +1 -1
  105. package/dist/fields/AnalyticsStatField.js +2 -2
  106. package/dist/fields/config/FilterDimensionSelectField.d.ts +14 -0
  107. package/dist/fields/config/FilterDimensionSelectField.js +77 -0
  108. package/dist/fields/config/FilterDimensionSelectField.js.map +1 -0
  109. package/dist/fields/config/FilterOperatorSelectField.d.ts +14 -0
  110. package/dist/fields/config/FilterOperatorSelectField.js +75 -0
  111. package/dist/fields/config/FilterOperatorSelectField.js.map +1 -0
  112. package/dist/fields/config/MetricSelectField.js +3 -3
  113. package/dist/fields/config/MetricSelectField.js.map +1 -1
  114. package/dist/fields/config/SourceSelectField.js +3 -3
  115. package/dist/fields/config/SourceSelectField.js.map +1 -1
  116. package/dist/fields/config/fetchSources.d.ts +5 -1
  117. package/dist/fields/config/fetchSources.js +7 -3
  118. package/dist/fields/config/fetchSources.js.map +1 -1
  119. package/dist/fields/config/narrow.js +2 -0
  120. package/dist/fields/config/narrow.js.map +1 -1
  121. package/dist/fields/config/sourcesState.js +19 -3
  122. package/dist/fields/config/sourcesState.js.map +1 -1
  123. package/dist/fields/config/useAnalyticsSources.d.ts +8 -3
  124. package/dist/fields/config/useAnalyticsSources.js +9 -6
  125. package/dist/fields/config/useAnalyticsSources.js.map +1 -1
  126. package/dist/fields/config/useFilterCapabilities.d.ts +28 -0
  127. package/dist/fields/config/useFilterCapabilities.js +52 -0
  128. package/dist/fields/config/useFilterCapabilities.js.map +1 -0
  129. package/dist/fields/readForDocument.d.ts +5 -0
  130. package/dist/fields/readForDocument.js +22 -10
  131. package/dist/fields/readForDocument.js.map +1 -1
  132. package/dist/goals/GoalSelectField.d.ts +7 -0
  133. package/dist/goals/GoalSelectField.js +77 -0
  134. package/dist/goals/GoalSelectField.js.map +1 -0
  135. package/dist/goals/collection.js +254 -0
  136. package/dist/goals/collection.js.map +1 -0
  137. package/dist/goals/currency.js +14 -0
  138. package/dist/goals/currency.js.map +1 -0
  139. package/dist/goals/fetchGoals.d.ts +18 -0
  140. package/dist/goals/fetchGoals.js +33 -0
  141. package/dist/goals/fetchGoals.js.map +1 -0
  142. package/dist/goals/goalField.d.ts +31 -0
  143. package/dist/goals/goalField.js +56 -0
  144. package/dist/goals/goalField.js.map +1 -0
  145. package/dist/goals/goalsEndpoint.d.ts +1 -0
  146. package/dist/goals/goalsEndpoint.js +58 -0
  147. package/dist/goals/goalsEndpoint.js.map +1 -0
  148. package/dist/goals/match.js +64 -0
  149. package/dist/goals/match.js.map +1 -0
  150. package/dist/goals/resolver.d.ts +8 -0
  151. package/dist/goals/resolver.js +147 -0
  152. package/dist/goals/resolver.js.map +1 -0
  153. package/dist/goals/trackGoalAction.d.ts +76 -0
  154. package/dist/goals/trackGoalAction.js +158 -0
  155. package/dist/goals/trackGoalAction.js.map +1 -0
  156. package/dist/goals/types.d.ts +33 -0
  157. package/dist/goals/types.js +7 -0
  158. package/dist/goals/types.js.map +1 -0
  159. package/dist/goals/useAnalyticsGoals.d.ts +20 -0
  160. package/dist/goals/useAnalyticsGoals.js +67 -0
  161. package/dist/goals/useAnalyticsGoals.js.map +1 -0
  162. package/dist/index.d.ts +14 -3
  163. package/dist/index.js +174 -19
  164. package/dist/index.js.map +1 -1
  165. package/dist/native/collections/events.js +65 -1
  166. package/dist/native/collections/events.js.map +1 -1
  167. package/dist/native/collections/rollups.js +39 -3
  168. package/dist/native/collections/rollups.js.map +1 -1
  169. package/dist/native/eventScan.js +25 -0
  170. package/dist/native/eventScan.js.map +1 -0
  171. package/dist/native/geo/composeGeoResolvers.js +2 -2
  172. package/dist/native/geo/composeGeoResolvers.js.map +1 -1
  173. package/dist/native/geo/geoResolver.d.ts +9 -2
  174. package/dist/native/geo/geoResolver.js.map +1 -1
  175. package/dist/native/geo/maxmindResolver.js +3 -5
  176. package/dist/native/geo/maxmindResolver.js.map +1 -1
  177. package/dist/native/ingest/bots.d.ts +11 -0
  178. package/dist/native/ingest/bots.js +71 -0
  179. package/dist/native/ingest/bots.js.map +1 -0
  180. package/dist/native/ingest/browser.js +47 -0
  181. package/dist/native/ingest/browser.js.map +1 -0
  182. package/dist/native/ingest/clientIp.js +20 -0
  183. package/dist/native/ingest/clientIp.js.map +1 -0
  184. package/dist/native/ingest/device.js +11 -3
  185. package/dist/native/ingest/device.js.map +1 -1
  186. package/dist/native/ingest/endpoint.d.ts +1 -0
  187. package/dist/native/ingest/endpoint.js +107 -21
  188. package/dist/native/ingest/endpoint.js.map +1 -1
  189. package/dist/native/ingest/flushBatch.js +29 -38
  190. package/dist/native/ingest/flushBatch.js.map +1 -1
  191. package/dist/native/ingest/language.js +14 -0
  192. package/dist/native/ingest/language.js.map +1 -0
  193. package/dist/native/ingest/normalizeEvent.d.ts +30 -0
  194. package/dist/native/ingest/normalizeEvent.js +115 -16
  195. package/dist/native/ingest/normalizeEvent.js.map +1 -1
  196. package/dist/native/ingest/referrer.js +48 -0
  197. package/dist/native/ingest/referrer.js.map +1 -0
  198. package/dist/native/ingest/requestHost.js +57 -0
  199. package/dist/native/ingest/requestHost.js.map +1 -0
  200. package/dist/native/ingest/resolveHostname.d.ts +29 -0
  201. package/dist/native/ingest/resolveHostname.js +52 -0
  202. package/dist/native/ingest/resolveHostname.js.map +1 -0
  203. package/dist/native/ingest/salt.js +27 -2
  204. package/dist/native/ingest/salt.js.map +1 -1
  205. package/dist/native/ingest/serverTrack.d.ts +20 -0
  206. package/dist/native/ingest/serverTrack.js +109 -0
  207. package/dist/native/ingest/serverTrack.js.map +1 -0
  208. package/dist/native/ingest/source.d.ts +11 -0
  209. package/dist/native/ingest/source.js +264 -16
  210. package/dist/native/ingest/source.js.map +1 -1
  211. package/dist/native/ingest/utm.js +33 -0
  212. package/dist/native/ingest/utm.js.map +1 -0
  213. package/dist/native/ingest/validate.js +26 -0
  214. package/dist/native/ingest/validate.js.map +1 -0
  215. package/dist/native/nativeAdapter.d.ts +37 -1
  216. package/dist/native/nativeAdapter.js +175 -22
  217. package/dist/native/nativeAdapter.js.map +1 -1
  218. package/dist/native/query/eventAgg.js +175 -0
  219. package/dist/native/query/eventAgg.js.map +1 -0
  220. package/dist/native/retention/pruneTask.js +53 -13
  221. package/dist/native/retention/pruneTask.js.map +1 -1
  222. package/dist/native/rollupAcc.js +12 -1
  223. package/dist/native/rollupAcc.js.map +1 -1
  224. package/dist/native/rollups/bucketKey.js +15 -0
  225. package/dist/native/rollups/bucketKey.js.map +1 -0
  226. package/dist/native/rollups/bumpRollups.js +116 -0
  227. package/dist/native/rollups/bumpRollups.js.map +1 -0
  228. package/dist/native/rollups/deltas.js +86 -11
  229. package/dist/native/rollups/deltas.js.map +1 -1
  230. package/dist/native/rollups/insertManyIfNew.js +93 -0
  231. package/dist/native/rollups/insertManyIfNew.js.map +1 -0
  232. package/dist/next/captureRewrites.d.ts +42 -0
  233. package/dist/next/captureRewrites.js +57 -0
  234. package/dist/next/captureRewrites.js.map +1 -0
  235. package/dist/next/posthogProxyRewrites.d.ts +5 -0
  236. package/dist/next/posthogProxyRewrites.js +16 -21
  237. package/dist/next/posthogProxyRewrites.js.map +1 -1
  238. package/dist/plugin/documentEndpoint.js +71 -24
  239. package/dist/plugin/documentEndpoint.js.map +1 -1
  240. package/dist/plugin/errors.d.ts +31 -0
  241. package/dist/plugin/errors.js +79 -0
  242. package/dist/plugin/errors.js.map +1 -0
  243. package/dist/plugin/goalHint.d.ts +1 -0
  244. package/dist/plugin/goalHint.js +24 -0
  245. package/dist/plugin/goalHint.js.map +1 -0
  246. package/dist/plugin/paths.js +17 -1
  247. package/dist/plugin/paths.js.map +1 -1
  248. package/dist/plugin/queryEndpoint.js +124 -0
  249. package/dist/plugin/queryEndpoint.js.map +1 -0
  250. package/dist/plugin/readContextForRequest.js +73 -0
  251. package/dist/plugin/readContextForRequest.js.map +1 -0
  252. package/dist/plugin/realtimeEndpoint.js +37 -16
  253. package/dist/plugin/realtimeEndpoint.js.map +1 -1
  254. package/dist/plugin/refreshEndpoint.js +113 -0
  255. package/dist/plugin/refreshEndpoint.js.map +1 -0
  256. package/dist/plugin/runtime.d.ts +1 -0
  257. package/dist/plugin/runtime.js +33 -1
  258. package/dist/plugin/runtime.js.map +1 -1
  259. package/dist/plugin/scopeChange.js +22 -0
  260. package/dist/plugin/scopeChange.js.map +1 -0
  261. package/dist/plugin/scopeFieldBoot.js +22 -0
  262. package/dist/plugin/scopeFieldBoot.js.map +1 -0
  263. package/dist/plugin/sourcesEndpoint.js +16 -41
  264. package/dist/plugin/sourcesEndpoint.js.map +1 -1
  265. package/dist/plugin/warmTask.js +0 -0
  266. package/dist/plugin/warmTask.js.map +1 -1
  267. package/dist/providers/collection.js +89 -29
  268. package/dist/providers/collection.js.map +1 -1
  269. package/dist/providers/factory.js +11 -3
  270. package/dist/providers/factory.js.map +1 -1
  271. package/dist/providers/resolver.js.map +1 -1
  272. package/dist/query/dates.js +64 -0
  273. package/dist/query/dates.js.map +1 -0
  274. package/dist/query/errors.d.ts +14 -0
  275. package/dist/query/fetchQuery.d.ts +79 -0
  276. package/dist/query/fetchQuery.js +117 -0
  277. package/dist/query/fetchQuery.js.map +1 -0
  278. package/dist/query/parse.d.ts +22 -0
  279. package/dist/query/parse.js +168 -0
  280. package/dist/query/parse.js.map +1 -0
  281. package/dist/query/response.d.ts +39 -0
  282. package/dist/query/response.js +11 -0
  283. package/dist/query/response.js.map +1 -0
  284. package/dist/react/AnalyticsProvider.d.ts +50 -0
  285. package/dist/react/AnalyticsProvider.js +67 -0
  286. package/dist/react/AnalyticsProvider.js.map +1 -0
  287. package/dist/react/TrackerBoot.d.ts +22 -0
  288. package/dist/react/TrackerBoot.js +30 -0
  289. package/dist/react/TrackerBoot.js.map +1 -0
  290. package/dist/react/useAnalytics.d.ts +20 -0
  291. package/dist/react/useAnalytics.js +52 -0
  292. package/dist/react/useAnalytics.js.map +1 -0
  293. package/dist/rsc/AnalyticsScripts.d.ts +30 -0
  294. package/dist/rsc/AnalyticsScripts.js +41 -0
  295. package/dist/rsc/AnalyticsScripts.js.map +1 -0
  296. package/dist/surfacing/cacheStore.d.ts +1 -0
  297. package/dist/surfacing/cacheStore.js +18 -2
  298. package/dist/surfacing/cacheStore.js.map +1 -1
  299. package/dist/surfacing/engine.d.ts +1 -0
  300. package/dist/surfacing/engine.js +47 -6
  301. package/dist/surfacing/engine.js.map +1 -1
  302. package/dist/surfacing/epoch.d.ts +1 -0
  303. package/dist/surfacing/epoch.js +72 -0
  304. package/dist/surfacing/epoch.js.map +1 -0
  305. package/dist/surfacing/queue.js +22 -6
  306. package/dist/surfacing/queue.js.map +1 -1
  307. package/dist/surfacing/rateLimiter.js +130 -0
  308. package/dist/surfacing/rateLimiter.js.map +1 -0
  309. package/dist/surfacing/retryPolicy.js +15 -0
  310. package/dist/surfacing/retryPolicy.js.map +1 -0
  311. package/dist/sync/collection.js +23 -7
  312. package/dist/sync/collection.js.map +1 -1
  313. package/dist/sync/syncTask.js +68 -33
  314. package/dist/sync/syncTask.js.map +1 -1
  315. package/dist/testing/memoryAdapter.d.ts +2 -0
  316. package/dist/testing/memoryAdapter.js +17 -1
  317. package/dist/testing/memoryAdapter.js.map +1 -1
  318. package/dist/timeframe/tz.js +17 -6
  319. package/dist/timeframe/tz.js.map +1 -1
  320. package/dist/tracker/autoCapture.d.ts +48 -0
  321. package/dist/tracker/autoCapture.js +129 -0
  322. package/dist/tracker/autoCapture.js.map +1 -0
  323. package/dist/tracker/consent.d.ts +24 -0
  324. package/dist/tracker/consent.js +48 -0
  325. package/dist/tracker/consent.js.map +1 -0
  326. package/dist/tracker/createTracker.d.ts +18 -0
  327. package/dist/tracker/createTracker.js +215 -0
  328. package/dist/tracker/createTracker.js.map +1 -0
  329. package/dist/tracker/exclusion.d.ts +28 -0
  330. package/dist/tracker/exclusion.js +50 -0
  331. package/dist/tracker/exclusion.js.map +1 -0
  332. package/dist/tracker/initTracker.d.ts +22 -0
  333. package/dist/tracker/initTracker.js +33 -0
  334. package/dist/tracker/initTracker.js.map +1 -0
  335. package/dist/tracker/loadScript.d.ts +14 -0
  336. package/dist/tracker/loadScript.js +41 -0
  337. package/dist/tracker/loadScript.js.map +1 -0
  338. package/dist/tracker/pageTracking.d.ts +17 -0
  339. package/dist/tracker/pageTracking.js +38 -0
  340. package/dist/tracker/pageTracking.js.map +1 -0
  341. package/dist/tracker/registry.d.ts +27 -0
  342. package/dist/tracker/registry.js +73 -0
  343. package/dist/tracker/registry.js.map +1 -0
  344. package/dist/tracker/sinks/ga4.d.ts +29 -0
  345. package/dist/tracker/sinks/ga4.js +30 -0
  346. package/dist/tracker/sinks/ga4.js.map +1 -0
  347. package/dist/tracker/sinks/native.d.ts +22 -0
  348. package/dist/tracker/sinks/native.js +56 -0
  349. package/dist/tracker/sinks/native.js.map +1 -0
  350. package/dist/tracker/sinks/plausible.d.ts +20 -0
  351. package/dist/tracker/sinks/plausible.js +32 -0
  352. package/dist/tracker/sinks/plausible.js.map +1 -0
  353. package/dist/tracker/sinks/posthog.d.ts +18 -0
  354. package/dist/tracker/sinks/posthog.js +30 -0
  355. package/dist/tracker/sinks/posthog.js.map +1 -0
  356. package/dist/tracker/sinks/umami.d.ts +18 -0
  357. package/dist/tracker/sinks/umami.js +23 -0
  358. package/dist/tracker/sinks/umami.js.map +1 -0
  359. package/dist/tracker/sinks/vendor.d.ts +14 -0
  360. package/dist/tracker/sinks/vendor.js +81 -0
  361. package/dist/tracker/sinks/vendor.js.map +1 -0
  362. package/dist/tracker/transport.js +28 -0
  363. package/dist/tracker/transport.js.map +1 -0
  364. package/dist/tracker/types.d.ts +91 -0
  365. package/dist/translations/ar.js +221 -0
  366. package/dist/translations/ar.js.map +1 -0
  367. package/dist/translations/de.js +145 -1
  368. package/dist/translations/de.js.map +1 -1
  369. package/dist/translations/en.js +145 -1
  370. package/dist/translations/en.js.map +1 -1
  371. package/dist/translations/es.js +221 -0
  372. package/dist/translations/es.js.map +1 -0
  373. package/dist/translations/fr.js +221 -0
  374. package/dist/translations/fr.js.map +1 -0
  375. package/dist/translations/id.js +221 -0
  376. package/dist/translations/id.js.map +1 -0
  377. package/dist/translations/index.d.ts +10 -1
  378. package/dist/translations/index.js +19 -1
  379. package/dist/translations/index.js.map +1 -1
  380. package/dist/translations/keys.d.ts +144 -0
  381. package/dist/translations/keys.js +145 -1
  382. package/dist/translations/keys.js.map +1 -1
  383. package/dist/translations/ko.js +221 -0
  384. package/dist/translations/ko.js.map +1 -0
  385. package/dist/translations/metricKeys.js +8 -2
  386. package/dist/translations/metricKeys.js.map +1 -1
  387. package/dist/translations/pt.js +221 -0
  388. package/dist/translations/pt.js.map +1 -0
  389. package/dist/translations/ru.js +221 -0
  390. package/dist/translations/ru.js.map +1 -0
  391. package/dist/translations/server.js.map +1 -1
  392. package/dist/translations/uk.js +221 -0
  393. package/dist/translations/uk.js.map +1 -0
  394. package/dist/translations/zh.js +221 -0
  395. package/dist/translations/zh.js.map +1 -0
  396. package/dist/view/AnalyticsNavLink.d.ts +19 -0
  397. package/dist/view/AnalyticsNavLink.js +40 -0
  398. package/dist/view/AnalyticsNavLink.js.map +1 -0
  399. package/dist/view/AnalyticsView.d.ts +23 -0
  400. package/dist/view/AnalyticsView.js +45 -0
  401. package/dist/view/AnalyticsView.js.map +1 -0
  402. package/dist/view/AnalyticsViewClient.d.ts +15 -0
  403. package/dist/view/AnalyticsViewClient.js +244 -0
  404. package/dist/view/AnalyticsViewClient.js.map +1 -0
  405. package/dist/view/authRedirect.js +32 -0
  406. package/dist/view/authRedirect.js.map +1 -0
  407. package/dist/view/conversionRate.js +18 -0
  408. package/dist/view/conversionRate.js.map +1 -0
  409. package/dist/view/dayRange.js +68 -0
  410. package/dist/view/dayRange.js.map +1 -0
  411. package/dist/view/gating.d.ts +1 -0
  412. package/dist/view/gating.js +142 -0
  413. package/dist/view/gating.js.map +1 -0
  414. package/dist/view/labels.js +76 -0
  415. package/dist/view/labels.js.map +1 -0
  416. package/dist/view/registerView.js +48 -0
  417. package/dist/view/registerView.js.map +1 -0
  418. package/dist/view/sections/Breakdowns.js +198 -0
  419. package/dist/view/sections/Breakdowns.js.map +1 -0
  420. package/dist/view/sections/EmptyStates.js +92 -0
  421. package/dist/view/sections/EmptyStates.js.map +1 -0
  422. package/dist/view/sections/FilterChips.js +46 -0
  423. package/dist/view/sections/FilterChips.js.map +1 -0
  424. package/dist/view/sections/GoalsPanel.js +82 -0
  425. package/dist/view/sections/GoalsPanel.js.map +1 -0
  426. package/dist/view/sections/OverviewCards.js +65 -0
  427. package/dist/view/sections/OverviewCards.js.map +1 -0
  428. package/dist/view/sections/RealtimeStrip.js +80 -0
  429. package/dist/view/sections/RealtimeStrip.js.map +1 -0
  430. package/dist/view/sections/Toolbar.js +207 -0
  431. package/dist/view/sections/Toolbar.js.map +1 -0
  432. package/dist/view/sections/Trend.js +125 -0
  433. package/dist/view/sections/Trend.js.map +1 -0
  434. package/dist/view/sections/styles.js +76 -0
  435. package/dist/view/sections/styles.js.map +1 -0
  436. package/dist/view/state.js +211 -0
  437. package/dist/view/state.js.map +1 -0
  438. package/dist/view/useViewQueries.js +153 -0
  439. package/dist/view/useViewQueries.js.map +1 -0
  440. package/dist/view/viewProps.d.ts +40 -0
  441. package/dist/view/viewProps.js +90 -0
  442. package/dist/view/viewProps.js.map +1 -0
  443. package/dist/widgets/AnalyticsBreakdownWidget.d.ts +2 -1
  444. package/dist/widgets/AnalyticsBreakdownWidget.js +78 -11
  445. package/dist/widgets/AnalyticsBreakdownWidget.js.map +1 -1
  446. package/dist/widgets/AnalyticsGoalsWidget.d.ts +14 -0
  447. package/dist/widgets/AnalyticsGoalsWidget.js +196 -0
  448. package/dist/widgets/AnalyticsGoalsWidget.js.map +1 -0
  449. package/dist/widgets/AnalyticsMetricWidget.d.ts +2 -1
  450. package/dist/widgets/AnalyticsMetricWidget.js +63 -13
  451. package/dist/widgets/AnalyticsMetricWidget.js.map +1 -1
  452. package/dist/widgets/AnalyticsRealtimeWidget.d.ts +2 -1
  453. package/dist/widgets/AnalyticsRealtimeWidget.js +44 -22
  454. package/dist/widgets/AnalyticsRealtimeWidget.js.map +1 -1
  455. package/dist/widgets/AnalyticsTrendWidget.d.ts +2 -1
  456. package/dist/widgets/AnalyticsTrendWidget.js +79 -16
  457. package/dist/widgets/AnalyticsTrendWidget.js.map +1 -1
  458. package/dist/widgets/RealtimeCounter.d.ts +4 -0
  459. package/dist/widgets/RealtimeCounter.js +18 -4
  460. package/dist/widgets/RealtimeCounter.js.map +1 -1
  461. package/dist/widgets/WidgetViewLink.js +17 -0
  462. package/dist/widgets/WidgetViewLink.js.map +1 -0
  463. package/dist/widgets/breakdownTypes.js +38 -0
  464. package/dist/widgets/breakdownTypes.js.map +1 -1
  465. package/dist/widgets/cardChrome.js +31 -7
  466. package/dist/widgets/cardChrome.js.map +1 -1
  467. package/dist/widgets/comparison.js +15 -1
  468. package/dist/widgets/comparison.js.map +1 -1
  469. package/dist/widgets/defaults.d.ts +6 -2
  470. package/dist/widgets/defaults.js +78 -23
  471. package/dist/widgets/defaults.js.map +1 -1
  472. package/dist/widgets/filterCaption.js +27 -0
  473. package/dist/widgets/filterCaption.js.map +1 -0
  474. package/dist/widgets/filterField.d.ts +19 -0
  475. package/dist/widgets/filterField.js +75 -0
  476. package/dist/widgets/filterField.js.map +1 -0
  477. package/dist/widgets/prepareWidgetRead.d.ts +7 -0
  478. package/dist/widgets/prepareWidgetRead.js +74 -0
  479. package/dist/widgets/prepareWidgetRead.js.map +1 -0
  480. package/dist/widgets/range.js +43 -12
  481. package/dist/widgets/range.js.map +1 -1
  482. package/dist/widgets/readForWidget.d.ts +26 -3
  483. package/dist/widgets/readForWidget.js +48 -44
  484. package/dist/widgets/readForWidget.js.map +1 -1
  485. package/dist/widgets/readForWidgetBreakdown.d.ts +34 -2
  486. package/dist/widgets/readForWidgetBreakdown.js +53 -49
  487. package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
  488. package/dist/widgets/readForWidgetGoals.d.ts +67 -0
  489. package/dist/widgets/readForWidgetGoals.js +140 -0
  490. package/dist/widgets/readForWidgetGoals.js.map +1 -0
  491. package/dist/widgets/readForWidgetRealtime.d.ts +8 -0
  492. package/dist/widgets/readForWidgetRealtime.js +23 -21
  493. package/dist/widgets/readForWidgetRealtime.js.map +1 -1
  494. package/dist/widgets/readForWidgetSeries.d.ts +26 -2
  495. package/dist/widgets/readForWidgetSeries.js +78 -53
  496. package/dist/widgets/readForWidgetSeries.js.map +1 -1
  497. package/dist/widgets/readMeta.js +18 -0
  498. package/dist/widgets/readMeta.js.map +1 -0
  499. package/dist/widgets/realtimePoll.js +13 -1
  500. package/dist/widgets/realtimePoll.js.map +1 -1
  501. package/dist/widgets/registerWidgets.js +62 -10
  502. package/dist/widgets/registerWidgets.js.map +1 -1
  503. package/dist/widgets/types.d.ts +15 -0
  504. package/dist/widgets/types.js +16 -2
  505. package/dist/widgets/types.js.map +1 -1
  506. package/dist/widgets/viewLink.d.ts +22 -0
  507. package/dist/widgets/viewLink.js +86 -0
  508. package/dist/widgets/viewLink.js.map +1 -0
  509. package/package.json +28 -8
  510. package/dist/native/rollups/applyDistinctDeltas.js +0 -9
  511. package/dist/native/rollups/applyDistinctDeltas.js.map +0 -1
  512. package/dist/native/rollups/bumpRollup.js +0 -68
  513. package/dist/native/rollups/bumpRollup.js.map +0 -1
  514. package/dist/native/rollups/insertIfNew.js +0 -19
  515. package/dist/native/rollups/insertIfNew.js.map +0 -1
@@ -0,0 +1,57 @@
1
+ import { normalizeMountPath } from "../capture/mountPath.js";
2
+ //#region src/next/captureRewrites.ts
3
+ const assertNotRoot = (path) => {
4
+ if (path === "/") throw new Error("captureRewrites: mount path must not be the site root");
5
+ };
6
+ const isPrefixOrEqual = (a, b) => a === b || b.startsWith(`${a}/`);
7
+ const assertNoCollisions = (paths) => {
8
+ for (let i = 0; i < paths.length; i++) for (let j = i + 1; j < paths.length; j++) {
9
+ const a = paths[i];
10
+ const b = paths[j];
11
+ if (isPrefixOrEqual(a, b) || isPrefixOrEqual(b, a)) throw new Error(`captureRewrites: mount paths collide: '${a}' and '${b}'`);
12
+ }
13
+ };
14
+ /**
15
+ * Next.js `rewrites()` entries for every adapter's capture proxy, one mount at a time.
16
+ * Each route's `source`/`upstream` already share `path-to-regexp` param names (e.g.
17
+ * `:p*`), so no translation happens beyond prefixing `source` with the mount's
18
+ * (normalized) path; `upstream` is used verbatim as `destination`. Next always strips a
19
+ * trailing slash from the matched path before substituting it into `destination` (unlike
20
+ * the runtime proxy, which can be told to keep one via `trailingSlashes`); harmless for
21
+ * every vendor this helper supports today.
22
+ *
23
+ * An adapter without `capture`, or with no proxy routes (the native adapter, and GA4 whose
24
+ * tag is served from Google's own CDN), contributes nothing rather than throwing, so one
25
+ * broken slot never blanks the rest.
26
+ * Output preserves mount order, then each mount's declared route order.
27
+ *
28
+ * Throws for a mount path that normalizes to the site root (an unprefixed catch-all
29
+ * route would swallow the whole app) or for two mounts whose normalized paths are equal
30
+ * or nested (Next matches rewrites first-match-wins, so an earlier catch-all would
31
+ * silently shadow a later mount's routes). Distinct sibling paths that merely share a
32
+ * string prefix, e.g. `/ph` and `/phx`, are unaffected.
33
+ *
34
+ * When any mounted adapter's descriptor sets `capture.proxy.trailingSlashes`, add
35
+ * `skipTrailingSlashRedirect: true` to `next.config` (see `posthogProxyRewrites`'s
36
+ * JSDoc for why PostHog needs it).
37
+ */
38
+ const captureRewrites = (mounts) => {
39
+ const normalized = mounts.map((mount) => normalizeMountPath(mount.path));
40
+ for (const path of normalized) assertNotRoot(path);
41
+ assertNoCollisions(normalized);
42
+ const rewrites = [];
43
+ for (let i = 0; i < mounts.length; i++) {
44
+ const routes = mounts[i].adapter.capture?.proxy.routes;
45
+ if (!routes?.length) continue;
46
+ const base = normalized[i];
47
+ for (const route of routes) rewrites.push({
48
+ source: `${base}${route.source}`,
49
+ destination: route.upstream
50
+ });
51
+ }
52
+ return rewrites;
53
+ };
54
+ //#endregion
55
+ export { captureRewrites };
56
+
57
+ //# sourceMappingURL=captureRewrites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureRewrites.js","names":[],"sources":["../../src/next/captureRewrites.ts"],"sourcesContent":["import { normalizeMountPath } from '../capture/mountPath'\nimport type { AnalyticsAdapter } from '../core/contract'\n\n/** One Next.js rewrite entry (the shape `next.config` `rewrites()` returns). */\nexport interface CaptureRewrite {\n\tsource: string\n\tdestination: string\n}\n\n/** An adapter's capture proxy mounted at a base path in the consumer's Next app. */\nexport interface CaptureRewriteMount {\n\t/** Base path this adapter's proxy is mounted at, e.g. '/ph' or '/api/analytics/p/global'. */\n\tpath: string\n\tadapter: AnalyticsAdapter\n}\n\nconst assertNotRoot = (path: string): void => {\n\tif (path === '/') {\n\t\tthrow new Error('captureRewrites: mount path must not be the site root')\n\t}\n}\n\n// One base is a prefix of another when they're equal or the longer one continues past a\n// '/' boundary, so '/ph' collides with '/ph' and '/ph/x' but not the mere string-prefix\n// sibling '/phx'.\nconst isPrefixOrEqual = (a: string, b: string): boolean => a === b || b.startsWith(`${a}/`)\n\nconst assertNoCollisions = (paths: string[]): void => {\n\tfor (let i = 0; i < paths.length; i++) {\n\t\tfor (let j = i + 1; j < paths.length; j++) {\n\t\t\tconst a = paths[i] as string\n\t\t\tconst b = paths[j] as string\n\t\t\tif (isPrefixOrEqual(a, b) || isPrefixOrEqual(b, a)) {\n\t\t\t\tthrow new Error(`captureRewrites: mount paths collide: '${a}' and '${b}'`)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Next.js `rewrites()` entries for every adapter's capture proxy, one mount at a time.\n * Each route's `source`/`upstream` already share `path-to-regexp` param names (e.g.\n * `:p*`), so no translation happens beyond prefixing `source` with the mount's\n * (normalized) path; `upstream` is used verbatim as `destination`. Next always strips a\n * trailing slash from the matched path before substituting it into `destination` (unlike\n * the runtime proxy, which can be told to keep one via `trailingSlashes`); harmless for\n * every vendor this helper supports today.\n *\n * An adapter without `capture`, or with no proxy routes (the native adapter, and GA4 whose\n * tag is served from Google's own CDN), contributes nothing rather than throwing, so one\n * broken slot never blanks the rest.\n * Output preserves mount order, then each mount's declared route order.\n *\n * Throws for a mount path that normalizes to the site root (an unprefixed catch-all\n * route would swallow the whole app) or for two mounts whose normalized paths are equal\n * or nested (Next matches rewrites first-match-wins, so an earlier catch-all would\n * silently shadow a later mount's routes). Distinct sibling paths that merely share a\n * string prefix, e.g. `/ph` and `/phx`, are unaffected.\n *\n * When any mounted adapter's descriptor sets `capture.proxy.trailingSlashes`, add\n * `skipTrailingSlashRedirect: true` to `next.config` (see `posthogProxyRewrites`'s\n * JSDoc for why PostHog needs it).\n */\nexport const captureRewrites = (mounts: CaptureRewriteMount[]): CaptureRewrite[] => {\n\tconst normalized = mounts.map((mount) => normalizeMountPath(mount.path))\n\tfor (const path of normalized) {\n\t\tassertNotRoot(path)\n\t}\n\tassertNoCollisions(normalized)\n\n\tconst rewrites: CaptureRewrite[] = []\n\tfor (let i = 0; i < mounts.length; i++) {\n\t\tconst mount = mounts[i] as CaptureRewriteMount\n\t\tconst routes = mount.adapter.capture?.proxy.routes\n\t\tif (!routes?.length) {\n\t\t\tcontinue\n\t\t}\n\t\tconst base = normalized[i] as string\n\t\tfor (const route of routes) {\n\t\t\trewrites.push({ source: `${base}${route.source}`, destination: route.upstream })\n\t\t}\n\t}\n\treturn rewrites\n}\n"],"mappings":";;AAgBA,MAAM,iBAAiB,SAAuB;CAC7C,IAAI,SAAS,KACZ,MAAM,IAAI,MAAM,uDAAuD;AAEzE;AAKA,MAAM,mBAAmB,GAAW,MAAuB,MAAM,KAAK,EAAE,WAAW,GAAG,EAAE,EAAE;AAE1F,MAAM,sBAAsB,UAA0B;CACrD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KACjC,KAAK,IAAI,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EAC1C,MAAM,IAAI,MAAM;EAChB,MAAM,IAAI,MAAM;EAChB,IAAI,gBAAgB,GAAG,CAAC,KAAK,gBAAgB,GAAG,CAAC,GAChD,MAAM,IAAI,MAAM,0CAA0C,EAAE,SAAS,EAAE,EAAE;CAE3E;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,mBAAmB,WAAoD;CACnF,MAAM,aAAa,OAAO,KAAK,UAAU,mBAAmB,MAAM,IAAI,CAAC;CACvE,KAAK,MAAM,QAAQ,YAClB,cAAc,IAAI;CAEnB,mBAAmB,UAAU;CAE7B,MAAM,WAA6B,CAAC;CACpC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EAEvC,MAAM,SADQ,OAAO,GACA,QAAQ,SAAS,MAAM;EAC5C,IAAI,CAAC,QAAQ,QACZ;EAED,MAAM,OAAO,WAAW;EACxB,KAAK,MAAM,SAAS,QACnB,SAAS,KAAK;GAAE,QAAQ,GAAG,OAAO,MAAM;GAAU,aAAa,MAAM;EAAS,CAAC;CAEjF;CACA,OAAO;AACR"}
@@ -29,6 +29,11 @@ type PosthogProxyRewritesOptions = {
29
29
  * ```
30
30
  *
31
31
  * Point the snippet at it with `api_host: '/ph'` (plus `ui_host` for the region).
32
+ *
33
+ * @deprecated Use `captureRewrites` with a `posthog()` adapter instance instead: this
34
+ * helper is now a thin wrapper over it, kept only so existing `next.config` files don't
35
+ * break. `captureRewrites` also covers Plausible, Umami, and any adapter that mixes
36
+ * PostHog with another vendor across multiple mount paths.
32
37
  */
33
38
  declare const posthogProxyRewrites: (options?: PosthogProxyRewritesOptions) => PosthogProxyRewrite[];
34
39
  //#endregion
@@ -1,8 +1,6 @@
1
+ import { posthog } from "../adapters/posthog/posthog.js";
2
+ import { captureRewrites } from "./captureRewrites.js";
1
3
  //#region src/next/posthogProxyRewrites.ts
2
- const normalizePath = (path) => {
3
- const trimmed = (path.startsWith("/") ? path : `/${path}`).replace(/\/+$/, "");
4
- return trimmed === "" ? "/" : trimmed;
5
- };
6
4
  /**
7
5
  * Next.js rewrites for a first-party PostHog reverse proxy, per PostHog's own
8
6
  * guidance: static assets and the array loader route to the region's assets host,
@@ -23,26 +21,23 @@ const normalizePath = (path) => {
23
21
  * ```
24
22
  *
25
23
  * Point the snippet at it with `api_host: '/ph'` (plus `ui_host` for the region).
24
+ *
25
+ * @deprecated Use `captureRewrites` with a `posthog()` adapter instance instead: this
26
+ * helper is now a thin wrapper over it, kept only so existing `next.config` files don't
27
+ * break. `captureRewrites` also covers Plausible, Umami, and any adapter that mixes
28
+ * PostHog with another vendor across multiple mount paths.
26
29
  */
27
30
  const posthogProxyRewrites = (options = {}) => {
28
31
  const region = options.region ?? "eu";
29
- const path = normalizePath(options.path ?? "/ph");
30
- const assets = `https://${region}-assets.i.posthog.com`;
31
- const ingest = `https://${region}.i.posthog.com`;
32
- return [
33
- {
34
- source: `${path}/static/:path*`,
35
- destination: `${assets}/static/:path*`
36
- },
37
- {
38
- source: `${path}/array/:path*`,
39
- destination: `${assets}/array/:path*`
40
- },
41
- {
42
- source: `${path}/:path*`,
43
- destination: `${ingest}/:path*`
44
- }
45
- ];
32
+ return captureRewrites([{
33
+ path: options.path ?? "/ph",
34
+ adapter: posthog({
35
+ projectId: "",
36
+ apiKey: "",
37
+ region,
38
+ projectToken: "rewrites-only"
39
+ })
40
+ }]);
46
41
  };
47
42
  //#endregion
48
43
  export { posthogProxyRewrites };
@@ -1 +1 @@
1
- {"version":3,"file":"posthogProxyRewrites.js","names":[],"sources":["../../src/next/posthogProxyRewrites.ts"],"sourcesContent":["export type PosthogProxyRegion = 'eu' | 'us'\n\n/** One Next.js rewrite entry (the shape `next.config` `rewrites()` returns). */\nexport type PosthogProxyRewrite = { source: string; destination: string }\n\nexport type PosthogProxyRewritesOptions = {\n\t/** First-party base path the snippet's `api_host` points at. Default '/ph'. */\n\tpath?: string\n\t/** PostHog Cloud region. Default 'eu'. */\n\tregion?: PosthogProxyRegion\n}\n\nconst normalizePath = (path: string): string => {\n\tconst withLeading = path.startsWith('/') ? path : `/${path}`\n\tconst trimmed = withLeading.replace(/\\/+$/, '')\n\treturn trimmed === '' ? '/' : trimmed\n}\n\n/**\n * Next.js rewrites for a first-party PostHog reverse proxy, per PostHog's own\n * guidance: static assets and the array loader route to the region's assets host,\n * everything else to the ingest host. Order matters (Next evaluates rewrites in\n * order), and the app should also set `skipTrailingSlashRedirect: true` because\n * PostHog's capture endpoints use trailing slashes.\n *\n * ```ts\n * // next.config.ts\n * import { posthogProxyRewrites } from '@10x-media/analytics/next'\n *\n * const nextConfig = {\n * skipTrailingSlashRedirect: true,\n * async rewrites() {\n * return posthogProxyRewrites({ path: '/ph', region: 'eu' })\n * },\n * }\n * ```\n *\n * Point the snippet at it with `api_host: '/ph'` (plus `ui_host` for the region).\n */\nexport const posthogProxyRewrites = (\n\toptions: PosthogProxyRewritesOptions = {}\n): PosthogProxyRewrite[] => {\n\tconst region = options.region ?? 'eu'\n\tconst path = normalizePath(options.path ?? '/ph')\n\tconst assets = `https://${region}-assets.i.posthog.com`\n\tconst ingest = `https://${region}.i.posthog.com`\n\treturn [\n\t\t{ source: `${path}/static/:path*`, destination: `${assets}/static/:path*` },\n\t\t{ source: `${path}/array/:path*`, destination: `${assets}/array/:path*` },\n\t\t{ source: `${path}/:path*`, destination: `${ingest}/:path*` },\n\t]\n}\n"],"mappings":";AAYA,MAAM,iBAAiB,SAAyB;CAE/C,MAAM,WADc,KAAK,WAAW,GAAG,IAAI,OAAO,IAAI,QAC1B,QAAQ,QAAQ,EAAE;CAC9C,OAAO,YAAY,KAAK,MAAM;AAC/B;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,wBACZ,UAAuC,CAAC,MACb;CAC3B,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,OAAO,cAAc,QAAQ,QAAQ,KAAK;CAChD,MAAM,SAAS,WAAW,OAAO;CACjC,MAAM,SAAS,WAAW,OAAO;CACjC,OAAO;EACN;GAAE,QAAQ,GAAG,KAAK;GAAiB,aAAa,GAAG,OAAO;EAAgB;EAC1E;GAAE,QAAQ,GAAG,KAAK;GAAgB,aAAa,GAAG,OAAO;EAAe;EACxE;GAAE,QAAQ,GAAG,KAAK;GAAU,aAAa,GAAG,OAAO;EAAS;CAC7D;AACD"}
1
+ {"version":3,"file":"posthogProxyRewrites.js","names":[],"sources":["../../src/next/posthogProxyRewrites.ts"],"sourcesContent":["import { posthog } from '../adapters/posthog/posthog'\nimport { captureRewrites } from './captureRewrites'\n\nexport type PosthogProxyRegion = 'eu' | 'us'\n\n/** One Next.js rewrite entry (the shape `next.config` `rewrites()` returns). */\nexport type PosthogProxyRewrite = { source: string; destination: string }\n\nexport type PosthogProxyRewritesOptions = {\n\t/** First-party base path the snippet's `api_host` points at. Default '/ph'. */\n\tpath?: string\n\t/** PostHog Cloud region. Default 'eu'. */\n\tregion?: PosthogProxyRegion\n}\n\n/**\n * Next.js rewrites for a first-party PostHog reverse proxy, per PostHog's own\n * guidance: static assets and the array loader route to the region's assets host,\n * everything else to the ingest host. Order matters (Next evaluates rewrites in\n * order), and the app should also set `skipTrailingSlashRedirect: true` because\n * PostHog's capture endpoints use trailing slashes.\n *\n * ```ts\n * // next.config.ts\n * import { posthogProxyRewrites } from '@10x-media/analytics/next'\n *\n * const nextConfig = {\n * skipTrailingSlashRedirect: true,\n * async rewrites() {\n * return posthogProxyRewrites({ path: '/ph', region: 'eu' })\n * },\n * }\n * ```\n *\n * Point the snippet at it with `api_host: '/ph'` (plus `ui_host` for the region).\n *\n * @deprecated Use `captureRewrites` with a `posthog()` adapter instance instead: this\n * helper is now a thin wrapper over it, kept only so existing `next.config` files don't\n * break. `captureRewrites` also covers Plausible, Umami, and any adapter that mixes\n * PostHog with another vendor across multiple mount paths.\n */\nexport const posthogProxyRewrites = (\n\toptions: PosthogProxyRewritesOptions = {}\n): PosthogProxyRewrite[] => {\n\tconst region = options.region ?? 'eu'\n\tconst path = options.path ?? '/ph'\n\t// A token is what makes an adapter declare capture, and only the capture descriptor's\n\t// routes are read here; the placeholder never reaches a snippet or a browser.\n\tconst adapter = posthog({ projectId: '', apiKey: '', region, projectToken: 'rewrites-only' })\n\treturn captureRewrites([{ path, adapter }])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,wBACZ,UAAuC,CAAC,MACb;CAC3B,MAAM,SAAS,QAAQ,UAAU;CAKjC,OAAO,gBAAgB,CAAC;EAAE,MAJb,QAAQ,QAAQ;EAIG,SADhB,QAAQ;GAAE,WAAW;GAAI,QAAQ;GAAI;GAAQ,cAAc;EAAgB,CACrD;CAAE,CAAC,CAAC;AAC3C"}
@@ -1,8 +1,11 @@
1
- import { getRuntime } from "./runtime.js";
1
+ import "./paths.js";
2
+ import { getRuntime, readAccessFor, requestTimezone } from "./runtime.js";
2
3
  import { TIMEFRAME_PRESETS } from "../timeframe/presets.js";
3
- import { readForField } from "../fields/readForDocument.js";
4
4
  import { METRIC_KEYS } from "../translations/metricKeys.js";
5
- import "./paths.js";
5
+ import { NO_STORE, RETRY_AFTER, analyticsError, errorResponse } from "./errors.js";
6
+ import { readForField } from "../fields/readForDocument.js";
7
+ import { parseDayOrInstant } from "../query/dates.js";
8
+ import { APIError } from "payload";
6
9
  //#region src/plugin/documentEndpoint.ts
7
10
  const KNOWN_METRICS = new Set(Object.keys(METRIC_KEYS));
8
11
  const MAX_METRICS = 8;
@@ -11,36 +14,77 @@ const parseMetrics = (raw) => {
11
14
  const metrics = raw.split(",").map((m) => m.trim()).filter((m) => KNOWN_METRICS.has(m));
12
15
  return metrics.length > 0 ? metrics.slice(0, MAX_METRICS) : null;
13
16
  };
14
- const parseRange = (from, to) => {
15
- if (!from || !to) return null;
16
- const start = new Date(from);
17
- const end = new Date(to);
18
- if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime()) || start >= end) return null;
17
+ /**
18
+ * A custom window from the query string, read exactly like the query endpoint's: a
19
+ * `YYYY-MM-DD` day is the whole calendar day in the reporting timezone (`to` inclusive of
20
+ * its final instant), a datetime must carry `Z` or a `±HH:MM` offset, and anything else,
21
+ * including an offset-less datetime, is rejected. `from` equal to `to` is one whole day for
22
+ * day strings and a zero-width window for two instants, so only the latter is rejected. A
23
+ * rejection names the bound at fault, and an inverted window blames `to`: `from` is the one
24
+ * the reader picked first.
25
+ */
26
+ const parseRange = (from, to, timezone) => {
27
+ if (!from) return {
28
+ ok: false,
29
+ param: "from"
30
+ };
31
+ if (!to) return {
32
+ ok: false,
33
+ param: "to"
34
+ };
35
+ const start = parseDayOrInstant(from, {
36
+ timezone,
37
+ edge: "start"
38
+ });
39
+ if (!start) return {
40
+ ok: false,
41
+ param: "from"
42
+ };
43
+ const end = parseDayOrInstant(to, {
44
+ timezone,
45
+ edge: "end"
46
+ });
47
+ if (!end || end.getTime() <= start.getTime()) return {
48
+ ok: false,
49
+ param: "to"
50
+ };
19
51
  return {
20
- start,
21
- end
52
+ ok: true,
53
+ range: {
54
+ start,
55
+ end
56
+ }
22
57
  };
23
58
  };
24
59
  /**
25
- * Authenticated GET handler behind the interactive document analytics panel. The
26
- * caller must be able to read the target document (enforced through `findByID`
60
+ * Authenticated GET handler behind the interactive document analytics panel, gated
61
+ * by `access.read` like every other read endpoint. The caller must also be able to
62
+ * read the target document (enforced through `findByID`
27
63
  * without `overrideAccess`), so analytics never leak for content the user cannot
28
- * see; an unreadable or missing document is a uniform 404. Timeframe, metrics, and
29
- * data source are whitelist-validated; `timeframe=custom` requires a parseable
30
- * `from`/`to` pair.
64
+ * see; an unreadable or missing document is a uniform 404, while a read that fails for
65
+ * any other reason is a logged 500 rather than a 404 that hides a broken install.
66
+ * Timeframe, metrics, and data source are whitelist-validated; `timeframe=custom`
67
+ * requires a parseable `from`/`to` pair.
31
68
  */
32
69
  const makeDocumentHandler = () => async (req) => {
33
- if (!req.user) return Response.json({ error: "unauthorized" }, { status: 401 });
70
+ if (!req.user) return errorResponse(401, analyticsError("unauthorized", "analytics: authentication required"));
34
71
  const runtime = getRuntime(req.payload);
35
- if (!runtime) return Response.json({ error: "unavailable" }, { status: 503 });
72
+ if (!runtime) return errorResponse(503, analyticsError("unavailable", "analytics: not available"), RETRY_AFTER);
73
+ if (!await readAccessFor(runtime, req)) return errorResponse(403, analyticsError("forbidden", "analytics: read access denied"));
36
74
  const params = new URL(req.url ?? "", "http://localhost").searchParams;
37
75
  const collection = params.get("collection") ?? "";
38
76
  const id = params.get("id") ?? "";
39
- if (!runtime.bindings[collection] || !id) return Response.json({ error: "not found" }, { status: 404 });
77
+ if (!runtime.bindings[collection] || !id) return errorResponse(404, analyticsError("not_found", "analytics: no such document"));
40
78
  const rawTimeframe = params.get("timeframe") ?? "last30days";
41
- const range = rawTimeframe === "custom" ? parseRange(params.get("from"), params.get("to")) : void 0;
79
+ let timezone;
80
+ let range;
81
+ if (rawTimeframe === "custom") {
82
+ timezone = await requestTimezone(req);
83
+ const parsed = parseRange(params.get("from"), params.get("to"), timezone);
84
+ if (!parsed.ok) return errorResponse(400, analyticsError("invalid_param", "analytics: the custom range could not be read", parsed.param));
85
+ range = parsed.range;
86
+ }
42
87
  const timeframe = TIMEFRAME_PRESETS.includes(rawTimeframe) ? rawTimeframe : "last30days";
43
- if (rawTimeframe === "custom" && !range) return Response.json({ error: "invalid range" }, { status: 400 });
44
88
  const metrics = parseMetrics(params.get("metrics")) ?? [
45
89
  "pageviews",
46
90
  "visitors",
@@ -57,8 +101,10 @@ const makeDocumentHandler = () => async (req) => {
57
101
  user: req.user,
58
102
  req
59
103
  });
60
- } catch {
61
- return Response.json({ error: "not found" }, { status: 404 });
104
+ } catch (err) {
105
+ if (err instanceof APIError && (err.status === 404 || err.status === 403)) return errorResponse(404, analyticsError("not_found", "analytics: no such document"));
106
+ req.payload.logger?.error(`analytics: document read failed for "${collection}": ${String(err)}`);
107
+ return errorResponse(500, analyticsError("internal", "analytics: document read failed"));
62
108
  }
63
109
  const result = await readForField({
64
110
  req,
@@ -66,13 +112,14 @@ const makeDocumentHandler = () => async (req) => {
66
112
  data,
67
113
  metrics,
68
114
  timeframe,
69
- range: range ?? void 0,
115
+ range,
116
+ ...timezone !== void 0 ? { timezone } : {},
70
117
  adapterId: params.get("dataSource") ?? void 0,
71
118
  now: /* @__PURE__ */ new Date(),
72
119
  compare: params.get("compare") === "1",
73
120
  series: params.get("series") === "1"
74
121
  });
75
- return Response.json(result);
122
+ return Response.json(result, { headers: NO_STORE });
76
123
  };
77
124
  //#endregion
78
125
  export { makeDocumentHandler };
@@ -1 +1 @@
1
- {"version":3,"file":"documentEndpoint.js","names":[],"sources":["../../src/plugin/documentEndpoint.ts"],"sourcesContent":["import type { CollectionSlug, PayloadHandler } from 'payload'\nimport type { BindingDoc } from '../binding/types'\nimport type { DateRange, MetricKey } from '../core/contract'\nimport { readForField } from '../fields/readForDocument'\nimport { TIMEFRAME_PRESETS, type TimeframePreset } from '../timeframe/presets'\nimport { METRIC_KEYS } from '../translations/metricKeys'\nimport { DOCUMENT_PATH } from './paths'\nimport { getRuntime } from './runtime'\n\nexport { DOCUMENT_PATH }\n\nconst KNOWN_METRICS = new Set(Object.keys(METRIC_KEYS) as MetricKey[])\nconst MAX_METRICS = 8\n\nconst parseMetrics = (raw: string | null): MetricKey[] | null => {\n\tif (!raw) {\n\t\treturn null\n\t}\n\tconst metrics = raw\n\t\t.split(',')\n\t\t.map((m) => m.trim())\n\t\t.filter((m): m is MetricKey => KNOWN_METRICS.has(m as MetricKey))\n\treturn metrics.length > 0 ? metrics.slice(0, MAX_METRICS) : null\n}\n\nconst parseRange = (from: string | null, to: string | null): DateRange | null => {\n\tif (!from || !to) {\n\t\treturn null\n\t}\n\tconst start = new Date(from)\n\tconst end = new Date(to)\n\tif (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime()) || start >= end) {\n\t\treturn null\n\t}\n\treturn { start, end }\n}\n\n/**\n * Authenticated GET handler behind the interactive document analytics panel. The\n * caller must be able to read the target document (enforced through `findByID`\n * without `overrideAccess`), so analytics never leak for content the user cannot\n * see; an unreadable or missing document is a uniform 404. Timeframe, metrics, and\n * data source are whitelist-validated; `timeframe=custom` requires a parseable\n * `from`/`to` pair.\n */\nexport const makeDocumentHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn Response.json({ error: 'unauthorized' }, { status: 401 })\n\t}\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn Response.json({ error: 'unavailable' }, { status: 503 })\n\t}\n\tconst params = new URL(req.url ?? '', 'http://localhost').searchParams\n\tconst collection = params.get('collection') ?? ''\n\tconst id = params.get('id') ?? ''\n\tif (!runtime.bindings[collection] || !id) {\n\t\treturn Response.json({ error: 'not found' }, { status: 404 })\n\t}\n\tconst rawTimeframe = params.get('timeframe') ?? 'last30days'\n\tconst range =\n\t\trawTimeframe === 'custom' ? parseRange(params.get('from'), params.get('to')) : undefined\n\tconst timeframe: TimeframePreset = TIMEFRAME_PRESETS.includes(rawTimeframe as TimeframePreset)\n\t\t? (rawTimeframe as TimeframePreset)\n\t\t: 'last30days'\n\tif (rawTimeframe === 'custom' && !range) {\n\t\treturn Response.json({ error: 'invalid range' }, { status: 400 })\n\t}\n\tconst metrics = parseMetrics(params.get('metrics')) ?? [\n\t\t'pageviews',\n\t\t'visitors',\n\t\t'sessions',\n\t\t'avgDuration',\n\t]\n\tlet data: BindingDoc\n\ttry {\n\t\tdata = (await req.payload.findByID({\n\t\t\tcollection: collection as CollectionSlug,\n\t\t\tid,\n\t\t\tdepth: 0,\n\t\t\toverrideAccess: false,\n\t\t\tuser: req.user,\n\t\t\treq,\n\t\t})) as BindingDoc\n\t} catch {\n\t\treturn Response.json({ error: 'not found' }, { status: 404 })\n\t}\n\tconst result = await readForField({\n\t\treq,\n\t\tcollectionSlug: collection,\n\t\tdata,\n\t\tmetrics,\n\t\ttimeframe,\n\t\trange: range ?? undefined,\n\t\tadapterId: params.get('dataSource') ?? undefined,\n\t\tnow: new Date(),\n\t\tcompare: params.get('compare') === '1',\n\t\tseries: params.get('series') === '1',\n\t})\n\treturn Response.json(result)\n}\n"],"mappings":";;;;;;AAWA,MAAM,gBAAgB,IAAI,IAAI,OAAO,KAAK,WAAW,CAAgB;AACrE,MAAM,cAAc;AAEpB,MAAM,gBAAgB,QAA2C;CAChE,IAAI,CAAC,KACJ,OAAO;CAER,MAAM,UAAU,IACd,MAAM,GAAG,EACT,KAAK,MAAM,EAAE,KAAK,CAAC,EACnB,QAAQ,MAAsB,cAAc,IAAI,CAAc,CAAC;CACjE,OAAO,QAAQ,SAAS,IAAI,QAAQ,MAAM,GAAG,WAAW,IAAI;AAC7D;AAEA,MAAM,cAAc,MAAqB,OAAwC;CAChF,IAAI,CAAC,QAAQ,CAAC,IACb,OAAO;CAER,MAAM,QAAQ,IAAI,KAAK,IAAI;CAC3B,MAAM,MAAM,IAAI,KAAK,EAAE;CACvB,IAAI,OAAO,MAAM,MAAM,QAAQ,CAAC,KAAK,OAAO,MAAM,IAAI,QAAQ,CAAC,KAAK,SAAS,KAC5E,OAAO;CAER,OAAO;EAAE;EAAO;CAAI;AACrB;;;;;;;;;AAUA,MAAa,4BAA4C,OAAO,QAAQ;CACvE,IAAI,CAAC,IAAI,MACR,OAAO,SAAS,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEhE,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAO,SAAS,KAAK,EAAE,OAAO,cAAc,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE/D,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,kBAAkB,EAAE;CAC1D,MAAM,aAAa,OAAO,IAAI,YAAY,KAAK;CAC/C,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK;CAC/B,IAAI,CAAC,QAAQ,SAAS,eAAe,CAAC,IACrC,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE7D,MAAM,eAAe,OAAO,IAAI,WAAW,KAAK;CAChD,MAAM,QACL,iBAAiB,WAAW,WAAW,OAAO,IAAI,MAAM,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,KAAA;CAChF,MAAM,YAA6B,kBAAkB,SAAS,YAA+B,IACzF,eACD;CACH,IAAI,iBAAiB,YAAY,CAAC,OACjC,OAAO,SAAS,KAAK,EAAE,OAAO,gBAAgB,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEjE,MAAM,UAAU,aAAa,OAAO,IAAI,SAAS,CAAC,KAAK;EACtD;EACA;EACA;EACA;CACD;CACA,IAAI;CACJ,IAAI;EACH,OAAQ,MAAM,IAAI,QAAQ,SAAS;GACtB;GACZ;GACA,OAAO;GACP,gBAAgB;GAChB,MAAM,IAAI;GACV;EACD,CAAC;CACF,QAAQ;EACP,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAC7D;CACA,MAAM,SAAS,MAAM,aAAa;EACjC;EACA,gBAAgB;EAChB;EACA;EACA;EACA,OAAO,SAAS,KAAA;EAChB,WAAW,OAAO,IAAI,YAAY,KAAK,KAAA;EACvC,qBAAK,IAAI,KAAK;EACd,SAAS,OAAO,IAAI,SAAS,MAAM;EACnC,QAAQ,OAAO,IAAI,QAAQ,MAAM;CAClC,CAAC;CACD,OAAO,SAAS,KAAK,MAAM;AAC5B"}
1
+ {"version":3,"file":"documentEndpoint.js","names":[],"sources":["../../src/plugin/documentEndpoint.ts"],"sourcesContent":["import { APIError, type CollectionSlug, type PayloadHandler } from 'payload'\nimport type { BindingDoc } from '../binding/types'\nimport type { DateRange, MetricKey } from '../core/contract'\nimport { readForField } from '../fields/readForDocument'\nimport { parseDayOrInstant } from '../query/dates'\nimport { TIMEFRAME_PRESETS, type TimeframePreset } from '../timeframe/presets'\nimport { METRIC_KEYS } from '../translations/metricKeys'\nimport { analyticsError, errorResponse, NO_STORE, RETRY_AFTER } from './errors'\nimport { DOCUMENT_PATH } from './paths'\nimport { getRuntime, readAccessFor, requestTimezone } from './runtime'\n\nexport { DOCUMENT_PATH }\n\nconst KNOWN_METRICS = new Set(Object.keys(METRIC_KEYS) as MetricKey[])\nconst MAX_METRICS = 8\n\nconst parseMetrics = (raw: string | null): MetricKey[] | null => {\n\tif (!raw) {\n\t\treturn null\n\t}\n\tconst metrics = raw\n\t\t.split(',')\n\t\t.map((m) => m.trim())\n\t\t.filter((m): m is MetricKey => KNOWN_METRICS.has(m as MetricKey))\n\treturn metrics.length > 0 ? metrics.slice(0, MAX_METRICS) : null\n}\n\ntype RangeResult = { ok: true; range: DateRange } | { ok: false; param: 'from' | 'to' }\n\n/**\n * A custom window from the query string, read exactly like the query endpoint's: a\n * `YYYY-MM-DD` day is the whole calendar day in the reporting timezone (`to` inclusive of\n * its final instant), a datetime must carry `Z` or a `±HH:MM` offset, and anything else,\n * including an offset-less datetime, is rejected. `from` equal to `to` is one whole day for\n * day strings and a zero-width window for two instants, so only the latter is rejected. A\n * rejection names the bound at fault, and an inverted window blames `to`: `from` is the one\n * the reader picked first.\n */\nconst parseRange = (from: string | null, to: string | null, timezone: string): RangeResult => {\n\tif (!from) {\n\t\treturn { ok: false, param: 'from' }\n\t}\n\tif (!to) {\n\t\treturn { ok: false, param: 'to' }\n\t}\n\tconst start = parseDayOrInstant(from, { timezone, edge: 'start' })\n\tif (!start) {\n\t\treturn { ok: false, param: 'from' }\n\t}\n\tconst end = parseDayOrInstant(to, { timezone, edge: 'end' })\n\tif (!end || end.getTime() <= start.getTime()) {\n\t\treturn { ok: false, param: 'to' }\n\t}\n\treturn { ok: true, range: { start, end } }\n}\n\n/**\n * Authenticated GET handler behind the interactive document analytics panel, gated\n * by `access.read` like every other read endpoint. The caller must also be able to\n * read the target document (enforced through `findByID`\n * without `overrideAccess`), so analytics never leak for content the user cannot\n * see; an unreadable or missing document is a uniform 404, while a read that fails for\n * any other reason is a logged 500 rather than a 404 that hides a broken install.\n * Timeframe, metrics, and data source are whitelist-validated; `timeframe=custom`\n * requires a parseable `from`/`to` pair.\n */\nexport const makeDocumentHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn errorResponse(401, analyticsError('unauthorized', 'analytics: authentication required'))\n\t}\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn errorResponse(\n\t\t\t503,\n\t\t\tanalyticsError('unavailable', 'analytics: not available'),\n\t\t\tRETRY_AFTER\n\t\t)\n\t}\n\tif (!(await readAccessFor(runtime, req))) {\n\t\treturn errorResponse(403, analyticsError('forbidden', 'analytics: read access denied'))\n\t}\n\tconst params = new URL(req.url ?? '', 'http://localhost').searchParams\n\tconst collection = params.get('collection') ?? ''\n\tconst id = params.get('id') ?? ''\n\tif (!runtime.bindings[collection] || !id) {\n\t\treturn errorResponse(404, analyticsError('not_found', 'analytics: no such document'))\n\t}\n\tconst rawTimeframe = params.get('timeframe') ?? 'last30days'\n\tlet timezone: string | undefined\n\tlet range: DateRange | undefined\n\tif (rawTimeframe === 'custom') {\n\t\t// Custom bounds name calendar days, so the reporting timezone has to be resolved before\n\t\t// they can be read; a preset resolves its window inside `readForField` as before.\n\t\ttimezone = await requestTimezone(req)\n\t\tconst parsed = parseRange(params.get('from'), params.get('to'), timezone)\n\t\tif (!parsed.ok) {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\tanalyticsError(\n\t\t\t\t\t'invalid_param',\n\t\t\t\t\t'analytics: the custom range could not be read',\n\t\t\t\t\tparsed.param\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\t\trange = parsed.range\n\t}\n\tconst timeframe: TimeframePreset = TIMEFRAME_PRESETS.includes(rawTimeframe as TimeframePreset)\n\t\t? (rawTimeframe as TimeframePreset)\n\t\t: 'last30days'\n\tconst metrics = parseMetrics(params.get('metrics')) ?? [\n\t\t'pageviews',\n\t\t'visitors',\n\t\t'sessions',\n\t\t'avgDuration',\n\t]\n\tlet data: BindingDoc\n\ttry {\n\t\tdata = (await req.payload.findByID({\n\t\t\tcollection: collection as CollectionSlug,\n\t\t\tid,\n\t\t\tdepth: 0,\n\t\t\toverrideAccess: false,\n\t\t\tuser: req.user,\n\t\t\treq,\n\t\t})) as BindingDoc\n\t} catch (err) {\n\t\t// `findByID` raises a `NotFound` for a missing row and a `Forbidden` for one this\n\t\t// caller may not read; both stay a uniform 404 so analytics never confirm a document\n\t\t// exists. Anything else is this install failing rather than the request being wrong.\n\t\tif (err instanceof APIError && (err.status === 404 || err.status === 403)) {\n\t\t\treturn errorResponse(404, analyticsError('not_found', 'analytics: no such document'))\n\t\t}\n\t\treq.payload.logger?.error(`analytics: document read failed for \"${collection}\": ${String(err)}`)\n\t\treturn errorResponse(500, analyticsError('internal', 'analytics: document read failed'))\n\t}\n\tconst result = await readForField({\n\t\treq,\n\t\tcollectionSlug: collection,\n\t\tdata,\n\t\tmetrics,\n\t\ttimeframe,\n\t\trange,\n\t\t...(timezone !== undefined ? { timezone } : {}),\n\t\tadapterId: params.get('dataSource') ?? undefined,\n\t\tnow: new Date(),\n\t\tcompare: params.get('compare') === '1',\n\t\tseries: params.get('series') === '1',\n\t})\n\treturn Response.json(result, { headers: NO_STORE })\n}\n"],"mappings":";;;;;;;;;AAaA,MAAM,gBAAgB,IAAI,IAAI,OAAO,KAAK,WAAW,CAAgB;AACrE,MAAM,cAAc;AAEpB,MAAM,gBAAgB,QAA2C;CAChE,IAAI,CAAC,KACJ,OAAO;CAER,MAAM,UAAU,IACd,MAAM,GAAG,EACT,KAAK,MAAM,EAAE,KAAK,CAAC,EACnB,QAAQ,MAAsB,cAAc,IAAI,CAAc,CAAC;CACjE,OAAO,QAAQ,SAAS,IAAI,QAAQ,MAAM,GAAG,WAAW,IAAI;AAC7D;;;;;;;;;;AAaA,MAAM,cAAc,MAAqB,IAAmB,aAAkC;CAC7F,IAAI,CAAC,MACJ,OAAO;EAAE,IAAI;EAAO,OAAO;CAAO;CAEnC,IAAI,CAAC,IACJ,OAAO;EAAE,IAAI;EAAO,OAAO;CAAK;CAEjC,MAAM,QAAQ,kBAAkB,MAAM;EAAE;EAAU,MAAM;CAAQ,CAAC;CACjE,IAAI,CAAC,OACJ,OAAO;EAAE,IAAI;EAAO,OAAO;CAAO;CAEnC,MAAM,MAAM,kBAAkB,IAAI;EAAE;EAAU,MAAM;CAAM,CAAC;CAC3D,IAAI,CAAC,OAAO,IAAI,QAAQ,KAAK,MAAM,QAAQ,GAC1C,OAAO;EAAE,IAAI;EAAO,OAAO;CAAK;CAEjC,OAAO;EAAE,IAAI;EAAM,OAAO;GAAE;GAAO;EAAI;CAAE;AAC1C;;;;;;;;;;;AAYA,MAAa,4BAA4C,OAAO,QAAQ;CACvE,IAAI,CAAC,IAAI,MACR,OAAO,cAAc,KAAK,eAAe,gBAAgB,oCAAoC,CAAC;CAE/F,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAO,cACN,KACA,eAAe,eAAe,0BAA0B,GACxD,WACD;CAED,IAAI,CAAE,MAAM,cAAc,SAAS,GAAG,GACrC,OAAO,cAAc,KAAK,eAAe,aAAa,+BAA+B,CAAC;CAEvF,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,kBAAkB,EAAE;CAC1D,MAAM,aAAa,OAAO,IAAI,YAAY,KAAK;CAC/C,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK;CAC/B,IAAI,CAAC,QAAQ,SAAS,eAAe,CAAC,IACrC,OAAO,cAAc,KAAK,eAAe,aAAa,6BAA6B,CAAC;CAErF,MAAM,eAAe,OAAO,IAAI,WAAW,KAAK;CAChD,IAAI;CACJ,IAAI;CACJ,IAAI,iBAAiB,UAAU;EAG9B,WAAW,MAAM,gBAAgB,GAAG;EACpC,MAAM,SAAS,WAAW,OAAO,IAAI,MAAM,GAAG,OAAO,IAAI,IAAI,GAAG,QAAQ;EACxE,IAAI,CAAC,OAAO,IACX,OAAO,cACN,KACA,eACC,iBACA,iDACA,OAAO,KACR,CACD;EAED,QAAQ,OAAO;CAChB;CACA,MAAM,YAA6B,kBAAkB,SAAS,YAA+B,IACzF,eACD;CACH,MAAM,UAAU,aAAa,OAAO,IAAI,SAAS,CAAC,KAAK;EACtD;EACA;EACA;EACA;CACD;CACA,IAAI;CACJ,IAAI;EACH,OAAQ,MAAM,IAAI,QAAQ,SAAS;GACtB;GACZ;GACA,OAAO;GACP,gBAAgB;GAChB,MAAM,IAAI;GACV;EACD,CAAC;CACF,SAAS,KAAK;EAIb,IAAI,eAAe,aAAa,IAAI,WAAW,OAAO,IAAI,WAAW,MACpE,OAAO,cAAc,KAAK,eAAe,aAAa,6BAA6B,CAAC;EAErF,IAAI,QAAQ,QAAQ,MAAM,wCAAwC,WAAW,KAAK,OAAO,GAAG,GAAG;EAC/F,OAAO,cAAc,KAAK,eAAe,YAAY,iCAAiC,CAAC;CACxF;CACA,MAAM,SAAS,MAAM,aAAa;EACjC;EACA,gBAAgB;EAChB;EACA;EACA;EACA;EACA,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC7C,WAAW,OAAO,IAAI,YAAY,KAAK,KAAA;EACvC,qBAAK,IAAI,KAAK;EACd,SAAS,OAAO,IAAI,SAAS,MAAM;EACnC,QAAQ,OAAO,IAAI,QAAQ,MAAM;CAClC,CAAC;CACD,OAAO,SAAS,KAAK,QAAQ,EAAE,SAAS,SAAS,CAAC;AACnD"}
@@ -0,0 +1,31 @@
1
+ //#region src/plugin/errors.d.ts
2
+ /**
3
+ * Every code any analytics endpoint answers with, in one place so a handler cannot invent
4
+ * a word only its own client knows. Kept free of Payload and Node imports: admin clients
5
+ * import {@link readErrorCode} from here to branch on what an endpoint said.
6
+ *
7
+ * `invalid_param` and the `unsupported_*` family are the query parser's `400`s;
8
+ * `unauthorized` (`401`), `forbidden` (`403`), `not_found` (`404`), `unknown_source`
9
+ * (`404`), `untrusted_scope` (`400`), `payload_too_large` (`413`), `unavailable` (`503`)
10
+ * and `internal` (`500`) are raised by the handlers themselves.
11
+ */
12
+ declare const ANALYTICS_ERROR_CODES: readonly ["invalid_param", "unsupported_metric", "unsupported_dimension", "unsupported_filter", "unsupported_operator", "unsupported_granularity", "range_too_long", "unknown_source", "untrusted_scope", "not_found", "payload_too_large", "unauthorized", "forbidden", "unavailable", "internal"];
13
+ type AnalyticsErrorCode = (typeof ANALYTICS_ERROR_CODES)[number];
14
+ /** Wire shape of a refused request: `param` names the parameter or field at fault. */
15
+ interface AnalyticsError {
16
+ code: AnalyticsErrorCode;
17
+ message: string;
18
+ param?: string;
19
+ }
20
+ declare const analyticsError: (code: AnalyticsErrorCode, message: string, param?: string) => AnalyticsError;
21
+ /** The code an endpoint answered with, or undefined when the body is not the envelope. */
22
+ declare const readErrorCode: (body: unknown) => AnalyticsErrorCode | undefined;
23
+ /**
24
+ * {@link readError} over a response whose body has yet to be read. A body that is not JSON
25
+ * at all, including an empty one, reads as no error rather than throwing: the status still
26
+ * carries the failure.
27
+ */
28
+ declare const readResponseError: (res: Response) => Promise<AnalyticsError | undefined>;
29
+ //#endregion
30
+ export { ANALYTICS_ERROR_CODES, AnalyticsError, AnalyticsErrorCode, analyticsError, readErrorCode, readResponseError };
31
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,79 @@
1
+ //#region src/plugin/errors.ts
2
+ /**
3
+ * Every code any analytics endpoint answers with, in one place so a handler cannot invent
4
+ * a word only its own client knows. Kept free of Payload and Node imports: admin clients
5
+ * import {@link readErrorCode} from here to branch on what an endpoint said.
6
+ *
7
+ * `invalid_param` and the `unsupported_*` family are the query parser's `400`s;
8
+ * `unauthorized` (`401`), `forbidden` (`403`), `not_found` (`404`), `unknown_source`
9
+ * (`404`), `untrusted_scope` (`400`), `payload_too_large` (`413`), `unavailable` (`503`)
10
+ * and `internal` (`500`) are raised by the handlers themselves.
11
+ */
12
+ const ANALYTICS_ERROR_CODES = [
13
+ "invalid_param",
14
+ "unsupported_metric",
15
+ "unsupported_dimension",
16
+ "unsupported_filter",
17
+ "unsupported_operator",
18
+ "unsupported_granularity",
19
+ "range_too_long",
20
+ "unknown_source",
21
+ "untrusted_scope",
22
+ "not_found",
23
+ "payload_too_large",
24
+ "unauthorized",
25
+ "forbidden",
26
+ "unavailable",
27
+ "internal"
28
+ ];
29
+ const analyticsError = (code, message, param) => ({
30
+ code,
31
+ message,
32
+ ...param === void 0 ? {} : { param }
33
+ });
34
+ /** Scope depends on the caller's cookies, so no shared cache may ever hold an answer. */
35
+ const NO_STORE = { "Cache-Control": "private, no-store" };
36
+ /** How long a client should wait out a provider outage before retrying the same read. */
37
+ const RETRY_AFTER = { "Retry-After": "30" };
38
+ /** An endpoint's error answer: coded body, never cached, headers merged over `NO_STORE`. */
39
+ const errorResponse = (status, error, headers = {}) => Response.json({ error }, {
40
+ status,
41
+ headers: {
42
+ ...NO_STORE,
43
+ ...headers
44
+ }
45
+ });
46
+ const CODES = new Set(ANALYTICS_ERROR_CODES);
47
+ const isRecord = (value) => typeof value === "object" && value !== null;
48
+ const isErrorCode = (value) => CODES.has(value);
49
+ /**
50
+ * The error out of a parsed response body, or undefined for anything this version cannot
51
+ * read: a body that is not the envelope, and a code no release of this package ever sent.
52
+ * A code added by a newer server therefore reads as a generic failure rather than as a lie.
53
+ */
54
+ const readError = (body) => {
55
+ if (!isRecord(body)) return;
56
+ const error = body.error;
57
+ if (!isRecord(error)) return;
58
+ const { code, message, param } = error;
59
+ if (typeof code !== "string" || !isErrorCode(code) || typeof message !== "string") return;
60
+ return analyticsError(code, message, typeof param === "string" ? param : void 0);
61
+ };
62
+ /** The code an endpoint answered with, or undefined when the body is not the envelope. */
63
+ const readErrorCode = (body) => readError(body)?.code;
64
+ /**
65
+ * {@link readError} over a response whose body has yet to be read. A body that is not JSON
66
+ * at all, including an empty one, reads as no error rather than throwing: the status still
67
+ * carries the failure.
68
+ */
69
+ const readResponseError = async (res) => {
70
+ try {
71
+ return readError(await res.json());
72
+ } catch {
73
+ return;
74
+ }
75
+ };
76
+ //#endregion
77
+ export { ANALYTICS_ERROR_CODES, NO_STORE, RETRY_AFTER, analyticsError, errorResponse, readErrorCode, readResponseError };
78
+
79
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/plugin/errors.ts"],"sourcesContent":["/**\n * Every code any analytics endpoint answers with, in one place so a handler cannot invent\n * a word only its own client knows. Kept free of Payload and Node imports: admin clients\n * import {@link readErrorCode} from here to branch on what an endpoint said.\n *\n * `invalid_param` and the `unsupported_*` family are the query parser's `400`s;\n * `unauthorized` (`401`), `forbidden` (`403`), `not_found` (`404`), `unknown_source`\n * (`404`), `untrusted_scope` (`400`), `payload_too_large` (`413`), `unavailable` (`503`)\n * and `internal` (`500`) are raised by the handlers themselves.\n */\nexport const ANALYTICS_ERROR_CODES = [\n\t'invalid_param',\n\t'unsupported_metric',\n\t'unsupported_dimension',\n\t'unsupported_filter',\n\t'unsupported_operator',\n\t'unsupported_granularity',\n\t'range_too_long',\n\t'unknown_source',\n\t'untrusted_scope',\n\t'not_found',\n\t'payload_too_large',\n\t'unauthorized',\n\t'forbidden',\n\t'unavailable',\n\t'internal',\n] as const\n\nexport type AnalyticsErrorCode = (typeof ANALYTICS_ERROR_CODES)[number]\n\n/** Wire shape of a refused request: `param` names the parameter or field at fault. */\nexport interface AnalyticsError {\n\tcode: AnalyticsErrorCode\n\tmessage: string\n\tparam?: string\n}\n\nexport const analyticsError = (\n\tcode: AnalyticsErrorCode,\n\tmessage: string,\n\tparam?: string\n): AnalyticsError => ({\n\tcode,\n\tmessage,\n\t...(param === undefined ? {} : { param }),\n})\n\n/** Scope depends on the caller's cookies, so no shared cache may ever hold an answer. */\nexport const NO_STORE = { 'Cache-Control': 'private, no-store' }\n\n/** How long a client should wait out a provider outage before retrying the same read. */\nexport const RETRY_AFTER = { 'Retry-After': '30' }\n\n/** An endpoint's error answer: coded body, never cached, headers merged over `NO_STORE`. */\nexport const errorResponse = (\n\tstatus: number,\n\terror: AnalyticsError,\n\theaders: Record<string, string> = {}\n): Response => Response.json({ error }, { status, headers: { ...NO_STORE, ...headers } })\n\nconst CODES: ReadonlySet<string> = new Set<AnalyticsErrorCode>(ANALYTICS_ERROR_CODES)\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null\n\nconst isErrorCode = (value: string): value is AnalyticsErrorCode => CODES.has(value)\n\n/**\n * The error out of a parsed response body, or undefined for anything this version cannot\n * read: a body that is not the envelope, and a code no release of this package ever sent.\n * A code added by a newer server therefore reads as a generic failure rather than as a lie.\n */\nexport const readError = (body: unknown): AnalyticsError | undefined => {\n\tif (!isRecord(body)) {\n\t\treturn undefined\n\t}\n\tconst error: unknown = body.error\n\tif (!isRecord(error)) {\n\t\treturn undefined\n\t}\n\tconst { code, message, param } = error\n\tif (typeof code !== 'string' || !isErrorCode(code) || typeof message !== 'string') {\n\t\treturn undefined\n\t}\n\treturn analyticsError(code, message, typeof param === 'string' ? param : undefined)\n}\n\n/** The code an endpoint answered with, or undefined when the body is not the envelope. */\nexport const readErrorCode = (body: unknown): AnalyticsErrorCode | undefined =>\n\treadError(body)?.code\n\n/**\n * {@link readError} over a response whose body has yet to be read. A body that is not JSON\n * at all, including an empty one, reads as no error rather than throwing: the status still\n * carries the failure.\n */\nexport const readResponseError = async (res: Response): Promise<AnalyticsError | undefined> => {\n\ttry {\n\t\treturn readError(await res.json())\n\t} catch {\n\t\treturn undefined\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,wBAAwB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAWA,MAAa,kBACZ,MACA,SACA,WACqB;CACrB;CACA;CACA,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;AACxC;;AAGA,MAAa,WAAW,EAAE,iBAAiB,oBAAoB;;AAG/D,MAAa,cAAc,EAAE,eAAe,KAAK;;AAGjD,MAAa,iBACZ,QACA,OACA,UAAkC,CAAC,MACrB,SAAS,KAAK,EAAE,MAAM,GAAG;CAAE;CAAQ,SAAS;EAAE,GAAG;EAAU,GAAG;CAAQ;AAAE,CAAC;AAExF,MAAM,QAA6B,IAAI,IAAwB,qBAAqB;AAEpF,MAAM,YAAY,UACjB,OAAO,UAAU,YAAY,UAAU;AAExC,MAAM,eAAe,UAA+C,MAAM,IAAI,KAAK;;;;;;AAOnF,MAAa,aAAa,SAA8C;CACvE,IAAI,CAAC,SAAS,IAAI,GACjB;CAED,MAAM,QAAiB,KAAK;CAC5B,IAAI,CAAC,SAAS,KAAK,GAClB;CAED,MAAM,EAAE,MAAM,SAAS,UAAU;CACjC,IAAI,OAAO,SAAS,YAAY,CAAC,YAAY,IAAI,KAAK,OAAO,YAAY,UACxE;CAED,OAAO,eAAe,MAAM,SAAS,OAAO,UAAU,WAAW,QAAQ,KAAA,CAAS;AACnF;;AAGA,MAAa,iBAAiB,SAC7B,UAAU,IAAI,GAAG;;;;;;AAOlB,MAAa,oBAAoB,OAAO,QAAuD;CAC9F,IAAI;EACH,OAAO,UAAU,MAAM,IAAI,KAAK,CAAC;CAClC,QAAQ;EACP;CACD;AACD"}
@@ -0,0 +1 @@
1
+ import { PayloadRequest } from "payload";
@@ -0,0 +1,24 @@
1
+ import { resolveGoalsFor } from "./runtime.js";
2
+ //#region src/plugin/goalHint.ts
3
+ /** A read whose numbers are goal completions: the `goal` breakdown, or the `conversions` metric. */
4
+ const needsGoalHint = (read) => read.metrics.includes("conversions") || (read.dimensions ?? []).includes("goal");
5
+ /**
6
+ * The scope's goal slugs for a read that asks about goals, and undefined for every other
7
+ * read, which no adapter restricts. An empty list is an install with no goals, which reads
8
+ * as an empty result; a resolver that throws hints `'unresolved'` instead, so the read
9
+ * costs only its goal rows (the provider answers `goalsUnresolved`) and is neither cached
10
+ * as a healthy answer nor mistaken for an install that configured nothing.
11
+ */
12
+ const goalSlugsFor = async (args) => {
13
+ if (!needsGoalHint(args)) return;
14
+ try {
15
+ return (await resolveGoalsFor(args.runtime, args.req, args.scope)).map((goal) => goal.slug);
16
+ } catch (err) {
17
+ args.req.payload.logger?.warn(`analytics: goal slugs failed to resolve: ${String(err)}`);
18
+ return "unresolved";
19
+ }
20
+ };
21
+ //#endregion
22
+ export { goalSlugsFor };
23
+
24
+ //# sourceMappingURL=goalHint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goalHint.js","names":[],"sources":["../../src/plugin/goalHint.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport type { DimensionKey, MetricKey } from '../core/contract'\nimport { type AnalyticsRuntime, resolveGoalsFor } from './runtime'\n\n/** What a read asks for, which is all the hint needs to know whether goals are involved. */\nexport interface GoalRead {\n\tmetrics: MetricKey[]\n\tdimensions?: DimensionKey[]\n}\n\nexport interface GoalSlugsArgs extends GoalRead {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\t/** The read's own scope; goals are resolved per scope. */\n\tscope: string | null | undefined\n}\n\n/** A read whose numbers are goal completions: the `goal` breakdown, or the `conversions` metric. */\nexport const needsGoalHint = (read: GoalRead): boolean =>\n\tread.metrics.includes('conversions') || (read.dimensions ?? []).includes('goal')\n\n/**\n * The scope's goal slugs for a read that asks about goals, and undefined for every other\n * read, which no adapter restricts. An empty list is an install with no goals, which reads\n * as an empty result; a resolver that throws hints `'unresolved'` instead, so the read\n * costs only its goal rows (the provider answers `goalsUnresolved`) and is neither cached\n * as a healthy answer nor mistaken for an install that configured nothing.\n */\nexport const goalSlugsFor = async (\n\targs: GoalSlugsArgs\n): Promise<string[] | 'unresolved' | undefined> => {\n\tif (!needsGoalHint(args)) {\n\t\treturn undefined\n\t}\n\ttry {\n\t\tconst goals = await resolveGoalsFor(args.runtime, args.req, args.scope)\n\t\treturn goals.map((goal) => goal.slug)\n\t} catch (err) {\n\t\targs.req.payload.logger?.warn(`analytics: goal slugs failed to resolve: ${String(err)}`)\n\t\treturn 'unresolved'\n\t}\n}\n"],"mappings":";;;AAkBA,MAAa,iBAAiB,SAC7B,KAAK,QAAQ,SAAS,aAAa,MAAM,KAAK,cAAc,CAAC,GAAG,SAAS,MAAM;;;;;;;;AAShF,MAAa,eAAe,OAC3B,SACkD;CAClD,IAAI,CAAC,cAAc,IAAI,GACtB;CAED,IAAI;EAEH,QAAO,MADa,gBAAgB,KAAK,SAAS,KAAK,KAAK,KAAK,KAAK,GACzD,KAAK,SAAS,KAAK,IAAI;CACrC,SAAS,KAAK;EACb,KAAK,IAAI,QAAQ,QAAQ,KAAK,4CAA4C,OAAO,GAAG,GAAG;EACvF,OAAO;CACR;AACD"}
@@ -6,8 +6,24 @@
6
6
  */
7
7
  const DOCUMENT_PATH = "/analytics/document";
8
8
  const SOURCES_PATH = "/analytics/sources";
9
+ /** Authenticated goal list for the admin goal picker, per-request scope. */
10
+ const GOALS_PATH = "/analytics/goals";
11
+ /** Authenticated read endpoint over the surfacing engine, per-request scope. */
12
+ const QUERY_PATH = "/analytics/query";
13
+ /** Authenticated POST raising a scope's cache epoch, which retires its cached reads. */
14
+ const REFRESH_PATH = "/analytics/refresh";
9
15
  const REALTIME_PATH = "/analytics/realtime";
16
+ /** Mount of the public capture proxy; each slot is served under `${PROXY_PATH}/<slot>`. */
17
+ const PROXY_PATH = "/analytics/p";
18
+ /** Public tracker config, per-request scope. */
19
+ const TRACKER_PATH = "/analytics/tracker";
20
+ /**
21
+ * Default mount of the native ingest endpoint, and the fallback for the `ingestPath` the
22
+ * tracker config hands the browser. `native({ ingestPath })` moves both: the adapter
23
+ * declares the override through `ingest.path`, which the runtime lifts onto the config.
24
+ */
25
+ const INGEST_PATH = "/analytics/ingest";
10
26
  //#endregion
11
- export { DOCUMENT_PATH, REALTIME_PATH, SOURCES_PATH };
27
+ export { DOCUMENT_PATH, GOALS_PATH, INGEST_PATH, PROXY_PATH, QUERY_PATH, REALTIME_PATH, REFRESH_PATH, SOURCES_PATH, TRACKER_PATH };
12
28
 
13
29
  //# sourceMappingURL=paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","names":[],"sources":["../../src/plugin/paths.ts"],"sourcesContent":["/**\n * Endpoint paths shared between server registration and client fetchers. Kept in a\n * dependency-free leaf module so client components can import the path without\n * pulling server code into the bundle.\n */\nexport const DOCUMENT_PATH = '/analytics/document'\nexport const SOURCES_PATH = '/analytics/sources'\nexport const REALTIME_PATH = '/analytics/realtime'\n"],"mappings":";;;;;;AAKA,MAAa,gBAAgB;AAC7B,MAAa,eAAe;AAC5B,MAAa,gBAAgB"}
1
+ {"version":3,"file":"paths.js","names":[],"sources":["../../src/plugin/paths.ts"],"sourcesContent":["/**\n * Endpoint paths shared between server registration and client fetchers. Kept in a\n * dependency-free leaf module so client components can import the path without\n * pulling server code into the bundle.\n */\nexport const DOCUMENT_PATH = '/analytics/document'\nexport const SOURCES_PATH = '/analytics/sources'\n/** Authenticated goal list for the admin goal picker, per-request scope. */\nexport const GOALS_PATH = '/analytics/goals'\n/** Authenticated read endpoint over the surfacing engine, per-request scope. */\nexport const QUERY_PATH = '/analytics/query'\n/** Authenticated POST raising a scope's cache epoch, which retires its cached reads. */\nexport const REFRESH_PATH = '/analytics/refresh'\nexport const REALTIME_PATH = '/analytics/realtime'\n/** Mount of the public capture proxy; each slot is served under `${PROXY_PATH}/<slot>`. */\nexport const PROXY_PATH = '/analytics/p'\n/** Public tracker config, per-request scope. */\nexport const TRACKER_PATH = '/analytics/tracker'\n/**\n * Default mount of the native ingest endpoint, and the fallback for the `ingestPath` the\n * tracker config hands the browser. `native({ ingestPath })` moves both: the adapter\n * declares the override through `ingest.path`, which the runtime lifts onto the config.\n */\nexport const INGEST_PATH = '/analytics/ingest'\n"],"mappings":";;;;;;AAKA,MAAa,gBAAgB;AAC7B,MAAa,eAAe;;AAE5B,MAAa,aAAa;;AAE1B,MAAa,aAAa;;AAE1B,MAAa,eAAe;AAC5B,MAAa,gBAAgB;;AAE7B,MAAa,aAAa;;AAE1B,MAAa,eAAe;;;;;;AAM5B,MAAa,cAAc"}