@10x-media/analytics 1.0.0-beta.14 → 1.0.0-beta.15

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 (168) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/adapters/ga4/ga4.d.ts +7 -0
  3. package/dist/adapters/ga4/ga4.js +17 -3
  4. package/dist/adapters/ga4/ga4.js.map +1 -1
  5. package/dist/adapters/plausible/plausible.d.ts +6 -0
  6. package/dist/adapters/plausible/plausible.js +6 -3
  7. package/dist/adapters/plausible/plausible.js.map +1 -1
  8. package/dist/adapters/posthog/posthog.d.ts +7 -0
  9. package/dist/adapters/posthog/posthog.js +92 -19
  10. package/dist/adapters/posthog/posthog.js.map +1 -1
  11. package/dist/adapters/posthog/projectCheck.js +56 -0
  12. package/dist/adapters/posthog/projectCheck.js.map +1 -0
  13. package/dist/adapters/umami/umami.d.ts +6 -0
  14. package/dist/adapters/umami/umami.js +3 -1
  15. package/dist/adapters/umami/umami.js.map +1 -1
  16. package/dist/capture/trackerConfig.js +29 -6
  17. package/dist/capture/trackerConfig.js.map +1 -1
  18. package/dist/capture/withoutConsent.js +91 -0
  19. package/dist/capture/withoutConsent.js.map +1 -0
  20. package/dist/core/capture.d.ts +41 -11
  21. package/dist/core/captureOptions.js +97 -8
  22. package/dist/core/captureOptions.js.map +1 -1
  23. package/dist/core/contract.d.ts +25 -0
  24. package/dist/core/contract.js.map +1 -1
  25. package/dist/core/options.d.ts +24 -2
  26. package/dist/core/options.js.map +1 -1
  27. package/dist/core/sourceOptions.js +2 -1
  28. package/dist/core/sourceOptions.js.map +1 -1
  29. package/dist/exports/adapters/contract.d.ts +3 -3
  30. package/dist/exports/adapters/ga4.d.ts +4 -4
  31. package/dist/exports/adapters/native.d.ts +5 -5
  32. package/dist/exports/adapters/plausible.d.ts +4 -4
  33. package/dist/exports/adapters/posthog.d.ts +4 -4
  34. package/dist/exports/adapters/umami.d.ts +4 -4
  35. package/dist/exports/next.d.ts +4 -4
  36. package/dist/exports/react.d.ts +3 -2
  37. package/dist/exports/site.d.ts +2 -2
  38. package/dist/exports/testing.d.ts +4 -4
  39. package/dist/exports/tracker.d.ts +3 -2
  40. package/dist/exports/types.d.ts +5 -5
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +2 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/native/collections/hits.js +1 -0
  45. package/dist/native/collections/hits.js.map +1 -1
  46. package/dist/native/engine/engine.js +5 -1
  47. package/dist/native/engine/engine.js.map +1 -1
  48. package/dist/native/engine/planner.js +2 -1
  49. package/dist/native/engine/planner.js.map +1 -1
  50. package/dist/native/engine/toHit.js +4 -2
  51. package/dist/native/engine/toHit.js.map +1 -1
  52. package/dist/native/ingest/endpoint.js +5 -2
  53. package/dist/native/ingest/endpoint.js.map +1 -1
  54. package/dist/native/ingest/normalizeEvent.d.ts +6 -1
  55. package/dist/native/ingest/normalizeEvent.js +17 -7
  56. package/dist/native/ingest/normalizeEvent.js.map +1 -1
  57. package/dist/native/ingest/serverTrack.js +2 -1
  58. package/dist/native/ingest/serverTrack.js.map +1 -1
  59. package/dist/native/ingest/validate.js +3 -0
  60. package/dist/native/ingest/validate.js.map +1 -1
  61. package/dist/native/nativeAdapter.d.ts +10 -1
  62. package/dist/native/nativeAdapter.js +11 -1
  63. package/dist/native/nativeAdapter.js.map +1 -1
  64. package/dist/native/store/aggregate.js +1 -1
  65. package/dist/native/store/aggregate.js.map +1 -1
  66. package/dist/native/store/hitRow.js +3 -0
  67. package/dist/native/store/hitRow.js.map +1 -1
  68. package/dist/native/store/hits.js +3 -1
  69. package/dist/native/store/hits.js.map +1 -1
  70. package/dist/native/store/mongo/aggregatePipelines.js +10 -2
  71. package/dist/native/store/mongo/aggregatePipelines.js.map +1 -1
  72. package/dist/native/store/mongo/pipelines.js +15 -5
  73. package/dist/native/store/mongo/pipelines.js.map +1 -1
  74. package/dist/native/store/parts.js +9 -3
  75. package/dist/native/store/parts.js.map +1 -1
  76. package/dist/native/store/rawRead.js +6 -3
  77. package/dist/native/store/rawRead.js.map +1 -1
  78. package/dist/native/store/sql/aggregateSql.js +6 -2
  79. package/dist/native/store/sql/aggregateSql.js.map +1 -1
  80. package/dist/native/store/sql/columns.js +1 -0
  81. package/dist/native/store/sql/columns.js.map +1 -1
  82. package/dist/native/store/sql/compile.js +19 -7
  83. package/dist/native/store/sql/compile.js.map +1 -1
  84. package/dist/native/store/types.d.ts +7 -1
  85. package/dist/native/store/types.js +10 -0
  86. package/dist/native/store/types.js.map +1 -0
  87. package/dist/plugin/createRuntime.js +10 -1
  88. package/dist/plugin/createRuntime.js.map +1 -1
  89. package/dist/plugin/runtime.js.map +1 -1
  90. package/dist/providers/collection.d.ts +2 -0
  91. package/dist/providers/collection.js +22 -1
  92. package/dist/providers/collection.js.map +1 -1
  93. package/dist/providers/factory.d.ts +9 -1
  94. package/dist/providers/factory.js +14 -5
  95. package/dist/providers/factory.js.map +1 -1
  96. package/dist/providers/registry.js +2 -1
  97. package/dist/providers/registry.js.map +1 -1
  98. package/dist/react/AnalyticsProvider.d.ts +6 -0
  99. package/dist/react/AnalyticsProvider.js.map +1 -1
  100. package/dist/react/useAnalytics.js +9 -5
  101. package/dist/react/useAnalytics.js.map +1 -1
  102. package/dist/site/AnalyticsScripts.d.ts +4 -3
  103. package/dist/site/AnalyticsScripts.js +18 -4
  104. package/dist/site/AnalyticsScripts.js.map +1 -1
  105. package/dist/surfacing/todaySplit.js +7 -1
  106. package/dist/surfacing/todaySplit.js.map +1 -1
  107. package/dist/tracker/config.d.ts +26 -1
  108. package/dist/tracker/config.js.map +1 -1
  109. package/dist/tracker/createTracker.d.ts +2 -1
  110. package/dist/tracker/createTracker.js +91 -59
  111. package/dist/tracker/createTracker.js.map +1 -1
  112. package/dist/tracker/gate.d.ts +8 -0
  113. package/dist/tracker/gate.js +61 -11
  114. package/dist/tracker/gate.js.map +1 -1
  115. package/dist/tracker/loadScript.js +2 -1
  116. package/dist/tracker/loadScript.js.map +1 -1
  117. package/dist/tracker/registry.js +14 -3
  118. package/dist/tracker/registry.js.map +1 -1
  119. package/dist/tracker/sinks/createSink.js +27 -8
  120. package/dist/tracker/sinks/createSink.js.map +1 -1
  121. package/dist/tracker/sinks/ga4.js +38 -6
  122. package/dist/tracker/sinks/ga4.js.map +1 -1
  123. package/dist/tracker/sinks/native.js +17 -3
  124. package/dist/tracker/sinks/native.js.map +1 -1
  125. package/dist/tracker/sinks/plausible.js +8 -2
  126. package/dist/tracker/sinks/plausible.js.map +1 -1
  127. package/dist/tracker/sinks/posthog.js +108 -16
  128. package/dist/tracker/sinks/posthog.js.map +1 -1
  129. package/dist/tracker/sinks/umami.js +2 -2
  130. package/dist/tracker/sinks/umami.js.map +1 -1
  131. package/dist/tracker/sinks/vendor.js +25 -11
  132. package/dist/tracker/sinks/vendor.js.map +1 -1
  133. package/dist/tracker/types.d.ts +10 -3
  134. package/dist/translations/ar.js +7 -0
  135. package/dist/translations/ar.js.map +1 -1
  136. package/dist/translations/de.js +7 -0
  137. package/dist/translations/de.js.map +1 -1
  138. package/dist/translations/en.js +7 -0
  139. package/dist/translations/en.js.map +1 -1
  140. package/dist/translations/es.js +7 -0
  141. package/dist/translations/es.js.map +1 -1
  142. package/dist/translations/fr.js +7 -0
  143. package/dist/translations/fr.js.map +1 -1
  144. package/dist/translations/id.js +7 -0
  145. package/dist/translations/id.js.map +1 -1
  146. package/dist/translations/keys.d.ts +7 -0
  147. package/dist/translations/keys.js +8 -1
  148. package/dist/translations/keys.js.map +1 -1
  149. package/dist/translations/ko.js +7 -0
  150. package/dist/translations/ko.js.map +1 -1
  151. package/dist/translations/pt.js +7 -0
  152. package/dist/translations/pt.js.map +1 -1
  153. package/dist/translations/ru.js +7 -0
  154. package/dist/translations/ru.js.map +1 -1
  155. package/dist/translations/uk.js +7 -0
  156. package/dist/translations/uk.js.map +1 -1
  157. package/dist/translations/zh.js +7 -0
  158. package/dist/translations/zh.js.map +1 -1
  159. package/dist/view/consentShare.js +15 -0
  160. package/dist/view/consentShare.js.map +1 -0
  161. package/dist/view/sections/OverviewCards.js +38 -28
  162. package/dist/view/sections/OverviewCards.js.map +1 -1
  163. package/dist/widgets/notices.js +6 -1
  164. package/dist/widgets/notices.js.map +1 -1
  165. package/dist/widgets/readMeta.d.ts +4 -0
  166. package/dist/widgets/readMeta.js +5 -0
  167. package/dist/widgets/readMeta.js.map +1 -1
  168. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","names":[],"sources":["../../src/core/contract.ts"],"sourcesContent":["import type { Config, Payload, PayloadRequest } from 'payload'\nimport type { CurrencyConverter } from '../goals/currency'\nimport type { BrowserAmounts, OrderSignatureMode } from '../goals/match'\nimport type { Goal } from '../goals/types'\nimport type { TrustedPlatform } from '../net/platform'\nimport type { RoutePaths } from '../plugin/routes'\nimport type { CaptureSupport } from './capture'\nimport type { AdapterJobs } from './jobs'\nimport type { AnalyticsSdks } from './sdks'\nimport type { IngestHostnameResolver, ServerTrack } from './serverEvent'\n\n/**\n * Explicit cross-scope read marker: pass as a read's `scope` to aggregate over every\n * scope. Gated by `access.crossScope.aggregate`; the query reaches the adapter unscoped.\n */\nexport const PLATFORM_SCOPE = '*'\n\nexport type { AdapterJobs, AnalyticsTaskName, ScheduledTask } from './jobs'\n\nexport type MetricKey =\n\t| 'pageviews'\n\t| 'visitors'\n\t| 'visits'\n\t| 'sessions'\n\t| 'bounceRate'\n\t/** Time on page: engaged time per pageview, an average in milliseconds over the pageviews it is read for. */\n\t| 'avgDuration'\n\t/** Time per visit: engaged time per visit, an average in milliseconds over the visits it is read for. */\n\t| 'visitDuration'\n\t| 'scrollDepth'\n\t| 'events'\n\t| 'conversions'\n\t| 'revenue'\n\t/** Times a content item was seen on screen. Counted per item only, never per page or site. */\n\t| 'impressions'\n\t/** Clicks on a content item, the first per item and pageview. */\n\t| 'interactions'\n\n/**\n * One metric's reading. `null` is an average or a share with nothing to average over (no\n * pageviews to time, no scroll reported, no sessions to bounce): no data, not zero.\n */\nexport type MetricValue = number | null\n\n/** A row's or a read's metrics. A metric the source did not report is absent. */\nexport type MetricValues = Partial<Record<MetricKey, MetricValue>>\n\n/** Every breakdown key the contract defines, the list request parsers validate against. */\nexport const DIMENSION_KEYS = [\n\t'page',\n\t'referrer',\n\t'source',\n\t'channel',\n\t'medium',\n\t'campaign',\n\t'utmSource',\n\t'utmMedium',\n\t'utmCampaign',\n\t'utmContent',\n\t'utmTerm',\n\t'device',\n\t'browser',\n\t'os',\n\t'country',\n\t'region',\n\t'city',\n\t'language',\n\t'event',\n\t'goal',\n\t'currency',\n\t'item',\n] as const\n\nexport type DimensionKey = (typeof DIMENSION_KEYS)[number]\n\nexport type Granularity = 'minute' | 'hour' | 'day' | 'week' | 'month'\n\nexport interface DateRange {\n\tstart: Date\n\tend: Date\n}\n\n/** Every filter operator the contract defines, the list request parsers validate against. */\nexport const FILTER_OPERATORS = ['eq', 'contains', 'matches'] as const\n\nexport type FilterOperator = (typeof FILTER_OPERATORS)[number]\n\nexport interface AnalyticsFilter {\n\tdimension: DimensionKey\n\toperator: FilterOperator\n\tvalue: string\n}\n\nexport interface AnalyticsQuery {\n\tpath?: string\n\thostname?: string\n\t/**\n\t * One content item's ref (`<collection>:<id>`): the read answers about that item, wherever\n\t * it was shown. Only a source declaring `capabilities.perItemQuery` can serve it.\n\t */\n\titem?: string\n\tmetrics: MetricKey[]\n\tdimensions?: DimensionKey[]\n\tdateRange: DateRange\n\tgranularity?: Granularity\n\tfilters?: AnalyticsFilter[]\n\tlimit?: number\n\t/**\n\t * How a breakdown is ranked before `limit` cuts it. The metric belongs in `metrics`: ranked by\n\t * one the read did not ask for, rows keep the source's order.\n\t */\n\torder?: { metric: MetricKey; direction: 'asc' | 'desc' }\n\t/**\n\t * Analytics boundary of the read (tenant id, site key); undefined means install-wide. Adapters\n\t * that can filter by scope apply it, and it is always part of the cache key.\n\t */\n\tscope?: string\n\t/**\n\t * IANA timezone the read's day boundaries align to; undefined means UTC. Adapters that can bucket\n\t * in a zone apply it, others report in their account's own.\n\t */\n\ttimezone?: string\n\t/**\n\t * The scope's goal slugs, which provider adapters restrict goal rows to (native matches goals\n\t * itself). `'unresolved'` marks a failed goal resolver and never shares a healthy cache key.\n\t */\n\tgoalSlugs?: string[] | 'unresolved'\n}\n\nexport interface AnalyticsRow {\n\tdimensions?: Partial<Record<DimensionKey, string>>\n\tmetrics: MetricValues\n\ttimestamp?: string\n\t/**\n\t * How many observations each average in `metrics` was taken over, which folds days into weeks\n\t * exactly. An average without one is weighted by its row's matching count.\n\t */\n\tsamples?: Partial<Record<MetricKey, number>>\n}\n\n/** How a read's `visitors` were counted. */\nexport type VisitorCounting = 'distinct' | 'sumOfDaily'\n\n/** Why a stale answer's source needs a look: its settings were refused, or its host is not allowed. */\nexport type SourceErrorKind = 'misconfigured' | 'host-refused'\n\nexport interface AnalyticsResult {\n\trows: AnalyticsRow[]\n\ttotals?: MetricValues\n\tmeta: {\n\t\tprovider: string\n\t\t/** The source counted from a sample of its data (GA4 on a large property), so the numbers are estimates. */\n\t\tsampled?: boolean\n\t\t/** The read covers less than it asked for: from `dataFrom` and up to `dataTo`, where set. */\n\t\tclamped?: boolean\n\t\t/** ISO instant the data starts at, set with `clamped` when later than the range's start. */\n\t\tdataFrom?: string\n\t\t/**\n\t\t * ISO instant the data ends at, set with `clamped` when earlier than the range's end: a day\n\t\t * the range cuts lies past raw retention in a scope's own zone.\n\t\t */\n\t\tdataTo?: string\n\t\t/**\n\t\t * `distinct` counts each person once per number; `sumOfDaily` means some number adds up daily\n\t\t * visitors, so a person who came on two days counts twice.\n\t\t */\n\t\tvisitorsAre?: VisitorCounting\n\t\t/** Some days of the range could not be read yet, so the numbers are a floor. */\n\t\tpartial?: { missingDays: number }\n\t\t/**\n\t\t * On this many days of the range a value the read asks about was folded into the `(other)`\n\t\t * row of its daily totals, and its raw hits are no longer kept: the numbers are a floor.\n\t\t */\n\t\tcapped?: { days: number }\n\t\t/**\n\t\t * On this many days of the range counting failed again and again and was given up: each is\n\t\t * read from an earlier count when it had one, and left out otherwise.\n\t\t */\n\t\tfailed?: { days: number }\n\t\t/**\n\t\t * The scope's reporting timezone could not be resolved and none was ever recorded, so this\n\t\t * read cut its days in UTC and counted nothing for later reads.\n\t\t */\n\t\ttimezoneUnresolved?: true\n\t\t/** ISO instant the numbers were last brought up to date, when older than `fetchedAt`. */\n\t\tasOf?: string\n\t\t/**\n\t\t * ISO instant the source was read (`ctx.now`), never later than the engine got the answer; a\n\t\t * cached answer keeps it.\n\t\t */\n\t\tfetchedAt: string\n\t\t/**\n\t\t * ISO 4217 code `revenue` is reported in: the vendor's own, else the install's\n\t\t * `revenue.currency` or the read's `currency` filter. Absent, revenue is a plain sum as sent.\n\t\t */\n\t\tcurrency?: string\n\t\t/**\n\t\t * The currencies the read's revenue adds unconverted amounts of, when more than one. Native\n\t\t * sets it.\n\t\t */\n\t\tmixedCurrencies?: string[]\n\t\t/**\n\t\t * Served from a cache entry past its TTL: at once while a refresh runs, or because the refresh\n\t\t * failed. `asOf` then says when the entry was fetched.\n\t\t */\n\t\tstale?: boolean\n\t\t/**\n\t\t * Set on a stale answer whose source last failed as set up rather than as an outage:\n\t\t * credentials refused (`misconfigured`) or host not allowed (`host-refused`).\n\t\t */\n\t\tsourceError?: SourceErrorKind\n\t\t/**\n\t\t * Filters the source could not carry, so the rows are wider than the query asked for.\n\t\t * A provider whose API takes one value per dimension reports the ones it dropped here.\n\t\t */\n\t\tunappliedFilters?: AnalyticsFilter[]\n\t\t/**\n\t\t * The read's goal numbers are absent because resolving them failed. A scope with no goals gets\n\t\t * an empty result instead, not this flag.\n\t\t */\n\t\tgoalsUnresolved?: true\n\t}\n}\n\n/**\n * The vendor's limits the source's lane keeps to, one token per upstream request per window. A read\n * with conversions may cost a second, goal-filtered request.\n */\nexport interface RateLimitDescriptor {\n\trequestsPerMinute?: number\n\trequestsPerHour?: number\n\t/** Upstream requests the source may have in flight; `cache.concurrency.perSource` when unset. */\n\tmaxConcurrent?: number\n\t/** Whether reads also spend the provider's write or ingest quota. */\n\treadsCountAsUsage?: boolean\n}\n\n/**\n * Which operators each dimension can be filtered with. A dimension absent here, or listed with\n * no operator, cannot be filtered at all.\n */\nexport type FilterOperatorMap = Partial<Record<DimensionKey, readonly FilterOperator[]>>\n\n/** Where a source reads one metric, when it cannot read it under every breakdown it offers. */\nexport interface MetricReach {\n\t/**\n\t * The breakdowns the metric is read under; empty when only whole-site numbers carry it.\n\t * Absent: every dimension the source declares.\n\t */\n\tdimensions?: readonly DimensionKey[]\n\t/**\n\t * A dimension the read must break down or filter by for the metric to have a value at all.\n\t * A read of one page (`AnalyticsQuery.path`) counts as filtering by `page`.\n\t */\n\trequires?: DimensionKey\n}\n\n/** What the numbers of a source mean where sources differ. */\nexport interface MetricSemantics {\n\t/**\n\t * `distinct` counts each person once over a range; `sumOfDaily` adds up each day's visitors.\n\t * Either may be per hostname: native's visitor id is, so two hostnames add up.\n\t */\n\tvisitors: VisitorCounting\n\t/** `inactivity30m` ends a visit after 30 minutes without activity; `provider` is the vendor's own rule. */\n\tsessions: 'inactivity30m' | 'provider'\n}\n\nexport interface AnalyticsCapabilities {\n\t/** The source answers `AnalyticsQuery.item`: one content item's views, clicks and outcomes. */\n\tperItemQuery?: boolean\n\trealtime: boolean\n\trealtimeWindowMinutes?: number\n\t/**\n\t * Period-over-period comparison, which the engine serves for every source by reading the\n\t * previous window itself. Adapters omit this; set it false only to opt a source out.\n\t */\n\tcomparison?: boolean\n\tminGranularity: Granularity\n\t/**\n\t * The source answers `week` and `month` series itself, exactly. Without it the engine reads\n\t * days and folds them into weeks and months in the read's reporting timezone.\n\t */\n\tcalendarBuckets?: boolean\n\tmaxLookbackDays: number | null\n\t/**\n\t * How far back a filtered read reaches, when that is shorter than `maxLookbackDays`: the\n\t * source narrows a longer one itself and marks it `clamped`. Absent or null: as far as any read.\n\t */\n\tfilterLookbackDays?: number | null\n\tmetrics: ReadonlySet<MetricKey>\n\tdimensions: ReadonlySet<DimensionKey>\n\t/**\n\t * Metrics the source reads only under some breakdowns or only for a page; any other is read under\n\t * every dimension. Reads outside a metric's reach are refused and hidden by pickers.\n\t */\n\tmetricReach?: Partial<Record<MetricKey, MetricReach>>\n\t/**\n\t * The `AnalyticsQuery.filters` the source applies, per dimension. A read carrying any other\n\t * pair is refused before it reaches the adapter. Absent: no filter at all.\n\t */\n\tfilters?: FilterOperatorMap\n\t/** What `visitors` and `sessions` mean here. Absent: not declared. */\n\tsemantics?: MetricSemantics\n\trateLimit: RateLimitDescriptor | null\n\t/**\n\t * Seconds an answer stays fresh. `today`, for a source cheap to read again, caps a window that\n\t * reaches into the current day whatever `cache.ttl` says; such an answer is never served stale.\n\t */\n\trecommendedTtl: { realtime: number; aggregate: number; today?: number }\n\t/**\n\t * The adapter applies `AnalyticsQuery.scope` as a native filter. Without it a scoped read through\n\t * a shared adapter would see other scopes, so it is gated by `access.crossScope.unscopedSource`.\n\t */\n\tscopedQueries?: boolean\n\t/**\n\t * The adapter sends every vendor request through `AdapterContext.upstream`, so each one spends\n\t * its own rate token and slot. Without it the engine counts a whole read as one request.\n\t */\n\tupstreamAware?: boolean\n}\n\nexport interface AdapterContext {\n\tsignal?: AbortSignal\n\t/**\n\t * The Payload instance the read is for, which the surfacing engine always passes. An adapter\n\t * that stores its data in Payload's database reads through it.\n\t */\n\tpayload?: Payload\n\t/**\n\t * Sends one vendor request through the source's lane: rate token, slot, retries on outage,\n\t * circuit breaker. Absent outside the engine, where `fn(ctx.signal)` is called directly.\n\t */\n\tupstream?: <T>(fn: (signal?: AbortSignal) => Promise<T>) => Promise<T>\n\t/**\n\t * Milliseconds the read has left before it gives up, for a vendor SDK that takes a deadline of\n\t * its own rather than a signal. Absent outside the engine.\n\t */\n\tremainingMs?: () => number\n\t/**\n\t * What time it is by the plugin's clock (Payload's), which an adapter stamps `meta.fetchedAt`\n\t * with. The engine always passes it; absent outside the engine.\n\t */\n\tnow?: () => Date\n}\n\n/** Extra context the plugin hands adapters when they register config surface. */\nexport interface AdapterRegisterContext {\n\t/** True when the plugin has `scope.resolve` configured. */\n\tscoped: boolean\n\t/**\n\t * `scope.resolve` at the `capture` call site, for ingest stamping: the host's resolver sees no\n\t * user, cookies or authorization header, so a hit files under the site it landed on.\n\t */\n\tresolveScope: (req: PayloadRequest) => Promise<string | null>\n\t/**\n\t * The plugin's reportingTimezone bound for adapter use, for what is shown in it. Resolves to\n\t * `'UTC'` when no reportingTimezone is set, and when the host's resolver fails.\n\t */\n\tresolveTimezone: (req: PayloadRequest, scope?: string | null) => Promise<string>\n\t/**\n\t * The same timezone, thrown rather than falling back to UTC: for an adapter storing days counted\n\t * in it, where recounting a day in UTC would move its numbers.\n\t */\n\tresolveTimezoneStrict: (req: PayloadRequest, scope?: string | null) => Promise<string>\n\t/** The install's `revenue` settings, for adapters that declare or reconcile revenue. */\n\trevenue: {\n\t\tenabled: boolean\n\t\tdimension: boolean\n\t\t/** `revenue.currency` bound for adapter use: `undefined` when none is set, revenue a plain number. */\n\t\tcurrency: (req: PayloadRequest, scope?: string | null) => Promise<string | undefined>\n\t\t/** `revenue.convert`, for adapters that reconcile revenue at ingest. */\n\t\tconvert?: CurrencyConverter\n\t\t/** `revenue.browserAmounts`, for an adapter that takes amounts from the browser itself. */\n\t\tbrowserAmounts?: BrowserAmounts\n\t\t/** `revenue.orderSignature`, for an adapter that takes the browser's order ids. */\n\t\torderSignature?: OrderSignatureMode\n\t}\n\t/**\n\t * The install's goals for a request's scope (config goals, the collection's merged over them),\n\t * for adapters that match completions themselves.\n\t */\n\tresolveGoals: (req: PayloadRequest, scope?: string | null) => Promise<Goal[]>\n\t/**\n\t * Whether a scope's own provider documents grant it this adapter; present only when the providers\n\t * collection runs under `scope.resolve`. Native ingest stores nothing for a scope it denies.\n\t */\n\tadapterGrantedForScope?: (\n\t\treq: PayloadRequest,\n\t\tscope: string | null,\n\t\tadapterId: string\n\t) => Promise<boolean>\n\t/** The plugin's `trustedProxyHops`, for adapters that read a request's client address. */\n\ttrustedProxyHops?: number\n\t/**\n\t * The plugin's `trustedPlatform`, for adapters that read a request's client address or\n\t * location: the only platform whose edge headers may be believed.\n\t */\n\ttrustedPlatform?: TrustedPlatform\n\t/**\n\t * `capture.allowedOrigins`, normalized, for adapters that register a public POST endpoint: the\n\t * only other sites whose pages may send to it from a visitor's browser.\n\t */\n\tallowedOrigins?: ReadonlySet<string>\n\t/**\n\t * The collections bound as content items, the only ones whose refs ingest keeps, and whether\n\t * an item is also counted per page it appeared on. Absent means no item is bound.\n\t */\n\titems?: { collections: ReadonlySet<string>; pages: boolean }\n\t/** The plugin's mounts under `routes.api`, for adapters that register an endpoint of their own. */\n\troutes?: RoutePaths\n\t/**\n\t * The packages the host handed the plugin as `sdks`, for adapters that would otherwise load\n\t * them at runtime: GA4's Data API client, the native engine's MaxMind reader.\n\t */\n\tsdks?: AnalyticsSdks\n\t/**\n\t * The plugin's `jobs`: the queue and schedule of the maintenance task an adapter registers, or\n\t * false when the install registers no task and the adapter's own requests do that work instead.\n\t */\n\tjobs?: AdapterJobs\n\t/**\n\t * The host's `jobs.enableConcurrencyControl`: only then may a task an adapter registers carry a\n\t * concurrency key, which Payload refuses otherwise.\n\t */\n\tjobsConcurrency?: boolean\n\t/** Says something at init, once the instance can log: what the boot warns about rather than refuses. */\n\tnotice?: (message: string) => void\n}\n\n/** What a switched-off install hands an adapter that keeps its schema (`disabled: true`). */\nexport interface AdapterSchemaContext {\n\t/** The plugin's `jobs`, which decides whether the adapter's task slug is in the jobs enum. */\n\tjobs: AdapterJobs\n\t/** What the boot would warn about, which a switched-off install never says. */\n\tnotice?: (message: string) => void\n}\n\n/** Whom a source's label is read for: the request, and the scope its sources were listed for. */\nexport interface AdapterLabelArgs {\n\treq: PayloadRequest\n\t/** Null is install-wide, `*` is cross-scope. */\n\tscope: string | null\n}\n\nexport interface AnalyticsAdapter {\n\treadonly id: string\n\t/** The source's name wherever no reader is known (boot-time pickers, logs). */\n\treadonly label: string\n\t/**\n\t * The source's name for one reader, where it differs by language or by who reads. Read through\n\t * `sourceLabelFor`, which falls back to `label` when this fails.\n\t */\n\treadonly labelFor?: (args: AdapterLabelArgs) => string | Promise<string>\n\treadonly capabilities: AnalyticsCapabilities\n\t/** Browser-tracker proxying/boot descriptor. Absent when no public capture field is set. */\n\treadonly capture?: CaptureSupport\n\t/**\n\t * Where the adapter's own ingest endpoint listens, relative to `routes.api`, and how server code\n\t * reaches that pipeline directly. Server-side only, never serialized.\n\t */\n\treadonly ingest?: { path: string; track?: ServerTrack; hostname?: IngestHostnameResolver }\n\tisConfigured(): boolean\n\tquery(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>\n\trealtime?(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>\n\tregister?(config: Config, context?: AdapterRegisterContext): void\n\t/**\n\t * For `disabled: true`: adds exactly the schema `register` would (collections, fields, indexes,\n\t * task slugs) and nothing that runs, so a switched-off install keeps its tables.\n\t */\n\tregisterSchema?(config: Config, context: AdapterSchemaContext): void\n\t/**\n\t * Binds the adapter to the Payload instance a runtime is built for, whenever one is, with or\n\t * without `onInit`. Called again for every rebuild, so it must be idempotent per instance.\n\t */\n\tattach?(payload: Payload): void\n\t/**\n\t * Releases what the adapter holds for one instance (buffers, clients, timers) once that\n\t * instance's runtime is retired; another instance the adapter serves keeps what it holds.\n\t */\n\tclose?(payload: Payload): void | Promise<void>\n}\n\nexport type AnalyticsAdapterFactory<Config> = (config: Config) => AnalyticsAdapter\n"],"mappings":";;;;;AAeA,MAAa,iBAAiB;;AAiC9B,MAAa,iBAAiB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAYA,MAAa,mBAAmB;CAAC;CAAM;CAAY;AAAS"}
1
+ {"version":3,"file":"contract.js","names":[],"sources":["../../src/core/contract.ts"],"sourcesContent":["import type { Config, Payload, PayloadRequest } from 'payload'\nimport type { CurrencyConverter } from '../goals/currency'\nimport type { BrowserAmounts, OrderSignatureMode } from '../goals/match'\nimport type { Goal } from '../goals/types'\nimport type { TrustedPlatform } from '../net/platform'\nimport type { RoutePaths } from '../plugin/routes'\nimport type { CaptureSupport } from './capture'\nimport type { AdapterJobs } from './jobs'\nimport type { AnalyticsSdks } from './sdks'\nimport type { IngestHostnameResolver, ServerTrack } from './serverEvent'\n\n/**\n * Explicit cross-scope read marker: pass as a read's `scope` to aggregate over every\n * scope. Gated by `access.crossScope.aggregate`; the query reaches the adapter unscoped.\n */\nexport const PLATFORM_SCOPE = '*'\n\nexport type { AdapterJobs, AnalyticsTaskName, ScheduledTask } from './jobs'\n\nexport type MetricKey =\n\t| 'pageviews'\n\t| 'visitors'\n\t| 'visits'\n\t| 'sessions'\n\t| 'bounceRate'\n\t/** Time on page: engaged time per pageview, an average in milliseconds over the pageviews it is read for. */\n\t| 'avgDuration'\n\t/** Time per visit: engaged time per visit, an average in milliseconds over the visits it is read for. */\n\t| 'visitDuration'\n\t| 'scrollDepth'\n\t| 'events'\n\t| 'conversions'\n\t| 'revenue'\n\t/** Times a content item was seen on screen. Counted per item only, never per page or site. */\n\t| 'impressions'\n\t/** Clicks on a content item, the first per item and pageview. */\n\t| 'interactions'\n\n/**\n * One metric's reading. `null` is an average or a share with nothing to average over (no\n * pageviews to time, no scroll reported, no sessions to bounce): no data, not zero.\n */\nexport type MetricValue = number | null\n\n/** A row's or a read's metrics. A metric the source did not report is absent. */\nexport type MetricValues = Partial<Record<MetricKey, MetricValue>>\n\n/** Every breakdown key the contract defines, the list request parsers validate against. */\nexport const DIMENSION_KEYS = [\n\t'page',\n\t'referrer',\n\t'source',\n\t'channel',\n\t'medium',\n\t'campaign',\n\t'utmSource',\n\t'utmMedium',\n\t'utmCampaign',\n\t'utmContent',\n\t'utmTerm',\n\t'device',\n\t'browser',\n\t'os',\n\t'country',\n\t'region',\n\t'city',\n\t'language',\n\t'event',\n\t'goal',\n\t'currency',\n\t'item',\n] as const\n\nexport type DimensionKey = (typeof DIMENSION_KEYS)[number]\n\nexport type Granularity = 'minute' | 'hour' | 'day' | 'week' | 'month'\n\nexport interface DateRange {\n\tstart: Date\n\tend: Date\n}\n\n/** Every filter operator the contract defines, the list request parsers validate against. */\nexport const FILTER_OPERATORS = ['eq', 'contains', 'matches'] as const\n\nexport type FilterOperator = (typeof FILTER_OPERATORS)[number]\n\nexport interface AnalyticsFilter {\n\tdimension: DimensionKey\n\toperator: FilterOperator\n\tvalue: string\n}\n\nexport interface AnalyticsQuery {\n\tpath?: string\n\thostname?: string\n\t/**\n\t * One content item's ref (`<collection>:<id>`): the read answers about that item, wherever\n\t * it was shown. Only a source declaring `capabilities.perItemQuery` can serve it.\n\t */\n\titem?: string\n\tmetrics: MetricKey[]\n\tdimensions?: DimensionKey[]\n\tdateRange: DateRange\n\tgranularity?: Granularity\n\tfilters?: AnalyticsFilter[]\n\tlimit?: number\n\t/**\n\t * How a breakdown is ranked before `limit` cuts it. The metric belongs in `metrics`: ranked by\n\t * one the read did not ask for, rows keep the source's order.\n\t */\n\torder?: { metric: MetricKey; direction: 'asc' | 'desc' }\n\t/**\n\t * Analytics boundary of the read (tenant id, site key); undefined means install-wide. Adapters\n\t * that can filter by scope apply it, and it is always part of the cache key.\n\t */\n\tscope?: string\n\t/**\n\t * IANA timezone the read's day boundaries align to; undefined means UTC. Adapters that can bucket\n\t * in a zone apply it, others report in their account's own.\n\t */\n\ttimezone?: string\n\t/**\n\t * The scope's goal slugs, which provider adapters restrict goal rows to (native matches goals\n\t * itself). `'unresolved'` marks a failed goal resolver and never shares a healthy cache key.\n\t */\n\tgoalSlugs?: string[] | 'unresolved'\n}\n\nexport interface AnalyticsRow {\n\tdimensions?: Partial<Record<DimensionKey, string>>\n\tmetrics: MetricValues\n\ttimestamp?: string\n\t/**\n\t * How many observations each average in `metrics` was taken over, which folds days into weeks\n\t * exactly. An average without one is weighted by its row's matching count.\n\t */\n\tsamples?: Partial<Record<MetricKey, number>>\n}\n\n/** How a read's `visitors` were counted. */\nexport type VisitorCounting = 'distinct' | 'sumOfDaily'\n\n/** Why a stale answer's source needs a look: its settings were refused, or its host is not allowed. */\nexport type SourceErrorKind = 'misconfigured' | 'host-refused'\n\nexport interface AnalyticsResult {\n\trows: AnalyticsRow[]\n\ttotals?: MetricValues\n\tmeta: {\n\t\tprovider: string\n\t\t/** The source counted from a sample of its data (GA4 on a large property), so the numbers are estimates. */\n\t\tsampled?: boolean\n\t\t/** The read covers less than it asked for: from `dataFrom` and up to `dataTo`, where set. */\n\t\tclamped?: boolean\n\t\t/** ISO instant the data starts at, set with `clamped` when later than the range's start. */\n\t\tdataFrom?: string\n\t\t/**\n\t\t * ISO instant the data ends at, set with `clamped` when earlier than the range's end: a day\n\t\t * the range cuts lies past raw retention in a scope's own zone.\n\t\t */\n\t\tdataTo?: string\n\t\t/**\n\t\t * `distinct` counts each person once per number; `sumOfDaily` means some number adds up daily\n\t\t * visitors, so a person who came on two days counts twice.\n\t\t */\n\t\tvisitorsAre?: VisitorCounting\n\t\t/** Some days of the range could not be read yet, so the numbers are a floor. */\n\t\tpartial?: { missingDays: number }\n\t\t/**\n\t\t * On this many days of the range a value the read asks about was folded into the `(other)`\n\t\t * row of its daily totals, and its raw hits are no longer kept: the numbers are a floor.\n\t\t */\n\t\tcapped?: { days: number }\n\t\t/**\n\t\t * On this many days of the range counting failed again and again and was given up: each is\n\t\t * read from an earlier count when it had one, and left out otherwise.\n\t\t */\n\t\tfailed?: { days: number }\n\t\t/**\n\t\t * The scope's reporting timezone could not be resolved and none was ever recorded, so this\n\t\t * read cut its days in UTC and counted nothing for later reads.\n\t\t */\n\t\ttimezoneUnresolved?: true\n\t\t/** ISO instant the numbers were last brought up to date, when older than `fetchedAt`. */\n\t\tasOf?: string\n\t\t/**\n\t\t * ISO instant the source was read (`ctx.now`), never later than the engine got the answer; a\n\t\t * cached answer keeps it.\n\t\t */\n\t\tfetchedAt: string\n\t\t/**\n\t\t * ISO 4217 code `revenue` is reported in: the vendor's own, else the install's\n\t\t * `revenue.currency` or the read's `currency` filter. Absent, revenue is a plain sum as sent.\n\t\t */\n\t\tcurrency?: string\n\t\t/**\n\t\t * The currencies the read's revenue adds unconverted amounts of, when more than one. Native\n\t\t * sets it.\n\t\t */\n\t\tmixedCurrencies?: string[]\n\t\t/**\n\t\t * Served from a cache entry past its TTL: at once while a refresh runs, or because the refresh\n\t\t * failed. `asOf` then says when the entry was fetched.\n\t\t */\n\t\tstale?: boolean\n\t\t/**\n\t\t * Set on a stale answer whose source last failed as set up rather than as an outage:\n\t\t * credentials refused (`misconfigured`) or host not allowed (`host-refused`).\n\t\t */\n\t\tsourceError?: SourceErrorKind\n\t\t/**\n\t\t * Filters the source could not carry, so the rows are wider than the query asked for.\n\t\t * A provider whose API takes one value per dimension reports the ones it dropped here.\n\t\t */\n\t\tunappliedFilters?: AnalyticsFilter[]\n\t\t/**\n\t\t * The read's goal numbers are absent because resolving them failed. A scope with no goals gets\n\t\t * an empty result instead, not this flag.\n\t\t */\n\t\tgoalsUnresolved?: true\n\t\t/**\n\t\t * Pageviews of the read counted without consent, at a cookieless or anonymous level, which\n\t\t * the view shows as a share of all pageviews. Absent when the source cannot tell or found none.\n\t\t */\n\t\twithoutConsent?: { pageviews: number }\n\t\t/**\n\t\t * Pageviews of the read recorded without a visitor (native's anonymous level): they count as\n\t\t * pageviews, and toward no visitor, visit, bounce rate or time.\n\t\t */\n\t\twithoutVisitor?: { pageviews: number }\n\t\t/**\n\t\t * The vendor drops what a slot counts without consent, so those visits are missing from every\n\t\t * number: PostHog with its project's cookieless tracking setting off.\n\t\t */\n\t\twithoutConsentDropped?: true\n\t}\n}\n\n/**\n * The vendor's limits the source's lane keeps to, one token per upstream request per window. A read\n * with conversions may cost a second, goal-filtered request.\n */\nexport interface RateLimitDescriptor {\n\trequestsPerMinute?: number\n\trequestsPerHour?: number\n\t/** Upstream requests the source may have in flight; `cache.concurrency.perSource` when unset. */\n\tmaxConcurrent?: number\n\t/** Whether reads also spend the provider's write or ingest quota. */\n\treadsCountAsUsage?: boolean\n}\n\n/**\n * Which operators each dimension can be filtered with. A dimension absent here, or listed with\n * no operator, cannot be filtered at all.\n */\nexport type FilterOperatorMap = Partial<Record<DimensionKey, readonly FilterOperator[]>>\n\n/** Where a source reads one metric, when it cannot read it under every breakdown it offers. */\nexport interface MetricReach {\n\t/**\n\t * The breakdowns the metric is read under; empty when only whole-site numbers carry it.\n\t * Absent: every dimension the source declares.\n\t */\n\tdimensions?: readonly DimensionKey[]\n\t/**\n\t * A dimension the read must break down or filter by for the metric to have a value at all.\n\t * A read of one page (`AnalyticsQuery.path`) counts as filtering by `page`.\n\t */\n\trequires?: DimensionKey\n}\n\n/** What the numbers of a source mean where sources differ. */\nexport interface MetricSemantics {\n\t/**\n\t * `distinct` counts each person once over a range; `sumOfDaily` adds up each day's visitors.\n\t * Either may be per hostname: native's visitor id is, so two hostnames add up.\n\t */\n\tvisitors: VisitorCounting\n\t/** `inactivity30m` ends a visit after 30 minutes without activity; `provider` is the vendor's own rule. */\n\tsessions: 'inactivity30m' | 'provider'\n}\n\nexport interface AnalyticsCapabilities {\n\t/** The source answers `AnalyticsQuery.item`: one content item's views, clicks and outcomes. */\n\tperItemQuery?: boolean\n\trealtime: boolean\n\trealtimeWindowMinutes?: number\n\t/**\n\t * Period-over-period comparison, which the engine serves for every source by reading the\n\t * previous window itself. Adapters omit this; set it false only to opt a source out.\n\t */\n\tcomparison?: boolean\n\tminGranularity: Granularity\n\t/**\n\t * The source answers `week` and `month` series itself, exactly. Without it the engine reads\n\t * days and folds them into weeks and months in the read's reporting timezone.\n\t */\n\tcalendarBuckets?: boolean\n\tmaxLookbackDays: number | null\n\t/**\n\t * How far back a filtered read reaches, when that is shorter than `maxLookbackDays`: the\n\t * source narrows a longer one itself and marks it `clamped`. Absent or null: as far as any read.\n\t */\n\tfilterLookbackDays?: number | null\n\tmetrics: ReadonlySet<MetricKey>\n\tdimensions: ReadonlySet<DimensionKey>\n\t/**\n\t * Metrics the source reads only under some breakdowns or only for a page; any other is read under\n\t * every dimension. Reads outside a metric's reach are refused and hidden by pickers.\n\t */\n\tmetricReach?: Partial<Record<MetricKey, MetricReach>>\n\t/**\n\t * The `AnalyticsQuery.filters` the source applies, per dimension. A read carrying any other\n\t * pair is refused before it reaches the adapter. Absent: no filter at all.\n\t */\n\tfilters?: FilterOperatorMap\n\t/** What `visitors` and `sessions` mean here. Absent: not declared. */\n\tsemantics?: MetricSemantics\n\trateLimit: RateLimitDescriptor | null\n\t/**\n\t * Seconds an answer stays fresh. `today`, for a source cheap to read again, caps a window that\n\t * reaches into the current day whatever `cache.ttl` says; such an answer is never served stale.\n\t */\n\trecommendedTtl: { realtime: number; aggregate: number; today?: number }\n\t/**\n\t * The adapter applies `AnalyticsQuery.scope` as a native filter. Without it a scoped read through\n\t * a shared adapter would see other scopes, so it is gated by `access.crossScope.unscopedSource`.\n\t */\n\tscopedQueries?: boolean\n\t/**\n\t * The adapter sends every vendor request through `AdapterContext.upstream`, so each one spends\n\t * its own rate token and slot. Without it the engine counts a whole read as one request.\n\t */\n\tupstreamAware?: boolean\n}\n\nexport interface AdapterContext {\n\tsignal?: AbortSignal\n\t/**\n\t * The Payload instance the read is for, which the surfacing engine always passes. An adapter\n\t * that stores its data in Payload's database reads through it.\n\t */\n\tpayload?: Payload\n\t/**\n\t * Sends one vendor request through the source's lane: rate token, slot, retries on outage,\n\t * circuit breaker. Absent outside the engine, where `fn(ctx.signal)` is called directly.\n\t */\n\tupstream?: <T>(fn: (signal?: AbortSignal) => Promise<T>) => Promise<T>\n\t/**\n\t * Milliseconds the read has left before it gives up, for a vendor SDK that takes a deadline of\n\t * its own rather than a signal. Absent outside the engine.\n\t */\n\tremainingMs?: () => number\n\t/**\n\t * What time it is by the plugin's clock (Payload's), which an adapter stamps `meta.fetchedAt`\n\t * with. The engine always passes it; absent outside the engine.\n\t */\n\tnow?: () => Date\n}\n\n/** Extra context the plugin hands adapters when they register config surface. */\nexport interface AdapterRegisterContext {\n\t/** True when the plugin has `scope.resolve` configured. */\n\tscoped: boolean\n\t/**\n\t * `scope.resolve` at the `capture` call site, for ingest stamping: the host's resolver sees no\n\t * user, cookies or authorization header, so a hit files under the site it landed on.\n\t */\n\tresolveScope: (req: PayloadRequest) => Promise<string | null>\n\t/**\n\t * The plugin's reportingTimezone bound for adapter use, for what is shown in it. Resolves to\n\t * `'UTC'` when no reportingTimezone is set, and when the host's resolver fails.\n\t */\n\tresolveTimezone: (req: PayloadRequest, scope?: string | null) => Promise<string>\n\t/**\n\t * The same timezone, thrown rather than falling back to UTC: for an adapter storing days counted\n\t * in it, where recounting a day in UTC would move its numbers.\n\t */\n\tresolveTimezoneStrict: (req: PayloadRequest, scope?: string | null) => Promise<string>\n\t/** The install's `revenue` settings, for adapters that declare or reconcile revenue. */\n\trevenue: {\n\t\tenabled: boolean\n\t\tdimension: boolean\n\t\t/** `revenue.currency` bound for adapter use: `undefined` when none is set, revenue a plain number. */\n\t\tcurrency: (req: PayloadRequest, scope?: string | null) => Promise<string | undefined>\n\t\t/** `revenue.convert`, for adapters that reconcile revenue at ingest. */\n\t\tconvert?: CurrencyConverter\n\t\t/** `revenue.browserAmounts`, for an adapter that takes amounts from the browser itself. */\n\t\tbrowserAmounts?: BrowserAmounts\n\t\t/** `revenue.orderSignature`, for an adapter that takes the browser's order ids. */\n\t\torderSignature?: OrderSignatureMode\n\t}\n\t/**\n\t * The install's goals for a request's scope (config goals, the collection's merged over them),\n\t * for adapters that match completions themselves.\n\t */\n\tresolveGoals: (req: PayloadRequest, scope?: string | null) => Promise<Goal[]>\n\t/**\n\t * Whether a scope's own provider documents grant it this adapter; present only when the providers\n\t * collection runs under `scope.resolve`. Native ingest stores nothing for a scope it denies.\n\t */\n\tadapterGrantedForScope?: (\n\t\treq: PayloadRequest,\n\t\tscope: string | null,\n\t\tadapterId: string\n\t) => Promise<boolean>\n\t/** The plugin's `trustedProxyHops`, for adapters that read a request's client address. */\n\ttrustedProxyHops?: number\n\t/**\n\t * The plugin's `trustedPlatform`, for adapters that read a request's client address or\n\t * location: the only platform whose edge headers may be believed.\n\t */\n\ttrustedPlatform?: TrustedPlatform\n\t/**\n\t * `capture.allowedOrigins`, normalized, for adapters that register a public POST endpoint: the\n\t * only other sites whose pages may send to it from a visitor's browser.\n\t */\n\tallowedOrigins?: ReadonlySet<string>\n\t/**\n\t * False when this adapter fills no slot `capture.gate` holds that can count without consent, as\n\t * far as the boot can tell, so it need not check its vendor accepts such events. Absent reads as\n\t * true.\n\t */\n\tadapterCountsWithoutConsent?: boolean\n\t/**\n\t * The collections bound as content items, the only ones whose refs ingest keeps, and whether\n\t * an item is also counted per page it appeared on. Absent means no item is bound.\n\t */\n\titems?: { collections: ReadonlySet<string>; pages: boolean }\n\t/** The plugin's mounts under `routes.api`, for adapters that register an endpoint of their own. */\n\troutes?: RoutePaths\n\t/**\n\t * The packages the host handed the plugin as `sdks`, for adapters that would otherwise load\n\t * them at runtime: GA4's Data API client, the native engine's MaxMind reader.\n\t */\n\tsdks?: AnalyticsSdks\n\t/**\n\t * The plugin's `jobs`: the queue and schedule of the maintenance task an adapter registers, or\n\t * false when the install registers no task and the adapter's own requests do that work instead.\n\t */\n\tjobs?: AdapterJobs\n\t/**\n\t * The host's `jobs.enableConcurrencyControl`: only then may a task an adapter registers carry a\n\t * concurrency key, which Payload refuses otherwise.\n\t */\n\tjobsConcurrency?: boolean\n\t/** Says something at init, once the instance can log: what the boot warns about rather than refuses. */\n\tnotice?: (message: string) => void\n}\n\n/** What a switched-off install hands an adapter that keeps its schema (`disabled: true`). */\nexport interface AdapterSchemaContext {\n\t/** The plugin's `jobs`, which decides whether the adapter's task slug is in the jobs enum. */\n\tjobs: AdapterJobs\n\t/** What the boot would warn about, which a switched-off install never says. */\n\tnotice?: (message: string) => void\n}\n\n/** Whom a source's label is read for: the request, and the scope its sources were listed for. */\nexport interface AdapterLabelArgs {\n\treq: PayloadRequest\n\t/** Null is install-wide, `*` is cross-scope. */\n\tscope: string | null\n}\n\nexport interface AnalyticsAdapter {\n\treadonly id: string\n\t/** The source's name wherever no reader is known (boot-time pickers, logs). */\n\treadonly label: string\n\t/**\n\t * The source's name for one reader, where it differs by language or by who reads. Read through\n\t * `sourceLabelFor`, which falls back to `label` when this fails.\n\t */\n\treadonly labelFor?: (args: AdapterLabelArgs) => string | Promise<string>\n\treadonly capabilities: AnalyticsCapabilities\n\t/** Browser-tracker proxying/boot descriptor. Absent when no public capture field is set. */\n\treadonly capture?: CaptureSupport\n\t/**\n\t * Where the adapter's own ingest endpoint listens, relative to `routes.api`, and how server code\n\t * reaches that pipeline directly. Server-side only, never serialized.\n\t */\n\treadonly ingest?: { path: string; track?: ServerTrack; hostname?: IngestHostnameResolver }\n\tisConfigured(): boolean\n\tquery(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>\n\trealtime?(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>\n\tregister?(config: Config, context?: AdapterRegisterContext): void\n\t/**\n\t * For `disabled: true`: adds exactly the schema `register` would (collections, fields, indexes,\n\t * task slugs) and nothing that runs, so a switched-off install keeps its tables.\n\t */\n\tregisterSchema?(config: Config, context: AdapterSchemaContext): void\n\t/**\n\t * Binds the adapter to the Payload instance a runtime is built for, whenever one is, with or\n\t * without `onInit`. Called again for every rebuild, so it must be idempotent per instance.\n\t */\n\tattach?(payload: Payload): void\n\t/**\n\t * Releases what the adapter holds for one instance (buffers, clients, timers) once that\n\t * instance's runtime is retired; another instance the adapter serves keeps what it holds.\n\t */\n\tclose?(payload: Payload): void | Promise<void>\n}\n\nexport type AnalyticsAdapterFactory<Config> = (config: Config) => AnalyticsAdapter\n"],"mappings":";;;;;AAeA,MAAa,iBAAiB;;AAiC9B,MAAa,iBAAiB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAYA,MAAa,mBAAmB;CAAC;CAAM;CAAY;AAAS"}
@@ -1,5 +1,5 @@
1
1
  import { CurrencyConverter } from "../goals/currency.js";
2
- import { CaptureClientKind, CaptureSlot } from "../tracker/config.js";
2
+ import { CaptureClientKind, CaptureSlot, ConsentPhase, WithoutConsentLevel } from "../tracker/config.js";
3
3
  import { Goal } from "../goals/types.js";
4
4
  import { BrowserAmounts, OrderSignatureMode } from "../goals/match.js";
5
5
  import { TrustedPlatform } from "../net/platform.js";
@@ -269,6 +269,21 @@ interface CaptureGateArgs {
269
269
  * function answering per slot (true waits).
270
270
  */
271
271
  type CaptureGate = 'all' | 'off' | CaptureSlot[] | ((args: CaptureGateArgs) => boolean);
272
+ /** What `capture.withoutConsent` is asked about one held slot in one phase. */
273
+ interface WithoutConsentArgs extends CaptureGateArgs {
274
+ phase: ConsentPhase;
275
+ }
276
+ /** `capture.withoutConsent` as a function: a throw, or any other answer, means `'off'`. */
277
+ type WithoutConsentFunction = (args: WithoutConsentArgs) => WithoutConsentLevel;
278
+ /**
279
+ * What a slot `capture.gate` holds does before an answer (`pending`) and after a refusal
280
+ * (`refused`): one level for both, one per phase (an omitted phase is `'cookieless'`), or a
281
+ * function answering per slot and phase.
282
+ */
283
+ type WithoutConsentOption = WithoutConsentLevel | {
284
+ pending?: WithoutConsentLevel;
285
+ refused?: WithoutConsentLevel;
286
+ } | WithoutConsentFunction;
272
287
  /** An adapter id to fill a capture slot with, or `false` to leave it deliberately empty. */
273
288
  type CaptureSlotOption = string | false;
274
289
  /** What the tracker and ingest do with elements marked by `itemAttributes`. */
@@ -349,6 +364,13 @@ type AnalyticsCaptureOptions = {
349
364
  * whether tracking needs consent is the operator's call, so there is no default.
350
365
  */
351
366
  gate?: CaptureGate;
367
+ /**
368
+ * What a slot `gate` holds does before an answer and after a refusal. Default `'cookieless'`:
369
+ * count without storing anything on the device, at the level each adapter declares (GA4's is
370
+ * `'off'`). `'off'` sends nothing until consent and nothing after a refusal. An adapter's own
371
+ * `withoutConsent` beats this for its slot; a slot the gate does not hold runs in full.
372
+ */
373
+ withoutConsent?: WithoutConsentOption;
352
374
  /**
353
375
  * Exact origins of other sites (`https://shop.example.com`, no path or wildcard) whose pages may
354
376
  * send to ingest and the capture proxy. Unset, only the site and its subdomains can.
@@ -654,5 +676,5 @@ type AnalyticsPluginOptions = {
654
676
  hooks?: AnalyticsHooksOptions;
655
677
  };
656
678
  //#endregion
657
- export { AnalyticsAccessOptions, AnalyticsCacheCollectionOptions, AnalyticsCacheOptions, AnalyticsCaptureOptions, AnalyticsComponent, AnalyticsConcurrencyOptions, AnalyticsCountryFlags, AnalyticsCrossScopeOptions, AnalyticsExclusionOptions, AnalyticsGoalsCollectionOptions, AnalyticsGoalsOptions, AnalyticsHooksOptions, AnalyticsPluginOptions, AnalyticsReadAccess, AnalyticsRevenueOptions, AnalyticsRoutesOptions, AnalyticsScopeOptions, AnalyticsSyncCollectionOptions, AnalyticsSyncOptions, AnalyticsViewAccess, AnalyticsViewOptions, AnalyticsWarmOptions, AnalyticsWidgetOverride, AnalyticsWidgetOverrides, AnalyticsWidgetsOptions, AutoCaptureOptions, CaptureGate, CaptureGateArgs, CaptureSlotOption, CrossScopeAccess, CurrencyResolver, ExclusionSitesResolver, ItemCaptureOptions, ProviderHostsOptions, ProvidersCollectionOptions, ProvidersOptions, ProvidersResolve, ProvidersResolveArgs, ScopeCallSite, ScopeLabelResolver, ScopeListResolver, ScopeMemberAccess, ScopeResolver, TimezoneResolver };
679
+ export { AnalyticsAccessOptions, AnalyticsCacheCollectionOptions, AnalyticsCacheOptions, AnalyticsCaptureOptions, AnalyticsComponent, AnalyticsConcurrencyOptions, AnalyticsCountryFlags, AnalyticsCrossScopeOptions, AnalyticsExclusionOptions, AnalyticsGoalsCollectionOptions, AnalyticsGoalsOptions, AnalyticsHooksOptions, AnalyticsPluginOptions, AnalyticsReadAccess, AnalyticsRevenueOptions, AnalyticsRoutesOptions, AnalyticsScopeOptions, AnalyticsSyncCollectionOptions, AnalyticsSyncOptions, AnalyticsViewAccess, AnalyticsViewOptions, AnalyticsWarmOptions, AnalyticsWidgetOverride, AnalyticsWidgetOverrides, AnalyticsWidgetsOptions, AutoCaptureOptions, CaptureGate, CaptureGateArgs, CaptureSlotOption, CrossScopeAccess, CurrencyResolver, ExclusionSitesResolver, ItemCaptureOptions, ProviderHostsOptions, ProvidersCollectionOptions, ProvidersOptions, ProvidersResolve, ProvidersResolveArgs, ScopeCallSite, ScopeLabelResolver, ScopeListResolver, ScopeMemberAccess, ScopeResolver, TimezoneResolver, WithoutConsentArgs, WithoutConsentFunction, WithoutConsentOption };
658
680
  //# sourceMappingURL=options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","names":[],"sources":["../../src/core/options.ts"],"sourcesContent":["import type { KeysConfig } from '@10x-media/fields/encrypted'\nimport type {\n\tAccess,\n\tCollectionConfig,\n\tCollectionSlug,\n\tField,\n\tPayload,\n\tPayloadRequest,\n\tRawPayloadComponent,\n\tWidget,\n} from 'payload'\nimport type { AnalyticsBinding, ResolvedBinding } from '../binding/types'\nimport type { GoalCollectionFieldOverrides } from '../goals/collection'\nimport type { CurrencyConverter } from '../goals/currency'\nimport type { BrowserAmounts, OrderSignatureMode } from '../goals/match'\nimport type { Goal } from '../goals/types'\nimport type { TrustedPlatform } from '../net/platform'\nimport { type RouteBase, resolveRouteBase } from '../plugin/routes'\nimport type { ScopeDecision } from '../plugin/runtime'\nimport type {\n\tConnectionAccess,\n\tConnectionFieldAccess,\n\tProviderCollectionFieldOverrides,\n} from '../providers/collection'\nimport type { ProviderId } from '../providers/factory'\nimport type { ProviderHostPolicy } from '../providers/hosts'\nimport type { AfterReadHook } from '../surfacing/afterRead'\nimport type { CacheStore } from '../surfacing/cacheStore'\nimport type { TimeframePreset } from '../timeframe/presets'\nimport { isValidTimeZone } from '../timeframe/tz'\nimport type {\n\tCaptureClientKind,\n\tCaptureSlot,\n\tResolvedAutoCapture,\n\tTrackerSkip,\n} from '../tracker/config'\nimport type { TranslationsOption } from '../translations'\nimport { keys, pluralKeys } from '../translations/keys'\nimport type { CustomWidgetDef } from '../widgets/customWidget'\nimport { resolveCountryFlags, resolveView, resolveWidgets } from './adminOptions'\nimport { resolveCache, resolveHooks, resolveSync } from './cacheOptions'\nimport { resolveCapture, resolveTrust } from './captureOptions'\nimport type {\n\tAnalyticsCollectionOptions,\n\tCollectionOverrides,\n\tResolvedCollectionOption,\n\tResolvedScopedCollection,\n} from './collectionOption'\nimport type { AnalyticsAdapter, MetricKey } from './contract'\nimport type { FetchLike } from './fetch'\nimport { resolveGoals, resolveRevenue } from './goalOptions'\nimport { type AnalyticsJobsOptions, assertJobsFit, type ResolvedJobs, resolveJobs } from './jobs'\nimport { assertNoLegacyOptions } from './legacyOptions'\nimport {\n\tflatFieldName,\n\tkeysOf,\n\toptionalBoolean,\n\toptionalFunction,\n\toptionsObject,\n} from './optionChecks'\nimport { assertScopedOnlyOptions, resolveAccess, resolveScope } from './scopeOptions'\nimport { type AnalyticsSdks, resolveSdks } from './sdks'\nimport { assertAdapters, assertNamesAdapter, resolveProviders } from './sourceOptions'\nimport {\n\ttype AnalyticsSourceOptions,\n\ttype DefaultSourceRule,\n\ttype ResolvedSources,\n\tresolveSources,\n} from './sourcePolicy'\nimport { isRecord, kindOf, listOf } from './values'\nimport type { BuiltInWidgetSlug } from './widgetSlugs'\n\nexport { DEFAULT_VIEW } from './adminOptions'\nexport { fillableSlots, trackerAutoCapture, untrustedAddressNotice } from './captureOptions'\nexport type { AnalyticsCollectionOptions, CollectionOverrides } from './collectionOption'\nexport { revenueOffWarning } from './goalOptions'\nexport type { AnalyticsJobsOptions, AnalyticsTaskOptions } from './jobs'\nexport { allCrossScope } from './scopeOptions'\nexport type {\n\tAnalyticsSourceOptions,\n\tDefaultSourceFunction,\n\tDefaultSourceRule,\n\tOwnSource,\n\tResolvedSources,\n\tSourcePolicy,\n\tSourcePolicyFunction,\n\tSourceRef,\n} from './sourcePolicy'\nexport type { CurrencyConverter }\n\n/** The multi-tenant plugin's own relationship field, which a scoped install almost always has. */\nexport const DEFAULT_BINDING_SCOPE_FIELD = 'tenant'\n\n/**\n * Who asks for a request's scope: `capture` files a visitor's hit and carries no user or cookies,\n * so it resolves from the host; `admin` is every signed-in read or edit.\n */\nexport type ScopeCallSite = 'capture' | 'admin'\n\n/**\n * Maps a request to the scope it selected (tenant id, site key), null for the whole install;\n * whether its user may act there is `scope.member`. `'*'` is refused.\n */\nexport type ScopeResolver = (args: {\n\treq: PayloadRequest\n\tcallSite: ScopeCallSite\n}) => string | null | Promise<string | null>\n\n/**\n * Lists the tenant scopes the sync task runs over, in addition to the install-wide scope it always\n * covers. Warming needs no list: it repeats the reads each scope's readers made.\n */\nexport type ScopeListResolver = (args: { payload: Payload }) => string[] | Promise<string[]>\n\n/**\n * Names a scope on screen, so a tenant admin reads a name rather than an id in the view's caption.\n * Undefined keeps the id.\n */\nexport type ScopeLabelResolver = (args: {\n\treq: PayloadRequest\n\tscope: string\n}) => string | undefined | Promise<string | undefined>\n\n/** Whether the request's user belongs to `scope`, as opposed to having merely selected it. */\nexport type ScopeMemberAccess = (args: {\n\treq: PayloadRequest\n\tscope: string\n}) => boolean | Promise<boolean>\n\n/** How the install divides its analytics into tenants. Unset, the install is one scope. */\nexport type AnalyticsScopeOptions = {\n\tresolve: ScopeResolver\n\t/**\n\t * Whether the request's user belongs to the scope `resolve` selected, asked on every read and\n\t * config write. `tenantMembership()` reads the multi-tenant plugin's tenants.\n\t */\n\tmember: ScopeMemberAccess\n\tlist?: ScopeListResolver\n\tlabel?: ScopeLabelResolver\n}\n\n/**\n * Resolves a scope's IANA reporting timezone, also asked at ingest without the user or cookies.\n * Null means UTC.\n */\nexport type TimezoneResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string | null | Promise<string | null>\n\n/**\n * Resolves a scope's ISO 4217 revenue currency, so each tenant can have its own. Undefined reports\n * revenue as a plain number.\n */\nexport type CurrencyResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string | undefined | Promise<string | undefined>\n\n/**\n * How the install measures money once `revenue` turns it on. Off hides every money surface but\n * keeps stored data, so turning it on later reports the history.\n */\nexport type AnalyticsRevenueOptions = {\n\t/**\n\t * ISO 4217 currency revenue is reported in, or a resolver per tenant. Unset, amounts are summed\n\t * as sent and a mix of currencies is flagged in `meta.mixedCurrencies`.\n\t */\n\tcurrency?: string | CurrencyResolver\n\t/**\n\t * FX hook native ingest calls when an event's currency differs from `currency`. Without it such\n\t * an amount stays out of revenue, though the conversion still counts.\n\t */\n\tconvert?: CurrencyConverter\n\t/**\n\t * The `currency` breakdown dimension, keyed by the currency each amount was sent in. Default: on\n\t * while no `convert` hook is set.\n\t */\n\tdimension?: boolean\n\t/**\n\t * How far native ingest trusts an amount a browser sends, which anyone can forge. `'fixed'`\n\t * (default) prefers a goal's fixed value, `'none'` ignores it, `'trust'` prefers it.\n\t */\n\tbrowserAmounts?: BrowserAmounts\n\t/**\n\t * Whether native ingest takes an order id sent without the server's `signOrderId` signature.\n\t * `'optional'` (default) takes it; `'required'` answers an unsigned one with `400`.\n\t */\n\torderSignature?: OrderSignatureMode\n}\n\n/** What `providers.resolve` is handed for one scope. */\nexport interface ProvidersResolveArgs {\n\tpayload: Payload\n\treq?: PayloadRequest\n\tscope: string | null\n\t/**\n\t * The runtime's guarded fetch: every address a vendor's host resolves to has to be public, on\n\t * every connection and every redirect. Hand it to `adapterFromProviderDoc`.\n\t */\n\tfetch: FetchLike\n\t/**\n\t * The hosts a document may name: each vendor's own cloud, plus `providers.hosts`. Hand it to\n\t * `adapterFromProviderDoc` with `fetch`, which reaches a private network only when it allows one.\n\t */\n\thosts: ProviderHostPolicy\n\t/** The plugin's `sdks`, which a GA4 document's adapter reads through. */\n\tsdks: AnalyticsSdks\n}\n\n/**\n * Replaces the providers collection lookup with a scope's adapters, uncached. Build each with\n * `adapterFromProviderDoc(row, { fetch, hosts, sdks })` so a stored key reaches allowed hosts only.\n */\nexport type ProvidersResolve = (\n\targs: ProvidersResolveArgs\n) => AnalyticsAdapter[] | Promise<AnalyticsAdapter[]>\n\n/**\n * Where provider documents may point. Each vendor's own cloud is always allowed: Plausible, Umami\n * Cloud, and PostHog's US and EU regions.\n */\nexport type ProviderHostsOptions = {\n\t/**\n\t * Origins a document's host may name besides its vendor's cloud, such as `https://*.example.com`;\n\t * no paths. A host outside them reads as `source_misconfigured`.\n\t */\n\tallow?: string[]\n\t/**\n\t * Lets document adapters reach any address over http or https, private networks included (Umami\n\t * on the same Docker network). Default off.\n\t */\n\tallowPrivateNetwork?: boolean\n}\n\nexport type ProvidersCollectionOptions = {\n\tslug?: string\n\t/**\n\t * Field matched against the resolved scope when looking up a scope's providers. Default `scope`;\n\t * name a tenant plugin's field (`tenant`) when that plugin scopes the collection.\n\t */\n\tscopeField?: string\n\t/**\n\t * Replaces one of the collection's own fields, each handed the plugin's default. Applied before\n\t * `overrides`.\n\t */\n\tfields?: ProviderCollectionFieldOverrides\n\t/**\n\t * Reshapes the whole config last. It may not rename the collection (`slug` does) nor turn off\n\t * its timestamps, which every instance notices a saved document by: the boot refuses both.\n\t */\n\toverrides?: CollectionOverrides\n\taccess?: Partial<CollectionConfig['access']>\n\t/**\n\t * Dedicated key ring for stored provider credentials. Unset, the fields plugin's `encrypted.keys`\n\t * applies, else a ring derived from the Payload secret, fit for dev only.\n\t */\n\tencryption?: { keys?: KeysConfig }\n\t/**\n\t * Who may set or change where a document connects (provider, host, ids); a denied value is\n\t * dropped. Default: the creator, then `access.crossScope.named` when scoped, else update access.\n\t */\n\tconnectionAccess?: ConnectionAccess\n\t/**\n\t * Who may set or change a scoped install's \"Default for this site\" checkbox; a denied value is\n\t * dropped. Default: `connectionAccess`, else its default (the creator, then `crossScope.named`).\n\t */\n\tdefaultAccess?: ConnectionAccess\n\t/**\n\t * Which provider types documents may have, the first being the select's default; the select lists\n\t * them in a fixed order. Default: every type, `native` only while `adapters` holds native().\n\t */\n\ttypes?: ProviderId[]\n\t/**\n\t * Which provider documents a reader reads analytics through, as collection access ANDed with\n\t * enabled and scope. Default: the collection's own read access.\n\t */\n\tsourceAccess?: Access\n}\n\nexport type ProvidersOptions = {\n\t/** Opt-in admin collection storing runtime provider configurations. */\n\tcollection?: boolean | ProvidersCollectionOptions\n\t/** Replaces the collection: the two cannot both be set. */\n\tresolve?: ProvidersResolve\n\t/** Where the documents of either one may point. Needs `collection` or `resolve`. */\n\thosts?: ProviderHostsOptions\n}\n\n/** Access checker for authenticated analytics reads. */\nexport type AnalyticsReadAccess = (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\n/** Access checker for the analytics admin view. */\nexport type AnalyticsViewAccess = (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\n/**\n * Access checker for one of the cross-scope gates under `access.crossScope`, told what is asked\n * where the read knows it: the scope (`'*'` or null for every scope) and, for `unscopedSource`, the adapter.\n */\nexport type CrossScopeAccess = (args: {\n\treq: PayloadRequest\n\tscope?: string | null\n\tadapterId?: string\n}) => boolean | Promise<boolean>\n\n/**\n * The three ways a reader on a scoped install reaches past their own scope, each denied by default.\n * Split so platform staff can aggregate without singling out one tenant.\n */\nexport type AnalyticsCrossScopeOptions = {\n\t/**\n\t * Reading a scope the request does not resolve to, by naming it. Also decides who manages other\n\t * tenants' provider, goal and sync documents.\n\t */\n\tnamed?: CrossScopeAccess\n\t/** Reading every scope at once: the `'*'` marker, and a scoped install's null scope. */\n\taggregate?: CrossScopeAccess\n\t/**\n\t * Reading a tenant through a shared config adapter that cannot narrow its query to one scope.\n\t * Also decides whether such an adapter is listed as a source at all.\n\t */\n\tunscopedSource?: CrossScopeAccess\n}\n\nexport type AnalyticsAccessOptions = {\n\t/**\n\t * Gates every read: endpoints, dashboard widgets and display fields. Default `isAdminUser` (the\n\t * `admin.user` collection); scope gating applies on top and is never widened by it.\n\t */\n\tread?: AnalyticsReadAccess\n\t/**\n\t * Gates the analytics admin view. Default: `read`. A denied reader still sees the nav link and\n\t * lands on the view's no-access message.\n\t */\n\tview?: AnalyticsViewAccess\n\t/**\n\t * Reads past the request's own scope, scoped installs only: a function grants all three gates,\n\t * the object form each one (unset denies). Unscoped, all three open to `isAdminUser`.\n\t */\n\tcrossScope?: CrossScopeAccess | AnalyticsCrossScopeOptions\n}\n\n/** The three cross-scope gates, each filled. */\nexport type ResolvedCrossScope = Record<ScopeDecision, CrossScopeAccess>\n\n/** What `capture.gate` is asked about one capture slot. */\nexport interface CaptureGateArgs {\n\tslot: CaptureSlot\n\t/** The adapter filling the slot for this request. */\n\tadapterId: string\n\tkind: CaptureClientKind\n}\n\n/**\n * Which capture slots wait for the host's consent manager: `'all'`, `'off'`, a list of slots, or a\n * function answering per slot (true waits).\n */\nexport type CaptureGate = 'all' | 'off' | CaptureSlot[] | ((args: CaptureGateArgs) => boolean)\n\n/** `capture.gate` resolved: whether one slot, filled by one adapter, waits. */\nexport type CaptureGatePolicy = (args: CaptureGateArgs) => boolean\n\n/** An adapter id to fill a capture slot with, or `false` to leave it deliberately empty. */\nexport type CaptureSlotOption = string | false\n\n/** What the tracker and ingest do with elements marked by `itemAttributes`. */\nexport type ItemCaptureOptions = {\n\t/** Count an item as seen once at least half of it stays on screen for a second. */\n\timpressions?: boolean\n\t/** Send `item_click` for the first click on an item during a pageview. */\n\tclicks?: boolean\n\t/** Also count an item per page it appeared on, beside its own total. */\n\tpages?: boolean\n}\n\nexport type AutoCaptureOptions = {\n\tscrollDepth?: boolean\n\toutboundLinks?: boolean\n\tfileDownloads?: boolean\n\tgoalAttribute?: boolean\n\t/**\n\t * Send each pageview's query string so ingest can extract its utm keys. The raw query is\n\t * never stored, only the five campaign values; set false to stop sending it at all.\n\t */\n\tquery?: boolean\n\t/**\n\t * Content items, on by default and inert until a page marks an element with `itemAttributes`.\n\t * `false` turns them off, crediting goals to items included.\n\t */\n\titems?: false | ItemCaptureOptions\n}\n\nexport type AnalyticsGoalsCollectionOptions = {\n\tslug?: string\n\t/**\n\t * Field matched against the resolved scope when looking up a scope's goals. Point it at\n\t * a tenant plugin's field (e.g. 'tenant') when that plugin manages scoping.\n\t */\n\tscopeField?: string\n\t/**\n\t * Replaces one of the collection's own fields, each handed the plugin's default; applied before\n\t * `overrides`. A `slug` replacement must keep a field named `slug` or the boot fails.\n\t */\n\tfields?: GoalCollectionFieldOverrides\n\t/**\n\t * Reshapes the whole config last. It may not rename the collection (`slug` does) nor turn off\n\t * its timestamps, which every instance notices a saved document by: the boot refuses both.\n\t */\n\toverrides?: CollectionOverrides\n\taccess?: Partial<CollectionConfig['access']>\n}\n\n/** Goals as config, plus the opt-in collection editors manage their own goals through. */\nexport type AnalyticsGoalsOptions = {\n\tdefaults?: Goal[]\n\t/** Opt-in admin collection whose goals merge over `defaults`, by slug, per scope. */\n\tcollection?: boolean | AnalyticsGoalsCollectionOptions\n\t/**\n\t * The built-in `purchase` goal sales book against, on unless a configured goal claims that slug.\n\t * `false` removes it, for an install that never sells.\n\t */\n\tpurchase?: boolean\n}\n\n/**\n * The website addresses where the scope's tracker runs, one per site, each an `http(s)` origin with\n * an optional path. May be async; scope is null on an unscoped install.\n */\nexport type ExclusionSitesResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string[] | Promise<string[]>\n\n/** The signed link staff open to leave their own browser out of the numbers. */\nexport type AnalyticsExclusionOptions = {\n\t/**\n\t * The query parameter the tracker reads. Default `analytics_exclude`. Letters, digits, `.`,\n\t * `_`, `~` and `-`, at most 64 of them.\n\t */\n\tparam?: string\n\t/**\n\t * Website addresses where the tracker runs, one per site, for the view to link to: a list, or\n\t * a per-scope function (async allowed). Unset, the view hands out only the query to append.\n\t */\n\tsites?: string[] | ExclusionSitesResolver\n}\n\nexport type AnalyticsCaptureOptions = {\n\t/**\n\t * Which capture slots wait for the host's consent manager. Required whenever a slot can fill:\n\t * whether tracking needs consent is the operator's call, so there is no default.\n\t */\n\tgate?: CaptureGate\n\t/**\n\t * Exact origins of other sites (`https://shop.example.com`, no path or wildcard) whose pages may\n\t * send to ingest and the capture proxy. Unset, only the site and its subdomains can.\n\t */\n\tallowedOrigins?: string[]\n\t/**\n\t * The signed link staff open to leave their browser out of the numbers. Off by default; `true`\n\t * turns it on as `analytics_exclude`, an object renames it through `param`.\n\t */\n\texclusion?: boolean | AnalyticsExclusionOptions\n\t/**\n\t * Which adapter fills each slot (`global`: `platformAdapter` or the only adapter; `tenant`: the\n\t * scope's default). `false` leaves a slot empty: no proxy mount, no tracker entry.\n\t */\n\tslots?: { global?: CaptureSlotOption; tenant?: CaptureSlotOption }\n\t/**\n\t * Mount each slot's snippet points at. Default: the runtime proxy endpoint; set it to a\n\t * `captureRoute` handler's path, without the Next `basePath`, which the tracker config adds.\n\t */\n\tpaths?: { global?: string; tenant?: string }\n\t/** Browser auto-capture listeners, all on by default except `scrollDepth`. */\n\tautoCapture?: AutoCaptureOptions\n\t/**\n\t * Pages the tracker leaves uncounted, each on unless false: `automation` (`navigator.webdriver`;\n\t * turn it off for e2e suites asserting on hits) and `previews` (draft mode, live preview).\n\t */\n\tskip?: { automation?: boolean; previews?: boolean }\n\t/** Limits for the public runtime capture proxy, separate from the read-path `cache`. */\n\tproxy?: {\n\t\t/**\n\t\t * Deadline for the upstream response headers, in ms. Default 10000. The body\n\t\t * download is not on the clock, so a large tracker bundle streams to completion.\n\t\t */\n\t\ttimeoutMs?: number\n\t\t/**\n\t\t * Largest proxied request body, in bytes. Default 1 MiB, which clears a PostHog\n\t\t * batch carrying session-replay data. Anything larger is refused with 413.\n\t\t */\n\t\tmaxBodyBytes?: number\n\t}\n}\n\nexport type AnalyticsViewOptions = {\n\t/** Admin path the view mounts at, under `routes.admin`. Default `/analytics`. */\n\tpath?: `/${string}`\n\t/** Timeframe the view opens on before the URL says otherwise. Default `last30days`. */\n\tdefaultRange?: TimeframePreset\n\t/** Metric the cards and the trend open on. Default `pageviews`. */\n\tdefaultMetric?: MetricKey\n\t/**\n\t * Nav link label. A string is used as-is; a map is keyed by admin language code and\n\t * falls back to `en`. Unset, the plugin's own translated label applies.\n\t */\n\tnavLabel?: string | Record<string, string>\n\t/**\n\t * Whether the view adds its link to the admin sidebar. Default true; false mounts the view\n\t * without one, for a host that links it from its own navigation.\n\t */\n\tnavLink?: boolean\n\t/**\n\t * A client component replacing the view's body under the same server shell, given\n\t * `AnalyticsViewClientProps`; compose it from the sections `@10x-media/analytics/client` exports.\n\t *\n\t * @beta\n\t */\n\tComponent?: AnalyticsComponent\n}\n\nexport interface ResolvedView {\n\tpath: `/${string}`\n\tdefaultRange: TimeframePreset\n\tdefaultMetric: MetricKey\n\tnavLabel?: string | Record<string, string>\n\tnavLink: boolean\n\tComponent?: AnalyticsComponent\n}\n\n/**\n * A component a host puts in one of the plugin's places, as Payload takes one: an import-map path\n * such as `'/components/Flag#Flag'`, or the object form with its export and props.\n *\n * @beta\n */\nexport type AnalyticsComponent = string | RawPayloadComponent\n\n/**\n * How a host changes one built-in dashboard widget.\n *\n * @beta\n */\nexport interface AnalyticsWidgetOverride {\n\t/**\n\t * Rendered in place of the plugin's own component. A server component receives the full widget\n\t * props, a client component its `clientProps` alone.\n\t */\n\tComponent?: AnalyticsComponent\n\t/** The widget's name in the dashboard's widget list. */\n\tlabel?: Widget['label']\n\t/**\n\t * The widget's settings, given the plugin's own fields as `defaultFields`, the shape Payload's\n\t * form builder and search plugins take; what it returns is the form.\n\t */\n\tfields?: (args: { defaultFields: Field[] }) => Field[]\n}\n\n/** @beta */\nexport type AnalyticsWidgetOverrides = Partial<Record<BuiltInWidgetSlug, AnalyticsWidgetOverride>>\n\n/** @beta */\nexport interface AnalyticsWidgetsOptions {\n\tdisabled?: string[]\n\tregister?: CustomWidgetDef[]\n\t/**\n\t * Marks each widget's free-text Title field `localized`. Default off; takes effect only when the\n\t * Payload config enables localization.\n\t */\n\tlocalizeText?: boolean\n\t/**\n\t * Period-over-period comparison on the metric and trend widgets. Default on, except for a source\n\t * whose adapter sets `capabilities.comparison` false; `false` skips the second read.\n\t */\n\tcomparison?: boolean\n\t/** Built-in widgets changed by slug: their component, their name, their settings. */\n\toverrides?: AnalyticsWidgetOverrides\n}\n\n/**\n * `countryFlags` with a flag of the host's own.\n *\n * @beta\n */\nexport interface AnalyticsCountryFlags {\n\t/**\n\t * A client component drawing one flag from `{ code }`, an ISO 3166-1 alpha-2 code in capitals.\n\t * Registered through `admin.dependencies`, so `payload generate:importmap` picks it up.\n\t */\n\tComponent: AnalyticsComponent\n}\n\n/** The collection the sync job persists daily metrics into: `slug` defaults to `analytics-daily`. */\nexport type AnalyticsSyncCollectionOptions = AnalyticsCollectionOptions & {\n\t/** Keeps the collection out of the admin nav. Default true. */\n\thidden?: boolean\n}\n\n/** The read cache's collection: `slug` defaults to `analytics-cache`. */\nexport type AnalyticsCacheCollectionOptions = AnalyticsCollectionOptions\n\n/** What `analytics-sync` copies; when it runs is `jobs.tasks.sync`. */\nexport type AnalyticsSyncOptions = {\n\t/** Days each run reads back, today counted. Default 3. */\n\tlookbackDays?: number\n\t/**\n\t * The sources it copies: a config adapter's id, or a provider type for every source built from\n\t * provider documents of that type. Default every vendor source.\n\t */\n\tadapters?: string[]\n\tcollection?: AnalyticsSyncCollectionOptions\n}\n\n/** How much reads may ask of their sources at once (`cache.concurrency`). */\nexport type AnalyticsConcurrencyOptions = {\n\t/** Requests in flight across every vendor source of one instance. Default 16. */\n\tglobal?: number\n\t/** Requests in flight per vendor source that declares no `rateLimit.maxConcurrent`. Default 4. */\n\tperSource?: number\n\t/** Reads with nothing cached one scope may have waiting on its sources. Default 8. */\n\tperScope?: number\n}\n\n/** How reads are cached, how long they wait for their sources, and which are kept warm. */\nexport type AnalyticsCacheOptions = {\n\t/**\n\t * Seconds an answer stays fresh; unset, each adapter's `recommendedTtl` applies. A native read\n\t * whose window reaches into today stays fresh 10 seconds at most whatever this says.\n\t */\n\tttl?: { aggregate?: number; realtime?: number }\n\t/**\n\t * Keeps recently asked reads warm: `analytics-warm` rereads each shortly before its cached answer\n\t * expires. Default off; `true` uses the defaults. Scheduled by `jobs.tasks.warm`.\n\t */\n\twarm?: boolean | AnalyticsWarmOptions\n\t/**\n\t * How long a read waits for its source, in ms, retries included. Default 15000. Only a read with\n\t * nothing cached (and sync) waits; others answer an expired entry at once.\n\t */\n\ttimeoutMs?: number\n\t/**\n\t * How much reads may ask of their sources at once; past `perScope` the query endpoint answers\n\t * 429. Native reads have a lane of their own outside these: 8, or on Postgres a third of\n\t * `pool.max`, between 1 and 8.\n\t */\n\tconcurrency?: AnalyticsConcurrencyOptions\n\t/**\n\t * Where reads are cached across requests and instances. Default: the `analytics-cache`\n\t * collection; a self-expiring store (Redis) replaces it. Live counts stay in memory.\n\t */\n\tstore?: CacheStore\n\t/** The `analytics-cache` collection of the default store; refused beside `store`. */\n\tcollection?: AnalyticsCacheCollectionOptions\n}\n\n/** Hooks into what the plugin does. */\nexport type AnalyticsHooksOptions = {\n\t/**\n\t * Runs once for every read answered to a reader, after it is cached, to observe it or answer\n\t * that one read differently. See {@link AfterReadHook} for the contract.\n\t */\n\tafterRead?: AfterReadHook\n}\n\n/** Which reads `analytics-warm` keeps warm; when it runs is `jobs.tasks.warm`. */\nexport type AnalyticsWarmOptions = {\n\t/** Reads asked for in this many hours count as recent. Default 24. */\n\twindowHours?: number\n\t/** The most reads one run refreshes, most recently read first. Default 200. */\n\tmaxReads?: number\n}\n\n/** Where the plugin's endpoints answer. */\nexport type AnalyticsRoutesOptions = {\n\t/**\n\t * The path every plugin endpoint hangs off, under `routes.api`. Default `/_x`; the boot fails\n\t * when a collection slug is its first segment, which would swallow those requests.\n\t */\n\tbase?: RouteBase\n}\n\nexport type AnalyticsPluginOptions = {\n\t/**\n\t * Switches the plugin off but keeps its schema (collections, fields, indexes, task slugs), so\n\t * nothing is dropped. No endpoint, view, widget or task work runs; options are still checked.\n\t */\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for the plugin's UI strings, keyed by `@10x-media/analytics/i18n` keys.\n\t * They win per key over built-ins; app `i18n.translations` wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\tadapters: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\t/**\n\t * Id of one config adapter shared by every scope (the platform's own analytics). Reading a tenant\n\t * through it needs `access.crossScope.unscopedSource` unless it supports scoped queries.\n\t */\n\tplatformAdapter?: string\n\t/** Tenancy: how a request maps to its scope. Unset, the whole install is one scope. */\n\tscope?: AnalyticsScopeOptions\n\t/**\n\t * Per shared config adapter, keyed by its id: which tenant users besides platform staff\n\t * (`access.crossScope.unscopedSource`) read their own tenant through it. Scoped installs only.\n\t */\n\tsources?: Record<string, AnalyticsSourceOptions>\n\t/**\n\t * A tenant scope's default source when none of its provider documents is flagged the default.\n\t * Unset keeps the registry's own order. Scoped installs only.\n\t */\n\tdefaultSource?: DefaultSourceRule\n\t/**\n\t * IANA timezone days are cut in. Default UTC; a resolver answers per scope. After a change,\n\t * native recounts in the new zone only days whose raw hits it still keeps.\n\t */\n\treportingTimezone?: string | TimezoneResolver\n\t/**\n\t * Money as a capability. `false` or unset measures none; `true` measures it with the\n\t * defaults; an object turns it on and says in which currency, and how.\n\t */\n\trevenue?: boolean | AnalyticsRevenueOptions\n\t/**\n\t * How many proxies to trust, counted from the right of `x-forwarded-for`, when reading a client\n\t * address. Unset keeps the leftmost entry, which the client controls. Not with `trustedPlatform`.\n\t */\n\ttrustedProxyHops?: number\n\t/**\n\t * Platform (`'vercel'` or `'cloudflare'`) whose edge headers carry the visitor's address and\n\t * location. Set it only when every request passes through it, or the headers can be forged.\n\t */\n\ttrustedPlatform?: TrustedPlatform\n\taccess?: AnalyticsAccessOptions\n\tcapture?: AnalyticsCaptureOptions\n\t/**\n\t * Conversion goals the tracker and native ingest match events against: a list, or `{ defaults,\n\t * collection, purchase }`. A goal's name never reaches the browser.\n\t */\n\tgoals?: Goal[] | AnalyticsGoalsOptions\n\t/**\n\t * Per-collection bindings, keyed by collection slug. With generated types\n\t * augmented, each slug's resolvers receive that collection's typed document.\n\t */\n\tcollections?: { [TSlug in CollectionSlug]?: AnalyticsBinding<TSlug> }\n\tproviders?: ProvidersOptions\n\t/**\n\t * The analytics admin view and its nav link, on by default. `false` registers neither;\n\t * the read endpoints stay mounted either way, so a custom surface keeps working.\n\t */\n\tview?: false | AnalyticsViewOptions\n\t/**\n\t * Dashboard widgets, on by default. Payload's dashboard is experimental, so this option is too.\n\t *\n\t * @beta\n\t */\n\twidgets?: boolean | AnalyticsWidgetsOptions\n\t/**\n\t * Flag beside country names in the view, widgets and document panel. Default on, served by the\n\t * plugin's cached route; `false` shows none, `{ Component }` draws the host's own.\n\t *\n\t * @beta\n\t */\n\tcountryFlags?: boolean | AnalyticsCountryFlags\n\tcache?: AnalyticsCacheOptions\n\t/**\n\t * Opt-in sync tier: `analytics-sync` copies each vendor source's daily metrics into a queryable\n\t * collection, every six hours unless `jobs.tasks.sync` says otherwise.\n\t */\n\tsync?: boolean | AnalyticsSyncOptions\n\troutes?: AnalyticsRoutesOptions\n\t/**\n\t * The plugin's tasks (maintain, sync, warm) on `jobs.queue`, scheduled by `jobs.tasks`. `false`\n\t * registers none: reads and ingest then do native upkeep, and sync or warming is refused.\n\t */\n\tjobs?: false | AnalyticsJobsOptions\n\t/**\n\t * Optional packages handed in, which a standalone or serverless build then ships: GA4's\n\t * `{ BetaAnalyticsDataClient }` and MaxMind's `{ open }`. A production boot warns about one missing.\n\t */\n\tsdks?: AnalyticsSdks\n\thooks?: AnalyticsHooksOptions\n}\n\n/** `capture.exclusion` while the link is on. */\nexport interface ResolvedExclusion {\n\tparam: string\n\t/** `sites`, a list made a function answering it; absent when the install names none. */\n\tsites?: ExclusionSitesResolver\n}\n\nexport interface ResolvedCapture {\n\tslots: { global?: CaptureSlotOption; tenant?: CaptureSlotOption }\n\tpaths: { global?: string; tenant?: string }\n\tgate: CaptureGatePolicy\n\tautoCapture: ResolvedAutoCapture\n\tproxy: { timeoutMs: number; maxBodyBytes: number }\n\t/** `allowedOrigins`, each as a browser writes it in `Origin`. */\n\tallowedOrigins: ReadonlySet<string>\n\t/** The exclusion link's parameter and site addresses, or false while the link is off. */\n\texclusion: false | ResolvedExclusion\n\tskip: TrackerSkip\n}\n\nexport interface ResolvedRevenue {\n\t/** Whether the install measures money at all. Every money surface reads this one answer. */\n\tenabled: boolean\n\t/** Raw currency option; the plugin normalizes it into a resolver. */\n\tcurrency?: string | CurrencyResolver\n\tconvert?: CurrencyConverter\n\t/** Whether native declares the `currency` dimension; always false while money is off. */\n\tdimension: boolean\n\tbrowserAmounts: BrowserAmounts\n\torderSignature: OrderSignatureMode\n}\n\nexport interface ResolvedScope {\n\t/** The host's resolver with `'*'` refused; resolves null for every request when unscoped. */\n\tresolve: ScopeResolver\n\tlist?: ScopeListResolver\n\tlabel?: ScopeLabelResolver\n\t/** Present exactly when the install is scoped. */\n\tmember?: ScopeMemberAccess\n}\n\nexport interface ResolvedOptions {\n\tadapters: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\tscope: ResolvedScope\n\t/** True when the app configured `scope.resolve` (scoped install). */\n\tscoped: boolean\n\t/** Raw `reportingTimezone`, a string already validated; the runtime makes it a resolver. */\n\treportingTimezone?: string | TimezoneResolver\n\trevenue: ResolvedRevenue\n\tplatformAdapter?: string\n\t/** `sources` and `defaultSource`; no policies and no rule on an unscoped install. */\n\tsources: ResolvedSources\n\t/** Raw trustedProxyHops option; undefined keeps the leftmost forwarded-for entry. */\n\ttrustedProxyHops?: number\n\t/** The platform whose edge headers are believed; undefined believes none. */\n\ttrustedPlatform?: TrustedPlatform\n\taccess: {\n\t\tread: AnalyticsReadAccess\n\t\tview: AnalyticsViewAccess\n\t\tcrossScope: ResolvedCrossScope\n\t}\n\t/** The admin view, filled with its defaults, or false when the app turned it off. */\n\tview: false | ResolvedView\n\t/** `true` the plugin's own flags, `false` none, or the host's component. */\n\tcountryFlags: boolean | AnalyticsCountryFlags\n\tcapture: ResolvedCapture\n\t/** Config goals, validated; the goals collection layers its own on top of these. */\n\tgoals: Goal[]\n\t/** `goals.purchase`: whether the resolver adds the built-in `purchase` goal. */\n\tpurchaseGoal: boolean\n\tgoalsCollection: ResolvedScopedCollection<GoalCollectionFieldOverrides>\n\tproviders: {\n\t\tcollection: ResolvedScopedCollection<ProviderCollectionFieldOverrides> & {\n\t\t\tencryption?: { keys?: KeysConfig }\n\t\t\tconnectionAccess?: ConnectionFieldAccess\n\t\t\tdefaultAccess?: ConnectionFieldAccess\n\t\t\t/** The types the install serves, `types` applied; filled whether the collection is on or not. */\n\t\t\ttypes: readonly ProviderId[]\n\t\t\tsourceAccess?: Access\n\t\t}\n\t\tresolve?: ProvidersResolve\n\t\t/** `providers.hosts`, for the collection's documents and the rows `resolve` reads alike. */\n\t\thosts: ProviderHostPolicy\n\t}\n\t/** Each binding with its `scopeField` filled. */\n\tbindings: Record<string, ResolvedBinding>\n\tcache: {\n\t\t/** Undefined when unset: adapter recommendedTtl is the fallback, an explicit value wins. */\n\t\tttl: { aggregate?: number; realtime?: number }\n\t\twarm: { enabled: boolean; windowHours: number; maxReads: number }\n\t\ttimeoutMs: number\n\t\tconcurrency: { global: number; perSource: number; perScope: number }\n\t\t/** The host's store; absent, the `analytics-cache` collection is the store. */\n\t\tstore?: CacheStore\n\t\t/** The default store's collection, used only while `store` is absent. */\n\t\tcollection: ResolvedCollectionOption\n\t}\n\twidgets: {\n\t\tenabled: boolean\n\t\tdisabled: string[]\n\t\tregister: CustomWidgetDef[]\n\t\tlocalizeText: boolean\n\t\tcomparison: boolean\n\t\toverrides: AnalyticsWidgetOverrides\n\t}\n\tsync: {\n\t\tenabled: boolean\n\t\tlookbackDays: number\n\t\tadapters?: string[]\n\t\tcollection: ResolvedCollectionOption & {\n\t\t\thidden: boolean\n\t\t}\n\t}\n\troutes: { base: RouteBase }\n\tjobs: ResolvedJobs\n\tsdks: AnalyticsSdks\n\thooks: { afterRead?: AfterReadHook }\n}\n\nconst PLUGIN_KEYS = keysOf<AnalyticsPluginOptions>({\n\tdisabled: true,\n\ttranslations: true,\n\tadapters: true,\n\tdefaultAdapter: true,\n\tplatformAdapter: true,\n\tscope: true,\n\tsources: true,\n\tdefaultSource: true,\n\treportingTimezone: true,\n\trevenue: true,\n\ttrustedProxyHops: true,\n\ttrustedPlatform: true,\n\taccess: true,\n\tcapture: true,\n\tgoals: true,\n\tcollections: true,\n\tproviders: true,\n\tview: true,\n\twidgets: true,\n\tcountryFlags: true,\n\tcache: true,\n\tsync: true,\n\troutes: true,\n\tjobs: true,\n\tsdks: true,\n\thooks: true,\n})\nconst ROUTES_KEYS = keysOf<AnalyticsRoutesOptions>({ base: true })\nconst BINDING_KEYS = keysOf<AnalyticsBinding>({\n\tpath: true,\n\tpathField: true,\n\thostname: true,\n\titem: true,\n\tscopeField: true,\n})\n\n/** Every key the plugin's own translations override, singular and plural forms alike. */\nconst TRANSLATION_KEYS: ReadonlySet<string> = new Set<string>([\n\t...Object.values(keys),\n\t...Object.values(pluralKeys).flatMap((forms) => Object.values(forms)),\n])\n\n/** `translations`: per language, strings keyed by the plugin's own translation keys. */\nconst assertTranslations = (option: unknown): void => {\n\tif (option === undefined) {\n\t\treturn\n\t}\n\tif (!isRecord(option) || Array.isArray(option)) {\n\t\tthrow new Error(\n\t\t\t`analytics: translations must be an object keyed by language, such as { de: { 'analytics:viewTitle': 'Statistik' } }, got ${kindOf(option)}`\n\t\t)\n\t}\n\tfor (const [language, strings] of Object.entries(option)) {\n\t\tif (!isRecord(strings) || Array.isArray(strings)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: translations.${language} must be an object of strings keyed by translation key, got ${kindOf(strings)}`\n\t\t\t)\n\t\t}\n\t\tfor (const [key, text] of Object.entries(strings)) {\n\t\t\tif (!TRANSLATION_KEYS.has(key)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`analytics: translations.${language}[\"${key}\"] is not one of the plugin's translation keys, which @10x-media/analytics/i18n exports as keys`\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (text !== undefined && typeof text !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`analytics: translations.${language}[\"${key}\"] must be a string, got ${kindOf(text)}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** `reportingTimezone`: an IANA name checked at boot, or a resolver answering per scope. */\nconst assertTimezone = (option: unknown): void => {\n\tif (option !== undefined && typeof option !== 'string' && typeof option !== 'function') {\n\t\tthrow new Error(\n\t\t\t`analytics: reportingTimezone must be an IANA timezone or a function, got ${kindOf(option)}`\n\t\t)\n\t}\n\tif (typeof option === 'string' && !isValidTimeZone(option)) {\n\t\tthrow new Error(\n\t\t\t`analytics: reportingTimezone \"${option}\" is not an IANA timezone name, such as \"Europe/Berlin\"`\n\t\t)\n\t}\n}\n\n/** One `collections` entry: how a bound document's page is found, and whether it is an item. */\nconst assertBinding = (binding: unknown, slug: string): void => {\n\tconst at = `collections.${slug}`\n\tconst shaped = optionsObject(binding, {\n\t\tpath: at,\n\t\tknown: BINDING_KEYS,\n\t\texample: \"an object such as { pathField: 'slug' }\",\n\t})\n\toptionalFunction(shaped.path, `${at}.path`)\n\tif (\n\t\tshaped.pathField !== undefined &&\n\t\t(typeof shaped.pathField !== 'string' || shaped.pathField.trim() === '')\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${at}.pathField must be a field name, got ${kindOf(shaped.pathField)}`\n\t\t)\n\t}\n\tif (\n\t\tshaped.hostname !== undefined &&\n\t\ttypeof shaped.hostname !== 'string' &&\n\t\ttypeof shaped.hostname !== 'function'\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${at}.hostname must be a hostname or a function answering one, got ${kindOf(shaped.hostname)}`\n\t\t)\n\t}\n\toptionalBoolean(shaped.item, `${at}.item`)\n\tif (!shaped.path && !shaped.pathField && shaped.item !== true) {\n\t\tthrow new Error(\n\t\t\t`analytics: binding for \"${slug}\" needs a path resolver, a pathField, or item: true`\n\t\t)\n\t}\n\tif (shaped.item === true && slug.includes(':')) {\n\t\tthrow new Error(\n\t\t\t`analytics: collection \"${slug}\" cannot be bound as an item: a ref is \"<collection>:<id>\", so the slug cannot hold a colon`\n\t\t)\n\t}\n}\n\n/**\n * Each binding with its scope field filled: `'tenant'` when scoped, else `false` (the request's own\n * scope). Whether that field exists is checked at init, after every plugin adds fields.\n */\nconst resolveBindings = (\n\tcollections: AnalyticsPluginOptions['collections'],\n\tscoped: boolean\n): Record<string, ResolvedBinding> => {\n\tconst keyed: unknown = collections\n\tif (keyed !== undefined && (!isRecord(keyed) || Array.isArray(keyed))) {\n\t\tthrow new Error(\n\t\t\t`analytics: collections must be an object keyed by collection slug, such as { pages: { pathField: 'slug' } }, got ${kindOf(keyed)}`\n\t\t)\n\t}\n\tconst out: Record<string, ResolvedBinding> = {}\n\tfor (const [slug, binding] of Object.entries(collections ?? {})) {\n\t\tif (!binding) continue\n\t\tassertBinding(binding, slug)\n\t\tconst declared = binding.scopeField ?? (scoped ? DEFAULT_BINDING_SCOPE_FIELD : false)\n\t\tconst scopeField =\n\t\t\tdeclared === false\n\t\t\t\t? false\n\t\t\t\t: flatFieldName(declared, {\n\t\t\t\t\t\tpath: `collections.${slug}.scopeField`,\n\t\t\t\t\t\treason: \"a document's scope is read from one of its own top-level fields\",\n\t\t\t\t\t})\n\t\t// Erases the per-slug document generic: the runtime only hands a binding its own documents.\n\t\tout[slug] = { ...(binding as AnalyticsBinding), scopeField }\n\t}\n\treturn out\n}\n\nconst resolveRoutes = (option: AnalyticsPluginOptions['routes']): ResolvedOptions['routes'] => {\n\tif (option !== undefined) {\n\t\toptionsObject(option, {\n\t\t\tpath: 'routes',\n\t\t\tknown: ROUTES_KEYS,\n\t\t\texample: \"an object such as { base: '/_x' }\",\n\t\t})\n\t}\n\treturn { base: resolveRouteBase(option?.base) }\n}\n\n/** `adapters`, and the options naming one of them by id. */\nconst assertAdapterOptions = (options: AnalyticsPluginOptions, requireAdapters: boolean): void => {\n\tassertAdapters(options.adapters)\n\tconst adapters = options.adapters ?? []\n\tif (requireAdapters && adapters.length === 0) {\n\t\tthrow new Error('analytics: at least one adapter is required')\n\t}\n\tif (adapters.length > 0) {\n\t\tassertNamesAdapter(options.defaultAdapter, 'defaultAdapter', adapters)\n\t}\n\tassertNamesAdapter(options.platformAdapter, 'platformAdapter', adapters)\n}\n\n/**\n * The options checked and filled. `requireAdapters: false` is the switched-off plugin's, which\n * reads through no adapter and only asks each for its schema.\n */\nexport function resolveOptions(\n\toptions: AnalyticsPluginOptions,\n\tsettings: { requireAdapters?: boolean } = {}\n): ResolvedOptions {\n\tassertNoLegacyOptions(options)\n\tfor (const key of Object.keys(options)) {\n\t\tif (!PLUGIN_KEYS.includes(key)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: ${key} is not an option; analytics() takes ${listOf(PLUGIN_KEYS)}`\n\t\t\t)\n\t\t}\n\t}\n\toptionalBoolean(options.disabled, 'disabled')\n\tassertTranslations(options.translations)\n\tassertAdapterOptions(options, settings.requireAdapters !== false)\n\tconst scope = resolveScope(options.scope)\n\tconst scoped = options.scope?.resolve !== undefined\n\tif (!scoped) {\n\t\tassertScopedOnlyOptions(options)\n\t}\n\tconst capture = resolveCapture(options, scoped)\n\tconst access = resolveAccess(options.access, scoped)\n\tconst trust = resolveTrust(options)\n\tassertTimezone(options.reportingTimezone)\n\tconst countryFlags = resolveCountryFlags(options.countryFlags)\n\tconst cache = resolveCache(options.cache)\n\tconst sync = resolveSync(options.sync)\n\tconst jobs = resolveJobs(options.jobs)\n\tassertJobsFit(jobs, { sync: sync.enabled, warm: cache.warm.enabled })\n\treturn {\n\t\tadapters: options.adapters,\n\t\tdefaultAdapter: options.defaultAdapter,\n\t\tscope,\n\t\tscoped,\n\t\treportingTimezone: options.reportingTimezone,\n\t\trevenue: resolveRevenue(options.revenue),\n\t\tplatformAdapter: options.platformAdapter,\n\t\tsources: resolveSources(options),\n\t\t...trust,\n\t\taccess,\n\t\tview: resolveView(options.view),\n\t\tcountryFlags,\n\t\tcapture,\n\t\t...resolveGoals(options.goals),\n\t\tproviders: resolveProviders(options.providers, options.adapters),\n\t\tbindings: resolveBindings(options.collections, scoped),\n\t\tcache,\n\t\twidgets: resolveWidgets(options.widgets),\n\t\tsync,\n\t\troutes: resolveRoutes(options.routes),\n\t\tjobs,\n\t\tsdks: resolveSdks(options.sdks),\n\t\thooks: resolveHooks(options.hooks),\n\t}\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"options.js","names":[],"sources":["../../src/core/options.ts"],"sourcesContent":["import type { KeysConfig } from '@10x-media/fields/encrypted'\nimport type {\n\tAccess,\n\tCollectionConfig,\n\tCollectionSlug,\n\tField,\n\tPayload,\n\tPayloadRequest,\n\tRawPayloadComponent,\n\tWidget,\n} from 'payload'\nimport type { AnalyticsBinding, ResolvedBinding } from '../binding/types'\nimport type { GoalCollectionFieldOverrides } from '../goals/collection'\nimport type { CurrencyConverter } from '../goals/currency'\nimport type { BrowserAmounts, OrderSignatureMode } from '../goals/match'\nimport type { Goal } from '../goals/types'\nimport type { TrustedPlatform } from '../net/platform'\nimport { type RouteBase, resolveRouteBase } from '../plugin/routes'\nimport type { ScopeDecision } from '../plugin/runtime'\nimport type {\n\tConnectionAccess,\n\tConnectionFieldAccess,\n\tProviderCollectionFieldOverrides,\n} from '../providers/collection'\nimport type { ProviderId } from '../providers/factory'\nimport type { ProviderHostPolicy } from '../providers/hosts'\nimport type { AfterReadHook } from '../surfacing/afterRead'\nimport type { CacheStore } from '../surfacing/cacheStore'\nimport type { TimeframePreset } from '../timeframe/presets'\nimport { isValidTimeZone } from '../timeframe/tz'\nimport type {\n\tCaptureClientKind,\n\tCaptureSlot,\n\tConsentPhase,\n\tResolvedAutoCapture,\n\tTrackerSkip,\n\tWithoutConsentLevel,\n} from '../tracker/config'\nimport type { TranslationsOption } from '../translations'\nimport { keys, pluralKeys } from '../translations/keys'\nimport type { CustomWidgetDef } from '../widgets/customWidget'\nimport { resolveCountryFlags, resolveView, resolveWidgets } from './adminOptions'\nimport { resolveCache, resolveHooks, resolveSync } from './cacheOptions'\nimport { resolveCapture, resolveTrust } from './captureOptions'\nimport type {\n\tAnalyticsCollectionOptions,\n\tCollectionOverrides,\n\tResolvedCollectionOption,\n\tResolvedScopedCollection,\n} from './collectionOption'\nimport type { AnalyticsAdapter, MetricKey } from './contract'\nimport type { FetchLike } from './fetch'\nimport { resolveGoals, resolveRevenue } from './goalOptions'\nimport { type AnalyticsJobsOptions, assertJobsFit, type ResolvedJobs, resolveJobs } from './jobs'\nimport { assertNoLegacyOptions } from './legacyOptions'\nimport {\n\tflatFieldName,\n\tkeysOf,\n\toptionalBoolean,\n\toptionalFunction,\n\toptionsObject,\n} from './optionChecks'\nimport { assertScopedOnlyOptions, resolveAccess, resolveScope } from './scopeOptions'\nimport { type AnalyticsSdks, resolveSdks } from './sdks'\nimport { assertAdapters, assertNamesAdapter, resolveProviders } from './sourceOptions'\nimport {\n\ttype AnalyticsSourceOptions,\n\ttype DefaultSourceRule,\n\ttype ResolvedSources,\n\tresolveSources,\n} from './sourcePolicy'\nimport { isRecord, kindOf, listOf } from './values'\nimport type { BuiltInWidgetSlug } from './widgetSlugs'\n\nexport { DEFAULT_VIEW } from './adminOptions'\nexport {\n\tadapterCountsWithoutConsent,\n\tcookielessTrustNotice,\n\tdocumentsFillHeldTenant,\n\tfillableSlots,\n\tfollowingCountsWithoutConsent,\n\ttrackerAutoCapture,\n\tuntrustedAddressNotice,\n\twithoutConsentUnsetNotice,\n} from './captureOptions'\nexport type { AnalyticsCollectionOptions, CollectionOverrides } from './collectionOption'\nexport { revenueOffWarning } from './goalOptions'\nexport type { AnalyticsJobsOptions, AnalyticsTaskOptions } from './jobs'\nexport { allCrossScope } from './scopeOptions'\nexport type {\n\tAnalyticsSourceOptions,\n\tDefaultSourceFunction,\n\tDefaultSourceRule,\n\tOwnSource,\n\tResolvedSources,\n\tSourcePolicy,\n\tSourcePolicyFunction,\n\tSourceRef,\n} from './sourcePolicy'\nexport type { CurrencyConverter }\n\n/** The multi-tenant plugin's own relationship field, which a scoped install almost always has. */\nexport const DEFAULT_BINDING_SCOPE_FIELD = 'tenant'\n\n/**\n * Who asks for a request's scope: `capture` files a visitor's hit and carries no user or cookies,\n * so it resolves from the host; `admin` is every signed-in read or edit.\n */\nexport type ScopeCallSite = 'capture' | 'admin'\n\n/**\n * Maps a request to the scope it selected (tenant id, site key), null for the whole install;\n * whether its user may act there is `scope.member`. `'*'` is refused.\n */\nexport type ScopeResolver = (args: {\n\treq: PayloadRequest\n\tcallSite: ScopeCallSite\n}) => string | null | Promise<string | null>\n\n/**\n * Lists the tenant scopes the sync task runs over, in addition to the install-wide scope it always\n * covers. Warming needs no list: it repeats the reads each scope's readers made.\n */\nexport type ScopeListResolver = (args: { payload: Payload }) => string[] | Promise<string[]>\n\n/**\n * Names a scope on screen, so a tenant admin reads a name rather than an id in the view's caption.\n * Undefined keeps the id.\n */\nexport type ScopeLabelResolver = (args: {\n\treq: PayloadRequest\n\tscope: string\n}) => string | undefined | Promise<string | undefined>\n\n/** Whether the request's user belongs to `scope`, as opposed to having merely selected it. */\nexport type ScopeMemberAccess = (args: {\n\treq: PayloadRequest\n\tscope: string\n}) => boolean | Promise<boolean>\n\n/** How the install divides its analytics into tenants. Unset, the install is one scope. */\nexport type AnalyticsScopeOptions = {\n\tresolve: ScopeResolver\n\t/**\n\t * Whether the request's user belongs to the scope `resolve` selected, asked on every read and\n\t * config write. `tenantMembership()` reads the multi-tenant plugin's tenants.\n\t */\n\tmember: ScopeMemberAccess\n\tlist?: ScopeListResolver\n\tlabel?: ScopeLabelResolver\n}\n\n/**\n * Resolves a scope's IANA reporting timezone, also asked at ingest without the user or cookies.\n * Null means UTC.\n */\nexport type TimezoneResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string | null | Promise<string | null>\n\n/**\n * Resolves a scope's ISO 4217 revenue currency, so each tenant can have its own. Undefined reports\n * revenue as a plain number.\n */\nexport type CurrencyResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string | undefined | Promise<string | undefined>\n\n/**\n * How the install measures money once `revenue` turns it on. Off hides every money surface but\n * keeps stored data, so turning it on later reports the history.\n */\nexport type AnalyticsRevenueOptions = {\n\t/**\n\t * ISO 4217 currency revenue is reported in, or a resolver per tenant. Unset, amounts are summed\n\t * as sent and a mix of currencies is flagged in `meta.mixedCurrencies`.\n\t */\n\tcurrency?: string | CurrencyResolver\n\t/**\n\t * FX hook native ingest calls when an event's currency differs from `currency`. Without it such\n\t * an amount stays out of revenue, though the conversion still counts.\n\t */\n\tconvert?: CurrencyConverter\n\t/**\n\t * The `currency` breakdown dimension, keyed by the currency each amount was sent in. Default: on\n\t * while no `convert` hook is set.\n\t */\n\tdimension?: boolean\n\t/**\n\t * How far native ingest trusts an amount a browser sends, which anyone can forge. `'fixed'`\n\t * (default) prefers a goal's fixed value, `'none'` ignores it, `'trust'` prefers it.\n\t */\n\tbrowserAmounts?: BrowserAmounts\n\t/**\n\t * Whether native ingest takes an order id sent without the server's `signOrderId` signature.\n\t * `'optional'` (default) takes it; `'required'` answers an unsigned one with `400`.\n\t */\n\torderSignature?: OrderSignatureMode\n}\n\n/** What `providers.resolve` is handed for one scope. */\nexport interface ProvidersResolveArgs {\n\tpayload: Payload\n\treq?: PayloadRequest\n\tscope: string | null\n\t/**\n\t * The runtime's guarded fetch: every address a vendor's host resolves to has to be public, on\n\t * every connection and every redirect. Hand it to `adapterFromProviderDoc`.\n\t */\n\tfetch: FetchLike\n\t/**\n\t * The hosts a document may name: each vendor's own cloud, plus `providers.hosts`. Hand it to\n\t * `adapterFromProviderDoc` with `fetch`, which reaches a private network only when it allows one.\n\t */\n\thosts: ProviderHostPolicy\n\t/** The plugin's `sdks`, which a GA4 document's adapter reads through. */\n\tsdks: AnalyticsSdks\n}\n\n/**\n * Replaces the providers collection lookup with a scope's adapters, uncached. Build each with\n * `adapterFromProviderDoc(row, { fetch, hosts, sdks })` so a stored key reaches allowed hosts only.\n */\nexport type ProvidersResolve = (\n\targs: ProvidersResolveArgs\n) => AnalyticsAdapter[] | Promise<AnalyticsAdapter[]>\n\n/**\n * Where provider documents may point. Each vendor's own cloud is always allowed: Plausible, Umami\n * Cloud, and PostHog's US and EU regions.\n */\nexport type ProviderHostsOptions = {\n\t/**\n\t * Origins a document's host may name besides its vendor's cloud, such as `https://*.example.com`;\n\t * no paths. A host outside them reads as `source_misconfigured`.\n\t */\n\tallow?: string[]\n\t/**\n\t * Lets document adapters reach any address over http or https, private networks included (Umami\n\t * on the same Docker network). Default off.\n\t */\n\tallowPrivateNetwork?: boolean\n}\n\nexport type ProvidersCollectionOptions = {\n\tslug?: string\n\t/**\n\t * Field matched against the resolved scope when looking up a scope's providers. Default `scope`;\n\t * name a tenant plugin's field (`tenant`) when that plugin scopes the collection.\n\t */\n\tscopeField?: string\n\t/**\n\t * Replaces one of the collection's own fields, each handed the plugin's default. Applied before\n\t * `overrides`.\n\t */\n\tfields?: ProviderCollectionFieldOverrides\n\t/**\n\t * Reshapes the whole config last. It may not rename the collection (`slug` does) nor turn off\n\t * its timestamps, which every instance notices a saved document by: the boot refuses both.\n\t */\n\toverrides?: CollectionOverrides\n\taccess?: Partial<CollectionConfig['access']>\n\t/**\n\t * Dedicated key ring for stored provider credentials. Unset, the fields plugin's `encrypted.keys`\n\t * applies, else a ring derived from the Payload secret, fit for dev only.\n\t */\n\tencryption?: { keys?: KeysConfig }\n\t/**\n\t * Who may set or change where a document connects (provider, host, ids); a denied value is\n\t * dropped. Default: the creator, then `access.crossScope.named` when scoped, else update access.\n\t */\n\tconnectionAccess?: ConnectionAccess\n\t/**\n\t * Who may set or change a scoped install's \"Default for this site\" checkbox; a denied value is\n\t * dropped. Default: `connectionAccess`, else its default (the creator, then `crossScope.named`).\n\t */\n\tdefaultAccess?: ConnectionAccess\n\t/**\n\t * Which provider types documents may have, the first being the select's default; the select lists\n\t * them in a fixed order. Default: every type, `native` only while `adapters` holds native().\n\t */\n\ttypes?: ProviderId[]\n\t/**\n\t * Which provider documents a reader reads analytics through, as collection access ANDed with\n\t * enabled and scope. Default: the collection's own read access.\n\t */\n\tsourceAccess?: Access\n}\n\nexport type ProvidersOptions = {\n\t/** Opt-in admin collection storing runtime provider configurations. */\n\tcollection?: boolean | ProvidersCollectionOptions\n\t/** Replaces the collection: the two cannot both be set. */\n\tresolve?: ProvidersResolve\n\t/** Where the documents of either one may point. Needs `collection` or `resolve`. */\n\thosts?: ProviderHostsOptions\n}\n\n/** Access checker for authenticated analytics reads. */\nexport type AnalyticsReadAccess = (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\n/** Access checker for the analytics admin view. */\nexport type AnalyticsViewAccess = (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\n/**\n * Access checker for one of the cross-scope gates under `access.crossScope`, told what is asked\n * where the read knows it: the scope (`'*'` or null for every scope) and, for `unscopedSource`, the adapter.\n */\nexport type CrossScopeAccess = (args: {\n\treq: PayloadRequest\n\tscope?: string | null\n\tadapterId?: string\n}) => boolean | Promise<boolean>\n\n/**\n * The three ways a reader on a scoped install reaches past their own scope, each denied by default.\n * Split so platform staff can aggregate without singling out one tenant.\n */\nexport type AnalyticsCrossScopeOptions = {\n\t/**\n\t * Reading a scope the request does not resolve to, by naming it. Also decides who manages other\n\t * tenants' provider, goal and sync documents.\n\t */\n\tnamed?: CrossScopeAccess\n\t/** Reading every scope at once: the `'*'` marker, and a scoped install's null scope. */\n\taggregate?: CrossScopeAccess\n\t/**\n\t * Reading a tenant through a shared config adapter that cannot narrow its query to one scope.\n\t * Also decides whether such an adapter is listed as a source at all.\n\t */\n\tunscopedSource?: CrossScopeAccess\n}\n\nexport type AnalyticsAccessOptions = {\n\t/**\n\t * Gates every read: endpoints, dashboard widgets and display fields. Default `isAdminUser` (the\n\t * `admin.user` collection); scope gating applies on top and is never widened by it.\n\t */\n\tread?: AnalyticsReadAccess\n\t/**\n\t * Gates the analytics admin view. Default: `read`. A denied reader still sees the nav link and\n\t * lands on the view's no-access message.\n\t */\n\tview?: AnalyticsViewAccess\n\t/**\n\t * Reads past the request's own scope, scoped installs only: a function grants all three gates,\n\t * the object form each one (unset denies). Unscoped, all three open to `isAdminUser`.\n\t */\n\tcrossScope?: CrossScopeAccess | AnalyticsCrossScopeOptions\n}\n\n/** The three cross-scope gates, each filled. */\nexport type ResolvedCrossScope = Record<ScopeDecision, CrossScopeAccess>\n\n/** What `capture.gate` is asked about one capture slot. */\nexport interface CaptureGateArgs {\n\tslot: CaptureSlot\n\t/** The adapter filling the slot for this request. */\n\tadapterId: string\n\tkind: CaptureClientKind\n}\n\n/**\n * Which capture slots wait for the host's consent manager: `'all'`, `'off'`, a list of slots, or a\n * function answering per slot (true waits).\n */\nexport type CaptureGate = 'all' | 'off' | CaptureSlot[] | ((args: CaptureGateArgs) => boolean)\n\n/** `capture.gate` resolved: whether one slot, filled by one adapter, waits. */\nexport type CaptureGatePolicy = (args: CaptureGateArgs) => boolean\n\n/** What `capture.withoutConsent` is asked about one held slot in one phase. */\nexport interface WithoutConsentArgs extends CaptureGateArgs {\n\tphase: ConsentPhase\n}\n\n/** `capture.withoutConsent` as a function: a throw, or any other answer, means `'off'`. */\nexport type WithoutConsentFunction = (args: WithoutConsentArgs) => WithoutConsentLevel\n\n/**\n * What a slot `capture.gate` holds does before an answer (`pending`) and after a refusal\n * (`refused`): one level for both, one per phase (an omitted phase is `'cookieless'`), or a\n * function answering per slot and phase.\n */\nexport type WithoutConsentOption =\n\t| WithoutConsentLevel\n\t| { pending?: WithoutConsentLevel; refused?: WithoutConsentLevel }\n\t| WithoutConsentFunction\n\n/** `capture.withoutConsent` checked: a level per phase, or the host's function. */\nexport type ResolvedWithoutConsent =\n\t| Record<ConsentPhase, WithoutConsentLevel>\n\t| WithoutConsentFunction\n\n/** An adapter id to fill a capture slot with, or `false` to leave it deliberately empty. */\nexport type CaptureSlotOption = string | false\n\n/** What the tracker and ingest do with elements marked by `itemAttributes`. */\nexport type ItemCaptureOptions = {\n\t/** Count an item as seen once at least half of it stays on screen for a second. */\n\timpressions?: boolean\n\t/** Send `item_click` for the first click on an item during a pageview. */\n\tclicks?: boolean\n\t/** Also count an item per page it appeared on, beside its own total. */\n\tpages?: boolean\n}\n\nexport type AutoCaptureOptions = {\n\tscrollDepth?: boolean\n\toutboundLinks?: boolean\n\tfileDownloads?: boolean\n\tgoalAttribute?: boolean\n\t/**\n\t * Send each pageview's query string so ingest can extract its utm keys. The raw query is\n\t * never stored, only the five campaign values; set false to stop sending it at all.\n\t */\n\tquery?: boolean\n\t/**\n\t * Content items, on by default and inert until a page marks an element with `itemAttributes`.\n\t * `false` turns them off, crediting goals to items included.\n\t */\n\titems?: false | ItemCaptureOptions\n}\n\nexport type AnalyticsGoalsCollectionOptions = {\n\tslug?: string\n\t/**\n\t * Field matched against the resolved scope when looking up a scope's goals. Point it at\n\t * a tenant plugin's field (e.g. 'tenant') when that plugin manages scoping.\n\t */\n\tscopeField?: string\n\t/**\n\t * Replaces one of the collection's own fields, each handed the plugin's default; applied before\n\t * `overrides`. A `slug` replacement must keep a field named `slug` or the boot fails.\n\t */\n\tfields?: GoalCollectionFieldOverrides\n\t/**\n\t * Reshapes the whole config last. It may not rename the collection (`slug` does) nor turn off\n\t * its timestamps, which every instance notices a saved document by: the boot refuses both.\n\t */\n\toverrides?: CollectionOverrides\n\taccess?: Partial<CollectionConfig['access']>\n}\n\n/** Goals as config, plus the opt-in collection editors manage their own goals through. */\nexport type AnalyticsGoalsOptions = {\n\tdefaults?: Goal[]\n\t/** Opt-in admin collection whose goals merge over `defaults`, by slug, per scope. */\n\tcollection?: boolean | AnalyticsGoalsCollectionOptions\n\t/**\n\t * The built-in `purchase` goal sales book against, on unless a configured goal claims that slug.\n\t * `false` removes it, for an install that never sells.\n\t */\n\tpurchase?: boolean\n}\n\n/**\n * The website addresses where the scope's tracker runs, one per site, each an `http(s)` origin with\n * an optional path. May be async; scope is null on an unscoped install.\n */\nexport type ExclusionSitesResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string[] | Promise<string[]>\n\n/** The signed link staff open to leave their own browser out of the numbers. */\nexport type AnalyticsExclusionOptions = {\n\t/**\n\t * The query parameter the tracker reads. Default `analytics_exclude`. Letters, digits, `.`,\n\t * `_`, `~` and `-`, at most 64 of them.\n\t */\n\tparam?: string\n\t/**\n\t * Website addresses where the tracker runs, one per site, for the view to link to: a list, or\n\t * a per-scope function (async allowed). Unset, the view hands out only the query to append.\n\t */\n\tsites?: string[] | ExclusionSitesResolver\n}\n\nexport type AnalyticsCaptureOptions = {\n\t/**\n\t * Which capture slots wait for the host's consent manager. Required whenever a slot can fill:\n\t * whether tracking needs consent is the operator's call, so there is no default.\n\t */\n\tgate?: CaptureGate\n\t/**\n\t * What a slot `gate` holds does before an answer and after a refusal. Default `'cookieless'`:\n\t * count without storing anything on the device, at the level each adapter declares (GA4's is\n\t * `'off'`). `'off'` sends nothing until consent and nothing after a refusal. An adapter's own\n\t * `withoutConsent` beats this for its slot; a slot the gate does not hold runs in full.\n\t */\n\twithoutConsent?: WithoutConsentOption\n\t/**\n\t * Exact origins of other sites (`https://shop.example.com`, no path or wildcard) whose pages may\n\t * send to ingest and the capture proxy. Unset, only the site and its subdomains can.\n\t */\n\tallowedOrigins?: string[]\n\t/**\n\t * The signed link staff open to leave their browser out of the numbers. Off by default; `true`\n\t * turns it on as `analytics_exclude`, an object renames it through `param`.\n\t */\n\texclusion?: boolean | AnalyticsExclusionOptions\n\t/**\n\t * Which adapter fills each slot (`global`: `platformAdapter` or the only adapter; `tenant`: the\n\t * scope's default). `false` leaves a slot empty: no proxy mount, no tracker entry.\n\t */\n\tslots?: { global?: CaptureSlotOption; tenant?: CaptureSlotOption }\n\t/**\n\t * Mount each slot's snippet points at. Default: the runtime proxy endpoint; set it to a\n\t * `captureRoute` handler's path, without the Next `basePath`, which the tracker config adds.\n\t */\n\tpaths?: { global?: string; tenant?: string }\n\t/** Browser auto-capture listeners, all on by default except `scrollDepth`. */\n\tautoCapture?: AutoCaptureOptions\n\t/**\n\t * Pages the tracker leaves uncounted, each on unless false: `automation` (`navigator.webdriver`;\n\t * turn it off for e2e suites asserting on hits) and `previews` (draft mode, live preview).\n\t */\n\tskip?: { automation?: boolean; previews?: boolean }\n\t/** Limits for the public runtime capture proxy, separate from the read-path `cache`. */\n\tproxy?: {\n\t\t/**\n\t\t * Deadline for the upstream response headers, in ms. Default 10000. The body\n\t\t * download is not on the clock, so a large tracker bundle streams to completion.\n\t\t */\n\t\ttimeoutMs?: number\n\t\t/**\n\t\t * Largest proxied request body, in bytes. Default 1 MiB, which clears a PostHog\n\t\t * batch carrying session-replay data. Anything larger is refused with 413.\n\t\t */\n\t\tmaxBodyBytes?: number\n\t}\n}\n\nexport type AnalyticsViewOptions = {\n\t/** Admin path the view mounts at, under `routes.admin`. Default `/analytics`. */\n\tpath?: `/${string}`\n\t/** Timeframe the view opens on before the URL says otherwise. Default `last30days`. */\n\tdefaultRange?: TimeframePreset\n\t/** Metric the cards and the trend open on. Default `pageviews`. */\n\tdefaultMetric?: MetricKey\n\t/**\n\t * Nav link label. A string is used as-is; a map is keyed by admin language code and\n\t * falls back to `en`. Unset, the plugin's own translated label applies.\n\t */\n\tnavLabel?: string | Record<string, string>\n\t/**\n\t * Whether the view adds its link to the admin sidebar. Default true; false mounts the view\n\t * without one, for a host that links it from its own navigation.\n\t */\n\tnavLink?: boolean\n\t/**\n\t * A client component replacing the view's body under the same server shell, given\n\t * `AnalyticsViewClientProps`; compose it from the sections `@10x-media/analytics/client` exports.\n\t *\n\t * @beta\n\t */\n\tComponent?: AnalyticsComponent\n}\n\nexport interface ResolvedView {\n\tpath: `/${string}`\n\tdefaultRange: TimeframePreset\n\tdefaultMetric: MetricKey\n\tnavLabel?: string | Record<string, string>\n\tnavLink: boolean\n\tComponent?: AnalyticsComponent\n}\n\n/**\n * A component a host puts in one of the plugin's places, as Payload takes one: an import-map path\n * such as `'/components/Flag#Flag'`, or the object form with its export and props.\n *\n * @beta\n */\nexport type AnalyticsComponent = string | RawPayloadComponent\n\n/**\n * How a host changes one built-in dashboard widget.\n *\n * @beta\n */\nexport interface AnalyticsWidgetOverride {\n\t/**\n\t * Rendered in place of the plugin's own component. A server component receives the full widget\n\t * props, a client component its `clientProps` alone.\n\t */\n\tComponent?: AnalyticsComponent\n\t/** The widget's name in the dashboard's widget list. */\n\tlabel?: Widget['label']\n\t/**\n\t * The widget's settings, given the plugin's own fields as `defaultFields`, the shape Payload's\n\t * form builder and search plugins take; what it returns is the form.\n\t */\n\tfields?: (args: { defaultFields: Field[] }) => Field[]\n}\n\n/** @beta */\nexport type AnalyticsWidgetOverrides = Partial<Record<BuiltInWidgetSlug, AnalyticsWidgetOverride>>\n\n/** @beta */\nexport interface AnalyticsWidgetsOptions {\n\tdisabled?: string[]\n\tregister?: CustomWidgetDef[]\n\t/**\n\t * Marks each widget's free-text Title field `localized`. Default off; takes effect only when the\n\t * Payload config enables localization.\n\t */\n\tlocalizeText?: boolean\n\t/**\n\t * Period-over-period comparison on the metric and trend widgets. Default on, except for a source\n\t * whose adapter sets `capabilities.comparison` false; `false` skips the second read.\n\t */\n\tcomparison?: boolean\n\t/** Built-in widgets changed by slug: their component, their name, their settings. */\n\toverrides?: AnalyticsWidgetOverrides\n}\n\n/**\n * `countryFlags` with a flag of the host's own.\n *\n * @beta\n */\nexport interface AnalyticsCountryFlags {\n\t/**\n\t * A client component drawing one flag from `{ code }`, an ISO 3166-1 alpha-2 code in capitals.\n\t * Registered through `admin.dependencies`, so `payload generate:importmap` picks it up.\n\t */\n\tComponent: AnalyticsComponent\n}\n\n/** The collection the sync job persists daily metrics into: `slug` defaults to `analytics-daily`. */\nexport type AnalyticsSyncCollectionOptions = AnalyticsCollectionOptions & {\n\t/** Keeps the collection out of the admin nav. Default true. */\n\thidden?: boolean\n}\n\n/** The read cache's collection: `slug` defaults to `analytics-cache`. */\nexport type AnalyticsCacheCollectionOptions = AnalyticsCollectionOptions\n\n/** What `analytics-sync` copies; when it runs is `jobs.tasks.sync`. */\nexport type AnalyticsSyncOptions = {\n\t/** Days each run reads back, today counted. Default 3. */\n\tlookbackDays?: number\n\t/**\n\t * The sources it copies: a config adapter's id, or a provider type for every source built from\n\t * provider documents of that type. Default every vendor source.\n\t */\n\tadapters?: string[]\n\tcollection?: AnalyticsSyncCollectionOptions\n}\n\n/** How much reads may ask of their sources at once (`cache.concurrency`). */\nexport type AnalyticsConcurrencyOptions = {\n\t/** Requests in flight across every vendor source of one instance. Default 16. */\n\tglobal?: number\n\t/** Requests in flight per vendor source that declares no `rateLimit.maxConcurrent`. Default 4. */\n\tperSource?: number\n\t/** Reads with nothing cached one scope may have waiting on its sources. Default 8. */\n\tperScope?: number\n}\n\n/** How reads are cached, how long they wait for their sources, and which are kept warm. */\nexport type AnalyticsCacheOptions = {\n\t/**\n\t * Seconds an answer stays fresh; unset, each adapter's `recommendedTtl` applies. A native read\n\t * whose window reaches into today stays fresh 10 seconds at most whatever this says.\n\t */\n\tttl?: { aggregate?: number; realtime?: number }\n\t/**\n\t * Keeps recently asked reads warm: `analytics-warm` rereads each shortly before its cached answer\n\t * expires. Default off; `true` uses the defaults. Scheduled by `jobs.tasks.warm`.\n\t */\n\twarm?: boolean | AnalyticsWarmOptions\n\t/**\n\t * How long a read waits for its source, in ms, retries included. Default 15000. Only a read with\n\t * nothing cached (and sync) waits; others answer an expired entry at once.\n\t */\n\ttimeoutMs?: number\n\t/**\n\t * How much reads may ask of their sources at once; past `perScope` the query endpoint answers\n\t * 429. Native reads have a lane of their own outside these: 8, or on Postgres a third of\n\t * `pool.max`, between 1 and 8.\n\t */\n\tconcurrency?: AnalyticsConcurrencyOptions\n\t/**\n\t * Where reads are cached across requests and instances. Default: the `analytics-cache`\n\t * collection; a self-expiring store (Redis) replaces it. Live counts stay in memory.\n\t */\n\tstore?: CacheStore\n\t/** The `analytics-cache` collection of the default store; refused beside `store`. */\n\tcollection?: AnalyticsCacheCollectionOptions\n}\n\n/** Hooks into what the plugin does. */\nexport type AnalyticsHooksOptions = {\n\t/**\n\t * Runs once for every read answered to a reader, after it is cached, to observe it or answer\n\t * that one read differently. See {@link AfterReadHook} for the contract.\n\t */\n\tafterRead?: AfterReadHook\n}\n\n/** Which reads `analytics-warm` keeps warm; when it runs is `jobs.tasks.warm`. */\nexport type AnalyticsWarmOptions = {\n\t/** Reads asked for in this many hours count as recent. Default 24. */\n\twindowHours?: number\n\t/** The most reads one run refreshes, most recently read first. Default 200. */\n\tmaxReads?: number\n}\n\n/** Where the plugin's endpoints answer. */\nexport type AnalyticsRoutesOptions = {\n\t/**\n\t * The path every plugin endpoint hangs off, under `routes.api`. Default `/_x`; the boot fails\n\t * when a collection slug is its first segment, which would swallow those requests.\n\t */\n\tbase?: RouteBase\n}\n\nexport type AnalyticsPluginOptions = {\n\t/**\n\t * Switches the plugin off but keeps its schema (collections, fields, indexes, task slugs), so\n\t * nothing is dropped. No endpoint, view, widget or task work runs; options are still checked.\n\t */\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for the plugin's UI strings, keyed by `@10x-media/analytics/i18n` keys.\n\t * They win per key over built-ins; app `i18n.translations` wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\tadapters: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\t/**\n\t * Id of one config adapter shared by every scope (the platform's own analytics). Reading a tenant\n\t * through it needs `access.crossScope.unscopedSource` unless it supports scoped queries.\n\t */\n\tplatformAdapter?: string\n\t/** Tenancy: how a request maps to its scope. Unset, the whole install is one scope. */\n\tscope?: AnalyticsScopeOptions\n\t/**\n\t * Per shared config adapter, keyed by its id: which tenant users besides platform staff\n\t * (`access.crossScope.unscopedSource`) read their own tenant through it. Scoped installs only.\n\t */\n\tsources?: Record<string, AnalyticsSourceOptions>\n\t/**\n\t * A tenant scope's default source when none of its provider documents is flagged the default.\n\t * Unset keeps the registry's own order. Scoped installs only.\n\t */\n\tdefaultSource?: DefaultSourceRule\n\t/**\n\t * IANA timezone days are cut in. Default UTC; a resolver answers per scope. After a change,\n\t * native recounts in the new zone only days whose raw hits it still keeps.\n\t */\n\treportingTimezone?: string | TimezoneResolver\n\t/**\n\t * Money as a capability. `false` or unset measures none; `true` measures it with the\n\t * defaults; an object turns it on and says in which currency, and how.\n\t */\n\trevenue?: boolean | AnalyticsRevenueOptions\n\t/**\n\t * How many proxies to trust, counted from the right of `x-forwarded-for`, when reading a client\n\t * address. Unset keeps the leftmost entry, which the client controls. Not with `trustedPlatform`.\n\t */\n\ttrustedProxyHops?: number\n\t/**\n\t * Platform (`'vercel'` or `'cloudflare'`) whose edge headers carry the visitor's address and\n\t * location. Set it only when every request passes through it, or the headers can be forged.\n\t */\n\ttrustedPlatform?: TrustedPlatform\n\taccess?: AnalyticsAccessOptions\n\tcapture?: AnalyticsCaptureOptions\n\t/**\n\t * Conversion goals the tracker and native ingest match events against: a list, or `{ defaults,\n\t * collection, purchase }`. A goal's name never reaches the browser.\n\t */\n\tgoals?: Goal[] | AnalyticsGoalsOptions\n\t/**\n\t * Per-collection bindings, keyed by collection slug. With generated types\n\t * augmented, each slug's resolvers receive that collection's typed document.\n\t */\n\tcollections?: { [TSlug in CollectionSlug]?: AnalyticsBinding<TSlug> }\n\tproviders?: ProvidersOptions\n\t/**\n\t * The analytics admin view and its nav link, on by default. `false` registers neither;\n\t * the read endpoints stay mounted either way, so a custom surface keeps working.\n\t */\n\tview?: false | AnalyticsViewOptions\n\t/**\n\t * Dashboard widgets, on by default. Payload's dashboard is experimental, so this option is too.\n\t *\n\t * @beta\n\t */\n\twidgets?: boolean | AnalyticsWidgetsOptions\n\t/**\n\t * Flag beside country names in the view, widgets and document panel. Default on, served by the\n\t * plugin's cached route; `false` shows none, `{ Component }` draws the host's own.\n\t *\n\t * @beta\n\t */\n\tcountryFlags?: boolean | AnalyticsCountryFlags\n\tcache?: AnalyticsCacheOptions\n\t/**\n\t * Opt-in sync tier: `analytics-sync` copies each vendor source's daily metrics into a queryable\n\t * collection, every six hours unless `jobs.tasks.sync` says otherwise.\n\t */\n\tsync?: boolean | AnalyticsSyncOptions\n\troutes?: AnalyticsRoutesOptions\n\t/**\n\t * The plugin's tasks (maintain, sync, warm) on `jobs.queue`, scheduled by `jobs.tasks`. `false`\n\t * registers none: reads and ingest then do native upkeep, and sync or warming is refused.\n\t */\n\tjobs?: false | AnalyticsJobsOptions\n\t/**\n\t * Optional packages handed in, which a standalone or serverless build then ships: GA4's\n\t * `{ BetaAnalyticsDataClient }` and MaxMind's `{ open }`. A production boot warns about one missing.\n\t */\n\tsdks?: AnalyticsSdks\n\thooks?: AnalyticsHooksOptions\n}\n\n/** `capture.exclusion` while the link is on. */\nexport interface ResolvedExclusion {\n\tparam: string\n\t/** `sites`, a list made a function answering it; absent when the install names none. */\n\tsites?: ExclusionSitesResolver\n}\n\nexport interface ResolvedCapture {\n\tslots: { global?: CaptureSlotOption; tenant?: CaptureSlotOption }\n\tpaths: { global?: string; tenant?: string }\n\tgate: CaptureGatePolicy\n\t/** Absent while the install leaves it unset, which means `'cookieless'` in both phases. */\n\twithoutConsent?: ResolvedWithoutConsent\n\t/** Slots the gate may hold, judged without calling host code: a function may hold either. */\n\theldSlots: ReadonlySet<CaptureSlot>\n\t/** Whether some held slot of the install may count without consent, as far as the boot can tell. */\n\tinstallCountsWithoutConsent: boolean\n\tautoCapture: ResolvedAutoCapture\n\tproxy: { timeoutMs: number; maxBodyBytes: number }\n\t/** `allowedOrigins`, each as a browser writes it in `Origin`. */\n\tallowedOrigins: ReadonlySet<string>\n\t/** The exclusion link's parameter and site addresses, or false while the link is off. */\n\texclusion: false | ResolvedExclusion\n\tskip: TrackerSkip\n}\n\nexport interface ResolvedRevenue {\n\t/** Whether the install measures money at all. Every money surface reads this one answer. */\n\tenabled: boolean\n\t/** Raw currency option; the plugin normalizes it into a resolver. */\n\tcurrency?: string | CurrencyResolver\n\tconvert?: CurrencyConverter\n\t/** Whether native declares the `currency` dimension; always false while money is off. */\n\tdimension: boolean\n\tbrowserAmounts: BrowserAmounts\n\torderSignature: OrderSignatureMode\n}\n\nexport interface ResolvedScope {\n\t/** The host's resolver with `'*'` refused; resolves null for every request when unscoped. */\n\tresolve: ScopeResolver\n\tlist?: ScopeListResolver\n\tlabel?: ScopeLabelResolver\n\t/** Present exactly when the install is scoped. */\n\tmember?: ScopeMemberAccess\n}\n\nexport interface ResolvedOptions {\n\tadapters: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\tscope: ResolvedScope\n\t/** True when the app configured `scope.resolve` (scoped install). */\n\tscoped: boolean\n\t/** Raw `reportingTimezone`, a string already validated; the runtime makes it a resolver. */\n\treportingTimezone?: string | TimezoneResolver\n\trevenue: ResolvedRevenue\n\tplatformAdapter?: string\n\t/** `sources` and `defaultSource`; no policies and no rule on an unscoped install. */\n\tsources: ResolvedSources\n\t/** Raw trustedProxyHops option; undefined keeps the leftmost forwarded-for entry. */\n\ttrustedProxyHops?: number\n\t/** The platform whose edge headers are believed; undefined believes none. */\n\ttrustedPlatform?: TrustedPlatform\n\taccess: {\n\t\tread: AnalyticsReadAccess\n\t\tview: AnalyticsViewAccess\n\t\tcrossScope: ResolvedCrossScope\n\t}\n\t/** The admin view, filled with its defaults, or false when the app turned it off. */\n\tview: false | ResolvedView\n\t/** `true` the plugin's own flags, `false` none, or the host's component. */\n\tcountryFlags: boolean | AnalyticsCountryFlags\n\tcapture: ResolvedCapture\n\t/** Config goals, validated; the goals collection layers its own on top of these. */\n\tgoals: Goal[]\n\t/** `goals.purchase`: whether the resolver adds the built-in `purchase` goal. */\n\tpurchaseGoal: boolean\n\tgoalsCollection: ResolvedScopedCollection<GoalCollectionFieldOverrides>\n\tproviders: {\n\t\tcollection: ResolvedScopedCollection<ProviderCollectionFieldOverrides> & {\n\t\t\tencryption?: { keys?: KeysConfig }\n\t\t\tconnectionAccess?: ConnectionFieldAccess\n\t\t\tdefaultAccess?: ConnectionFieldAccess\n\t\t\t/** The types the install serves, `types` applied; filled whether the collection is on or not. */\n\t\t\ttypes: readonly ProviderId[]\n\t\t\tsourceAccess?: Access\n\t\t}\n\t\tresolve?: ProvidersResolve\n\t\t/** `providers.hosts`, for the collection's documents and the rows `resolve` reads alike. */\n\t\thosts: ProviderHostPolicy\n\t}\n\t/** Each binding with its `scopeField` filled. */\n\tbindings: Record<string, ResolvedBinding>\n\tcache: {\n\t\t/** Undefined when unset: adapter recommendedTtl is the fallback, an explicit value wins. */\n\t\tttl: { aggregate?: number; realtime?: number }\n\t\twarm: { enabled: boolean; windowHours: number; maxReads: number }\n\t\ttimeoutMs: number\n\t\tconcurrency: { global: number; perSource: number; perScope: number }\n\t\t/** The host's store; absent, the `analytics-cache` collection is the store. */\n\t\tstore?: CacheStore\n\t\t/** The default store's collection, used only while `store` is absent. */\n\t\tcollection: ResolvedCollectionOption\n\t}\n\twidgets: {\n\t\tenabled: boolean\n\t\tdisabled: string[]\n\t\tregister: CustomWidgetDef[]\n\t\tlocalizeText: boolean\n\t\tcomparison: boolean\n\t\toverrides: AnalyticsWidgetOverrides\n\t}\n\tsync: {\n\t\tenabled: boolean\n\t\tlookbackDays: number\n\t\tadapters?: string[]\n\t\tcollection: ResolvedCollectionOption & {\n\t\t\thidden: boolean\n\t\t}\n\t}\n\troutes: { base: RouteBase }\n\tjobs: ResolvedJobs\n\tsdks: AnalyticsSdks\n\thooks: { afterRead?: AfterReadHook }\n}\n\nconst PLUGIN_KEYS = keysOf<AnalyticsPluginOptions>({\n\tdisabled: true,\n\ttranslations: true,\n\tadapters: true,\n\tdefaultAdapter: true,\n\tplatformAdapter: true,\n\tscope: true,\n\tsources: true,\n\tdefaultSource: true,\n\treportingTimezone: true,\n\trevenue: true,\n\ttrustedProxyHops: true,\n\ttrustedPlatform: true,\n\taccess: true,\n\tcapture: true,\n\tgoals: true,\n\tcollections: true,\n\tproviders: true,\n\tview: true,\n\twidgets: true,\n\tcountryFlags: true,\n\tcache: true,\n\tsync: true,\n\troutes: true,\n\tjobs: true,\n\tsdks: true,\n\thooks: true,\n})\nconst ROUTES_KEYS = keysOf<AnalyticsRoutesOptions>({ base: true })\nconst BINDING_KEYS = keysOf<AnalyticsBinding>({\n\tpath: true,\n\tpathField: true,\n\thostname: true,\n\titem: true,\n\tscopeField: true,\n})\n\n/** Every key the plugin's own translations override, singular and plural forms alike. */\nconst TRANSLATION_KEYS: ReadonlySet<string> = new Set<string>([\n\t...Object.values(keys),\n\t...Object.values(pluralKeys).flatMap((forms) => Object.values(forms)),\n])\n\n/** `translations`: per language, strings keyed by the plugin's own translation keys. */\nconst assertTranslations = (option: unknown): void => {\n\tif (option === undefined) {\n\t\treturn\n\t}\n\tif (!isRecord(option) || Array.isArray(option)) {\n\t\tthrow new Error(\n\t\t\t`analytics: translations must be an object keyed by language, such as { de: { 'analytics:viewTitle': 'Statistik' } }, got ${kindOf(option)}`\n\t\t)\n\t}\n\tfor (const [language, strings] of Object.entries(option)) {\n\t\tif (!isRecord(strings) || Array.isArray(strings)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: translations.${language} must be an object of strings keyed by translation key, got ${kindOf(strings)}`\n\t\t\t)\n\t\t}\n\t\tfor (const [key, text] of Object.entries(strings)) {\n\t\t\tif (!TRANSLATION_KEYS.has(key)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`analytics: translations.${language}[\"${key}\"] is not one of the plugin's translation keys, which @10x-media/analytics/i18n exports as keys`\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (text !== undefined && typeof text !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`analytics: translations.${language}[\"${key}\"] must be a string, got ${kindOf(text)}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** `reportingTimezone`: an IANA name checked at boot, or a resolver answering per scope. */\nconst assertTimezone = (option: unknown): void => {\n\tif (option !== undefined && typeof option !== 'string' && typeof option !== 'function') {\n\t\tthrow new Error(\n\t\t\t`analytics: reportingTimezone must be an IANA timezone or a function, got ${kindOf(option)}`\n\t\t)\n\t}\n\tif (typeof option === 'string' && !isValidTimeZone(option)) {\n\t\tthrow new Error(\n\t\t\t`analytics: reportingTimezone \"${option}\" is not an IANA timezone name, such as \"Europe/Berlin\"`\n\t\t)\n\t}\n}\n\n/** One `collections` entry: how a bound document's page is found, and whether it is an item. */\nconst assertBinding = (binding: unknown, slug: string): void => {\n\tconst at = `collections.${slug}`\n\tconst shaped = optionsObject(binding, {\n\t\tpath: at,\n\t\tknown: BINDING_KEYS,\n\t\texample: \"an object such as { pathField: 'slug' }\",\n\t})\n\toptionalFunction(shaped.path, `${at}.path`)\n\tif (\n\t\tshaped.pathField !== undefined &&\n\t\t(typeof shaped.pathField !== 'string' || shaped.pathField.trim() === '')\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${at}.pathField must be a field name, got ${kindOf(shaped.pathField)}`\n\t\t)\n\t}\n\tif (\n\t\tshaped.hostname !== undefined &&\n\t\ttypeof shaped.hostname !== 'string' &&\n\t\ttypeof shaped.hostname !== 'function'\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${at}.hostname must be a hostname or a function answering one, got ${kindOf(shaped.hostname)}`\n\t\t)\n\t}\n\toptionalBoolean(shaped.item, `${at}.item`)\n\tif (!shaped.path && !shaped.pathField && shaped.item !== true) {\n\t\tthrow new Error(\n\t\t\t`analytics: binding for \"${slug}\" needs a path resolver, a pathField, or item: true`\n\t\t)\n\t}\n\tif (shaped.item === true && slug.includes(':')) {\n\t\tthrow new Error(\n\t\t\t`analytics: collection \"${slug}\" cannot be bound as an item: a ref is \"<collection>:<id>\", so the slug cannot hold a colon`\n\t\t)\n\t}\n}\n\n/**\n * Each binding with its scope field filled: `'tenant'` when scoped, else `false` (the request's own\n * scope). Whether that field exists is checked at init, after every plugin adds fields.\n */\nconst resolveBindings = (\n\tcollections: AnalyticsPluginOptions['collections'],\n\tscoped: boolean\n): Record<string, ResolvedBinding> => {\n\tconst keyed: unknown = collections\n\tif (keyed !== undefined && (!isRecord(keyed) || Array.isArray(keyed))) {\n\t\tthrow new Error(\n\t\t\t`analytics: collections must be an object keyed by collection slug, such as { pages: { pathField: 'slug' } }, got ${kindOf(keyed)}`\n\t\t)\n\t}\n\tconst out: Record<string, ResolvedBinding> = {}\n\tfor (const [slug, binding] of Object.entries(collections ?? {})) {\n\t\tif (!binding) continue\n\t\tassertBinding(binding, slug)\n\t\tconst declared = binding.scopeField ?? (scoped ? DEFAULT_BINDING_SCOPE_FIELD : false)\n\t\tconst scopeField =\n\t\t\tdeclared === false\n\t\t\t\t? false\n\t\t\t\t: flatFieldName(declared, {\n\t\t\t\t\t\tpath: `collections.${slug}.scopeField`,\n\t\t\t\t\t\treason: \"a document's scope is read from one of its own top-level fields\",\n\t\t\t\t\t})\n\t\t// Erases the per-slug document generic: the runtime only hands a binding its own documents.\n\t\tout[slug] = { ...(binding as AnalyticsBinding), scopeField }\n\t}\n\treturn out\n}\n\nconst resolveRoutes = (option: AnalyticsPluginOptions['routes']): ResolvedOptions['routes'] => {\n\tif (option !== undefined) {\n\t\toptionsObject(option, {\n\t\t\tpath: 'routes',\n\t\t\tknown: ROUTES_KEYS,\n\t\t\texample: \"an object such as { base: '/_x' }\",\n\t\t})\n\t}\n\treturn { base: resolveRouteBase(option?.base) }\n}\n\n/** `adapters`, and the options naming one of them by id. */\nconst assertAdapterOptions = (options: AnalyticsPluginOptions, requireAdapters: boolean): void => {\n\tassertAdapters(options.adapters)\n\tconst adapters = options.adapters ?? []\n\tif (requireAdapters && adapters.length === 0) {\n\t\tthrow new Error('analytics: at least one adapter is required')\n\t}\n\tif (adapters.length > 0) {\n\t\tassertNamesAdapter(options.defaultAdapter, 'defaultAdapter', adapters)\n\t}\n\tassertNamesAdapter(options.platformAdapter, 'platformAdapter', adapters)\n}\n\n/**\n * The options checked and filled. `requireAdapters: false` is the switched-off plugin's, which\n * reads through no adapter and only asks each for its schema.\n */\nexport function resolveOptions(\n\toptions: AnalyticsPluginOptions,\n\tsettings: { requireAdapters?: boolean } = {}\n): ResolvedOptions {\n\tassertNoLegacyOptions(options)\n\tfor (const key of Object.keys(options)) {\n\t\tif (!PLUGIN_KEYS.includes(key)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: ${key} is not an option; analytics() takes ${listOf(PLUGIN_KEYS)}`\n\t\t\t)\n\t\t}\n\t}\n\toptionalBoolean(options.disabled, 'disabled')\n\tassertTranslations(options.translations)\n\tassertAdapterOptions(options, settings.requireAdapters !== false)\n\tconst scope = resolveScope(options.scope)\n\tconst scoped = options.scope?.resolve !== undefined\n\tif (!scoped) {\n\t\tassertScopedOnlyOptions(options)\n\t}\n\tconst capture = resolveCapture(options, scoped)\n\tconst access = resolveAccess(options.access, scoped)\n\tconst trust = resolveTrust(options)\n\tassertTimezone(options.reportingTimezone)\n\tconst countryFlags = resolveCountryFlags(options.countryFlags)\n\tconst cache = resolveCache(options.cache)\n\tconst sync = resolveSync(options.sync)\n\tconst jobs = resolveJobs(options.jobs)\n\tassertJobsFit(jobs, { sync: sync.enabled, warm: cache.warm.enabled })\n\treturn {\n\t\tadapters: options.adapters,\n\t\tdefaultAdapter: options.defaultAdapter,\n\t\tscope,\n\t\tscoped,\n\t\treportingTimezone: options.reportingTimezone,\n\t\trevenue: resolveRevenue(options.revenue),\n\t\tplatformAdapter: options.platformAdapter,\n\t\tsources: resolveSources(options),\n\t\t...trust,\n\t\taccess,\n\t\tview: resolveView(options.view),\n\t\tcountryFlags,\n\t\tcapture,\n\t\t...resolveGoals(options.goals),\n\t\tproviders: resolveProviders(options.providers, options.adapters),\n\t\tbindings: resolveBindings(options.collections, scoped),\n\t\tcache,\n\t\twidgets: resolveWidgets(options.widgets),\n\t\tsync,\n\t\troutes: resolveRoutes(options.routes),\n\t\tjobs,\n\t\tsdks: resolveSdks(options.sdks),\n\t\thooks: resolveHooks(options.hooks),\n\t}\n}\n"],"mappings":"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"}
@@ -26,7 +26,8 @@ const PROVIDER_FIELD_KEYS = keysOf({
26
26
  name: true,
27
27
  provider: true,
28
28
  enabled: true,
29
- isDefault: true
29
+ isDefault: true,
30
+ withoutConsent: true
30
31
  });
31
32
  const ENCRYPTION_KEYS = keysOf({ keys: true });
32
33
  const isAdapterShaped = (value) => isRecord(value) && typeof value.id === "string" && value.id !== "" && typeof value.isConfigured === "function" && typeof value.query === "function" && isRecord(value.capabilities);
@@ -1 +1 @@
1
- {"version":3,"file":"sourceOptions.js","names":[],"sources":["../../src/core/sourceOptions.ts"],"sourcesContent":["import {\n\tconnectionFieldAccess,\n\tPROVIDERS_SLUG,\n\ttype ProviderCollectionFieldOverrides,\n\tservedProviderTypes,\n} from '../providers/collection'\nimport { PROVIDER_IDS, type ProviderId } from '../providers/factory'\nimport { resolveHostPolicy } from '../providers/hosts'\nimport { resolveScopedCollection } from './collectionOption'\nimport { keysOf, optionalFunction, optionalList, optionsObject } from './optionChecks'\nimport type { ProvidersCollectionOptions, ProvidersOptions, ResolvedOptions } from './options'\nimport { isRecord, kindOf, listOf } from './values'\n\nconst PROVIDERS_KEYS = keysOf<ProvidersOptions>({ collection: true, resolve: true, hosts: true })\nconst PROVIDERS_COLLECTION_KEYS = keysOf<ProvidersCollectionOptions>({\n\tslug: true,\n\tscopeField: true,\n\tfields: true,\n\toverrides: true,\n\taccess: true,\n\tencryption: true,\n\tconnectionAccess: true,\n\tdefaultAccess: true,\n\ttypes: true,\n\tsourceAccess: true,\n})\nconst PROVIDER_FIELD_KEYS = keysOf<ProviderCollectionFieldOverrides>({\n\tname: true,\n\tprovider: true,\n\tenabled: true,\n\tisDefault: true,\n})\nconst ENCRYPTION_KEYS = keysOf<NonNullable<ProvidersCollectionOptions['encryption']>>({\n\tkeys: true,\n})\n\nconst isAdapterShaped = (value: unknown): value is { id: string } =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\tvalue.id !== '' &&\n\ttypeof value.isConfigured === 'function' &&\n\ttypeof value.query === 'function' &&\n\tisRecord(value.capabilities)\n\n/** `adapters`: a list of adapters with an id each, no two sharing one. */\nexport const assertAdapters = (value: unknown): void => {\n\tconst ids = new Set<string>()\n\tfor (const [index, adapter] of optionalList(value, 'adapters', '[native()]').entries()) {\n\t\tif (!isAdapterShaped(adapter)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters[${index}] must be an adapter such as native() or plausible({ siteId, apiKey }), got ${kindOf(adapter)}`\n\t\t\t)\n\t\t}\n\t\tif (ids.has(adapter.id)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters lists two adapters with the id \"${adapter.id}\"; every source is read by its id, so give each its own`\n\t\t\t)\n\t\t}\n\t\tids.add(adapter.id)\n\t}\n}\n\n/** An option naming one of `adapters` by its id. */\nexport const assertNamesAdapter = (\n\tvalue: unknown,\n\tpath: string,\n\tadapters: readonly { id: string }[]\n): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} must be the id of an adapter in adapters, got ${kindOf(value)}`\n\t\t)\n\t}\n\tif (!adapters.some((adapter) => adapter.id === value)) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} \"${value}\" names no adapter in adapters, whose ids are ${listOf(adapters.map((adapter) => `\"${adapter.id}\"`))}`\n\t\t)\n\t}\n}\n\n/** `providers.collection.encryption`: a dedicated key ring, or nothing. */\nconst assertEncryption = (value: unknown): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tconst { keys } = optionsObject(value, {\n\t\tpath: 'providers.collection.encryption',\n\t\tknown: ENCRYPTION_KEYS,\n\t\texample: 'an object such as { keys }',\n\t})\n\tif (\n\t\tkeys !== undefined &&\n\t\t(!isRecord(keys) || typeof keys.active !== 'string' || !isRecord(keys.keys))\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: providers.collection.encryption.keys must be a key set such as { active: 'k1', keys: { k1: process.env.PROVIDER_KEY } }, got ${kindOf(keys)}`\n\t\t)\n\t}\n}\n\n/** A `native` document lends the config native(), so the type is served only beside one. */\nconst availableTypes = (adapters: readonly { id: string }[]): ProviderId[] =>\n\tPROVIDER_IDS.filter((type) => type !== 'native' || adapters.some((a) => a.id === 'native'))\n\n/** `providers.collection` turned on, with what only that collection takes. */\nconst resolveProvidersCollection = (\n\toption: ProvidersOptions['collection'],\n\tavailable: readonly ProviderId[]\n): ResolvedOptions['providers']['collection'] => {\n\tconst collection = resolveScopedCollection(option, {\n\t\tpath: 'providers.collection',\n\t\tfallback: PROVIDERS_SLUG,\n\t\tknown: PROVIDERS_COLLECTION_KEYS,\n\t\tfieldKeys: PROVIDER_FIELD_KEYS,\n\t\texampleSlug: 'providers',\n\t})\n\tif (option === undefined || typeof option === 'boolean') {\n\t\treturn { ...collection, types: available }\n\t}\n\tassertEncryption(option.encryption)\n\tconst connectionAccess = connectionFieldAccess(\n\t\t'providers.collection.connectionAccess',\n\t\toption.connectionAccess\n\t)\n\tconst defaultAccess = connectionFieldAccess(\n\t\t'providers.collection.defaultAccess',\n\t\toption.defaultAccess\n\t)\n\tconst sourceAccess = optionalFunction(option.sourceAccess, 'providers.collection.sourceAccess')\n\treturn {\n\t\t...collection,\n\t\ttypes: servedProviderTypes('providers.collection.types', option.types, available),\n\t\t...(option.encryption ? { encryption: option.encryption } : {}),\n\t\t...(connectionAccess ? { connectionAccess } : {}),\n\t\t...(defaultAccess ? { defaultAccess } : {}),\n\t\t...(sourceAccess ? { sourceAccess } : {}),\n\t}\n}\n\n/** `providers`: the collection or `resolve` (never both), and the hosts either may reach. */\nexport const resolveProviders = (\n\toption: ProvidersOptions | undefined,\n\tadapters: readonly { id: string }[]\n): ResolvedOptions['providers'] => {\n\tif (option !== undefined) {\n\t\toptionsObject(option, {\n\t\t\tpath: 'providers',\n\t\t\tknown: PROVIDERS_KEYS,\n\t\t\texample: 'an object such as { collection: true }',\n\t\t})\n\t}\n\tconst resolve = optionalFunction(option?.resolve, 'providers.resolve')\n\tconst collection = resolveProvidersCollection(option?.collection, availableTypes(adapters))\n\tif (resolve && collection.enabled) {\n\t\tthrow new Error(\n\t\t\t\"analytics: providers.resolve and providers.collection cannot both be set. resolve replaces the collection lookup, so the adapters it returns would be filtered by provider document ids no reader holds, and the collection's sourceAccess and connectionAccess would do nothing. Keep one of them.\"\n\t\t)\n\t}\n\tif (option?.hosts !== undefined && !collection.enabled && !resolve) {\n\t\tthrow new Error(\n\t\t\t'analytics: providers.hosts only applies to provider documents, so it needs providers.collection or providers.resolve. Set one of them, or remove it.'\n\t\t)\n\t}\n\treturn {\n\t\tcollection,\n\t\t...(resolve ? { resolve } : {}),\n\t\thosts: resolveHostPolicy(option?.hosts),\n\t}\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"sourceOptions.js","names":[],"sources":["../../src/core/sourceOptions.ts"],"sourcesContent":["import {\n\tconnectionFieldAccess,\n\tPROVIDERS_SLUG,\n\ttype ProviderCollectionFieldOverrides,\n\tservedProviderTypes,\n} from '../providers/collection'\nimport { PROVIDER_IDS, type ProviderId } from '../providers/factory'\nimport { resolveHostPolicy } from '../providers/hosts'\nimport { resolveScopedCollection } from './collectionOption'\nimport { keysOf, optionalFunction, optionalList, optionsObject } from './optionChecks'\nimport type { ProvidersCollectionOptions, ProvidersOptions, ResolvedOptions } from './options'\nimport { isRecord, kindOf, listOf } from './values'\n\nconst PROVIDERS_KEYS = keysOf<ProvidersOptions>({ collection: true, resolve: true, hosts: true })\nconst PROVIDERS_COLLECTION_KEYS = keysOf<ProvidersCollectionOptions>({\n\tslug: true,\n\tscopeField: true,\n\tfields: true,\n\toverrides: true,\n\taccess: true,\n\tencryption: true,\n\tconnectionAccess: true,\n\tdefaultAccess: true,\n\ttypes: true,\n\tsourceAccess: true,\n})\nconst PROVIDER_FIELD_KEYS = keysOf<ProviderCollectionFieldOverrides>({\n\tname: true,\n\tprovider: true,\n\tenabled: true,\n\tisDefault: true,\n\twithoutConsent: true,\n})\nconst ENCRYPTION_KEYS = keysOf<NonNullable<ProvidersCollectionOptions['encryption']>>({\n\tkeys: true,\n})\n\nconst isAdapterShaped = (value: unknown): value is { id: string } =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\tvalue.id !== '' &&\n\ttypeof value.isConfigured === 'function' &&\n\ttypeof value.query === 'function' &&\n\tisRecord(value.capabilities)\n\n/** `adapters`: a list of adapters with an id each, no two sharing one. */\nexport const assertAdapters = (value: unknown): void => {\n\tconst ids = new Set<string>()\n\tfor (const [index, adapter] of optionalList(value, 'adapters', '[native()]').entries()) {\n\t\tif (!isAdapterShaped(adapter)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters[${index}] must be an adapter such as native() or plausible({ siteId, apiKey }), got ${kindOf(adapter)}`\n\t\t\t)\n\t\t}\n\t\tif (ids.has(adapter.id)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters lists two adapters with the id \"${adapter.id}\"; every source is read by its id, so give each its own`\n\t\t\t)\n\t\t}\n\t\tids.add(adapter.id)\n\t}\n}\n\n/** An option naming one of `adapters` by its id. */\nexport const assertNamesAdapter = (\n\tvalue: unknown,\n\tpath: string,\n\tadapters: readonly { id: string }[]\n): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} must be the id of an adapter in adapters, got ${kindOf(value)}`\n\t\t)\n\t}\n\tif (!adapters.some((adapter) => adapter.id === value)) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} \"${value}\" names no adapter in adapters, whose ids are ${listOf(adapters.map((adapter) => `\"${adapter.id}\"`))}`\n\t\t)\n\t}\n}\n\n/** `providers.collection.encryption`: a dedicated key ring, or nothing. */\nconst assertEncryption = (value: unknown): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tconst { keys } = optionsObject(value, {\n\t\tpath: 'providers.collection.encryption',\n\t\tknown: ENCRYPTION_KEYS,\n\t\texample: 'an object such as { keys }',\n\t})\n\tif (\n\t\tkeys !== undefined &&\n\t\t(!isRecord(keys) || typeof keys.active !== 'string' || !isRecord(keys.keys))\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: providers.collection.encryption.keys must be a key set such as { active: 'k1', keys: { k1: process.env.PROVIDER_KEY } }, got ${kindOf(keys)}`\n\t\t)\n\t}\n}\n\n/** A `native` document lends the config native(), so the type is served only beside one. */\nconst availableTypes = (adapters: readonly { id: string }[]): ProviderId[] =>\n\tPROVIDER_IDS.filter((type) => type !== 'native' || adapters.some((a) => a.id === 'native'))\n\n/** `providers.collection` turned on, with what only that collection takes. */\nconst resolveProvidersCollection = (\n\toption: ProvidersOptions['collection'],\n\tavailable: readonly ProviderId[]\n): ResolvedOptions['providers']['collection'] => {\n\tconst collection = resolveScopedCollection(option, {\n\t\tpath: 'providers.collection',\n\t\tfallback: PROVIDERS_SLUG,\n\t\tknown: PROVIDERS_COLLECTION_KEYS,\n\t\tfieldKeys: PROVIDER_FIELD_KEYS,\n\t\texampleSlug: 'providers',\n\t})\n\tif (option === undefined || typeof option === 'boolean') {\n\t\treturn { ...collection, types: available }\n\t}\n\tassertEncryption(option.encryption)\n\tconst connectionAccess = connectionFieldAccess(\n\t\t'providers.collection.connectionAccess',\n\t\toption.connectionAccess\n\t)\n\tconst defaultAccess = connectionFieldAccess(\n\t\t'providers.collection.defaultAccess',\n\t\toption.defaultAccess\n\t)\n\tconst sourceAccess = optionalFunction(option.sourceAccess, 'providers.collection.sourceAccess')\n\treturn {\n\t\t...collection,\n\t\ttypes: servedProviderTypes('providers.collection.types', option.types, available),\n\t\t...(option.encryption ? { encryption: option.encryption } : {}),\n\t\t...(connectionAccess ? { connectionAccess } : {}),\n\t\t...(defaultAccess ? { defaultAccess } : {}),\n\t\t...(sourceAccess ? { sourceAccess } : {}),\n\t}\n}\n\n/** `providers`: the collection or `resolve` (never both), and the hosts either may reach. */\nexport const resolveProviders = (\n\toption: ProvidersOptions | undefined,\n\tadapters: readonly { id: string }[]\n): ResolvedOptions['providers'] => {\n\tif (option !== undefined) {\n\t\toptionsObject(option, {\n\t\t\tpath: 'providers',\n\t\t\tknown: PROVIDERS_KEYS,\n\t\t\texample: 'an object such as { collection: true }',\n\t\t})\n\t}\n\tconst resolve = optionalFunction(option?.resolve, 'providers.resolve')\n\tconst collection = resolveProvidersCollection(option?.collection, availableTypes(adapters))\n\tif (resolve && collection.enabled) {\n\t\tthrow new Error(\n\t\t\t\"analytics: providers.resolve and providers.collection cannot both be set. resolve replaces the collection lookup, so the adapters it returns would be filtered by provider document ids no reader holds, and the collection's sourceAccess and connectionAccess would do nothing. Keep one of them.\"\n\t\t)\n\t}\n\tif (option?.hosts !== undefined && !collection.enabled && !resolve) {\n\t\tthrow new Error(\n\t\t\t'analytics: providers.hosts only applies to provider documents, so it needs providers.collection or providers.resolve. Set one of them, or remove it.'\n\t\t)\n\t}\n\treturn {\n\t\tcollection,\n\t\t...(resolve ? { resolve } : {}),\n\t\thosts: resolveHostPolicy(option?.hosts),\n\t}\n}\n"],"mappings":";;;;;;;AAaA,MAAM,iBAAiB,OAAyB;CAAE,YAAY;CAAM,SAAS;CAAM,OAAO;AAAK,CAAC;AAChG,MAAM,4BAA4B,OAAmC;CACpE,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,kBAAkB;CAClB,eAAe;CACf,OAAO;CACP,cAAc;AACf,CAAC;AACD,MAAM,sBAAsB,OAAyC;CACpE,MAAM;CACN,UAAU;CACV,SAAS;CACT,WAAW;CACX,gBAAgB;AACjB,CAAC;AACD,MAAM,kBAAkB,OAA8D,EACrF,MAAM,KACP,CAAC;AAED,MAAM,mBAAmB,UACxB,SAAS,KAAK,KACd,OAAO,MAAM,OAAO,YACpB,MAAM,OAAO,MACb,OAAO,MAAM,iBAAiB,cAC9B,OAAO,MAAM,UAAU,cACvB,SAAS,MAAM,YAAY;;AAG5B,MAAa,kBAAkB,UAAyB;CACvD,MAAM,sBAAM,IAAI,IAAY;CAC5B,KAAK,MAAM,CAAC,OAAO,YAAY,aAAa,OAAO,YAAY,YAAY,EAAE,QAAQ,GAAG;EACvF,IAAI,CAAC,gBAAgB,OAAO,GAC3B,MAAM,IAAI,MACT,uBAAuB,MAAM,8EAA8E,OAAO,OAAO,GAC1H;EAED,IAAI,IAAI,IAAI,QAAQ,EAAE,GACrB,MAAM,IAAI,MACT,uDAAuD,QAAQ,GAAG,wDACnE;EAED,IAAI,IAAI,QAAQ,EAAE;CACnB;AACD;;AAGA,MAAa,sBACZ,OACA,MACA,aACU;CACV,IAAI,UAAU,KAAA,GACb;CAED,IAAI,OAAO,UAAU,UACpB,MAAM,IAAI,MACT,cAAc,KAAK,iDAAiD,OAAO,KAAK,GACjF;CAED,IAAI,CAAC,SAAS,MAAM,YAAY,QAAQ,OAAO,KAAK,GACnD,MAAM,IAAI,MACT,cAAc,KAAK,IAAI,MAAM,gDAAgD,OAAO,SAAS,KAAK,YAAY,IAAI,QAAQ,GAAG,EAAE,CAAC,GACjI;AAEF;;AAGA,MAAM,oBAAoB,UAAyB;CAClD,IAAI,UAAU,KAAA,GACb;CAED,MAAM,EAAE,SAAS,cAAc,OAAO;EACrC,MAAM;EACN,OAAO;EACP,SAAS;CACV,CAAC;CACD,IACC,SAAS,KAAA,MACR,CAAC,SAAS,IAAI,KAAK,OAAO,KAAK,WAAW,YAAY,CAAC,SAAS,KAAK,IAAI,IAE1E,MAAM,IAAI,MACT,2IAA2I,OAAO,IAAI,GACvJ;AAEF;;AAGA,MAAM,kBAAkB,aACvB,aAAa,QAAQ,SAAS,SAAS,YAAY,SAAS,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC;;AAG3F,MAAM,8BACL,QACA,cACgD;CAChD,MAAM,aAAa,wBAAwB,QAAQ;EAClD,MAAM;EACN,UAAU;EACV,OAAO;EACP,WAAW;EACX,aAAa;CACd,CAAC;CACD,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,WAC7C,OAAO;EAAE,GAAG;EAAY,OAAO;CAAU;CAE1C,iBAAiB,OAAO,UAAU;CAClC,MAAM,mBAAmB,sBACxB,yCACA,OAAO,gBACR;CACA,MAAM,gBAAgB,sBACrB,sCACA,OAAO,aACR;CACA,MAAM,eAAe,iBAAiB,OAAO,cAAc,mCAAmC;CAC9F,OAAO;EACN,GAAG;EACH,OAAO,oBAAoB,8BAA8B,OAAO,OAAO,SAAS;EAChF,GAAI,OAAO,aAAa,EAAE,YAAY,OAAO,WAAW,IAAI,CAAC;EAC7D,GAAI,mBAAmB,EAAE,iBAAiB,IAAI,CAAC;EAC/C,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;EACzC,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;CACxC;AACD;;AAGA,MAAa,oBACZ,QACA,aACkC;CAClC,IAAI,WAAW,KAAA,GACd,cAAc,QAAQ;EACrB,MAAM;EACN,OAAO;EACP,SAAS;CACV,CAAC;CAEF,MAAM,UAAU,iBAAiB,QAAQ,SAAS,mBAAmB;CACrE,MAAM,aAAa,2BAA2B,QAAQ,YAAY,eAAe,QAAQ,CAAC;CAC1F,IAAI,WAAW,WAAW,SACzB,MAAM,IAAI,MACT,qSACD;CAED,IAAI,QAAQ,UAAU,KAAA,KAAa,CAAC,WAAW,WAAW,CAAC,SAC1D,MAAM,IAAI,MACT,sJACD;CAED,OAAO;EACN;EACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;EAC7B,OAAO,kBAAkB,QAAQ,KAAK;CACvC;AACD"}
@@ -1,14 +1,14 @@
1
1
  import { CurrencyConverter } from "../../goals/currency.js";
2
- import { CaptureClientKind, CaptureSlot, CaptureSnippet, GoalMatch, SnippetScript, TrackerGoal, TrackerSlotConfig } from "../../tracker/config.js";
2
+ import { CaptureClientKind, CaptureSlot, CaptureSnippet, ConsentPhase, GoalMatch, HeldSlotMode, SlotMode, SlotWithoutConsent, SnippetScript, TrackerGoal, TrackerSlotConfig, WithoutConsentLevel } from "../../tracker/config.js";
3
3
  import { Goal } from "../../goals/types.js";
4
4
  import { BrowserAmounts, OrderSignatureMode } from "../../goals/match.js";
5
5
  import { TrustedPlatform } from "../../net/platform.js";
6
6
  import { RouteBase, RoutePaths } from "../../plugin/routes.js";
7
7
  import { FetchInit, FetchLike } from "../../core/fetch.js";
8
- import { CaptureSupport, ProxyDescriptor, ProxyRoute, ProxyRouteKind } from "../../core/capture.js";
8
+ import { CaptureSupport, CookielessSupport, ProxyDescriptor, ProxyRoute, ProxyRouteKind, SnippetArgs, SnippetMode } from "../../core/capture.js";
9
9
  import { AdapterJobs, AnalyticsTaskName, ScheduledTask, TASK_NAMES } from "../../core/jobs.js";
10
10
  import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4ReportRow, Ga4Sdk, MaxmindReader, MaxmindSdk } from "../../core/sdks.js";
11
- import { HitType } from "../../native/store/types.js";
11
+ import { HitMode, HitType } from "../../native/store/types.js";
12
12
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
13
13
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
14
14
  import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
@@ -1,18 +1,18 @@
1
1
  import { ga4EventName } from "../../adapters/ga4/eventName.js";
2
2
  import { CurrencyConverter } from "../../goals/currency.js";
3
- import { CaptureClientKind, CaptureSlot, CaptureSnippet, GoalMatch, SnippetScript, TrackerGoal, TrackerSlotConfig } from "../../tracker/config.js";
3
+ import { CaptureClientKind, CaptureSlot, CaptureSnippet, ConsentPhase, GoalMatch, HeldSlotMode, SlotMode, SlotWithoutConsent, SnippetScript, TrackerGoal, TrackerSlotConfig, WithoutConsentLevel } from "../../tracker/config.js";
4
4
  import { Goal } from "../../goals/types.js";
5
5
  import { BrowserAmounts, OrderSignatureMode } from "../../goals/match.js";
6
6
  import { TrustedPlatform } from "../../net/platform.js";
7
7
  import { RouteBase, RoutePaths } from "../../plugin/routes.js";
8
8
  import { FetchInit, FetchLike } from "../../core/fetch.js";
9
- import { CaptureSupport, ProxyDescriptor, ProxyRoute, ProxyRouteKind } from "../../core/capture.js";
9
+ import { CaptureSupport, CookielessSupport, ProxyDescriptor, ProxyRoute, ProxyRouteKind, SnippetArgs, SnippetMode } from "../../core/capture.js";
10
10
  import { AdapterJobs, AnalyticsTaskName, ScheduledTask, TASK_NAMES } from "../../core/jobs.js";
11
11
  import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4ReportRow, Ga4Sdk, MaxmindReader, MaxmindSdk } from "../../core/sdks.js";
12
- import { HitType } from "../../native/store/types.js";
12
+ import { HitMode, HitType } from "../../native/store/types.js";
13
13
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
14
14
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
15
15
  import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
16
16
  import { AdapterLabelOption } from "../../core/sourceLabel.js";
17
17
  import { Ga4Config, ga4 } from "../../adapters/ga4/ga4.js";
18
- export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4Config, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, ga4, ga4EventName };
18
+ export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4Config, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, ga4, ga4EventName };
@@ -1,18 +1,18 @@
1
1
  import { CurrencyConverter } from "../../goals/currency.js";
2
- import { CaptureClientKind, CaptureSlot, CaptureSnippet, GoalMatch, SnippetScript, TrackerGoal, TrackerSlotConfig } from "../../tracker/config.js";
2
+ import { CaptureClientKind, CaptureSlot, CaptureSnippet, ConsentPhase, GoalMatch, HeldSlotMode, SlotMode, SlotWithoutConsent, SnippetScript, TrackerGoal, TrackerSlotConfig, WithoutConsentLevel } from "../../tracker/config.js";
3
3
  import { Goal } from "../../goals/types.js";
4
4
  import { BrowserAmounts, OrderSignatureMode } from "../../goals/match.js";
5
5
  import { TrustedPlatform } from "../../net/platform.js";
6
6
  import { RouteBase, RoutePaths } from "../../plugin/routes.js";
7
7
  import { FetchInit, FetchLike } from "../../core/fetch.js";
8
- import { CaptureSupport, ProxyDescriptor, ProxyRoute, ProxyRouteKind } from "../../core/capture.js";
8
+ import { CaptureSupport, CookielessSupport, ProxyDescriptor, ProxyRoute, ProxyRouteKind, SnippetArgs, SnippetMode } from "../../core/capture.js";
9
9
  import { AnalyticsCollectionOptions, CollectionOverrides } from "../../core/collectionOption.js";
10
10
  import { AdapterJobs, AnalyticsTaskName, ScheduledTask, TASK_NAMES } from "../../core/jobs.js";
11
11
  import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4ReportRow, Ga4Sdk, MaxmindReader, MaxmindSdk } from "../../core/sdks.js";
12
12
  import { Geo, GeoResolver, GeoResolverOptions } from "../../native/geo/geoResolver.js";
13
13
  import { SESSION_DIMENSIONS, SessionDimension } from "../../native/store/rawRead.js";
14
14
  import { CapKey, CapsOption, CardinalityCaps } from "../../native/store/caps.js";
15
- import { HitType } from "../../native/store/types.js";
15
+ import { HitMode, HitType } from "../../native/store/types.js";
16
16
  import { ItemSignatureMode } from "../../native/ingest/itemSignature.js";
17
17
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
18
18
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
@@ -24,6 +24,6 @@ import { WriteBufferLimits, WriteBufferOption } from "../../native/engine/writeB
24
24
  import { BotFilter, isBot } from "../../native/ingest/bots.js";
25
25
  import { EventHostnameResolver, HostnameOption } from "../../native/ingest/resolveHostname.js";
26
26
  import { SqliteThread } from "../../native/store/sql/sqliteThread.js";
27
- import { NativeAdapter, NativeCollections, NativeOptions, NativeRetention, NativeSqlite, NativeToday, native } from "../../native/nativeAdapter.js";
27
+ import { NativeAdapter, NativeCollections, NativeOptions, NativeRetention, NativeSqlite, NativeToday, NativeWithoutConsent, native } from "../../native/nativeAdapter.js";
28
28
  import { MAINTAIN_TASK_SLUG, MaintainTaskInput } from "../../native/tasks/maintainTask.js";
29
- export { AGGREGATES_SLUG, type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsCollectionOptions, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BotFilter, type BrowserAmounts, type CapKey, type CapsOption, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type CardinalityCaps, type CollectionOverrides, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type EventHostnameResolver, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Geo, type GeoResolver, type GeoResolverOptions, type Goal, type GoalMatch, type Granularity, HITS_SLUG, type HitType, type HostnameOption, type IngestHostnameResolver, type ItemSignatureMode, MAINTAIN_TASK_SLUG, type MaintainTaskInput, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type NativeAdapter, type NativeCollections, type NativeOptions, type NativeRetention, type NativeSqlite, type NativeToday, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RebuildDaysInput, type RebuildDaysReport, type RouteBase, type RoutePaths, SESSION_DIMENSIONS, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SessionDimension, type SnippetScript, type SourceErrorKind, type SqliteThread, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WriteBufferLimits, type WriteBufferOption, isBot, native };
29
+ export { AGGREGATES_SLUG, type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsCollectionOptions, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BotFilter, type BrowserAmounts, type CapKey, type CapsOption, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type CardinalityCaps, type CollectionOverrides, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type EventHostnameResolver, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Geo, type GeoResolver, type GeoResolverOptions, type Goal, type GoalMatch, type Granularity, HITS_SLUG, type HeldSlotMode, type HitMode, type HitType, type HostnameOption, type IngestHostnameResolver, type ItemSignatureMode, MAINTAIN_TASK_SLUG, type MaintainTaskInput, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type NativeAdapter, type NativeCollections, type NativeOptions, type NativeRetention, type NativeSqlite, type NativeToday, type NativeWithoutConsent, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RebuildDaysInput, type RebuildDaysReport, type RouteBase, type RoutePaths, SESSION_DIMENSIONS, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SessionDimension, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type SqliteThread, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, type WriteBufferLimits, type WriteBufferOption, isBot, native };