@10x-media/analytics 1.0.0-beta.13 → 1.0.0-beta.14
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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @10x-media/analytics
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Fix: the providers' create and edit views open again when the Provider select is narrowed.** In 1.0.0-beta.13 they answered 500 ("Functions cannot be passed directly to Client Components") on every install running the providers collection without `native()` in `adapters`, or with `providers.collection.types` naming fewer than every type: the select's `filterOptions` handed Payload's client form state option labels that were functions. It now hands over the types' values alone, which is all the client select reads. A document stored with a type the install no longer serves still opens showing its type, and its save is still refused on the **Provider** field ([Which provider types a document may have](https://docs.10xmedia.de/analytics/providers#which-provider-types-a-document-may-have)).
|
|
8
|
+
|
|
9
|
+
**Behavioral:** the docs no longer promise that `providers.collection.types` orders the select. Its first type is the default, and the select lists the types it offers in one fixed order, the order of the **Provider** column's values, so no install's column changes with the list. A host that wrapped `providers.collection.fields.provider` to map the result to values keeps working, and can drop the wrapper.
|
|
10
|
+
|
|
3
11
|
## 1.0.0-beta.13
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/dist/core/options.d.ts
CHANGED
|
@@ -191,8 +191,8 @@ type ProvidersCollectionOptions = {
|
|
|
191
191
|
*/
|
|
192
192
|
defaultAccess?: ConnectionAccess;
|
|
193
193
|
/**
|
|
194
|
-
* Which provider types documents may have,
|
|
195
|
-
*
|
|
194
|
+
* Which provider types documents may have, the first being the select's default; the select lists
|
|
195
|
+
* them in a fixed order. Default: every type, `native` only while `adapters` holds native().
|
|
196
196
|
*/
|
|
197
197
|
types?: ProviderId[];
|
|
198
198
|
/**
|
package/dist/core/options.js.map
CHANGED
|
@@ -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, in the order the select offers them, the first being\n\t * its default. 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":";;;;;;;;;;;;;;;;;AA2FA,MAAa,8BAA8B;AA2yB3C,MAAM,cAAc,OAA+B;CAClD,UAAU;CACV,cAAc;CACd,UAAU;CACV,gBAAgB;CAChB,iBAAiB;CACjB,OAAO;CACP,SAAS;CACT,eAAe;CACf,mBAAmB;CACnB,SAAS;CACT,kBAAkB;CAClB,iBAAiB;CACjB,QAAQ;CACR,SAAS;CACT,OAAO;CACP,aAAa;CACb,WAAW;CACX,MAAM;CACN,SAAS;CACT,cAAc;CACd,OA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,cAAc,MAAM;EAAE,MAAM,KAAK;EAAS,MAAM,MAAM,KAAK;CAAQ,CAAC;CACpE,OAAO;EACN,UAAU,QAAQ;EAClB,gBAAgB,QAAQ;EACxB;EACA;EACA,mBAAmB,QAAQ;EAC3B,SAAS,eAAe,QAAQ,OAAO;EACvC,iBAAiB,QAAQ;EACzB,SAAS,eAAe,OAAO;EAC/B,GAAG;EACH;EACA,MAAM,YAAY,QAAQ,IAAI;EAC9B;EACA;EACA,GAAG,aAAa,QAAQ,KAAK;EAC7B,WAAW,iBAAiB,QAAQ,WAAW,QAAQ,QAAQ;EAC/D,UAAU,gBAAgB,QAAQ,aAAa,MAAM;EACrD;EACA,SAAS,eAAe,QAAQ,OAAO;EACvC;EACA,QAAQ,cAAc,QAAQ,MAAM;EACpC;EACA,MAAM,YAAY,QAAQ,IAAI;EAC9B,OAAO,aAAa,QAAQ,KAAK;CAClC;AACD"}
|
|
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":";;;;;;;;;;;;;;;;;AA2FA,MAAa,8BAA8B;AA2yB3C,MAAM,cAAc,OAA+B;CAClD,UAAU;CACV,cAAc;CACd,UAAU;CACV,gBAAgB;CAChB,iBAAiB;CACjB,OAAO;CACP,SAAS;CACT,eAAe;CACf,mBAAmB;CACnB,SAAS;CACT,kBAAkB;CAClB,iBAAiB;CACjB,QAAQ;CACR,SAAS;CACT,OAAO;CACP,aAAa;CACb,WAAW;CACX,MAAM;CACN,SAAS;CACT,cAAc;CACd,OAAO;CACP,MAAM;CACN,QAAQ;CACR,MAAM;CACN,MAAM;CACN,OAAO;AACR,CAAC;AACD,MAAM,cAAc,OAA+B,EAAE,MAAM,KAAK,CAAC;AACjE,MAAM,eAAe,OAAyB;CAC7C,MAAM;CACN,WAAW;CACX,UAAU;CACV,MAAM;CACN,YAAY;AACb,CAAC;;AAGD,MAAM,mBAAwC,IAAI,IAAY,CAC7D,GAAG,OAAO,OAAO,IAAI,GACrB,GAAG,OAAO,OAAO,UAAU,EAAE,SAAS,UAAU,OAAO,OAAO,KAAK,CAAC,CACrE,CAAC;;AAGD,MAAM,sBAAsB,WAA0B;CACrD,IAAI,WAAW,KAAA,GACd;CAED,IAAI,CAAC,SAAS,MAAM,KAAK,MAAM,QAAQ,MAAM,GAC5C,MAAM,IAAI,MACT,4HAA4H,OAAO,MAAM,GAC1I;CAED,KAAK,MAAM,CAAC,UAAU,YAAY,OAAO,QAAQ,MAAM,GAAG;EACzD,IAAI,CAAC,SAAS,OAAO,KAAK,MAA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/
|
|
47
47
|
connectionAccess?: ConnectionAccess;
|
|
48
48
|
/**
|
|
49
|
-
* The provider types the select offers,
|
|
50
|
-
*
|
|
49
|
+
* The provider types the select offers, the first being its default; a document saved with any
|
|
50
|
+
* other type is refused. Default: every type, `native` first.
|
|
51
51
|
*/
|
|
52
52
|
types?: ProviderId[];
|
|
53
53
|
}
|
|
@@ -158,6 +158,12 @@ const PROVIDER_NAMES = {
|
|
|
158
158
|
*/
|
|
159
159
|
const validateServed = (types) => (value, options) => typeof value === "string" && value !== "" && !types.includes(value) ? asTranslate(options.req.t)(keys.providerErrorTypeUnserved) : validations.select(value, options);
|
|
160
160
|
/**
|
|
161
|
+
* The values a narrowed select offers: the served types, and a stored type no longer served so its
|
|
162
|
+
* save is refused by name. Values only, since form state carries the result to the client, where
|
|
163
|
+
* a label function cannot cross; Payload's select reads nothing else from it.
|
|
164
|
+
*/
|
|
165
|
+
const offeredTypes = (types, stored) => isOneOf(PROVIDER_IDS, stored) && !types.includes(stored) ? [...types, stored] : [...types];
|
|
166
|
+
/**
|
|
161
167
|
* Sits in the sidebar with `enabled`: every body field is conditional on the provider and
|
|
162
168
|
* meaningless while `enabled` is off. The schema keeps every type (options, groups, a static
|
|
163
169
|
* default while `native` leads), so narrowing the offer neither alters a column nor drops settings.
|
|
@@ -174,9 +180,7 @@ const providerField = (access, staticLabel, types) => {
|
|
|
174
180
|
...access ? { access } : {},
|
|
175
181
|
...narrowed ? {
|
|
176
182
|
validate: validateServed(types),
|
|
177
|
-
filterOptions: ({ data
|
|
178
|
-
return [...types, ...types.includes(data?.provider) ? [] : [data?.provider]].flatMap((type) => options.filter((option) => typeof option !== "string" && option.value === type));
|
|
179
|
-
}
|
|
183
|
+
filterOptions: ({ data }) => offeredTypes(types, data?.provider)
|
|
180
184
|
} : {},
|
|
181
185
|
options: PROVIDER_IDS.map((type) => ({
|
|
182
186
|
label: labelForKey(PROVIDER_NAMES[type]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","names":[],"sources":["../../src/providers/collection.ts"],"sourcesContent":["import {\n\ttype CollectionBeforeValidateHook,\n\ttype CollectionConfig,\n\ttype Field,\n\ttype FieldAccess,\n\ttype PayloadRequest,\n\ttype SelectField,\n\ttype SelectFieldSingleValidation,\n\ttype TextareaField,\n\ttype TextField,\n\ttype TextFieldSingleValidation,\n\tValidationError,\n\tvalidations,\n} from 'payload'\nimport { validateMeasurementId } from '../adapters/ga4/measurementId'\nimport { validateScriptId } from '../adapters/plausible/scriptId'\nimport { optionsObject } from '../core/optionChecks'\nimport { isOneOf, kindOf, listOf } from '../core/values'\nimport { validateCurrency } from '../goals/currency'\nimport { type CollectionFieldOverride, overrideField } from '../plugin/collectionFields'\nimport { docScope, type ScopeChange } from '../plugin/scopeChange'\nimport { keys, type SingularKey, type TranslationKey } from '../translations/keys'\nimport { asTranslate, labelForKey } from '../translations/server'\nimport { builtInStaticLabel, type StaticLabelFor } from '../translations/staticLabel'\nimport { type ProviderAccessArgs, providerCreateAccess, providerRowAccess } from './access'\nimport { PROVIDER_IDS, type ProviderId } from './factory'\nimport { validateProviderHost } from './hosts'\nimport { retargetSecrets } from './retarget'\nimport { takenInScope } from './scopeUnique'\nimport { stampScope } from './stampScope'\n\nexport const PROVIDERS_SLUG = 'analytics-providers'\n\n/** The list's note to a tenant reading the platform's source in `fallback`. */\nexport const PROVIDERS_LIST_NOTICE_COMPONENT = '@10x-media/analytics/client#ProvidersListNotice'\n\n/** Builds the sealed variant of a secret source field; injected so the fields peer stays lazy. */\nexport type BuildSecretField = (source: TextField | TextareaField) => Field[]\n\n/**\n * Replaces a default field; it receives the plugin's own field to spread and may return any field\n * type (a `row`, a `collapsible`) that still holds a field of that name.\n */\nexport type ProviderFieldOverride = CollectionFieldOverride\n\nexport interface ProviderCollectionFieldOverrides {\n\tname?: ProviderFieldOverride\n\tprovider?: ProviderFieldOverride\n\tenabled?: ProviderFieldOverride\n\t/** The \"Default for this site\" checkbox, which only a scoped install's collection carries. */\n\tisDefault?: ProviderFieldOverride\n}\n\n/** Field access on the fields that decide where a provider document connects (`CONNECTION_PATHS`). */\nexport interface ConnectionFieldAccess {\n\tcreate?: FieldAccess\n\tupdate?: FieldAccess\n}\n\n/** One field access function for create and update alike, or `{ create, update }`. */\nexport type ConnectionAccess = FieldAccess | ConnectionFieldAccess\n\n/** `connectionAccess` in its object form, checked at boot; undefined while unset. */\nexport const connectionFieldAccess = (\n\tpath: string,\n\toption: ConnectionAccess | undefined\n): ConnectionFieldAccess | undefined => {\n\tif (option === undefined) {\n\t\treturn undefined\n\t}\n\tif (typeof option === 'function') {\n\t\treturn { create: option, update: option }\n\t}\n\tconst halves = optionsObject(option, {\n\t\tpath,\n\t\tknown: ['create', 'update'],\n\t\texample: 'a function, or { create, update } with a function in each',\n\t})\n\tfor (const [half, access] of Object.entries(halves)) {\n\t\tif (access !== undefined && typeof access !== 'function') {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: ${path}.${half} must be a field access function, got ${kindOf(access)}`\n\t\t\t)\n\t\t}\n\t}\n\tconst { create, update } = option\n\treturn { ...(create ? { create } : {}), ...(update ? { update } : {}) }\n}\n\n/**\n * The provider types documents may be saved with: every type `available` serves, narrowed to\n * `option` in its order when given, checked at boot.\n */\nexport const servedProviderTypes = (\n\tpath: string,\n\toption: unknown,\n\tavailable: readonly ProviderId[] = PROVIDER_IDS\n): ProviderId[] => {\n\tif (option === undefined) {\n\t\treturn [...available]\n\t}\n\tif (!Array.isArray(option)) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} must be a list of provider types such as ['plausible', 'umami'], got ${kindOf(option)}`\n\t\t)\n\t}\n\tconst listed: ProviderId[] = []\n\tfor (const type of option) {\n\t\tif (!isOneOf(PROVIDER_IDS, type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: ${path} lists ${kindOf(type)}, which is no provider type; use ${listOf(PROVIDER_IDS.map((id) => `\"${id}\"`))}`\n\t\t\t)\n\t\t}\n\t\tlisted.push(type)\n\t}\n\tconst served = [...new Set(listed)].filter((type) => available.includes(type))\n\tif (served.length === 0) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} leaves no provider type this install serves, which are ${listOf(available.map((id) => `\"${id}\"`))}; \"native\" needs native() in adapters`\n\t\t)\n\t}\n\treturn served\n}\n\nexport interface BuildProvidersCollectionArgs extends ProviderAccessArgs {\n\tslug: string\n\taccess?: Partial<CollectionConfig['access']>\n\t/** Per-field overrides, applied before the whole-collection `overrides`. */\n\tfields?: ProviderCollectionFieldOverrides\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t/**\n\t * Called after any change or delete with the scopes the write touched and the request that\n\t * wrote, so that request's own Payload instance reads those scopes again once the write commits.\n\t */\n\tonChange: (change: ScopeChange, req: PayloadRequest) => void | Promise<void>\n\tbuildSecret: BuildSecretField\n\t/** The fields plugin's test for a sealed value, which tells a resent secret from a kept one. */\n\tisSealed: (value: unknown) => boolean\n\t/** `providers.hosts.allowPrivateNetwork`: the `host` fields accept `http://` too. */\n\tallowPrivateNetwork?: boolean\n\tconnectionAccess?: ConnectionFieldAccess\n\t/** The provider types a document may be saved with; every type when absent. */\n\ttypes?: readonly ProviderId[]\n\t/** Field access on `isDefault`, which a scoped install's collection carries. */\n\tdefaultAccess?: ConnectionFieldAccess\n\t/** The install's static labels; the built-in strings alone when absent. */\n\tstaticLabel?: StaticLabelFor\n\t/** Mount the list's note on the platform fallback, for an install with a `fallback` policy. */\n\tlistNotice?: boolean\n}\n\nconst plainSecret: BuildSecretField = (source) => [source]\n\nconst textField = (\n\tname: string,\n\tlabel: TranslationKey,\n\topts: { width?: string; help?: TranslationKey; access?: ConnectionFieldAccess } = {}\n): Field => ({\n\tname,\n\ttype: 'text',\n\tlabel: labelForKey(label),\n\t...(opts.access ? { access: opts.access } : {}),\n\t...(opts.width || opts.help\n\t\t? {\n\t\t\t\tadmin: {\n\t\t\t\t\t...(opts.width ? { width: opts.width } : {}),\n\t\t\t\t\t...(opts.help ? { description: labelForKey(opts.help) } : {}),\n\t\t\t\t},\n\t\t\t}\n\t\t: {}),\n})\n\n/**\n * A sealed credential. Its help is a string per locale: Payload drops a function description from\n * the client field, which the write-only editor renders.\n */\nconst secretField = (\n\tbuildSecret: BuildSecretField,\n\tstaticLabel: StaticLabelFor,\n\topts: { name: string; label: TranslationKey; help: SingularKey; width?: string }\n): Field[] =>\n\tbuildSecret({\n\t\tname: opts.name,\n\t\ttype: 'text',\n\t\tlabel: labelForKey(opts.label),\n\t\tadmin: {\n\t\t\tdescription: staticLabel(opts.help),\n\t\t\t...(opts.width ? { width: opts.width } : {}),\n\t\t},\n\t})\n\n/**\n * Public capture config, plain text because the tracker config serves it to the browser. An adapter\n * declares `capture` only once its public field is filled.\n */\nconst captureField = (\n\tname: string,\n\tlabel: TranslationKey,\n\topts: { width?: string; validate?: TextFieldSingleValidation; help?: TranslationKey } = {}\n): Field => ({\n\tname,\n\ttype: 'text',\n\tlabel: labelForKey(label),\n\t...(opts.validate ? { validate: opts.validate } : {}),\n\tadmin: {\n\t\tdescription: labelForKey(opts.help ?? keys.providerFieldCaptureHelp),\n\t\t...(opts.width ? { width: opts.width } : {}),\n\t},\n})\n\n/**\n * Only when `scopeField` names the plugin's own field: a host-owned scope field is the host's to\n * register, and shadowing it would store the scope twice.\n */\nconst scopeField = (include: boolean): Field[] =>\n\tinclude\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\t// Written by scoped setups; hidden because single-site installs never touch it.\n\t\t\t\t\tname: 'scope',\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tindex: true,\n\t\t\t\t\tlabel: labelForKey(keys.providerFieldScope),\n\t\t\t\t\tadmin: { hidden: true },\n\t\t\t\t},\n\t\t\t]\n\t\t: []\n\nconst hostField = (\n\tallowPrivateNetwork: boolean,\n\taccess: ConnectionFieldAccess | undefined\n): Field => ({\n\tname: 'host',\n\ttype: 'text',\n\tlabel: labelForKey(keys.providerFieldHost),\n\tvalidate: validateProviderHost(allowPrivateNetwork),\n\t...(access ? { access } : {}),\n\tadmin: { description: labelForKey(keys.providerFieldHostHelp) },\n})\n\nconst currencyField = (name: string, help: TranslationKey): Field => ({\n\tname,\n\ttype: 'text',\n\tlabel: labelForKey(keys.providerFieldRevenueCurrency),\n\tvalidate: validateCurrency,\n\tadmin: { description: labelForKey(help) },\n})\n\nconst providerGroup = (provider: ProviderId, label: TranslationKey, fields: Field[]): Field => ({\n\tname: provider,\n\ttype: 'group',\n\tlabel: labelForKey(label),\n\tadmin: { condition: (data) => data?.provider === provider },\n\tfields,\n})\n\n/**\n * The native choice configures nothing, so it gets a note in place of a settings group:\n * an unnamed group stores no data and reads as the section its siblings occupy.\n */\nconst nativeNote = (): Field => ({\n\ttype: 'group',\n\tlabel: labelForKey(keys.providerNameNative),\n\tadmin: {\n\t\tcondition: (data) => data?.provider === 'native',\n\t\tdescription: labelForKey(keys.providerNameNativeHelp),\n\t},\n\tfields: [],\n})\n\nconst nameField = (): Field => ({\n\tname: 'name',\n\ttype: 'text',\n\trequired: true,\n\tlabel: labelForKey(keys.providerFieldName),\n\tadmin: { description: labelForKey(keys.providerFieldNameHelp) },\n})\n\nconst PROVIDER_NAMES: Record<ProviderId, TranslationKey> = {\n\tnative: keys.providerNameNative,\n\tplausible: keys.providerNamePlausible,\n\tumami: keys.providerNameUmami,\n\tga4: keys.providerNameGa4,\n\tposthog: keys.providerNamePosthog,\n}\n\n/**\n * Names the refusal of a stored type the install no longer serves (native() removed, `types`\n * narrowed), which the select's own check would only call an invalid selection.\n */\nconst validateServed =\n\t(types: readonly string[]): SelectFieldSingleValidation =>\n\t(value, options) =>\n\t\ttypeof value === 'string' && value !== '' && !types.includes(value)\n\t\t\t? asTranslate(options.req.t)(keys.providerErrorTypeUnserved)\n\t\t\t: validations.select(value, options)\n\n/**\n * Sits in the sidebar with `enabled`: every body field is conditional on the provider and\n * meaningless while `enabled` is off. The schema keeps every type (options, groups, a static\n * default while `native` leads), so narrowing the offer neither alters a column nor drops settings.\n */\nconst providerField = (\n\taccess: ConnectionFieldAccess | undefined,\n\tstaticLabel: StaticLabelFor,\n\ttypes: readonly ProviderId[]\n): SelectField => {\n\tconst [first = 'native'] = types\n\tconst narrowed = types.length < PROVIDER_IDS.length\n\treturn {\n\t\tname: 'provider',\n\t\ttype: 'select',\n\t\trequired: true,\n\t\tlabel: labelForKey(keys.providerFieldProvider),\n\t\tdefaultValue: first === 'native' ? first : () => first,\n\t\t...(access ? { access } : {}),\n\t\t...(narrowed\n\t\t\t? {\n\t\t\t\t\tvalidate: validateServed(types),\n\t\t\t\t\t// A stored type no longer served stays listed, so its save is refused by name.\n\t\t\t\t\tfilterOptions: ({ data, options }) => {\n\t\t\t\t\t\tconst offered = [...types, ...(types.includes(data?.provider) ? [] : [data?.provider])]\n\t\t\t\t\t\treturn offered.flatMap((type) =>\n\t\t\t\t\t\t\toptions.filter((option) => typeof option !== 'string' && option.value === type)\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\toptions: PROVIDER_IDS.map((type) => ({\n\t\t\tlabel: labelForKey(PROVIDER_NAMES[type]),\n\t\t\tvalue: type,\n\t\t})),\n\t\t// `admin.description` on a select is read where a label function never runs.\n\t\tadmin: { position: 'sidebar', description: staticLabel(keys.providerFieldProviderHelp) },\n\t}\n}\n\nconst enabledField = (): Field => ({\n\tname: 'enabled',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.providerFieldEnabled),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.providerFieldEnabledHelp) },\n})\n\nconst isDefaultField = (access: ConnectionFieldAccess | undefined): Field => ({\n\tname: 'isDefault',\n\ttype: 'checkbox',\n\tdefaultValue: false,\n\tlabel: labelForKey(keys.providerFieldIsDefault),\n\t...(access ? { access } : {}),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.providerFieldIsDefaultHelp) },\n})\n\n/**\n * At most one document per scope is the default, checked at collection level so a replaced\n * `isDefault` field keeps it. No index backs it: a unique one would also cover the unflagged rows.\n */\nconst checkSingleDefault = (args: BuildProvidersCollectionArgs): CollectionBeforeValidateHook => {\n\treturn async ({ data, originalDoc, req }) => {\n\t\tif ((data?.isDefault ?? originalDoc?.isDefault) !== true) {\n\t\t\treturn data\n\t\t}\n\t\tif (await takenInScope(args, { data, originalDoc, req }, { isDefault: { equals: true } })) {\n\t\t\tthrow new ValidationError({\n\t\t\t\tcollection: args.slug,\n\t\t\t\terrors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: labelForKey(keys.providerFieldIsDefault),\n\t\t\t\t\t\tmessage: asTranslate(req.t)(keys.providerErrorDefaultTaken),\n\t\t\t\t\t\tpath: 'isDefault',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t})\n\t\t}\n\t\treturn data\n\t}\n}\n\nexport interface ProviderFieldsOptions {\n\t/**\n\t * Seals each credential field, normally `encryptedField` from `@10x-media/fields` in write-only\n\t * mode. Left out, credentials are plain text and securing them is the host's job.\n\t */\n\tbuildSecret?: BuildSecretField\n\t/** Replaces one of the default fields, applied per field. */\n\tfields?: Omit<ProviderCollectionFieldOverrides, 'isDefault'>\n\t/** Adds the plugin's own hidden `scope` text field. Off by default. */\n\tscopeField?: boolean\n\t/**\n\t * Accepts `http://` in a `host` field, for a vendor on a private network. Set it together with\n\t * `providers.hosts.allowPrivateNetwork`, which lets the plugin connect there. Off, https only.\n\t */\n\tallowPrivateNetwork?: boolean\n\t/**\n\t * Field access on every `CONNECTION_PATHS` field except the scope field. One function for create\n\t * and update alike, or `{ create, update }`.\n\t */\n\tconnectionAccess?: ConnectionAccess\n\t/**\n\t * The provider types the select offers, in this order, the first being the default; a document\n\t * saved with any other type is refused. Default: every type, `native` first.\n\t */\n\ttypes?: ProviderId[]\n}\n\n/** What the field list takes beyond the public options. */\ninterface FieldListArgs {\n\ttypes: readonly ProviderId[]\n\t/** The `isDefault` checkbox, overridden, placed after `enabled`; only a scoped collection has it. */\n\tisDefault?: Field\n}\n\n/**\n * Provider-settings fields alone, for a host that stores them elsewhere and feeds them back through\n * `providers.resolve`; {@link adapterFromProviderDoc} reads the result as is.\n */\nexport const analyticsProviderFields = (options: ProviderFieldsOptions = {}): Field[] =>\n\tproviderFields(options, builtInStaticLabel, {\n\t\ttypes: servedProviderTypes('analyticsProviderFields({ types })', options.types),\n\t})\n\nconst providerFields = (\n\toptions: ProviderFieldsOptions,\n\tstaticLabel: StaticLabelFor,\n\tlist: FieldListArgs\n): Field[] => {\n\tconst buildSecret = options.buildSecret ?? plainSecret\n\tconst access = connectionFieldAccess(\n\t\t'analyticsProviderFields({ connectionAccess })',\n\t\toptions.connectionAccess\n\t)\n\tconst allowPrivateNetwork = options.allowPrivateNetwork === true\n\tconst apiKeyField = (): Field[] =>\n\t\tsecretField(buildSecret, staticLabel, {\n\t\t\tname: 'apiKey',\n\t\t\tlabel: keys.providerFieldApiKey,\n\t\t\thelp: keys.providerFieldApiKeyHelp,\n\t\t\twidth: '50%',\n\t\t})\n\treturn [\n\t\toverrideField(nameField(), options.fields?.name),\n\t\toverrideField(providerField(access, staticLabel, list.types), options.fields?.provider),\n\t\toverrideField(enabledField(), options.fields?.enabled),\n\t\t...(list.isDefault ? [list.isDefault] : []),\n\t\t...scopeField(options.scopeField === true),\n\t\tnativeNote(),\n\t\tproviderGroup('plausible', keys.providerNamePlausible, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('siteId', keys.providerFieldSiteId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldSiteIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\t...apiKeyField(),\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\tcaptureField('domain', keys.providerFieldDomain, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldDomainHelp,\n\t\t\t\t\t}),\n\t\t\t\t\tcaptureField('scriptId', keys.providerFieldScriptId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldScriptIdHelp,\n\t\t\t\t\t\tvalidate: validateScriptId,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t},\n\t\t\tcurrencyField('revenueCurrency', keys.providerFieldRevenueCurrencyHelp),\n\t\t\thostField(allowPrivateNetwork, access),\n\t\t]),\n\t\tproviderGroup('umami', keys.providerNameUmami, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('websiteId', keys.providerFieldWebsiteId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldWebsiteIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\t...apiKeyField(),\n\t\t\t\t],\n\t\t\t},\n\t\t\t...secretField(buildSecret, staticLabel, {\n\t\t\t\tname: 'token',\n\t\t\t\tlabel: keys.providerFieldToken,\n\t\t\t\thelp: keys.providerFieldTokenHelp,\n\t\t\t}),\n\t\t\thostField(allowPrivateNetwork, access),\n\t\t]),\n\t\tproviderGroup('ga4', keys.providerNameGa4, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('propertyId', keys.providerFieldPropertyId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldPropertyIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\ttextField('projectId', keys.providerFieldProjectId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldProjectIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t},\n\t\t\ttextField('clientEmail', keys.providerFieldClientEmail, {\n\t\t\t\thelp: keys.providerFieldClientEmailHelp,\n\t\t\t\taccess,\n\t\t\t}),\n\t\t\tcaptureField('measurementId', keys.providerFieldMeasurementId, {\n\t\t\t\tvalidate: validateMeasurementId,\n\t\t\t}),\n\t\t\tcurrencyField('currency', keys.providerFieldGa4CurrencyHelp),\n\t\t\t...buildSecret({\n\t\t\t\tname: 'privateKey',\n\t\t\t\ttype: 'textarea',\n\t\t\t\tlabel: labelForKey(keys.providerFieldPrivateKey),\n\t\t\t\tadmin: { description: staticLabel(keys.providerFieldPrivateKeyHelp) },\n\t\t\t}),\n\t\t]),\n\t\tproviderGroup('posthog', keys.providerNamePosthog, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('projectId', keys.providerFieldProjectId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldProjectIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\t...apiKeyField(),\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\tcaptureField('projectToken', keys.providerFieldProjectToken, { width: '50%' }),\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'region',\n\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\tlabel: labelForKey(keys.providerFieldRegion),\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ label: 'US', value: 'us' },\n\t\t\t\t\t\t\t{ label: 'EU', value: 'eu' },\n\t\t\t\t\t\t],\n\t\t\t\t\t\t...(access ? { access } : {}),\n\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\tdescription: staticLabel(keys.providerFieldRegionHelp),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\ttextField('scopeProperty', keys.providerFieldScopeProperty, {\n\t\t\t\thelp: keys.providerFieldScopePropertyHelp,\n\t\t\t\taccess,\n\t\t\t}),\n\t\t\thostField(allowPrivateNetwork, access),\n\t\t]),\n\t]\n}\n\n/**\n * Runtime provider-settings collection, one document per provider (and scope). Admin-only by\n * default; `access` overrides single operations, `overrides` reshapes the whole config last.\n */\nexport const buildProvidersCollection = (args: BuildProvidersCollectionArgs): CollectionConfig => {\n\tconst staticLabel = args.staticLabel ?? builtInStaticLabel\n\tconst collection: CollectionConfig = {\n\t\tslug: args.slug,\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.providersCollectionSingular),\n\t\t\tplural: labelForKey(keys.providersCollectionPlural),\n\t\t},\n\t\tdisableDuplicate: true,\n\t\tadmin: {\n\t\t\tuseAsTitle: 'name',\n\t\t\tdefaultColumns: ['name', 'provider', 'enabled'],\n\t\t\tgroup: staticLabel(keys.adminGroup),\n\t\t\tdescription: staticLabel(keys.providersCollectionDescription),\n\t\t\t...(args.listNotice ? { components: { beforeList: [PROVIDERS_LIST_NOTICE_COMPONENT] } } : {}),\n\t\t},\n\t\taccess: {\n\t\t\tread: providerRowAccess(args),\n\t\t\tcreate: providerCreateAccess(args),\n\t\t\tupdate: providerRowAccess(args),\n\t\t\tdelete: providerRowAccess(args),\n\t\t\t...args.access,\n\t\t},\n\t\thooks: {\n\t\t\t...(args.scoped ? { beforeValidate: [checkSingleDefault(args)] } : {}),\n\t\t\tbeforeChange: [\n\t\t\t\tstampScope(args),\n\t\t\t\tretargetSecrets({ scopeField: args.scopeField, isSealed: args.isSealed }),\n\t\t\t],\n\t\t\tafterChange: [\n\t\t\t\tasync ({ doc, operation, previousDoc, req }) => {\n\t\t\t\t\tawait args.onChange(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tscope: docScope(doc, args.scopeField),\n\t\t\t\t\t\t\t...(operation === 'update'\n\t\t\t\t\t\t\t\t? { previousScope: docScope(previousDoc, args.scopeField) }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\treq\n\t\t\t\t\t)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t\tafterDelete: [\n\t\t\t\tasync ({ doc, req }) => {\n\t\t\t\t\tawait args.onChange({ scope: docScope(doc, args.scopeField) }, req)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tfields: providerFields(\n\t\t\t{\n\t\t\t\tbuildSecret: args.buildSecret,\n\t\t\t\t...(args.fields ? { fields: args.fields } : {}),\n\t\t\t\tscopeField: args.scopeField === 'scope',\n\t\t\t\tallowPrivateNetwork: args.allowPrivateNetwork === true,\n\t\t\t\t...(args.connectionAccess ? { connectionAccess: args.connectionAccess } : {}),\n\t\t\t},\n\t\t\tstaticLabel,\n\t\t\t{\n\t\t\t\ttypes: args.types ?? PROVIDER_IDS,\n\t\t\t\t// A default is picked per scope: an unscoped install has one site and nothing to pick.\n\t\t\t\t...(args.scoped\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tisDefault: overrideField(isDefaultField(args.defaultAccess), args.fields?.isDefault),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}\n\t\t),\n\t}\n\treturn args.overrides ? args.overrides(collection) : collection\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAa,iBAAiB;;AAG9B,MAAa,kCAAkC;;AA6B/C,MAAa,yBACZ,MACA,WACuC;CACvC,IAAI,WAAW,KAAA,GACd;CAED,IAAI,OAAO,WAAW,YACrB,OAAO;EAAE,QAAQ;EAAQ,QAAQ;CAAO;CAEzC,MAAM,SAAS,cAAc,QAAQ;EACpC;EACA,OAAO,CAAC,UAAU,QAAQ;EAC1B,SAAS;CACV,CAAC;CACD,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GACjD,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,YAC7C,MAAM,IAAI,MACT,cAAc,KAAK,GAAG,KAAK,wCAAwC,OAAO,MAAM,GACjF;CAGF,MAAM,EAAE,QAAQ,WAAW;CAC3B,OAAO;EAAE,GAAI,SAAS,EAAE,OAAO,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,QAAQ,qBAAqB,IAAI;GACjC,QAAQ,kBAAkB,IAAI;GAC9B,QAAQ,kBAAkB,IAAI;GAC9B,GAAG,KAAK;EACT;EACA,OAAO;GACN,GAAI,KAAK,SAAS,EAAE,gBAAgB,CAAC,mBAAmB,IAAI,CAAC,EAAE,IAAI,CAAC;GACpE,cAAc,CACb,WAAW,IAAI,GACf,gBAAgB;IAAE,YAAY,KAAK;IAAY,UAAU,KAAK;GAAS,CAAC,CACzE;GACA,aAAa,CACZ,OAAO,EAAE,KAAK,WAAW,aAAa,UAAU;IAC/C,MAAM,KAAK,SACV;KACC,OAAO,SAAS,KAAK,KAAK,UAAU;KACpC,GAAI,cAAc,WACf,EAAE,eAAe,SAAS,aAAa,KAAK,UAAU,EAAE,IACxD,CAAC;IACL,GACA,GACD;IACA,OAAO;GACR,CACD;GACA,aAAa,CACZ,OAAO,EAAE,KAAK,UAAU;IACvB,MAAM,KAAK,SAAS,EAAE,OAAO,SAAS,KAAK,KAAK,UAAU,EAAE,GAAG,GAAG;IAClE,OAAO;GACR,CACD;EACD;EACA,QAAQ,eACP;GACC,aAAa,KAAK;GAClB,GAAI,KAAK,SAAS,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;GAC7C,YAAY,KAAK,eAAe;GAChC,qBAAqB,KAAK,wBAAwB;GAClD,GAAI,KAAK,mBAAmB,EAAE,kBAAkB,KAAK,iBAAiB,IAAI,CAAC;EAC5E,GACA,aACA;GACC,OAAO,KAAK,SAAS;GAErB,GAAI,KAAK,SACN,EACA,WAAW,cAAc,eAAe,KAAK,aAAa,GAAG,KAAK,QAAQ,SAAS,EACpF,IACC,CAAC;EACL,CACD;CACD;CACA,OAAO,KAAK,YAAY,KAAK,UAAU,UAAU,IAAI;AACtD"}
|
|
1
|
+
{"version":3,"file":"collection.js","names":[],"sources":["../../src/providers/collection.ts"],"sourcesContent":["import {\n\ttype CollectionBeforeValidateHook,\n\ttype CollectionConfig,\n\ttype Field,\n\ttype FieldAccess,\n\ttype PayloadRequest,\n\ttype SelectField,\n\ttype SelectFieldSingleValidation,\n\ttype TextareaField,\n\ttype TextField,\n\ttype TextFieldSingleValidation,\n\tValidationError,\n\tvalidations,\n} from 'payload'\nimport { validateMeasurementId } from '../adapters/ga4/measurementId'\nimport { validateScriptId } from '../adapters/plausible/scriptId'\nimport { optionsObject } from '../core/optionChecks'\nimport { isOneOf, kindOf, listOf } from '../core/values'\nimport { validateCurrency } from '../goals/currency'\nimport { type CollectionFieldOverride, overrideField } from '../plugin/collectionFields'\nimport { docScope, type ScopeChange } from '../plugin/scopeChange'\nimport { keys, type SingularKey, type TranslationKey } from '../translations/keys'\nimport { asTranslate, labelForKey } from '../translations/server'\nimport { builtInStaticLabel, type StaticLabelFor } from '../translations/staticLabel'\nimport { type ProviderAccessArgs, providerCreateAccess, providerRowAccess } from './access'\nimport { PROVIDER_IDS, type ProviderId } from './factory'\nimport { validateProviderHost } from './hosts'\nimport { retargetSecrets } from './retarget'\nimport { takenInScope } from './scopeUnique'\nimport { stampScope } from './stampScope'\n\nexport const PROVIDERS_SLUG = 'analytics-providers'\n\n/** The list's note to a tenant reading the platform's source in `fallback`. */\nexport const PROVIDERS_LIST_NOTICE_COMPONENT = '@10x-media/analytics/client#ProvidersListNotice'\n\n/** Builds the sealed variant of a secret source field; injected so the fields peer stays lazy. */\nexport type BuildSecretField = (source: TextField | TextareaField) => Field[]\n\n/**\n * Replaces a default field; it receives the plugin's own field to spread and may return any field\n * type (a `row`, a `collapsible`) that still holds a field of that name.\n */\nexport type ProviderFieldOverride = CollectionFieldOverride\n\nexport interface ProviderCollectionFieldOverrides {\n\tname?: ProviderFieldOverride\n\tprovider?: ProviderFieldOverride\n\tenabled?: ProviderFieldOverride\n\t/** The \"Default for this site\" checkbox, which only a scoped install's collection carries. */\n\tisDefault?: ProviderFieldOverride\n}\n\n/** Field access on the fields that decide where a provider document connects (`CONNECTION_PATHS`). */\nexport interface ConnectionFieldAccess {\n\tcreate?: FieldAccess\n\tupdate?: FieldAccess\n}\n\n/** One field access function for create and update alike, or `{ create, update }`. */\nexport type ConnectionAccess = FieldAccess | ConnectionFieldAccess\n\n/** `connectionAccess` in its object form, checked at boot; undefined while unset. */\nexport const connectionFieldAccess = (\n\tpath: string,\n\toption: ConnectionAccess | undefined\n): ConnectionFieldAccess | undefined => {\n\tif (option === undefined) {\n\t\treturn undefined\n\t}\n\tif (typeof option === 'function') {\n\t\treturn { create: option, update: option }\n\t}\n\tconst halves = optionsObject(option, {\n\t\tpath,\n\t\tknown: ['create', 'update'],\n\t\texample: 'a function, or { create, update } with a function in each',\n\t})\n\tfor (const [half, access] of Object.entries(halves)) {\n\t\tif (access !== undefined && typeof access !== 'function') {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: ${path}.${half} must be a field access function, got ${kindOf(access)}`\n\t\t\t)\n\t\t}\n\t}\n\tconst { create, update } = option\n\treturn { ...(create ? { create } : {}), ...(update ? { update } : {}) }\n}\n\n/**\n * The provider types documents may be saved with: every type `available` serves, narrowed to\n * `option` in its order when given, checked at boot.\n */\nexport const servedProviderTypes = (\n\tpath: string,\n\toption: unknown,\n\tavailable: readonly ProviderId[] = PROVIDER_IDS\n): ProviderId[] => {\n\tif (option === undefined) {\n\t\treturn [...available]\n\t}\n\tif (!Array.isArray(option)) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} must be a list of provider types such as ['plausible', 'umami'], got ${kindOf(option)}`\n\t\t)\n\t}\n\tconst listed: ProviderId[] = []\n\tfor (const type of option) {\n\t\tif (!isOneOf(PROVIDER_IDS, type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: ${path} lists ${kindOf(type)}, which is no provider type; use ${listOf(PROVIDER_IDS.map((id) => `\"${id}\"`))}`\n\t\t\t)\n\t\t}\n\t\tlisted.push(type)\n\t}\n\tconst served = [...new Set(listed)].filter((type) => available.includes(type))\n\tif (served.length === 0) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} leaves no provider type this install serves, which are ${listOf(available.map((id) => `\"${id}\"`))}; \"native\" needs native() in adapters`\n\t\t)\n\t}\n\treturn served\n}\n\nexport interface BuildProvidersCollectionArgs extends ProviderAccessArgs {\n\tslug: string\n\taccess?: Partial<CollectionConfig['access']>\n\t/** Per-field overrides, applied before the whole-collection `overrides`. */\n\tfields?: ProviderCollectionFieldOverrides\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t/**\n\t * Called after any change or delete with the scopes the write touched and the request that\n\t * wrote, so that request's own Payload instance reads those scopes again once the write commits.\n\t */\n\tonChange: (change: ScopeChange, req: PayloadRequest) => void | Promise<void>\n\tbuildSecret: BuildSecretField\n\t/** The fields plugin's test for a sealed value, which tells a resent secret from a kept one. */\n\tisSealed: (value: unknown) => boolean\n\t/** `providers.hosts.allowPrivateNetwork`: the `host` fields accept `http://` too. */\n\tallowPrivateNetwork?: boolean\n\tconnectionAccess?: ConnectionFieldAccess\n\t/** The provider types a document may be saved with; every type when absent. */\n\ttypes?: readonly ProviderId[]\n\t/** Field access on `isDefault`, which a scoped install's collection carries. */\n\tdefaultAccess?: ConnectionFieldAccess\n\t/** The install's static labels; the built-in strings alone when absent. */\n\tstaticLabel?: StaticLabelFor\n\t/** Mount the list's note on the platform fallback, for an install with a `fallback` policy. */\n\tlistNotice?: boolean\n}\n\nconst plainSecret: BuildSecretField = (source) => [source]\n\nconst textField = (\n\tname: string,\n\tlabel: TranslationKey,\n\topts: { width?: string; help?: TranslationKey; access?: ConnectionFieldAccess } = {}\n): Field => ({\n\tname,\n\ttype: 'text',\n\tlabel: labelForKey(label),\n\t...(opts.access ? { access: opts.access } : {}),\n\t...(opts.width || opts.help\n\t\t? {\n\t\t\t\tadmin: {\n\t\t\t\t\t...(opts.width ? { width: opts.width } : {}),\n\t\t\t\t\t...(opts.help ? { description: labelForKey(opts.help) } : {}),\n\t\t\t\t},\n\t\t\t}\n\t\t: {}),\n})\n\n/**\n * A sealed credential. Its help is a string per locale: Payload drops a function description from\n * the client field, which the write-only editor renders.\n */\nconst secretField = (\n\tbuildSecret: BuildSecretField,\n\tstaticLabel: StaticLabelFor,\n\topts: { name: string; label: TranslationKey; help: SingularKey; width?: string }\n): Field[] =>\n\tbuildSecret({\n\t\tname: opts.name,\n\t\ttype: 'text',\n\t\tlabel: labelForKey(opts.label),\n\t\tadmin: {\n\t\t\tdescription: staticLabel(opts.help),\n\t\t\t...(opts.width ? { width: opts.width } : {}),\n\t\t},\n\t})\n\n/**\n * Public capture config, plain text because the tracker config serves it to the browser. An adapter\n * declares `capture` only once its public field is filled.\n */\nconst captureField = (\n\tname: string,\n\tlabel: TranslationKey,\n\topts: { width?: string; validate?: TextFieldSingleValidation; help?: TranslationKey } = {}\n): Field => ({\n\tname,\n\ttype: 'text',\n\tlabel: labelForKey(label),\n\t...(opts.validate ? { validate: opts.validate } : {}),\n\tadmin: {\n\t\tdescription: labelForKey(opts.help ?? keys.providerFieldCaptureHelp),\n\t\t...(opts.width ? { width: opts.width } : {}),\n\t},\n})\n\n/**\n * Only when `scopeField` names the plugin's own field: a host-owned scope field is the host's to\n * register, and shadowing it would store the scope twice.\n */\nconst scopeField = (include: boolean): Field[] =>\n\tinclude\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\t// Written by scoped setups; hidden because single-site installs never touch it.\n\t\t\t\t\tname: 'scope',\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tindex: true,\n\t\t\t\t\tlabel: labelForKey(keys.providerFieldScope),\n\t\t\t\t\tadmin: { hidden: true },\n\t\t\t\t},\n\t\t\t]\n\t\t: []\n\nconst hostField = (\n\tallowPrivateNetwork: boolean,\n\taccess: ConnectionFieldAccess | undefined\n): Field => ({\n\tname: 'host',\n\ttype: 'text',\n\tlabel: labelForKey(keys.providerFieldHost),\n\tvalidate: validateProviderHost(allowPrivateNetwork),\n\t...(access ? { access } : {}),\n\tadmin: { description: labelForKey(keys.providerFieldHostHelp) },\n})\n\nconst currencyField = (name: string, help: TranslationKey): Field => ({\n\tname,\n\ttype: 'text',\n\tlabel: labelForKey(keys.providerFieldRevenueCurrency),\n\tvalidate: validateCurrency,\n\tadmin: { description: labelForKey(help) },\n})\n\nconst providerGroup = (provider: ProviderId, label: TranslationKey, fields: Field[]): Field => ({\n\tname: provider,\n\ttype: 'group',\n\tlabel: labelForKey(label),\n\tadmin: { condition: (data) => data?.provider === provider },\n\tfields,\n})\n\n/**\n * The native choice configures nothing, so it gets a note in place of a settings group:\n * an unnamed group stores no data and reads as the section its siblings occupy.\n */\nconst nativeNote = (): Field => ({\n\ttype: 'group',\n\tlabel: labelForKey(keys.providerNameNative),\n\tadmin: {\n\t\tcondition: (data) => data?.provider === 'native',\n\t\tdescription: labelForKey(keys.providerNameNativeHelp),\n\t},\n\tfields: [],\n})\n\nconst nameField = (): Field => ({\n\tname: 'name',\n\ttype: 'text',\n\trequired: true,\n\tlabel: labelForKey(keys.providerFieldName),\n\tadmin: { description: labelForKey(keys.providerFieldNameHelp) },\n})\n\nconst PROVIDER_NAMES: Record<ProviderId, TranslationKey> = {\n\tnative: keys.providerNameNative,\n\tplausible: keys.providerNamePlausible,\n\tumami: keys.providerNameUmami,\n\tga4: keys.providerNameGa4,\n\tposthog: keys.providerNamePosthog,\n}\n\n/**\n * Names the refusal of a stored type the install no longer serves (native() removed, `types`\n * narrowed), which the select's own check would only call an invalid selection.\n */\nconst validateServed =\n\t(types: readonly string[]): SelectFieldSingleValidation =>\n\t(value, options) =>\n\t\ttypeof value === 'string' && value !== '' && !types.includes(value)\n\t\t\t? asTranslate(options.req.t)(keys.providerErrorTypeUnserved)\n\t\t\t: validations.select(value, options)\n\n/**\n * The values a narrowed select offers: the served types, and a stored type no longer served so its\n * save is refused by name. Values only, since form state carries the result to the client, where\n * a label function cannot cross; Payload's select reads nothing else from it.\n */\nconst offeredTypes = (types: readonly ProviderId[], stored: unknown): ProviderId[] =>\n\tisOneOf(PROVIDER_IDS, stored) && !types.includes(stored) ? [...types, stored] : [...types]\n\n/**\n * Sits in the sidebar with `enabled`: every body field is conditional on the provider and\n * meaningless while `enabled` is off. The schema keeps every type (options, groups, a static\n * default while `native` leads), so narrowing the offer neither alters a column nor drops settings.\n */\nconst providerField = (\n\taccess: ConnectionFieldAccess | undefined,\n\tstaticLabel: StaticLabelFor,\n\ttypes: readonly ProviderId[]\n): SelectField => {\n\tconst [first = 'native'] = types\n\tconst narrowed = types.length < PROVIDER_IDS.length\n\treturn {\n\t\tname: 'provider',\n\t\ttype: 'select',\n\t\trequired: true,\n\t\tlabel: labelForKey(keys.providerFieldProvider),\n\t\tdefaultValue: first === 'native' ? first : () => first,\n\t\t...(access ? { access } : {}),\n\t\t...(narrowed\n\t\t\t? {\n\t\t\t\t\tvalidate: validateServed(types),\n\t\t\t\t\tfilterOptions: ({ data }) => offeredTypes(types, data?.provider),\n\t\t\t\t}\n\t\t\t: {}),\n\t\toptions: PROVIDER_IDS.map((type) => ({\n\t\t\tlabel: labelForKey(PROVIDER_NAMES[type]),\n\t\t\tvalue: type,\n\t\t})),\n\t\t// `admin.description` on a select is read where a label function never runs.\n\t\tadmin: { position: 'sidebar', description: staticLabel(keys.providerFieldProviderHelp) },\n\t}\n}\n\nconst enabledField = (): Field => ({\n\tname: 'enabled',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.providerFieldEnabled),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.providerFieldEnabledHelp) },\n})\n\nconst isDefaultField = (access: ConnectionFieldAccess | undefined): Field => ({\n\tname: 'isDefault',\n\ttype: 'checkbox',\n\tdefaultValue: false,\n\tlabel: labelForKey(keys.providerFieldIsDefault),\n\t...(access ? { access } : {}),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.providerFieldIsDefaultHelp) },\n})\n\n/**\n * At most one document per scope is the default, checked at collection level so a replaced\n * `isDefault` field keeps it. No index backs it: a unique one would also cover the unflagged rows.\n */\nconst checkSingleDefault = (args: BuildProvidersCollectionArgs): CollectionBeforeValidateHook => {\n\treturn async ({ data, originalDoc, req }) => {\n\t\tif ((data?.isDefault ?? originalDoc?.isDefault) !== true) {\n\t\t\treturn data\n\t\t}\n\t\tif (await takenInScope(args, { data, originalDoc, req }, { isDefault: { equals: true } })) {\n\t\t\tthrow new ValidationError({\n\t\t\t\tcollection: args.slug,\n\t\t\t\terrors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: labelForKey(keys.providerFieldIsDefault),\n\t\t\t\t\t\tmessage: asTranslate(req.t)(keys.providerErrorDefaultTaken),\n\t\t\t\t\t\tpath: 'isDefault',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t})\n\t\t}\n\t\treturn data\n\t}\n}\n\nexport interface ProviderFieldsOptions {\n\t/**\n\t * Seals each credential field, normally `encryptedField` from `@10x-media/fields` in write-only\n\t * mode. Left out, credentials are plain text and securing them is the host's job.\n\t */\n\tbuildSecret?: BuildSecretField\n\t/** Replaces one of the default fields, applied per field. */\n\tfields?: Omit<ProviderCollectionFieldOverrides, 'isDefault'>\n\t/** Adds the plugin's own hidden `scope` text field. Off by default. */\n\tscopeField?: boolean\n\t/**\n\t * Accepts `http://` in a `host` field, for a vendor on a private network. Set it together with\n\t * `providers.hosts.allowPrivateNetwork`, which lets the plugin connect there. Off, https only.\n\t */\n\tallowPrivateNetwork?: boolean\n\t/**\n\t * Field access on every `CONNECTION_PATHS` field except the scope field. One function for create\n\t * and update alike, or `{ create, update }`.\n\t */\n\tconnectionAccess?: ConnectionAccess\n\t/**\n\t * The provider types the select offers, the first being its default; a document saved with any\n\t * other type is refused. Default: every type, `native` first.\n\t */\n\ttypes?: ProviderId[]\n}\n\n/** What the field list takes beyond the public options. */\ninterface FieldListArgs {\n\ttypes: readonly ProviderId[]\n\t/** The `isDefault` checkbox, overridden, placed after `enabled`; only a scoped collection has it. */\n\tisDefault?: Field\n}\n\n/**\n * Provider-settings fields alone, for a host that stores them elsewhere and feeds them back through\n * `providers.resolve`; {@link adapterFromProviderDoc} reads the result as is.\n */\nexport const analyticsProviderFields = (options: ProviderFieldsOptions = {}): Field[] =>\n\tproviderFields(options, builtInStaticLabel, {\n\t\ttypes: servedProviderTypes('analyticsProviderFields({ types })', options.types),\n\t})\n\nconst providerFields = (\n\toptions: ProviderFieldsOptions,\n\tstaticLabel: StaticLabelFor,\n\tlist: FieldListArgs\n): Field[] => {\n\tconst buildSecret = options.buildSecret ?? plainSecret\n\tconst access = connectionFieldAccess(\n\t\t'analyticsProviderFields({ connectionAccess })',\n\t\toptions.connectionAccess\n\t)\n\tconst allowPrivateNetwork = options.allowPrivateNetwork === true\n\tconst apiKeyField = (): Field[] =>\n\t\tsecretField(buildSecret, staticLabel, {\n\t\t\tname: 'apiKey',\n\t\t\tlabel: keys.providerFieldApiKey,\n\t\t\thelp: keys.providerFieldApiKeyHelp,\n\t\t\twidth: '50%',\n\t\t})\n\treturn [\n\t\toverrideField(nameField(), options.fields?.name),\n\t\toverrideField(providerField(access, staticLabel, list.types), options.fields?.provider),\n\t\toverrideField(enabledField(), options.fields?.enabled),\n\t\t...(list.isDefault ? [list.isDefault] : []),\n\t\t...scopeField(options.scopeField === true),\n\t\tnativeNote(),\n\t\tproviderGroup('plausible', keys.providerNamePlausible, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('siteId', keys.providerFieldSiteId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldSiteIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\t...apiKeyField(),\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\tcaptureField('domain', keys.providerFieldDomain, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldDomainHelp,\n\t\t\t\t\t}),\n\t\t\t\t\tcaptureField('scriptId', keys.providerFieldScriptId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldScriptIdHelp,\n\t\t\t\t\t\tvalidate: validateScriptId,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t},\n\t\t\tcurrencyField('revenueCurrency', keys.providerFieldRevenueCurrencyHelp),\n\t\t\thostField(allowPrivateNetwork, access),\n\t\t]),\n\t\tproviderGroup('umami', keys.providerNameUmami, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('websiteId', keys.providerFieldWebsiteId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldWebsiteIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\t...apiKeyField(),\n\t\t\t\t],\n\t\t\t},\n\t\t\t...secretField(buildSecret, staticLabel, {\n\t\t\t\tname: 'token',\n\t\t\t\tlabel: keys.providerFieldToken,\n\t\t\t\thelp: keys.providerFieldTokenHelp,\n\t\t\t}),\n\t\t\thostField(allowPrivateNetwork, access),\n\t\t]),\n\t\tproviderGroup('ga4', keys.providerNameGa4, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('propertyId', keys.providerFieldPropertyId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldPropertyIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\ttextField('projectId', keys.providerFieldProjectId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldProjectIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t},\n\t\t\ttextField('clientEmail', keys.providerFieldClientEmail, {\n\t\t\t\thelp: keys.providerFieldClientEmailHelp,\n\t\t\t\taccess,\n\t\t\t}),\n\t\t\tcaptureField('measurementId', keys.providerFieldMeasurementId, {\n\t\t\t\tvalidate: validateMeasurementId,\n\t\t\t}),\n\t\t\tcurrencyField('currency', keys.providerFieldGa4CurrencyHelp),\n\t\t\t...buildSecret({\n\t\t\t\tname: 'privateKey',\n\t\t\t\ttype: 'textarea',\n\t\t\t\tlabel: labelForKey(keys.providerFieldPrivateKey),\n\t\t\t\tadmin: { description: staticLabel(keys.providerFieldPrivateKeyHelp) },\n\t\t\t}),\n\t\t]),\n\t\tproviderGroup('posthog', keys.providerNamePosthog, [\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\ttextField('projectId', keys.providerFieldProjectId, {\n\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\thelp: keys.providerFieldProjectIdHelp,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t}),\n\t\t\t\t\t...apiKeyField(),\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: 'row',\n\t\t\t\tfields: [\n\t\t\t\t\tcaptureField('projectToken', keys.providerFieldProjectToken, { width: '50%' }),\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'region',\n\t\t\t\t\t\ttype: 'select',\n\t\t\t\t\t\tlabel: labelForKey(keys.providerFieldRegion),\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ label: 'US', value: 'us' },\n\t\t\t\t\t\t\t{ label: 'EU', value: 'eu' },\n\t\t\t\t\t\t],\n\t\t\t\t\t\t...(access ? { access } : {}),\n\t\t\t\t\t\tadmin: {\n\t\t\t\t\t\t\twidth: '50%',\n\t\t\t\t\t\t\tdescription: staticLabel(keys.providerFieldRegionHelp),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\ttextField('scopeProperty', keys.providerFieldScopeProperty, {\n\t\t\t\thelp: keys.providerFieldScopePropertyHelp,\n\t\t\t\taccess,\n\t\t\t}),\n\t\t\thostField(allowPrivateNetwork, access),\n\t\t]),\n\t]\n}\n\n/**\n * Runtime provider-settings collection, one document per provider (and scope). Admin-only by\n * default; `access` overrides single operations, `overrides` reshapes the whole config last.\n */\nexport const buildProvidersCollection = (args: BuildProvidersCollectionArgs): CollectionConfig => {\n\tconst staticLabel = args.staticLabel ?? builtInStaticLabel\n\tconst collection: CollectionConfig = {\n\t\tslug: args.slug,\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.providersCollectionSingular),\n\t\t\tplural: labelForKey(keys.providersCollectionPlural),\n\t\t},\n\t\tdisableDuplicate: true,\n\t\tadmin: {\n\t\t\tuseAsTitle: 'name',\n\t\t\tdefaultColumns: ['name', 'provider', 'enabled'],\n\t\t\tgroup: staticLabel(keys.adminGroup),\n\t\t\tdescription: staticLabel(keys.providersCollectionDescription),\n\t\t\t...(args.listNotice ? { components: { beforeList: [PROVIDERS_LIST_NOTICE_COMPONENT] } } : {}),\n\t\t},\n\t\taccess: {\n\t\t\tread: providerRowAccess(args),\n\t\t\tcreate: providerCreateAccess(args),\n\t\t\tupdate: providerRowAccess(args),\n\t\t\tdelete: providerRowAccess(args),\n\t\t\t...args.access,\n\t\t},\n\t\thooks: {\n\t\t\t...(args.scoped ? { beforeValidate: [checkSingleDefault(args)] } : {}),\n\t\t\tbeforeChange: [\n\t\t\t\tstampScope(args),\n\t\t\t\tretargetSecrets({ scopeField: args.scopeField, isSealed: args.isSealed }),\n\t\t\t],\n\t\t\tafterChange: [\n\t\t\t\tasync ({ doc, operation, previousDoc, req }) => {\n\t\t\t\t\tawait args.onChange(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tscope: docScope(doc, args.scopeField),\n\t\t\t\t\t\t\t...(operation === 'update'\n\t\t\t\t\t\t\t\t? { previousScope: docScope(previousDoc, args.scopeField) }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\treq\n\t\t\t\t\t)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t\tafterDelete: [\n\t\t\t\tasync ({ doc, req }) => {\n\t\t\t\t\tawait args.onChange({ scope: docScope(doc, args.scopeField) }, req)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tfields: providerFields(\n\t\t\t{\n\t\t\t\tbuildSecret: args.buildSecret,\n\t\t\t\t...(args.fields ? { fields: args.fields } : {}),\n\t\t\t\tscopeField: args.scopeField === 'scope',\n\t\t\t\tallowPrivateNetwork: args.allowPrivateNetwork === true,\n\t\t\t\t...(args.connectionAccess ? { connectionAccess: args.connectionAccess } : {}),\n\t\t\t},\n\t\t\tstaticLabel,\n\t\t\t{\n\t\t\t\ttypes: args.types ?? PROVIDER_IDS,\n\t\t\t\t// A default is picked per scope: an unscoped install has one site and nothing to pick.\n\t\t\t\t...(args.scoped\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tisDefault: overrideField(isDefaultField(args.defaultAccess), args.fields?.isDefault),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}\n\t\t),\n\t}\n\treturn args.overrides ? args.overrides(collection) : collection\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAa,iBAAiB;;AAG9B,MAAa,kCAAkC;;AA6B/C,MAAa,yBACZ,MACA,WACuC;CACvC,IAAI,WAAW,KAAA,GACd;CAED,IAAI,OAAO,WAAW,YACrB,OAAO;EAAE,QAAQ;EAAQ,QAAQ;CAAO;CAEzC,MAAM,SAAS,cAAc,QAAQ;EACpC;EACA,OAAO,CAAC,UAAU,QAAQ;EAC1B,SAAS;CACV,CAAC;CACD,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GACjD,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,YAC7C,MAAM,IAAI,MACT,cAAc,KAAK,GAAG,KAAK,wCAAwC,OAAO,MAAM,GACjF;CAGF,MAAM,EAAE,QAAQ,WAAW;CAC3B,OAAO;EAAE,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAAI,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;CAAG;AACvE;;;;;AAMA,MAAa,uBACZ,MACA,QACA,YAAmC,iBACjB;CAClB,IAA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B,CAAC,mBAAmB,IAAI,CAAC,EAAE,IAAI,CAAC;GACpE,cAAc,CACb,WAAW,IAAI,GACf,gBAAgB;IAAE,YAAY,KAAK;IAAY,UAAU,KAAK;GAAS,CAAC,CACzE;GACA,aAAa,CACZ,OAAO,EAAE,KAAK,WAAW,aAAa,UAAU;IAC/C,MAAM,KAAK,SACV;KACC,OAAO,SAAS,KAAK,KAAK,UAAU;KACpC,GAAI,cAAc,WACf,EAAE,eAAe,SAAS,aAAa,KAAK,UAAU,EAAE,IACxD,CAAC;IACL,GACA,GACD;IACA,OAAO;GACR,CACD;GACA,aAAa,CACZ,OAAO,EAAE,KAAK,UAAU;IACvB,MAAM,KAAK,SAAS,EAAE,OAAO,SAAS,KAAK,KAAK,UAAU,EAAE,GAAG,GAAG;IAClE,OAAO;GACR,CACD;EACD;EACA,QAAQ,eACP;GACC,aAAa,KAAK;GAClB,GAAI,KAAK,SAAS,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;GAC7C,YAAY,KAAK,eAAe;GAChC,qBAAqB,KAAK,wBAAwB;GAClD,GAAI,KAAK,mBAAmB,EAAE,kBAAkB,KAAK,iBAAiB,IAAI,CAAC;EAC5E,GACA,aACA;GACC,OAAO,KAAK,SAAS;GAErB,GAAI,KAAK,SACN,EACA,WAAW,cAAc,eAAe,KAAK,aAAa,GAAG,KAAK,QAAQ,SAAS,EACpF,IACC,CAAC;EACL,CACD;CACD;CACA,OAAO,KAAK,YAAY,KAAK,UAAU,UAAU,IAAI;AACtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@10x-media/analytics",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.14",
|
|
4
4
|
"description": "Adapter-based analytics for Payload: providers, a native engine, dashboard widgets, and portable fields.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -176,10 +176,10 @@
|
|
|
176
176
|
"tsdown": "0.22.1",
|
|
177
177
|
"typescript": "5.9.3",
|
|
178
178
|
"vitest": "4.1.7",
|
|
179
|
-
"@10x-media/
|
|
179
|
+
"@10x-media/form-builder": "0.1.0-beta.27",
|
|
180
180
|
"@10x-media/tsconfig": "0.0.0",
|
|
181
181
|
"@10x-media/payload-test-harness": "0.0.0",
|
|
182
|
-
"@10x-media/
|
|
182
|
+
"@10x-media/fields": "0.1.0-beta.8",
|
|
183
183
|
"@10x-media/tsdown-config": "0.0.0",
|
|
184
184
|
"@10x-media/vitest-config": "0.0.0"
|
|
185
185
|
},
|