@10x-media/analytics 1.0.0-beta.6 → 1.0.0-beta.7
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 +25 -0
- package/README.md +5 -1
- package/dist/adapters/http/fetchJson.js +1 -1
- package/dist/adapters/plausible/plausible.d.ts +10 -0
- package/dist/adapters/plausible/plausible.js +40 -0
- package/dist/adapters/plausible/plausible.js.map +1 -1
- package/dist/adapters/posthog/posthog.d.ts +10 -1
- package/dist/adapters/posthog/posthog.js +47 -0
- package/dist/adapters/posthog/posthog.js.map +1 -1
- package/dist/adapters/umami/umami.d.ts +5 -1
- package/dist/adapters/umami/umami.js +26 -0
- package/dist/adapters/umami/umami.js.map +1 -1
- package/dist/capture/getTrackerConfig.d.ts +20 -0
- package/dist/capture/getTrackerConfig.js +31 -0
- package/dist/capture/getTrackerConfig.js.map +1 -0
- package/dist/capture/mountPath.js +14 -0
- package/dist/capture/mountPath.js.map +1 -0
- package/dist/capture/proxyEndpoint.js +123 -0
- package/dist/capture/proxyEndpoint.js.map +1 -0
- package/dist/capture/proxyRoutes.js +108 -0
- package/dist/capture/proxyRoutes.js.map +1 -0
- package/dist/capture/requestBody.js +68 -0
- package/dist/capture/requestBody.js.map +1 -0
- package/dist/capture/slots.d.ts +8 -0
- package/dist/capture/slots.js +43 -0
- package/dist/capture/slots.js.map +1 -0
- package/dist/capture/trackerConfig.d.ts +32 -0
- package/dist/capture/trackerConfig.js +70 -0
- package/dist/capture/trackerConfig.js.map +1 -0
- package/dist/capture/trackerEndpoint.js +35 -0
- package/dist/capture/trackerEndpoint.js.map +1 -0
- package/dist/core/capture.d.ts +49 -0
- package/dist/core/contract.d.ts +26 -2
- package/dist/core/contract.js.map +1 -1
- package/dist/core/options.d.ts +97 -2
- package/dist/core/options.js +63 -2
- package/dist/core/options.js.map +1 -1
- package/dist/core/registry.d.ts +1 -0
- package/dist/core/scopeList.js +32 -0
- package/dist/core/scopeList.js.map +1 -0
- package/dist/core/scopedRead.js +13 -6
- package/dist/core/scopedRead.js.map +1 -1
- package/dist/exports/next.d.ts +2 -1
- package/dist/exports/next.js +2 -1
- package/dist/exports/react.d.ts +4 -0
- package/dist/exports/react.js +5 -0
- package/dist/exports/rsc.d.ts +4 -1
- package/dist/exports/rsc.js +3 -1
- package/dist/exports/tracker.d.ts +18 -0
- package/dist/exports/tracker.js +12 -0
- package/dist/exports/types.d.ts +5 -2
- package/dist/fields/AnalyticsPanelClient.js +1 -1
- package/dist/fields/config/narrow.js +2 -0
- package/dist/fields/config/narrow.js.map +1 -1
- package/dist/fields/readForDocument.js +1 -1
- package/dist/goals/match.js +64 -0
- package/dist/goals/match.js.map +1 -0
- package/dist/goals/types.d.ts +33 -0
- package/dist/goals/types.js +7 -0
- package/dist/goals/types.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/dist/native/collections/events.js +21 -1
- package/dist/native/collections/events.js.map +1 -1
- package/dist/native/collections/rollups.js +24 -0
- package/dist/native/collections/rollups.js.map +1 -1
- package/dist/native/geo/maxmindResolver.js +2 -4
- package/dist/native/geo/maxmindResolver.js.map +1 -1
- package/dist/native/ingest/clientIp.js +15 -0
- package/dist/native/ingest/clientIp.js.map +1 -0
- package/dist/native/ingest/endpoint.js +40 -4
- package/dist/native/ingest/endpoint.js.map +1 -1
- package/dist/native/ingest/flushBatch.js +4 -13
- package/dist/native/ingest/flushBatch.js.map +1 -1
- package/dist/native/ingest/normalizeEvent.js +76 -9
- package/dist/native/ingest/normalizeEvent.js.map +1 -1
- package/dist/native/nativeAdapter.js +20 -4
- package/dist/native/nativeAdapter.js.map +1 -1
- package/dist/native/query/eventAgg.js +39 -13
- package/dist/native/query/eventAgg.js.map +1 -1
- package/dist/native/rollupAcc.js +12 -1
- package/dist/native/rollupAcc.js.map +1 -1
- package/dist/native/rollups/bumpRollup.js +5 -1
- package/dist/native/rollups/bumpRollup.js.map +1 -1
- package/dist/native/rollups/deltas.js +28 -6
- package/dist/native/rollups/deltas.js.map +1 -1
- package/dist/next/captureRewrites.d.ts +41 -0
- package/dist/next/captureRewrites.js +56 -0
- package/dist/next/captureRewrites.js.map +1 -0
- package/dist/next/posthogProxyRewrites.d.ts +5 -0
- package/dist/next/posthogProxyRewrites.js +16 -21
- package/dist/next/posthogProxyRewrites.js.map +1 -1
- package/dist/plugin/documentEndpoint.js +1 -1
- package/dist/plugin/paths.js +11 -1
- package/dist/plugin/paths.js.map +1 -1
- package/dist/plugin/runtime.d.ts +1 -0
- package/dist/plugin/runtime.js.map +1 -1
- package/dist/plugin/sourcesEndpoint.js +16 -4
- package/dist/plugin/sourcesEndpoint.js.map +1 -1
- package/dist/plugin/warmTask.js +0 -0
- package/dist/plugin/warmTask.js.map +1 -1
- package/dist/providers/collection.js +56 -16
- package/dist/providers/collection.js.map +1 -1
- package/dist/providers/factory.js +8 -2
- package/dist/providers/factory.js.map +1 -1
- package/dist/react/AnalyticsProvider.d.ts +43 -0
- package/dist/react/AnalyticsProvider.js +66 -0
- package/dist/react/AnalyticsProvider.js.map +1 -0
- package/dist/react/TrackerBoot.d.ts +22 -0
- package/dist/react/TrackerBoot.js +30 -0
- package/dist/react/TrackerBoot.js.map +1 -0
- package/dist/react/useAnalytics.d.ts +17 -0
- package/dist/react/useAnalytics.js +36 -0
- package/dist/react/useAnalytics.js.map +1 -0
- package/dist/rsc/AnalyticsScripts.d.ts +30 -0
- package/dist/rsc/AnalyticsScripts.js +41 -0
- package/dist/rsc/AnalyticsScripts.js.map +1 -0
- package/dist/surfacing/cacheStore.d.ts +1 -0
- package/dist/surfacing/cacheStore.js +18 -2
- package/dist/surfacing/cacheStore.js.map +1 -1
- package/dist/surfacing/engine.d.ts +1 -0
- package/dist/surfacing/engine.js +44 -4
- package/dist/surfacing/engine.js.map +1 -1
- package/dist/surfacing/queue.js +22 -6
- package/dist/surfacing/queue.js.map +1 -1
- package/dist/surfacing/rateLimiter.js +130 -0
- package/dist/surfacing/rateLimiter.js.map +1 -0
- package/dist/surfacing/retryPolicy.js +15 -0
- package/dist/surfacing/retryPolicy.js.map +1 -0
- package/dist/sync/syncTask.js +60 -33
- package/dist/sync/syncTask.js.map +1 -1
- package/dist/testing/memoryAdapter.d.ts +2 -0
- package/dist/testing/memoryAdapter.js +10 -0
- package/dist/testing/memoryAdapter.js.map +1 -1
- package/dist/tracker/autoCapture.d.ts +48 -0
- package/dist/tracker/autoCapture.js +129 -0
- package/dist/tracker/autoCapture.js.map +1 -0
- package/dist/tracker/consent.d.ts +24 -0
- package/dist/tracker/consent.js +48 -0
- package/dist/tracker/consent.js.map +1 -0
- package/dist/tracker/createTracker.d.ts +18 -0
- package/dist/tracker/createTracker.js +163 -0
- package/dist/tracker/createTracker.js.map +1 -0
- package/dist/tracker/initTracker.d.ts +22 -0
- package/dist/tracker/initTracker.js +33 -0
- package/dist/tracker/initTracker.js.map +1 -0
- package/dist/tracker/loadScript.d.ts +14 -0
- package/dist/tracker/loadScript.js +41 -0
- package/dist/tracker/loadScript.js.map +1 -0
- package/dist/tracker/pageTracking.d.ts +17 -0
- package/dist/tracker/pageTracking.js +38 -0
- package/dist/tracker/pageTracking.js.map +1 -0
- package/dist/tracker/registry.d.ts +27 -0
- package/dist/tracker/registry.js +73 -0
- package/dist/tracker/registry.js.map +1 -0
- package/dist/tracker/sinks/native.d.ts +22 -0
- package/dist/tracker/sinks/native.js +56 -0
- package/dist/tracker/sinks/native.js.map +1 -0
- package/dist/tracker/sinks/plausible.d.ts +14 -0
- package/dist/tracker/sinks/plausible.js +25 -0
- package/dist/tracker/sinks/plausible.js.map +1 -0
- package/dist/tracker/sinks/posthog.d.ts +14 -0
- package/dist/tracker/sinks/posthog.js +18 -0
- package/dist/tracker/sinks/posthog.js.map +1 -0
- package/dist/tracker/sinks/umami.d.ts +13 -0
- package/dist/tracker/sinks/umami.js +17 -0
- package/dist/tracker/sinks/umami.js.map +1 -0
- package/dist/tracker/sinks/vendor.d.ts +14 -0
- package/dist/tracker/sinks/vendor.js +66 -0
- package/dist/tracker/sinks/vendor.js.map +1 -0
- package/dist/tracker/transport.js +28 -0
- package/dist/tracker/transport.js.map +1 -0
- package/dist/tracker/types.d.ts +66 -0
- package/dist/translations/ar.js +6 -0
- package/dist/translations/ar.js.map +1 -1
- package/dist/translations/de.js +6 -0
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +6 -0
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +6 -0
- package/dist/translations/es.js.map +1 -1
- package/dist/translations/fr.js +6 -0
- package/dist/translations/fr.js.map +1 -1
- package/dist/translations/id.js +6 -0
- package/dist/translations/id.js.map +1 -1
- package/dist/translations/keys.d.ts +6 -0
- package/dist/translations/keys.js +6 -0
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +6 -0
- package/dist/translations/ko.js.map +1 -1
- package/dist/translations/pt.js +6 -0
- package/dist/translations/pt.js.map +1 -1
- package/dist/translations/ru.js +6 -0
- package/dist/translations/ru.js.map +1 -1
- package/dist/translations/uk.js +6 -0
- package/dist/translations/uk.js.map +1 -1
- package/dist/translations/zh.js +6 -0
- package/dist/translations/zh.js.map +1 -1
- package/dist/widgets/breakdownTypes.js +5 -0
- package/dist/widgets/breakdownTypes.js.map +1 -1
- package/dist/widgets/readForWidget.js +24 -14
- package/dist/widgets/readForWidget.js.map +1 -1
- package/dist/widgets/readForWidgetBreakdown.js +23 -14
- package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
- package/dist/widgets/readForWidgetRealtime.js +1 -1
- package/dist/widgets/readForWidgetSeries.js +26 -16
- package/dist/widgets/readForWidgetSeries.js.map +1 -1
- package/dist/widgets/registerWidgets.js +10 -4
- package/dist/widgets/registerWidgets.js.map +1 -1
- package/dist/widgets/types.js +4 -1
- package/dist/widgets/types.js.map +1 -1
- package/package.json +21 -6
package/dist/core/contract.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Goal } from "../goals/types.js";
|
|
2
|
+
import { CaptureSupport } from "./capture.js";
|
|
1
3
|
import { Config, PayloadRequest } from "payload";
|
|
2
4
|
|
|
3
5
|
//#region src/core/contract.d.ts
|
|
@@ -7,7 +9,7 @@ import { Config, PayloadRequest } from "payload";
|
|
|
7
9
|
*/
|
|
8
10
|
declare const PLATFORM_SCOPE = "*";
|
|
9
11
|
type MetricKey = 'pageviews' | 'visitors' | 'visits' | 'sessions' | 'bounceRate' | 'avgDuration' | 'scrollDepth' | 'events' | 'conversions' | 'revenue';
|
|
10
|
-
type DimensionKey = 'page' | 'referrer' | 'source' | 'medium' | 'campaign' | 'utmSource' | 'utmMedium' | 'utmCampaign' | 'utmContent' | 'utmTerm' | 'device' | 'browser' | 'os' | 'country' | 'region' | 'city' | 'language' | 'event';
|
|
12
|
+
type DimensionKey = 'page' | 'referrer' | 'source' | 'medium' | 'campaign' | 'utmSource' | 'utmMedium' | 'utmCampaign' | 'utmContent' | 'utmTerm' | 'device' | 'browser' | 'os' | 'country' | 'region' | 'city' | 'language' | 'event' | 'goal';
|
|
11
13
|
type Granularity = 'minute' | 'hour' | 'day' | 'week' | 'month';
|
|
12
14
|
interface DateRange {
|
|
13
15
|
start: Date;
|
|
@@ -58,14 +60,20 @@ interface AnalyticsResult {
|
|
|
58
60
|
provider: string;
|
|
59
61
|
sampled?: boolean;
|
|
60
62
|
clamped?: boolean;
|
|
61
|
-
fetchedAt: string;
|
|
63
|
+
fetchedAt: string; /** Served from an expired cache entry because the live refresh failed. */
|
|
64
|
+
stale?: boolean;
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
interface RateLimitDescriptor {
|
|
65
68
|
requestsPerMinute?: number;
|
|
66
69
|
requestsPerHour?: number;
|
|
67
70
|
maxConcurrent?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Describes the provider's quota model for documentation; the limiter always
|
|
73
|
+
* throttles by request count regardless of this value.
|
|
74
|
+
*/
|
|
68
75
|
quotaModel?: 'requests' | 'tokens';
|
|
76
|
+
/** Documents whether reads consume the provider's write/ingest quota too. */
|
|
69
77
|
readsCountAsUsage?: boolean;
|
|
70
78
|
}
|
|
71
79
|
interface AnalyticsCapabilities {
|
|
@@ -109,11 +117,27 @@ interface AdapterRegisterContext {
|
|
|
109
117
|
* rollups at ingest). Resolves to `'UTC'` when no reportingTimezone is set.
|
|
110
118
|
*/
|
|
111
119
|
resolveTimezone: (req: PayloadRequest, scope?: string | null) => Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* The install's goals for a request's scope, for adapters that match completions
|
|
122
|
+
* themselves (the native engine, at ingest). Config goals today; a collection source
|
|
123
|
+
* merges in behind the same call.
|
|
124
|
+
*/
|
|
125
|
+
resolveGoals: (req: PayloadRequest, scope?: string | null) => Promise<Goal[]>;
|
|
112
126
|
}
|
|
113
127
|
interface AnalyticsAdapter {
|
|
114
128
|
readonly id: string;
|
|
115
129
|
readonly label: string;
|
|
116
130
|
readonly capabilities: AnalyticsCapabilities;
|
|
131
|
+
/** Browser-tracker proxying/boot descriptor. Absent when the adapter has no client-side script (GA4). */
|
|
132
|
+
readonly capture?: CaptureSupport;
|
|
133
|
+
/**
|
|
134
|
+
* Where this adapter's own ingest endpoint listens, relative to `routes.api`, for the
|
|
135
|
+
* adapters that register one (the native engine). Server-side only: the tracker learns
|
|
136
|
+
* the path from `TrackerConfig.ingestPath`, and this object is never serialized.
|
|
137
|
+
*/
|
|
138
|
+
readonly ingest?: {
|
|
139
|
+
path: string;
|
|
140
|
+
};
|
|
117
141
|
isConfigured(): boolean;
|
|
118
142
|
query(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>;
|
|
119
143
|
realtime?(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","names":[],"sources":["../../src/core/contract.ts"],"sourcesContent":["import type { Config, PayloadRequest } from 'payload'\n\n/**\n * Explicit cross-scope read marker: pass as a read's `scope` to aggregate over every\n * scope. Gated by `access.platformRead`; the query reaches the adapter unscoped.\n */\nexport const PLATFORM_SCOPE = '*'\n\nexport type MetricKey =\n\t| 'pageviews'\n\t| 'visitors'\n\t| 'visits'\n\t| 'sessions'\n\t| 'bounceRate'\n\t| 'avgDuration'\n\t| 'scrollDepth'\n\t| 'events'\n\t| 'conversions'\n\t| 'revenue'\n\nexport type DimensionKey =\n\t| 'page'\n\t| 'referrer'\n\t| 'source'\n\t| 'medium'\n\t| 'campaign'\n\t| 'utmSource'\n\t| 'utmMedium'\n\t| 'utmCampaign'\n\t| 'utmContent'\n\t| 'utmTerm'\n\t| 'device'\n\t| 'browser'\n\t| 'os'\n\t| 'country'\n\t| 'region'\n\t| 'city'\n\t| 'language'\n\t| 'event'\n\nexport type Granularity = 'minute' | 'hour' | 'day' | 'week' | 'month'\n\nexport interface DateRange {\n\tstart: Date\n\tend: Date\n}\n\nexport type FilterOperator = 'eq' | 'contains' | 'matches'\n\nexport interface AnalyticsFilter {\n\tdimension: DimensionKey\n\toperator: FilterOperator\n\tvalue: string\n}\n\nexport interface AnalyticsQuery {\n\tpath?: string\n\thostname?: string\n\tmetrics: MetricKey[]\n\tdimensions?: DimensionKey[]\n\tdateRange: DateRange\n\tgranularity?: Granularity\n\tfilters?: AnalyticsFilter[]\n\tlimit?: number\n\torder?: { metric: MetricKey; direction: 'asc' | 'desc' }\n\t/**\n\t * Analytics boundary this read belongs to (tenant id, site key). Undefined means\n\t * install-wide (the default). Adapters that can filter by scope apply it; others\n\t * ignore it. Always part of the surfacing cache key, so per-scope adapter\n\t * instances sharing an id never share cached results.\n\t */\n\tscope?: string\n\t/**\n\t * IANA reporting timezone the read's day boundaries are aligned to. Undefined\n\t * means UTC. Adapters that can bucket in a timezone apply it (PostHog, Umami);\n\t * others report in their own account timezone. Part of the cache key when set.\n\t */\n\ttimezone?: string\n}\n\nexport interface AnalyticsRow {\n\tdimensions?: Partial<Record<DimensionKey, string>>\n\tmetrics: Partial<Record<MetricKey, number>>\n\ttimestamp?: string\n}\n\nexport interface AnalyticsResult {\n\trows: AnalyticsRow[]\n\ttotals?: Partial<Record<MetricKey, number>>\n\tmeta: {
|
|
1
|
+
{"version":3,"file":"contract.js","names":[],"sources":["../../src/core/contract.ts"],"sourcesContent":["import type { Config, PayloadRequest } from 'payload'\nimport type { Goal } from '../goals/types'\nimport type { CaptureSupport } from './capture'\n\n/**\n * Explicit cross-scope read marker: pass as a read's `scope` to aggregate over every\n * scope. Gated by `access.platformRead`; the query reaches the adapter unscoped.\n */\nexport const PLATFORM_SCOPE = '*'\n\nexport type MetricKey =\n\t| 'pageviews'\n\t| 'visitors'\n\t| 'visits'\n\t| 'sessions'\n\t| 'bounceRate'\n\t| 'avgDuration'\n\t| 'scrollDepth'\n\t| 'events'\n\t| 'conversions'\n\t| 'revenue'\n\nexport type DimensionKey =\n\t| 'page'\n\t| 'referrer'\n\t| 'source'\n\t| 'medium'\n\t| 'campaign'\n\t| 'utmSource'\n\t| 'utmMedium'\n\t| 'utmCampaign'\n\t| 'utmContent'\n\t| 'utmTerm'\n\t| 'device'\n\t| 'browser'\n\t| 'os'\n\t| 'country'\n\t| 'region'\n\t| 'city'\n\t| 'language'\n\t| 'event'\n\t| 'goal'\n\nexport type Granularity = 'minute' | 'hour' | 'day' | 'week' | 'month'\n\nexport interface DateRange {\n\tstart: Date\n\tend: Date\n}\n\nexport type FilterOperator = 'eq' | 'contains' | 'matches'\n\nexport interface AnalyticsFilter {\n\tdimension: DimensionKey\n\toperator: FilterOperator\n\tvalue: string\n}\n\nexport interface AnalyticsQuery {\n\tpath?: string\n\thostname?: string\n\tmetrics: MetricKey[]\n\tdimensions?: DimensionKey[]\n\tdateRange: DateRange\n\tgranularity?: Granularity\n\tfilters?: AnalyticsFilter[]\n\tlimit?: number\n\torder?: { metric: MetricKey; direction: 'asc' | 'desc' }\n\t/**\n\t * Analytics boundary this read belongs to (tenant id, site key). Undefined means\n\t * install-wide (the default). Adapters that can filter by scope apply it; others\n\t * ignore it. Always part of the surfacing cache key, so per-scope adapter\n\t * instances sharing an id never share cached results.\n\t */\n\tscope?: string\n\t/**\n\t * IANA reporting timezone the read's day boundaries are aligned to. Undefined\n\t * means UTC. Adapters that can bucket in a timezone apply it (PostHog, Umami);\n\t * others report in their own account timezone. Part of the cache key when set.\n\t */\n\ttimezone?: string\n}\n\nexport interface AnalyticsRow {\n\tdimensions?: Partial<Record<DimensionKey, string>>\n\tmetrics: Partial<Record<MetricKey, number>>\n\ttimestamp?: string\n}\n\nexport interface AnalyticsResult {\n\trows: AnalyticsRow[]\n\ttotals?: Partial<Record<MetricKey, number>>\n\tmeta: {\n\t\tprovider: string\n\t\tsampled?: boolean\n\t\tclamped?: boolean\n\t\tfetchedAt: string\n\t\t/** Served from an expired cache entry because the live refresh failed. */\n\t\tstale?: boolean\n\t}\n}\n\nexport interface RateLimitDescriptor {\n\trequestsPerMinute?: number\n\trequestsPerHour?: number\n\tmaxConcurrent?: number\n\t/**\n\t * Describes the provider's quota model for documentation; the limiter always\n\t * throttles by request count regardless of this value.\n\t */\n\tquotaModel?: 'requests' | 'tokens'\n\t/** Documents whether reads consume the provider's write/ingest quota too. */\n\treadsCountAsUsage?: boolean\n}\n\nexport interface AnalyticsCapabilities {\n\tperPageQuery: boolean\n\trealtime: boolean\n\trealtimeWindowMinutes?: number\n\tcomparison: boolean\n\tminGranularity: Granularity\n\tmaxLookbackDays: number | null\n\tmetrics: ReadonlySet<MetricKey>\n\tdimensions: ReadonlySet<DimensionKey>\n\t/** Dimensions the adapter can apply AnalyticsQuery.filters on; empty = filters unsupported. */\n\tfilters: ReadonlySet<DimensionKey>\n\t/** Operators the adapter honors in filters; adapters ignore filters whose operator they lack. */\n\tfilterOperators: ReadonlySet<FilterOperator>\n\tbatchPageReport: boolean\n\trateLimit: RateLimitDescriptor | null\n\trecommendedTtl: { realtime: number; aggregate: number }\n\t/**\n\t * The adapter applies `AnalyticsQuery.scope` as a provider-native filter (native\n\t * scope column, PostHog `scopeProperty`, ...). Without it, a scoped read through\n\t * a shared platform adapter would expose cross-scope data, so such reads are\n\t * gated by `access.platformRead`.\n\t */\n\tscopedQueries?: boolean\n}\n\nexport interface AdapterContext {\n\tsignal?: AbortSignal\n}\n\n/** Extra context the plugin hands adapters when they register config surface. */\nexport interface AdapterRegisterContext {\n\t/** True when the plugin has a scopeResolver configured. */\n\tscoped: boolean\n\t/** The plugin's scopeResolver bound for adapter use (e.g. ingest stamping). */\n\tresolveScope: (req: PayloadRequest) => Promise<string | null>\n\t/**\n\t * The plugin's reportingTimezone bound for adapter use (e.g. bucketing native\n\t * rollups at ingest). Resolves to `'UTC'` when no reportingTimezone is set.\n\t */\n\tresolveTimezone: (req: PayloadRequest, scope?: string | null) => Promise<string>\n\t/**\n\t * The install's goals for a request's scope, for adapters that match completions\n\t * themselves (the native engine, at ingest). Config goals today; a collection source\n\t * merges in behind the same call.\n\t */\n\tresolveGoals: (req: PayloadRequest, scope?: string | null) => Promise<Goal[]>\n}\n\nexport interface AnalyticsAdapter {\n\treadonly id: string\n\treadonly label: string\n\treadonly capabilities: AnalyticsCapabilities\n\t/** Browser-tracker proxying/boot descriptor. Absent when the adapter has no client-side script (GA4). */\n\treadonly capture?: CaptureSupport\n\t/**\n\t * Where this adapter's own ingest endpoint listens, relative to `routes.api`, for the\n\t * adapters that register one (the native engine). Server-side only: the tracker learns\n\t * the path from `TrackerConfig.ingestPath`, and this object is never serialized.\n\t */\n\treadonly ingest?: { path: string }\n\tisConfigured(): boolean\n\tquery(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>\n\trealtime?(query: AnalyticsQuery, ctx: AdapterContext): Promise<AnalyticsResult>\n\tregister?(config: Config, context?: AdapterRegisterContext): void\n}\n\nexport type AnalyticsAdapterFactory<Config> = (config: Config) => AnalyticsAdapter\n"],"mappings":";;;;;AAQA,MAAa,iBAAiB"}
|
package/dist/core/options.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Goal } from "../goals/types.js";
|
|
1
2
|
import { AnalyticsAdapter } from "./contract.js";
|
|
2
3
|
import { TranslationsOption } from "../translations/index.js";
|
|
3
4
|
import { AnalyticsBinding } from "../binding/types.js";
|
|
5
|
+
import { CaptureSlot } from "../capture/slots.js";
|
|
4
6
|
import { CustomWidgetDef } from "../widgets/customWidget.js";
|
|
5
7
|
import { CollectionConfig, CollectionSlug, Payload, PayloadRequest } from "payload";
|
|
6
8
|
import { KeysConfig } from "@10x-media/fields/encrypted";
|
|
@@ -24,6 +26,13 @@ type TimezoneResolver = (args: {
|
|
|
24
26
|
req: PayloadRequest;
|
|
25
27
|
scope: string | null;
|
|
26
28
|
}) => string | null | Promise<string | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Enumerates the tenant scopes the cron tiers (cache warming, sync) fan out over.
|
|
31
|
+
* Absent, each tier runs once for the install-wide scope.
|
|
32
|
+
*/
|
|
33
|
+
type ScopesResolver = (args: {
|
|
34
|
+
payload: Payload;
|
|
35
|
+
}) => string[] | Promise<string[]>;
|
|
27
36
|
/**
|
|
28
37
|
* Escape hatch replacing the provider-collection lookup: return the runtime
|
|
29
38
|
* adapters for a scope yourself (any store, any shape). Results are layered onto
|
|
@@ -73,6 +82,79 @@ type AnalyticsAccessOptions = {
|
|
|
73
82
|
*/
|
|
74
83
|
platformRead?: PlatformReadAccess;
|
|
75
84
|
};
|
|
85
|
+
type ConsentMode = 'none' | 'required';
|
|
86
|
+
/** Per-slot consent decision, evaluated against the slot's resolved adapter. */
|
|
87
|
+
type ConsentResolver = (args: {
|
|
88
|
+
slot: CaptureSlot;
|
|
89
|
+
adapterId: string;
|
|
90
|
+
}) => ConsentMode;
|
|
91
|
+
/** An adapter id to fill a capture slot with, or `false` to leave it deliberately empty. */
|
|
92
|
+
type CaptureSlotOption = string | false;
|
|
93
|
+
/**
|
|
94
|
+
* A bare mode applies to every slot; a resolver decides per request-resolved adapter; the
|
|
95
|
+
* object form maps ids and slots, with an adapter entry winning over a slot entry. Every
|
|
96
|
+
* form overrides the default, which is `none` for the cookieless native tracker and
|
|
97
|
+
* `required` for a vendor's.
|
|
98
|
+
*/
|
|
99
|
+
type CaptureConsentOption = ConsentMode | ConsentResolver | {
|
|
100
|
+
slots?: Partial<Record<CaptureSlot, ConsentMode>>;
|
|
101
|
+
/**
|
|
102
|
+
* Keyed by adapter id. A bare id must name a config adapter; a runtime provider
|
|
103
|
+
* instance id (`<provider>:<instance>`) is taken on trust, since the providers it
|
|
104
|
+
* comes from are only resolved per request.
|
|
105
|
+
*/
|
|
106
|
+
adapters?: Record<string, ConsentMode>;
|
|
107
|
+
};
|
|
108
|
+
type AutoCaptureOptions = {
|
|
109
|
+
scrollDepth?: boolean;
|
|
110
|
+
outboundLinks?: boolean;
|
|
111
|
+
fileDownloads?: boolean;
|
|
112
|
+
goalAttribute?: boolean;
|
|
113
|
+
};
|
|
114
|
+
type ResolvedAutoCapture = Required<AutoCaptureOptions>;
|
|
115
|
+
/** Goals as config: the array form, or the object form 1b grows a collection source on. */
|
|
116
|
+
type AnalyticsGoalsOptions = {
|
|
117
|
+
defaults?: Goal[];
|
|
118
|
+
};
|
|
119
|
+
type AnalyticsCaptureOptions = {
|
|
120
|
+
/**
|
|
121
|
+
* Which adapter fills each capture slot, overriding the defaults: `global` is the
|
|
122
|
+
* designated `platformAdapter`, or the single config adapter when only one is
|
|
123
|
+
* configured; `tenant` is the resolved scope's default adapter. A `global` id must
|
|
124
|
+
* name a config adapter; a `tenant` id may also name a runtime provider instance,
|
|
125
|
+
* so it is resolved per request rather than validated at config time.
|
|
126
|
+
*
|
|
127
|
+
* `false` disables a slot outright: it fills with nothing, its proxy mount 404s, and
|
|
128
|
+
* the tracker config omits it. Use it to keep a default from filling a slot at all.
|
|
129
|
+
*/
|
|
130
|
+
slots?: {
|
|
131
|
+
global?: CaptureSlotOption;
|
|
132
|
+
tenant?: CaptureSlotOption;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Mount each slot's snippet points at. Defaults to the runtime proxy endpoint
|
|
136
|
+
* (`<routes.api>/analytics/p/<slot>`); set it when the slot is served through Next
|
|
137
|
+
* rewrites instead, passing the same path `captureRewrites` was mounted at.
|
|
138
|
+
*/
|
|
139
|
+
paths?: {
|
|
140
|
+
global?: string;
|
|
141
|
+
tenant?: string;
|
|
142
|
+
}; /** Whether a slot's tracker waits for consent. Native defaults to no gate, vendors to one. */
|
|
143
|
+
consent?: CaptureConsentOption; /** Browser auto-capture listeners, all on by default except `scrollDepth`. */
|
|
144
|
+
autoCapture?: AutoCaptureOptions; /** Limits for the public runtime capture proxy, separate from the read-path `cache`. */
|
|
145
|
+
proxy?: {
|
|
146
|
+
/**
|
|
147
|
+
* Deadline for the upstream response headers, in ms. Default 10000. The body
|
|
148
|
+
* download is not on the clock, so a large tracker bundle streams to completion.
|
|
149
|
+
*/
|
|
150
|
+
timeoutMs?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Largest proxied request body, in bytes. Default 1 MiB, which clears a PostHog
|
|
153
|
+
* batch carrying session-replay data. Anything larger is refused with 413.
|
|
154
|
+
*/
|
|
155
|
+
maxBodyBytes?: number;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
76
158
|
type AnalyticsPluginOptions = {
|
|
77
159
|
disabled?: boolean;
|
|
78
160
|
/**
|
|
@@ -85,6 +167,12 @@ type AnalyticsPluginOptions = {
|
|
|
85
167
|
adapters?: AnalyticsAdapter[];
|
|
86
168
|
defaultAdapter?: string;
|
|
87
169
|
scopeResolver?: ScopeResolver;
|
|
170
|
+
/**
|
|
171
|
+
* Enumerates the tenant scopes the cache-warming and sync cron tiers fan out
|
|
172
|
+
* over, in addition to the install-wide (null) scope every tier already runs.
|
|
173
|
+
* Unset, those tiers run once for the whole install, same as before.
|
|
174
|
+
*/
|
|
175
|
+
scopes?: ScopesResolver;
|
|
88
176
|
/**
|
|
89
177
|
* IANA reporting timezone that day boundaries (timeframe windows, series axes,
|
|
90
178
|
* native rollup buckets) align to. Defaults to UTC. A string forces one timezone
|
|
@@ -103,6 +191,12 @@ type AnalyticsPluginOptions = {
|
|
|
103
191
|
*/
|
|
104
192
|
platformAdapter?: string;
|
|
105
193
|
access?: AnalyticsAccessOptions;
|
|
194
|
+
capture?: AnalyticsCaptureOptions;
|
|
195
|
+
/**
|
|
196
|
+
* Conversion goals the tracker and the native ingest match events against. Slugs must
|
|
197
|
+
* be unique and kebab-case; only the slug and its match reach the browser.
|
|
198
|
+
*/
|
|
199
|
+
goals?: Goal[] | AnalyticsGoalsOptions;
|
|
106
200
|
/**
|
|
107
201
|
* Per-collection bindings, keyed by collection slug. With generated types
|
|
108
202
|
* augmented, each slug's resolvers receive that collection's typed document.
|
|
@@ -115,7 +209,8 @@ type AnalyticsPluginOptions = {
|
|
|
115
209
|
};
|
|
116
210
|
warm?: boolean | {
|
|
117
211
|
cron?: string;
|
|
118
|
-
};
|
|
212
|
+
}; /** Per-read provider timeout in ms, spanning retries and limiter waits. Default 15000. */
|
|
213
|
+
timeoutMs?: number;
|
|
119
214
|
};
|
|
120
215
|
widgets?: boolean | {
|
|
121
216
|
disabled?: string[];
|
|
@@ -148,5 +243,5 @@ type AnalyticsPluginOptions = {
|
|
|
148
243
|
};
|
|
149
244
|
};
|
|
150
245
|
//#endregion
|
|
151
|
-
export { AnalyticsAccessOptions, AnalyticsPluginOptions, PlatformReadAccess, ProvidersCollectionOptions, ProvidersOptions, ProvidersResolve, ScopeResolver, TimezoneResolver };
|
|
246
|
+
export { AnalyticsAccessOptions, AnalyticsCaptureOptions, AnalyticsGoalsOptions, AnalyticsPluginOptions, AutoCaptureOptions, CaptureConsentOption, ConsentMode, ConsentResolver, PlatformReadAccess, ProvidersCollectionOptions, ProvidersOptions, ProvidersResolve, ResolvedAutoCapture, ScopeResolver, ScopesResolver, TimezoneResolver };
|
|
152
247
|
//# sourceMappingURL=options.d.ts.map
|
package/dist/core/options.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "../capture/proxyEndpoint.js";
|
|
2
|
+
import { GOAL_SLUG_PATTERN } from "../goals/types.js";
|
|
1
3
|
import { PROVIDERS_SLUG } from "../providers/collection.js";
|
|
2
4
|
//#region src/core/options.ts
|
|
3
5
|
const DEFAULT_WARM_CRON = "*/30 * * * *";
|
|
@@ -5,6 +7,43 @@ const DEFAULT_SYNC_CRON = "0 */6 * * *";
|
|
|
5
7
|
const DEFAULT_SYNC_COLLECTION = "analytics-daily";
|
|
6
8
|
const DEFAULT_SYNC_LOOKBACK = 3;
|
|
7
9
|
const DEFAULT_SCOPE_FIELD = "scope";
|
|
10
|
+
const DEFAULT_TIMEOUT_MS = 15e3;
|
|
11
|
+
/** Scroll depth is the one listener off by default: it fires on every page, for every visitor. */
|
|
12
|
+
const DEFAULT_AUTO_CAPTURE = {
|
|
13
|
+
scrollDepth: false,
|
|
14
|
+
outboundLinks: true,
|
|
15
|
+
fileDownloads: true,
|
|
16
|
+
goalAttribute: true
|
|
17
|
+
};
|
|
18
|
+
const resolveAutoCapture = (option) => ({
|
|
19
|
+
scrollDepth: option?.scrollDepth ?? DEFAULT_AUTO_CAPTURE.scrollDepth,
|
|
20
|
+
outboundLinks: option?.outboundLinks ?? DEFAULT_AUTO_CAPTURE.outboundLinks,
|
|
21
|
+
fileDownloads: option?.fileDownloads ?? DEFAULT_AUTO_CAPTURE.fileDownloads,
|
|
22
|
+
goalAttribute: option?.goalAttribute ?? DEFAULT_AUTO_CAPTURE.goalAttribute
|
|
23
|
+
});
|
|
24
|
+
/** Cookieless native capture needs no consent gate; a vendor's tracker does. */
|
|
25
|
+
const defaultConsentFor = (kind) => kind === "native" ? "none" : "required";
|
|
26
|
+
const resolveConsent = (option, adapters) => {
|
|
27
|
+
if (option === "none" || option === "required") return () => option;
|
|
28
|
+
if (typeof option === "function") return (slot, adapterId) => option({
|
|
29
|
+
slot,
|
|
30
|
+
adapterId
|
|
31
|
+
});
|
|
32
|
+
for (const id of Object.keys(option?.adapters ?? {})) if (!id.includes(":") && !adapters.some((a) => a.id === id)) throw new Error(`analytics: unknown consent adapter "${id}"`);
|
|
33
|
+
return (slot, adapterId, kind) => option?.adapters?.[adapterId] ?? option?.slots?.[slot] ?? defaultConsentFor(kind);
|
|
34
|
+
};
|
|
35
|
+
const resolveGoals = (option) => {
|
|
36
|
+
const goals = Array.isArray(option) ? option : option?.defaults ?? [];
|
|
37
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38
|
+
for (const goal of goals) {
|
|
39
|
+
if (!GOAL_SLUG_PATTERN.test(goal.slug)) throw new Error(`analytics: goal slug "${goal.slug}" must be kebab-case`);
|
|
40
|
+
if (seen.has(goal.slug)) throw new Error(`analytics: duplicate goal slug "${goal.slug}"`);
|
|
41
|
+
const fixed = goal.value?.fixed;
|
|
42
|
+
if (fixed !== void 0 && (!Number.isFinite(fixed) || fixed < 0)) throw new Error(`analytics: goal "${goal.slug}" value.fixed must be a finite number >= 0, got ${String(fixed)}`);
|
|
43
|
+
seen.add(goal.slug);
|
|
44
|
+
}
|
|
45
|
+
return goals;
|
|
46
|
+
};
|
|
8
47
|
const resolveBindings = (collections) => {
|
|
9
48
|
const out = {};
|
|
10
49
|
for (const [slug, binding] of Object.entries(collections ?? {})) {
|
|
@@ -17,6 +56,9 @@ const resolveBindings = (collections) => {
|
|
|
17
56
|
function resolveOptions(options) {
|
|
18
57
|
if (!options.adapters || options.adapters.length === 0) throw new Error("analytics: at least one adapter is required");
|
|
19
58
|
if (options.platformAdapter !== void 0 && !options.adapters.some((a) => a.id === options.platformAdapter)) throw new Error(`analytics: unknown platform adapter "${options.platformAdapter}"`);
|
|
59
|
+
for (const [slot, value] of Object.entries(options.capture?.slots ?? {})) if (value !== false && typeof value !== "string" && value !== void 0) throw new Error(`analytics: capture slot "${slot}" must be an adapter id or false, got ${typeof value}`);
|
|
60
|
+
const globalSlot = options.capture?.slots?.global;
|
|
61
|
+
if (typeof globalSlot === "string" && !options.adapters.some((a) => a.id === globalSlot)) throw new Error(`analytics: unknown global capture slot adapter "${globalSlot}"`);
|
|
20
62
|
const widgets = options.widgets === false ? {
|
|
21
63
|
enabled: false,
|
|
22
64
|
disabled: [],
|
|
@@ -98,9 +140,27 @@ function resolveOptions(options) {
|
|
|
98
140
|
defaultAdapter: options.defaultAdapter,
|
|
99
141
|
scopeResolver: options.scopeResolver ?? (() => null),
|
|
100
142
|
scoped,
|
|
143
|
+
scopes: options.scopes,
|
|
101
144
|
reportingTimezone: options.reportingTimezone,
|
|
102
145
|
platformAdapter: options.platformAdapter,
|
|
103
146
|
access: { platformRead: options.access?.platformRead ?? (scoped ? () => false : ({ req }) => Boolean(req.user)) },
|
|
147
|
+
capture: {
|
|
148
|
+
slots: {
|
|
149
|
+
global: options.capture?.slots?.global,
|
|
150
|
+
tenant: options.capture?.slots?.tenant
|
|
151
|
+
},
|
|
152
|
+
paths: {
|
|
153
|
+
global: options.capture?.paths?.global,
|
|
154
|
+
tenant: options.capture?.paths?.tenant
|
|
155
|
+
},
|
|
156
|
+
consent: resolveConsent(options.capture?.consent, options.adapters),
|
|
157
|
+
autoCapture: resolveAutoCapture(options.capture?.autoCapture),
|
|
158
|
+
proxy: {
|
|
159
|
+
timeoutMs: options.capture?.proxy?.timeoutMs ?? 1e4,
|
|
160
|
+
maxBodyBytes: options.capture?.proxy?.maxBodyBytes ?? 1048576
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
goals: resolveGoals(options.goals),
|
|
104
164
|
providers,
|
|
105
165
|
bindings: resolveBindings(options.collections),
|
|
106
166
|
cache: {
|
|
@@ -108,13 +168,14 @@ function resolveOptions(options) {
|
|
|
108
168
|
aggregate: options.cache?.ttl?.aggregate,
|
|
109
169
|
realtime: options.cache?.ttl?.realtime
|
|
110
170
|
},
|
|
111
|
-
warm
|
|
171
|
+
warm,
|
|
172
|
+
timeoutMs: options.cache?.timeoutMs ?? DEFAULT_TIMEOUT_MS
|
|
112
173
|
},
|
|
113
174
|
widgets,
|
|
114
175
|
sync
|
|
115
176
|
};
|
|
116
177
|
}
|
|
117
178
|
//#endregion
|
|
118
|
-
export { resolveOptions };
|
|
179
|
+
export { DEFAULT_AUTO_CAPTURE, defaultConsentFor, resolveOptions };
|
|
119
180
|
|
|
120
181
|
//# sourceMappingURL=options.js.map
|
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 { CollectionConfig, CollectionSlug, Payload, PayloadRequest } from 'payload'\nimport type { AnalyticsBinding, ResolvedBinding } from '../binding/types'\nimport { PROVIDERS_SLUG } from '../providers/collection'\nimport type { TranslationsOption } from '../translations'\nimport type { CustomWidgetDef } from '../widgets/customWidget'\nimport type { AnalyticsAdapter } from './contract'\n\nconst DEFAULT_WARM_CRON = '*/30 * * * *'\nconst DEFAULT_SYNC_CRON = '0 */6 * * *'\nconst DEFAULT_SYNC_COLLECTION = 'analytics-daily'\nconst DEFAULT_SYNC_LOOKBACK = 3\nconst DEFAULT_SCOPE_FIELD = 'scope'\n\n/**\n * Maps a request to its analytics boundary (tenant id, site key). Null means the\n * whole install, which is the default single-site behavior. With a multi-tenant\n * plugin, return the request's tenant id here.\n */\nexport type ScopeResolver = (args: {\n\treq: PayloadRequest\n}) => string | null | Promise<string | null>\n\n/**\n * Resolves the IANA reporting timezone a read's (or ingest's) day boundaries align\n * to. Receives the request and its already-resolved scope, so per-tenant, per-user\n * (`req.user`), and selector (cookie/preference) strategies are all expressible.\n * Return `null` to fall back to UTC.\n */\nexport type TimezoneResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string | null | Promise<string | null>\n\n/**\n * Escape hatch replacing the provider-collection lookup: return the runtime\n * adapters for a scope yourself (any store, any shape). Results are layered onto\n * the static config adapters exactly like collection-resolved ones, but are not\n * cached; memoize inside the function if lookups are expensive.\n */\nexport type ProvidersResolve = (args: {\n\tpayload: Payload\n\treq?: PayloadRequest\n\tscope: string | null\n}) => AnalyticsAdapter[] | Promise<AnalyticsAdapter[]>\n\nexport type ProvidersCollectionOptions = {\n\tslug?: string\n\t/**\n\t * Field matched against the resolved scope when looking up a scope's providers.\n\t * Point it at a tenant plugin's field (e.g. 'tenant') when that plugin manages\n\t * scoping for the collection.\n\t */\n\tscopeField?: string\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\taccess?: Partial<CollectionConfig['access']>\n\t/**\n\t * Dedicated key ring for the stored provider credentials. Unset, the\n\t * fields plugin's global `encrypted.keys` applies, and with neither the\n\t * ring derives from the Payload secret. Configure a dedicated key for\n\t * anything beyond a dev install.\n\t */\n\tencryption?: { keys?: KeysConfig }\n}\n\nexport type ProvidersOptions = {\n\t/** Opt-in admin collection storing runtime provider configurations. */\n\tcollection?: boolean | ProvidersCollectionOptions\n\tresolve?: ProvidersResolve\n}\n\n/** Access checker for cross-scope (platform) analytics reads. */\nexport type PlatformReadAccess = (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\nexport type AnalyticsAccessOptions = {\n\t/**\n\t * Gates cross-scope reads: explicit `scope: '*'` reads, and scoped reads through\n\t * a shared config adapter that cannot filter by scope. Scoped installs\n\t * (`scopeResolver` configured) default to deny; configure it, for example a role\n\t * check, so platform admins can read cross-scope and manage every tenant's\n\t * providers. Unscoped installs default to any authenticated admin-panel user.\n\t */\n\tplatformRead?: PlatformReadAccess\n}\n\nexport type AnalyticsPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/analytics/i18n`. Values win over\n\t * the built-in locales key-by-key; locales the plugin does not ship are added\n\t * whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\tadapters?: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\tscopeResolver?: ScopeResolver\n\t/**\n\t * IANA reporting timezone that day boundaries (timeframe windows, series axes,\n\t * native rollup buckets) align to. Defaults to UTC. A string forces one timezone\n\t * (the single-tenant / no-multi-tenancy case); a resolver derives it per request\n\t * from the scope, user, or a selector. Native rollups bucket at ingest in the\n\t * resolved timezone, so changing it does not re-bucket existing history.\n\t */\n\treportingTimezone?: string | TimezoneResolver\n\tproviders?: ProvidersOptions\n\t/**\n\t * Id of one config adapter shared by every scope (the platform's own analytics,\n\t * e.g. a PostHog project capturing all tenants). Included in each scope's\n\t * registry like any config adapter; reads through it are scope-filtered only\n\t * when the adapter supports scoped queries, otherwise they are cross-scope and\n\t * require `access.platformRead`.\n\t */\n\tplatformAdapter?: string\n\taccess?: AnalyticsAccessOptions\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\tcache?: { ttl?: { aggregate?: number; realtime?: number }; warm?: boolean | { cron?: string } }\n\twidgets?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tdisabled?: string[]\n\t\t\t\tregister?: CustomWidgetDef[]\n\t\t\t\t/**\n\t\t\t\t * Marks the free-text widget config fields (each widget's Title) as\n\t\t\t\t * `localized`. Off by default; takes effect only when the Payload config\n\t\t\t\t * enables localization (Payload strips the flag otherwise).\n\t\t\t\t */\n\t\t\t\tlocalizeText?: boolean\n\t\t\t\t/**\n\t\t\t\t * Period-over-period comparison on the metric and trend widgets. On by\n\t\t\t\t * default for adapters that declare `capabilities.comparison`; set false\n\t\t\t\t * to skip the second (previous-window) read entirely.\n\t\t\t\t */\n\t\t\t\tcomparison?: boolean\n\t\t }\n\t/**\n\t * Opt-in sync tier: a cron job that persists each provider's daily metrics into a\n\t * queryable collection. Reads go through the surfacing cache, so persisted rows reflect\n\t * cached values up to `cache.ttl.aggregate` old; keep that TTL below the sync interval\n\t * for the freshest data.\n\t */\n\tsync?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tcollectionSlug?: CollectionSlug\n\t\t\t\tcron?: string\n\t\t\t\tlookbackDays?: number\n\t\t\t\tadapters?: string[]\n\t\t\t\t/** Surface the analytics-daily collection in the admin nav. Default false (hidden). */\n\t\t\t\thidden?: boolean\n\t\t }\n}\n\nexport interface ResolvedOptions {\n\tadapters: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\tscopeResolver: ScopeResolver\n\t/** True when the app configured a scopeResolver (scoped install). */\n\tscoped: boolean\n\t/** Raw reportingTimezone option; normalized into a resolver at init. */\n\treportingTimezone?: string | TimezoneResolver\n\tplatformAdapter?: string\n\taccess: { platformRead: PlatformReadAccess }\n\tproviders: {\n\t\tcollection: {\n\t\t\tenabled: boolean\n\t\t\tslug: string\n\t\t\tscopeField: string\n\t\t\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t\t\taccess?: Partial<CollectionConfig['access']>\n\t\t\tencryption?: { keys?: KeysConfig }\n\t\t}\n\t\tresolve?: ProvidersResolve\n\t}\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; cron: string }\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}\n\tsync: {\n\t\tenabled: boolean\n\t\tcollectionSlug: string\n\t\tcron: string\n\t\tlookbackDays: number\n\t\tadapters?: string[]\n\t\t/** True hides the analytics-daily collection from the admin nav (default). */\n\t\thidden: boolean\n\t}\n}\n\nconst resolveBindings = (\n\tcollections: AnalyticsPluginOptions['collections']\n): Record<string, ResolvedBinding> => {\n\tconst out: Record<string, ResolvedBinding> = {}\n\tfor (const [slug, binding] of Object.entries(collections ?? {})) {\n\t\tif (!binding) continue\n\t\tif (!binding.path && !binding.pathField) {\n\t\t\tthrow new Error(`analytics: binding for \"${slug}\" needs a path resolver or a pathField`)\n\t\t}\n\t\t// Erases the per-slug doc generic; safe because the runtime only ever hands\n\t\t// a binding documents from its own collection.\n\t\tout[slug] = binding as ResolvedBinding\n\t}\n\treturn out\n}\n\nexport function resolveOptions(options: AnalyticsPluginOptions): ResolvedOptions {\n\tif (!options.adapters || options.adapters.length === 0) {\n\t\tthrow new Error('analytics: at least one adapter is required')\n\t}\n\tif (\n\t\toptions.platformAdapter !== undefined &&\n\t\t!options.adapters.some((a) => a.id === options.platformAdapter)\n\t) {\n\t\tthrow new Error(`analytics: unknown platform adapter \"${options.platformAdapter}\"`)\n\t}\n\tconst widgets =\n\t\toptions.widgets === false\n\t\t\t? {\n\t\t\t\t\tenabled: false,\n\t\t\t\t\tdisabled: [] as string[],\n\t\t\t\t\tregister: [] as CustomWidgetDef[],\n\t\t\t\t\tlocalizeText: false,\n\t\t\t\t\tcomparison: true,\n\t\t\t\t}\n\t\t\t: options.widgets === undefined || options.widgets === true\n\t\t\t\t? {\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\tdisabled: [] as string[],\n\t\t\t\t\t\tregister: [] as CustomWidgetDef[],\n\t\t\t\t\t\tlocalizeText: false,\n\t\t\t\t\t\tcomparison: true,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\tdisabled: options.widgets.disabled ?? [],\n\t\t\t\t\t\tregister: options.widgets.register ?? [],\n\t\t\t\t\t\tlocalizeText: options.widgets.localizeText ?? false,\n\t\t\t\t\t\tcomparison: options.widgets.comparison ?? true,\n\t\t\t\t\t}\n\tconst warmOpt = options.cache?.warm\n\tconst warm =\n\t\twarmOpt === true\n\t\t\t? { enabled: true, cron: DEFAULT_WARM_CRON }\n\t\t\t: warmOpt && typeof warmOpt === 'object'\n\t\t\t\t? { enabled: true, cron: warmOpt.cron ?? DEFAULT_WARM_CRON }\n\t\t\t\t: { enabled: false, cron: DEFAULT_WARM_CRON }\n\tconst collectionOpt = options.providers?.collection\n\tconst providers = {\n\t\tcollection:\n\t\t\tcollectionOpt === true\n\t\t\t\t? { enabled: true, slug: PROVIDERS_SLUG, scopeField: DEFAULT_SCOPE_FIELD }\n\t\t\t\t: collectionOpt && typeof collectionOpt === 'object'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\tslug: collectionOpt.slug ?? PROVIDERS_SLUG,\n\t\t\t\t\t\t\tscopeField: collectionOpt.scopeField ?? DEFAULT_SCOPE_FIELD,\n\t\t\t\t\t\t\toverrides: collectionOpt.overrides,\n\t\t\t\t\t\t\taccess: collectionOpt.access,\n\t\t\t\t\t\t\tencryption: collectionOpt.encryption,\n\t\t\t\t\t\t}\n\t\t\t\t\t: { enabled: false, slug: PROVIDERS_SLUG, scopeField: DEFAULT_SCOPE_FIELD },\n\t\tresolve: options.providers?.resolve,\n\t}\n\tif (providers.collection.enabled) {\n\t\tif (providers.collection.scopeField.trim() === '') {\n\t\t\tthrow new Error('analytics: providers.collection.scopeField must be a non-empty field name')\n\t\t}\n\t\tif (providers.collection.scopeField.includes('.')) {\n\t\t\tthrow new Error(\n\t\t\t\t'analytics: providers.collection.scopeField must be a top-level field name (no dots); the scope stamp writes it as a flat key'\n\t\t\t)\n\t\t}\n\t}\n\tconst syncOpt = options.sync\n\tconst sync =\n\t\tsyncOpt === true\n\t\t\t? {\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tcollectionSlug: DEFAULT_SYNC_COLLECTION,\n\t\t\t\t\tcron: DEFAULT_SYNC_CRON,\n\t\t\t\t\tlookbackDays: DEFAULT_SYNC_LOOKBACK,\n\t\t\t\t\thidden: true,\n\t\t\t\t}\n\t\t\t: syncOpt && typeof syncOpt === 'object'\n\t\t\t\t? {\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\tcollectionSlug: syncOpt.collectionSlug ?? DEFAULT_SYNC_COLLECTION,\n\t\t\t\t\t\tcron: syncOpt.cron ?? DEFAULT_SYNC_CRON,\n\t\t\t\t\t\tlookbackDays: syncOpt.lookbackDays ?? DEFAULT_SYNC_LOOKBACK,\n\t\t\t\t\t\tadapters: syncOpt.adapters,\n\t\t\t\t\t\thidden: syncOpt.hidden ?? true,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tenabled: false,\n\t\t\t\t\t\tcollectionSlug: DEFAULT_SYNC_COLLECTION,\n\t\t\t\t\t\tcron: DEFAULT_SYNC_CRON,\n\t\t\t\t\t\tlookbackDays: DEFAULT_SYNC_LOOKBACK,\n\t\t\t\t\t\thidden: true,\n\t\t\t\t\t}\n\tconst scoped = options.scopeResolver !== undefined\n\treturn {\n\t\tadapters: options.adapters,\n\t\tdefaultAdapter: options.defaultAdapter,\n\t\tscopeResolver: options.scopeResolver ?? (() => null),\n\t\tscoped,\n\t\treportingTimezone: options.reportingTimezone,\n\t\tplatformAdapter: options.platformAdapter,\n\t\taccess: {\n\t\t\tplatformRead:\n\t\t\t\toptions.access?.platformRead ?? (scoped ? () => false : ({ req }) => Boolean(req.user)),\n\t\t},\n\t\tproviders,\n\t\tbindings: resolveBindings(options.collections),\n\t\tcache: {\n\t\t\t// Left undefined when the app did not set them so the adapter's recommendedTtl\n\t\t\t// applies as the default; an explicit value overrides the adapter recommendation.\n\t\t\tttl: {\n\t\t\t\taggregate: options.cache?.ttl?.aggregate,\n\t\t\t\trealtime: options.cache?.ttl?.realtime,\n\t\t\t},\n\t\t\twarm,\n\t\t},\n\t\twidgets,\n\t\tsync,\n\t}\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"options.js","names":[],"sources":["../../src/core/options.ts"],"sourcesContent":["import type { KeysConfig } from '@10x-media/fields/encrypted'\nimport type { CollectionConfig, CollectionSlug, Payload, PayloadRequest } from 'payload'\nimport type { AnalyticsBinding, ResolvedBinding } from '../binding/types'\nimport { DEFAULT_PROXY_MAX_BODY_BYTES, DEFAULT_PROXY_TIMEOUT_MS } from '../capture/proxyEndpoint'\nimport type { CaptureSlot } from '../capture/slots'\nimport { GOAL_SLUG_PATTERN, type Goal } from '../goals/types'\nimport { PROVIDERS_SLUG } from '../providers/collection'\nimport type { TranslationsOption } from '../translations'\nimport type { CustomWidgetDef } from '../widgets/customWidget'\nimport type { CaptureClientKind } from './capture'\nimport type { AnalyticsAdapter } from './contract'\n\nconst DEFAULT_WARM_CRON = '*/30 * * * *'\nconst DEFAULT_SYNC_CRON = '0 */6 * * *'\nconst DEFAULT_SYNC_COLLECTION = 'analytics-daily'\nconst DEFAULT_SYNC_LOOKBACK = 3\nconst DEFAULT_SCOPE_FIELD = 'scope'\nconst DEFAULT_TIMEOUT_MS = 15_000\n\n/**\n * Maps a request to its analytics boundary (tenant id, site key). Null means the\n * whole install, which is the default single-site behavior. With a multi-tenant\n * plugin, return the request's tenant id here.\n */\nexport type ScopeResolver = (args: {\n\treq: PayloadRequest\n}) => string | null | Promise<string | null>\n\n/**\n * Resolves the IANA reporting timezone a read's (or ingest's) day boundaries align\n * to. Receives the request and its already-resolved scope, so per-tenant, per-user\n * (`req.user`), and selector (cookie/preference) strategies are all expressible.\n * Return `null` to fall back to UTC.\n */\nexport type TimezoneResolver = (args: {\n\treq: PayloadRequest\n\tscope: string | null\n}) => string | null | Promise<string | null>\n\n/**\n * Enumerates the tenant scopes the cron tiers (cache warming, sync) fan out over.\n * Absent, each tier runs once for the install-wide scope.\n */\nexport type ScopesResolver = (args: { payload: Payload }) => string[] | Promise<string[]>\n\n/**\n * Escape hatch replacing the provider-collection lookup: return the runtime\n * adapters for a scope yourself (any store, any shape). Results are layered onto\n * the static config adapters exactly like collection-resolved ones, but are not\n * cached; memoize inside the function if lookups are expensive.\n */\nexport type ProvidersResolve = (args: {\n\tpayload: Payload\n\treq?: PayloadRequest\n\tscope: string | null\n}) => AnalyticsAdapter[] | Promise<AnalyticsAdapter[]>\n\nexport type ProvidersCollectionOptions = {\n\tslug?: string\n\t/**\n\t * Field matched against the resolved scope when looking up a scope's providers.\n\t * Point it at a tenant plugin's field (e.g. 'tenant') when that plugin manages\n\t * scoping for the collection.\n\t */\n\tscopeField?: string\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\taccess?: Partial<CollectionConfig['access']>\n\t/**\n\t * Dedicated key ring for the stored provider credentials. Unset, the\n\t * fields plugin's global `encrypted.keys` applies, and with neither the\n\t * ring derives from the Payload secret. Configure a dedicated key for\n\t * anything beyond a dev install.\n\t */\n\tencryption?: { keys?: KeysConfig }\n}\n\nexport type ProvidersOptions = {\n\t/** Opt-in admin collection storing runtime provider configurations. */\n\tcollection?: boolean | ProvidersCollectionOptions\n\tresolve?: ProvidersResolve\n}\n\n/** Access checker for cross-scope (platform) analytics reads. */\nexport type PlatformReadAccess = (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\nexport type AnalyticsAccessOptions = {\n\t/**\n\t * Gates cross-scope reads: explicit `scope: '*'` reads, and scoped reads through\n\t * a shared config adapter that cannot filter by scope. Scoped installs\n\t * (`scopeResolver` configured) default to deny; configure it, for example a role\n\t * check, so platform admins can read cross-scope and manage every tenant's\n\t * providers. Unscoped installs default to any authenticated admin-panel user.\n\t */\n\tplatformRead?: PlatformReadAccess\n}\n\nexport type ConsentMode = 'none' | 'required'\n\n/** Per-slot consent decision, evaluated against the slot's resolved adapter. */\nexport type ConsentResolver = (args: { slot: CaptureSlot; adapterId: string }) => ConsentMode\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/**\n * A bare mode applies to every slot; a resolver decides per request-resolved adapter; the\n * object form maps ids and slots, with an adapter entry winning over a slot entry. Every\n * form overrides the default, which is `none` for the cookieless native tracker and\n * `required` for a vendor's.\n */\nexport type CaptureConsentOption =\n\t| ConsentMode\n\t| ConsentResolver\n\t| {\n\t\t\tslots?: Partial<Record<CaptureSlot, ConsentMode>>\n\t\t\t/**\n\t\t\t * Keyed by adapter id. A bare id must name a config adapter; a runtime provider\n\t\t\t * instance id (`<provider>:<instance>`) is taken on trust, since the providers it\n\t\t\t * comes from are only resolved per request.\n\t\t\t */\n\t\t\tadapters?: Record<string, ConsentMode>\n\t }\n\n/** The normalized policy the runtime evaluates; `kind` carries the adapter's tracker family. */\nexport type ConsentPolicy = (\n\tslot: CaptureSlot,\n\tadapterId: string,\n\tkind: CaptureClientKind\n) => ConsentMode\n\nexport type AutoCaptureOptions = {\n\tscrollDepth?: boolean\n\toutboundLinks?: boolean\n\tfileDownloads?: boolean\n\tgoalAttribute?: boolean\n}\n\nexport type ResolvedAutoCapture = Required<AutoCaptureOptions>\n\n/** Goals as config: the array form, or the object form 1b grows a collection source on. */\nexport type AnalyticsGoalsOptions = { defaults?: Goal[] }\n\nexport type AnalyticsCaptureOptions = {\n\t/**\n\t * Which adapter fills each capture slot, overriding the defaults: `global` is the\n\t * designated `platformAdapter`, or the single config adapter when only one is\n\t * configured; `tenant` is the resolved scope's default adapter. A `global` id must\n\t * name a config adapter; a `tenant` id may also name a runtime provider instance,\n\t * so it is resolved per request rather than validated at config time.\n\t *\n\t * `false` disables a slot outright: it fills with nothing, its proxy mount 404s, and\n\t * the tracker config omits it. Use it to keep a default from filling a slot at all.\n\t */\n\tslots?: { global?: CaptureSlotOption; tenant?: CaptureSlotOption }\n\t/**\n\t * Mount each slot's snippet points at. Defaults to the runtime proxy endpoint\n\t * (`<routes.api>/analytics/p/<slot>`); set it when the slot is served through Next\n\t * rewrites instead, passing the same path `captureRewrites` was mounted at.\n\t */\n\tpaths?: { global?: string; tenant?: string }\n\t/** Whether a slot's tracker waits for consent. Native defaults to no gate, vendors to one. */\n\tconsent?: CaptureConsentOption\n\t/** Browser auto-capture listeners, all on by default except `scrollDepth`. */\n\tautoCapture?: AutoCaptureOptions\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 AnalyticsPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/analytics/i18n`. Values win over\n\t * the built-in locales key-by-key; locales the plugin does not ship are added\n\t * whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\tadapters?: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\tscopeResolver?: ScopeResolver\n\t/**\n\t * Enumerates the tenant scopes the cache-warming and sync cron tiers fan out\n\t * over, in addition to the install-wide (null) scope every tier already runs.\n\t * Unset, those tiers run once for the whole install, same as before.\n\t */\n\tscopes?: ScopesResolver\n\t/**\n\t * IANA reporting timezone that day boundaries (timeframe windows, series axes,\n\t * native rollup buckets) align to. Defaults to UTC. A string forces one timezone\n\t * (the single-tenant / no-multi-tenancy case); a resolver derives it per request\n\t * from the scope, user, or a selector. Native rollups bucket at ingest in the\n\t * resolved timezone, so changing it does not re-bucket existing history.\n\t */\n\treportingTimezone?: string | TimezoneResolver\n\tproviders?: ProvidersOptions\n\t/**\n\t * Id of one config adapter shared by every scope (the platform's own analytics,\n\t * e.g. a PostHog project capturing all tenants). Included in each scope's\n\t * registry like any config adapter; reads through it are scope-filtered only\n\t * when the adapter supports scoped queries, otherwise they are cross-scope and\n\t * require `access.platformRead`.\n\t */\n\tplatformAdapter?: string\n\taccess?: AnalyticsAccessOptions\n\tcapture?: AnalyticsCaptureOptions\n\t/**\n\t * Conversion goals the tracker and the native ingest match events against. Slugs must\n\t * be unique and kebab-case; only the slug and its match reach 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\tcache?: {\n\t\tttl?: { aggregate?: number; realtime?: number }\n\t\twarm?: boolean | { cron?: string }\n\t\t/** Per-read provider timeout in ms, spanning retries and limiter waits. Default 15000. */\n\t\ttimeoutMs?: number\n\t}\n\twidgets?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tdisabled?: string[]\n\t\t\t\tregister?: CustomWidgetDef[]\n\t\t\t\t/**\n\t\t\t\t * Marks the free-text widget config fields (each widget's Title) as\n\t\t\t\t * `localized`. Off by default; takes effect only when the Payload config\n\t\t\t\t * enables localization (Payload strips the flag otherwise).\n\t\t\t\t */\n\t\t\t\tlocalizeText?: boolean\n\t\t\t\t/**\n\t\t\t\t * Period-over-period comparison on the metric and trend widgets. On by\n\t\t\t\t * default for adapters that declare `capabilities.comparison`; set false\n\t\t\t\t * to skip the second (previous-window) read entirely.\n\t\t\t\t */\n\t\t\t\tcomparison?: boolean\n\t\t }\n\t/**\n\t * Opt-in sync tier: a cron job that persists each provider's daily metrics into a\n\t * queryable collection. Reads go through the surfacing cache, so persisted rows reflect\n\t * cached values up to `cache.ttl.aggregate` old; keep that TTL below the sync interval\n\t * for the freshest data.\n\t */\n\tsync?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tcollectionSlug?: CollectionSlug\n\t\t\t\tcron?: string\n\t\t\t\tlookbackDays?: number\n\t\t\t\tadapters?: string[]\n\t\t\t\t/** Surface the analytics-daily collection in the admin nav. Default false (hidden). */\n\t\t\t\thidden?: boolean\n\t\t }\n}\n\nexport interface ResolvedCapture {\n\tslots: { global?: CaptureSlotOption; tenant?: CaptureSlotOption }\n\tpaths: { global?: string; tenant?: string }\n\tconsent: ConsentPolicy\n\tautoCapture: ResolvedAutoCapture\n\tproxy: { timeoutMs: number; maxBodyBytes: number }\n}\n\nexport interface ResolvedOptions {\n\tadapters: AnalyticsAdapter[]\n\tdefaultAdapter?: string\n\tscopeResolver: ScopeResolver\n\t/** True when the app configured a scopeResolver (scoped install). */\n\tscoped: boolean\n\t/** Raw scopes option; undefined runs the cron tiers install-wide only. */\n\tscopes?: ScopesResolver\n\t/** Raw reportingTimezone option; normalized into a resolver at init. */\n\treportingTimezone?: string | TimezoneResolver\n\tplatformAdapter?: string\n\taccess: { platformRead: PlatformReadAccess }\n\tcapture: ResolvedCapture\n\t/** Config goals, validated; 1b layers collection-sourced goals on top of these. */\n\tgoals: Goal[]\n\tproviders: {\n\t\tcollection: {\n\t\t\tenabled: boolean\n\t\t\tslug: string\n\t\t\tscopeField: string\n\t\t\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t\t\taccess?: Partial<CollectionConfig['access']>\n\t\t\tencryption?: { keys?: KeysConfig }\n\t\t}\n\t\tresolve?: ProvidersResolve\n\t}\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; cron: string }\n\t\ttimeoutMs: number\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}\n\tsync: {\n\t\tenabled: boolean\n\t\tcollectionSlug: string\n\t\tcron: string\n\t\tlookbackDays: number\n\t\tadapters?: string[]\n\t\t/** True hides the analytics-daily collection from the admin nav (default). */\n\t\thidden: boolean\n\t}\n}\n\n/** Scroll depth is the one listener off by default: it fires on every page, for every visitor. */\nexport const DEFAULT_AUTO_CAPTURE: ResolvedAutoCapture = {\n\tscrollDepth: false,\n\toutboundLinks: true,\n\tfileDownloads: true,\n\tgoalAttribute: true,\n}\n\nconst resolveAutoCapture = (option: AutoCaptureOptions | undefined): ResolvedAutoCapture => ({\n\tscrollDepth: option?.scrollDepth ?? DEFAULT_AUTO_CAPTURE.scrollDepth,\n\toutboundLinks: option?.outboundLinks ?? DEFAULT_AUTO_CAPTURE.outboundLinks,\n\tfileDownloads: option?.fileDownloads ?? DEFAULT_AUTO_CAPTURE.fileDownloads,\n\tgoalAttribute: option?.goalAttribute ?? DEFAULT_AUTO_CAPTURE.goalAttribute,\n})\n\n/** Cookieless native capture needs no consent gate; a vendor's tracker does. */\nexport const defaultConsentFor = (kind: CaptureClientKind): ConsentMode =>\n\tkind === 'native' ? 'none' : 'required'\n\nconst resolveConsent = (\n\toption: CaptureConsentOption | undefined,\n\tadapters: AnalyticsAdapter[]\n): ConsentPolicy => {\n\tif (option === 'none' || option === 'required') {\n\t\treturn () => option\n\t}\n\tif (typeof option === 'function') {\n\t\treturn (slot, adapterId) => option({ slot, adapterId })\n\t}\n\tfor (const id of Object.keys(option?.adapters ?? {})) {\n\t\t// A runtime provider instance id is `<provider>:<instance>` and only exists once a\n\t\t// scope resolves, so it cannot be checked here; a bare id must name a config adapter.\n\t\tif (!id.includes(':') && !adapters.some((a) => a.id === id)) {\n\t\t\tthrow new Error(`analytics: unknown consent adapter \"${id}\"`)\n\t\t}\n\t}\n\treturn (slot, adapterId, kind) =>\n\t\toption?.adapters?.[adapterId] ?? option?.slots?.[slot] ?? defaultConsentFor(kind)\n}\n\nconst resolveGoals = (option: AnalyticsPluginOptions['goals']): Goal[] => {\n\tconst goals = Array.isArray(option) ? option : (option?.defaults ?? [])\n\tconst seen = new Set<string>()\n\tfor (const goal of goals) {\n\t\tif (!GOAL_SLUG_PATTERN.test(goal.slug)) {\n\t\t\tthrow new Error(`analytics: goal slug \"${goal.slug}\" must be kebab-case`)\n\t\t}\n\t\tif (seen.has(goal.slug)) {\n\t\t\tthrow new Error(`analytics: duplicate goal slug \"${goal.slug}\"`)\n\t\t}\n\t\tconst fixed = goal.value?.fixed\n\t\t// Revenue is money: a negative or non-finite fixed value would be silently ignored at\n\t\t// ingest, so it fails the boot instead.\n\t\tif (fixed !== undefined && (!Number.isFinite(fixed) || fixed < 0)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: goal \"${goal.slug}\" value.fixed must be a finite number >= 0, got ${String(fixed)}`\n\t\t\t)\n\t\t}\n\t\tseen.add(goal.slug)\n\t}\n\treturn goals\n}\n\nconst resolveBindings = (\n\tcollections: AnalyticsPluginOptions['collections']\n): Record<string, ResolvedBinding> => {\n\tconst out: Record<string, ResolvedBinding> = {}\n\tfor (const [slug, binding] of Object.entries(collections ?? {})) {\n\t\tif (!binding) continue\n\t\tif (!binding.path && !binding.pathField) {\n\t\t\tthrow new Error(`analytics: binding for \"${slug}\" needs a path resolver or a pathField`)\n\t\t}\n\t\t// Erases the per-slug doc generic; safe because the runtime only ever hands\n\t\t// a binding documents from its own collection.\n\t\tout[slug] = binding as ResolvedBinding\n\t}\n\treturn out\n}\n\nexport function resolveOptions(options: AnalyticsPluginOptions): ResolvedOptions {\n\tif (!options.adapters || options.adapters.length === 0) {\n\t\tthrow new Error('analytics: at least one adapter is required')\n\t}\n\tif (\n\t\toptions.platformAdapter !== undefined &&\n\t\t!options.adapters.some((a) => a.id === options.platformAdapter)\n\t) {\n\t\tthrow new Error(`analytics: unknown platform adapter \"${options.platformAdapter}\"`)\n\t}\n\tfor (const [slot, value] of Object.entries(options.capture?.slots ?? {})) {\n\t\tif (value !== false && typeof value !== 'string' && value !== undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: capture slot \"${slot}\" must be an adapter id or false, got ${typeof value}`\n\t\t\t)\n\t\t}\n\t}\n\tconst globalSlot = options.capture?.slots?.global\n\t// A tenant id may name a runtime provider instance, which only exists once a scope\n\t// resolves; a global one can only come from the config registry, so it is checked here.\n\tif (typeof globalSlot === 'string' && !options.adapters.some((a) => a.id === globalSlot)) {\n\t\tthrow new Error(`analytics: unknown global capture slot adapter \"${globalSlot}\"`)\n\t}\n\tconst widgets =\n\t\toptions.widgets === false\n\t\t\t? {\n\t\t\t\t\tenabled: false,\n\t\t\t\t\tdisabled: [] as string[],\n\t\t\t\t\tregister: [] as CustomWidgetDef[],\n\t\t\t\t\tlocalizeText: false,\n\t\t\t\t\tcomparison: true,\n\t\t\t\t}\n\t\t\t: options.widgets === undefined || options.widgets === true\n\t\t\t\t? {\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\tdisabled: [] as string[],\n\t\t\t\t\t\tregister: [] as CustomWidgetDef[],\n\t\t\t\t\t\tlocalizeText: false,\n\t\t\t\t\t\tcomparison: true,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\tdisabled: options.widgets.disabled ?? [],\n\t\t\t\t\t\tregister: options.widgets.register ?? [],\n\t\t\t\t\t\tlocalizeText: options.widgets.localizeText ?? false,\n\t\t\t\t\t\tcomparison: options.widgets.comparison ?? true,\n\t\t\t\t\t}\n\tconst warmOpt = options.cache?.warm\n\tconst warm =\n\t\twarmOpt === true\n\t\t\t? { enabled: true, cron: DEFAULT_WARM_CRON }\n\t\t\t: warmOpt && typeof warmOpt === 'object'\n\t\t\t\t? { enabled: true, cron: warmOpt.cron ?? DEFAULT_WARM_CRON }\n\t\t\t\t: { enabled: false, cron: DEFAULT_WARM_CRON }\n\tconst collectionOpt = options.providers?.collection\n\tconst providers = {\n\t\tcollection:\n\t\t\tcollectionOpt === true\n\t\t\t\t? { enabled: true, slug: PROVIDERS_SLUG, scopeField: DEFAULT_SCOPE_FIELD }\n\t\t\t\t: collectionOpt && typeof collectionOpt === 'object'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\tslug: collectionOpt.slug ?? PROVIDERS_SLUG,\n\t\t\t\t\t\t\tscopeField: collectionOpt.scopeField ?? DEFAULT_SCOPE_FIELD,\n\t\t\t\t\t\t\toverrides: collectionOpt.overrides,\n\t\t\t\t\t\t\taccess: collectionOpt.access,\n\t\t\t\t\t\t\tencryption: collectionOpt.encryption,\n\t\t\t\t\t\t}\n\t\t\t\t\t: { enabled: false, slug: PROVIDERS_SLUG, scopeField: DEFAULT_SCOPE_FIELD },\n\t\tresolve: options.providers?.resolve,\n\t}\n\tif (providers.collection.enabled) {\n\t\tif (providers.collection.scopeField.trim() === '') {\n\t\t\tthrow new Error('analytics: providers.collection.scopeField must be a non-empty field name')\n\t\t}\n\t\tif (providers.collection.scopeField.includes('.')) {\n\t\t\tthrow new Error(\n\t\t\t\t'analytics: providers.collection.scopeField must be a top-level field name (no dots); the scope stamp writes it as a flat key'\n\t\t\t)\n\t\t}\n\t}\n\tconst syncOpt = options.sync\n\tconst sync =\n\t\tsyncOpt === true\n\t\t\t? {\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tcollectionSlug: DEFAULT_SYNC_COLLECTION,\n\t\t\t\t\tcron: DEFAULT_SYNC_CRON,\n\t\t\t\t\tlookbackDays: DEFAULT_SYNC_LOOKBACK,\n\t\t\t\t\thidden: true,\n\t\t\t\t}\n\t\t\t: syncOpt && typeof syncOpt === 'object'\n\t\t\t\t? {\n\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\tcollectionSlug: syncOpt.collectionSlug ?? DEFAULT_SYNC_COLLECTION,\n\t\t\t\t\t\tcron: syncOpt.cron ?? DEFAULT_SYNC_CRON,\n\t\t\t\t\t\tlookbackDays: syncOpt.lookbackDays ?? DEFAULT_SYNC_LOOKBACK,\n\t\t\t\t\t\tadapters: syncOpt.adapters,\n\t\t\t\t\t\thidden: syncOpt.hidden ?? true,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tenabled: false,\n\t\t\t\t\t\tcollectionSlug: DEFAULT_SYNC_COLLECTION,\n\t\t\t\t\t\tcron: DEFAULT_SYNC_CRON,\n\t\t\t\t\t\tlookbackDays: DEFAULT_SYNC_LOOKBACK,\n\t\t\t\t\t\thidden: true,\n\t\t\t\t\t}\n\tconst scoped = options.scopeResolver !== undefined\n\treturn {\n\t\tadapters: options.adapters,\n\t\tdefaultAdapter: options.defaultAdapter,\n\t\tscopeResolver: options.scopeResolver ?? (() => null),\n\t\tscoped,\n\t\tscopes: options.scopes,\n\t\treportingTimezone: options.reportingTimezone,\n\t\tplatformAdapter: options.platformAdapter,\n\t\taccess: {\n\t\t\tplatformRead:\n\t\t\t\toptions.access?.platformRead ?? (scoped ? () => false : ({ req }) => Boolean(req.user)),\n\t\t},\n\t\tcapture: {\n\t\t\tslots: {\n\t\t\t\tglobal: options.capture?.slots?.global,\n\t\t\t\ttenant: options.capture?.slots?.tenant,\n\t\t\t},\n\t\t\tpaths: {\n\t\t\t\tglobal: options.capture?.paths?.global,\n\t\t\t\ttenant: options.capture?.paths?.tenant,\n\t\t\t},\n\t\t\tconsent: resolveConsent(options.capture?.consent, options.adapters),\n\t\t\tautoCapture: resolveAutoCapture(options.capture?.autoCapture),\n\t\t\tproxy: {\n\t\t\t\ttimeoutMs: options.capture?.proxy?.timeoutMs ?? DEFAULT_PROXY_TIMEOUT_MS,\n\t\t\t\tmaxBodyBytes: options.capture?.proxy?.maxBodyBytes ?? DEFAULT_PROXY_MAX_BODY_BYTES,\n\t\t\t},\n\t\t},\n\t\tgoals: resolveGoals(options.goals),\n\t\tproviders,\n\t\tbindings: resolveBindings(options.collections),\n\t\tcache: {\n\t\t\t// Left undefined when the app did not set them so the adapter's recommendedTtl\n\t\t\t// applies as the default; an explicit value overrides the adapter recommendation.\n\t\t\tttl: {\n\t\t\t\taggregate: options.cache?.ttl?.aggregate,\n\t\t\t\trealtime: options.cache?.ttl?.realtime,\n\t\t\t},\n\t\t\twarm,\n\t\t\ttimeoutMs: options.cache?.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n\t\t},\n\t\twidgets,\n\t\tsync,\n\t}\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Payload, PayloadRequest } from "payload";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/core/scopeList.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the scopes a cron tier (warm, sync) fans out over: the install-wide
|
|
4
|
+
* null scope first, then each tenant scope from `scopes()`, deduplicated (an
|
|
5
|
+
* empty string folds into null). A throwing or rejecting resolver degrades to
|
|
6
|
+
* the null-only pass so one tenant-enumeration bug does not block the whole run.
|
|
7
|
+
*/
|
|
8
|
+
const resolveScopeList = async (scopes, payload) => {
|
|
9
|
+
if (!scopes) return [null];
|
|
10
|
+
let raw;
|
|
11
|
+
try {
|
|
12
|
+
const result = await scopes({ payload });
|
|
13
|
+
if (!Array.isArray(result)) throw new Error("scopes() must resolve to an array of scope ids");
|
|
14
|
+
raw = result;
|
|
15
|
+
} catch (err) {
|
|
16
|
+
payload.logger.warn(`analytics: scopes() failed, falling back to the install-wide scope: ${String(err)}`);
|
|
17
|
+
return [null];
|
|
18
|
+
}
|
|
19
|
+
const out = [null];
|
|
20
|
+
const seen = new Set([null]);
|
|
21
|
+
for (const value of raw) {
|
|
22
|
+
const scope = value === "" ? null : value;
|
|
23
|
+
if (seen.has(scope)) continue;
|
|
24
|
+
seen.add(scope);
|
|
25
|
+
out.push(scope);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { resolveScopeList };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=scopeList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeList.js","names":[],"sources":["../../src/core/scopeList.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { ScopesResolver } from './options'\n\n/**\n * Resolves the scopes a cron tier (warm, sync) fans out over: the install-wide\n * null scope first, then each tenant scope from `scopes()`, deduplicated (an\n * empty string folds into null). A throwing or rejecting resolver degrades to\n * the null-only pass so one tenant-enumeration bug does not block the whole run.\n */\nexport const resolveScopeList = async (\n\tscopes: ScopesResolver | undefined,\n\tpayload: Payload\n): Promise<Array<string | null>> => {\n\tif (!scopes) {\n\t\treturn [null]\n\t}\n\tlet raw: string[]\n\ttry {\n\t\tconst result = await scopes({ payload })\n\t\tif (!Array.isArray(result)) {\n\t\t\tthrow new Error('scopes() must resolve to an array of scope ids')\n\t\t}\n\t\traw = result\n\t} catch (err) {\n\t\tpayload.logger.warn(\n\t\t\t`analytics: scopes() failed, falling back to the install-wide scope: ${String(err)}`\n\t\t)\n\t\treturn [null]\n\t}\n\tconst out: Array<string | null> = [null]\n\tconst seen = new Set<string | null>([null])\n\tfor (const value of raw) {\n\t\tconst scope = value === '' ? null : value\n\t\tif (seen.has(scope)) {\n\t\t\tcontinue\n\t\t}\n\t\tseen.add(scope)\n\t\tout.push(scope)\n\t}\n\treturn out\n}\n"],"mappings":";;;;;;;AASA,MAAa,mBAAmB,OAC/B,QACA,YACmC;CACnC,IAAI,CAAC,QACJ,OAAO,CAAC,IAAI;CAEb,IAAI;CACJ,IAAI;EACH,MAAM,SAAS,MAAM,OAAO,EAAE,QAAQ,CAAC;EACvC,IAAI,CAAC,MAAM,QAAQ,MAAM,GACxB,MAAM,IAAI,MAAM,gDAAgD;EAEjE,MAAM;CACP,SAAS,KAAK;EACb,QAAQ,OAAO,KACd,uEAAuE,OAAO,GAAG,GAClF;EACA,OAAO,CAAC,IAAI;CACb;CACA,MAAM,MAA4B,CAAC,IAAI;CACvC,MAAM,OAAO,IAAI,IAAmB,CAAC,IAAI,CAAC;CAC1C,KAAK,MAAM,SAAS,KAAK;EACxB,MAAM,QAAQ,UAAU,KAAK,OAAO;EACpC,IAAI,KAAK,IAAI,KAAK,GACjB;EAED,KAAK,IAAI,KAAK;EACd,IAAI,KAAK,KAAK;CACf;CACA,OAAO;AACR"}
|
package/dist/core/scopedRead.js
CHANGED
|
@@ -5,17 +5,24 @@ import "./contract.js";
|
|
|
5
5
|
* Resolve one read's scope and adapter: explicit scope wins over the request's
|
|
6
6
|
* resolved scope, the registry is resolved per scope, then the adapter is picked
|
|
7
7
|
* by id (or the registry default). Cross-scope reads fail closed behind
|
|
8
|
-
* `platformRead`: an explicit `'*'` scope always,
|
|
9
|
-
* shared config adapter that cannot narrow the query to one scope
|
|
10
|
-
* not it is the designated platform adapter
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* `platformRead`: an explicit `'*'` scope always, any scoped read through a
|
|
9
|
+
* shared config adapter that cannot narrow the query to one scope (whether or
|
|
10
|
+
* not it is the designated platform adapter), and, on a scoped install, a
|
|
11
|
+
* request that resolves no scope at all. That last case is ambiguous rather
|
|
12
|
+
* than intentionally install-wide (a tenant's scopeResolver returning null
|
|
13
|
+
* usually means "no tenant selected", not "read everything"), so it fails
|
|
14
|
+
* closed the same way. An explicit `scope: null` override bypasses that gate:
|
|
15
|
+
* it is the trusted server-side caller's path (cron passes, tests), never a
|
|
16
|
+
* request's own resolution. A tenant's own runtime adapters are never gated.
|
|
17
|
+
* Any resolution failure (unknown adapter id, a throwing scopeResolver or
|
|
18
|
+
* provider lookup) degrades to `{ ok: false }` so read paths render their
|
|
19
|
+
* unavailable state instead of throwing.
|
|
14
20
|
*/
|
|
15
21
|
const resolveReadContext = async (args) => {
|
|
16
22
|
const { runtime, req, adapterId } = args;
|
|
17
23
|
try {
|
|
18
24
|
const scope = args.scope !== void 0 ? args.scope : await resolveScopeFor(runtime, req);
|
|
25
|
+
if (runtime.scoped && args.scope === void 0 && scope === null && !await platformReadFor(runtime, req)) return { ok: false };
|
|
19
26
|
const registryScope = scope === "*" ? null : scope;
|
|
20
27
|
const registry = await resolveRegistryFor(runtime, {
|
|
21
28
|
payload: req.payload,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopedRead.js","names":[],"sources":["../../src/core/scopedRead.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport {\n\ttype AnalyticsRuntime,\n\tplatformReadFor,\n\tresolveRegistryFor,\n\tresolveScopeFor,\n} from '../plugin/runtime'\nimport { type AnalyticsAdapter, PLATFORM_SCOPE } from './contract'\n\nexport type ReadContext =\n\t| {\n\t\t\tok: true\n\t\t\tadapter: AnalyticsAdapter\n\t\t\tscope: string | null\n\t\t\t/** The scope to stamp on the adapter query; undefined for install-wide reads. */\n\t\t\tqueryScope?: string\n\t }\n\t| { ok: false }\n\nexport interface ResolveReadContextArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tadapterId?: string\n\t/** Explicit scope override; undefined resolves via the plugin's scopeResolver. */\n\tscope?: string | null\n}\n\n/**\n * Resolve one read's scope and adapter: explicit scope wins over the request's\n * resolved scope, the registry is resolved per scope, then the adapter is picked\n * by id (or the registry default). Cross-scope reads fail closed behind\n * `platformRead`: an explicit `'*'` scope always,
|
|
1
|
+
{"version":3,"file":"scopedRead.js","names":[],"sources":["../../src/core/scopedRead.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport {\n\ttype AnalyticsRuntime,\n\tplatformReadFor,\n\tresolveRegistryFor,\n\tresolveScopeFor,\n} from '../plugin/runtime'\nimport { type AnalyticsAdapter, PLATFORM_SCOPE } from './contract'\n\nexport type ReadContext =\n\t| {\n\t\t\tok: true\n\t\t\tadapter: AnalyticsAdapter\n\t\t\tscope: string | null\n\t\t\t/** The scope to stamp on the adapter query; undefined for install-wide reads. */\n\t\t\tqueryScope?: string\n\t }\n\t| { ok: false }\n\nexport interface ResolveReadContextArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tadapterId?: string\n\t/** Explicit scope override; undefined resolves via the plugin's scopeResolver. */\n\tscope?: string | null\n}\n\n/**\n * Resolve one read's scope and adapter: explicit scope wins over the request's\n * resolved scope, the registry is resolved per scope, then the adapter is picked\n * by id (or the registry default). Cross-scope reads fail closed behind\n * `platformRead`: an explicit `'*'` scope always, any scoped read through a\n * shared config adapter that cannot narrow the query to one scope (whether or\n * not it is the designated platform adapter), and, on a scoped install, a\n * request that resolves no scope at all. That last case is ambiguous rather\n * than intentionally install-wide (a tenant's scopeResolver returning null\n * usually means \"no tenant selected\", not \"read everything\"), so it fails\n * closed the same way. An explicit `scope: null` override bypasses that gate:\n * it is the trusted server-side caller's path (cron passes, tests), never a\n * request's own resolution. A tenant's own runtime adapters are never gated.\n * Any resolution failure (unknown adapter id, a throwing scopeResolver or\n * provider lookup) degrades to `{ ok: false }` so read paths render their\n * unavailable state instead of throwing.\n */\nexport const resolveReadContext = async (args: ResolveReadContextArgs): Promise<ReadContext> => {\n\tconst { runtime, req, adapterId } = args\n\ttry {\n\t\tconst scope = args.scope !== undefined ? args.scope : await resolveScopeFor(runtime, req)\n\t\tif (\n\t\t\truntime.scoped &&\n\t\t\targs.scope === undefined &&\n\t\t\tscope === null &&\n\t\t\t!(await platformReadFor(runtime, req))\n\t\t) {\n\t\t\treturn { ok: false }\n\t\t}\n\t\tconst registryScope = scope === PLATFORM_SCOPE ? null : scope\n\t\tconst registry = await resolveRegistryFor(runtime, {\n\t\t\tpayload: req.payload,\n\t\t\treq,\n\t\t\tscope: registryScope,\n\t\t})\n\t\tconst adapter = adapterId ? registry.get(adapterId) : registry.default()\n\t\tif (scope === PLATFORM_SCOPE) {\n\t\t\tif (!(await platformReadFor(runtime, req))) {\n\t\t\t\treturn { ok: false }\n\t\t\t}\n\t\t\treturn { ok: true, adapter, scope: null, queryScope: undefined }\n\t\t}\n\t\tif (\n\t\t\tscope !== null &&\n\t\t\truntime.configAdapterIds.has(adapter.id) &&\n\t\t\t!adapter.capabilities.scopedQueries\n\t\t) {\n\t\t\tif (!(await platformReadFor(runtime, req))) {\n\t\t\t\treturn { ok: false }\n\t\t\t}\n\t\t\treturn { ok: true, adapter, scope, queryScope: undefined }\n\t\t}\n\t\treturn { ok: true, adapter, scope, queryScope: scope ?? undefined }\n\t} catch (err) {\n\t\treq.payload.logger?.warn(`analytics: read context resolution failed: ${String(err)}`)\n\t\treturn { ok: false }\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,qBAAqB,OAAO,SAAuD;CAC/F,MAAM,EAAE,SAAS,KAAK,cAAc;CACpC,IAAI;EACH,MAAM,QAAQ,KAAK,UAAU,KAAA,IAAY,KAAK,QAAQ,MAAM,gBAAgB,SAAS,GAAG;EACxF,IACC,QAAQ,UACR,KAAK,UAAU,KAAA,KACf,UAAU,QACV,CAAE,MAAM,gBAAgB,SAAS,GAAG,GAEpC,OAAO,EAAE,IAAI,MAAM;EAEpB,MAAM,gBAAgB,UAAA,MAA2B,OAAO;EACxD,MAAM,WAAW,MAAM,mBAAmB,SAAS;GAClD,SAAS,IAAI;GACb;GACA,OAAO;EACR,CAAC;EACD,MAAM,UAAU,YAAY,SAAS,IAAI,SAAS,IAAI,SAAS,QAAQ;EACvE,IAAI,UAAA,KAA0B;GAC7B,IAAI,CAAE,MAAM,gBAAgB,SAAS,GAAG,GACvC,OAAO,EAAE,IAAI,MAAM;GAEpB,OAAO;IAAE,IAAI;IAAM;IAAS,OAAO;IAAM,YAAY,KAAA;GAAU;EAChE;EACA,IACC,UAAU,QACV,QAAQ,iBAAiB,IAAI,QAAQ,EAAE,KACvC,CAAC,QAAQ,aAAa,eACrB;GACD,IAAI,CAAE,MAAM,gBAAgB,SAAS,GAAG,GACvC,OAAO,EAAE,IAAI,MAAM;GAEpB,OAAO;IAAE,IAAI;IAAM;IAAS;IAAO,YAAY,KAAA;GAAU;EAC1D;EACA,OAAO;GAAE,IAAI;GAAM;GAAS;GAAO,YAAY,SAAS,KAAA;EAAU;CACnE,SAAS,KAAK;EACb,IAAI,QAAQ,QAAQ,KAAK,8CAA8C,OAAO,GAAG,GAAG;EACpF,OAAO,EAAE,IAAI,MAAM;CACpB;AACD"}
|
package/dist/exports/next.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { CaptureRewrite, CaptureRewriteMount, captureRewrites } from "../next/captureRewrites.js";
|
|
1
2
|
import { PosthogProxyRegion, PosthogProxyRewrite, PosthogProxyRewritesOptions, posthogProxyRewrites } from "../next/posthogProxyRewrites.js";
|
|
2
|
-
export { type PosthogProxyRegion, type PosthogProxyRewrite, type PosthogProxyRewritesOptions, posthogProxyRewrites };
|
|
3
|
+
export { type CaptureRewrite, type CaptureRewriteMount, type PosthogProxyRegion, type PosthogProxyRewrite, type PosthogProxyRewritesOptions, captureRewrites, posthogProxyRewrites };
|
package/dist/exports/next.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AnalyticsApi, AnalyticsProvider, AnalyticsProviderProps } from "../react/AnalyticsProvider.js";
|
|
2
|
+
import { TrackerBoot, TrackerBootProps } from "../react/TrackerBoot.js";
|
|
3
|
+
import { useAnalytics } from "../react/useAnalytics.js";
|
|
4
|
+
export { type AnalyticsApi, AnalyticsProvider, type AnalyticsProviderProps, TrackerBoot, type TrackerBootProps, useAnalytics };
|
package/dist/exports/rsc.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { AnalyticsFilter, DateRange, DimensionKey, MetricKey } from "../core/contract.js";
|
|
2
2
|
import { CapabilityRequirement } from "../core/capabilities.js";
|
|
3
3
|
import { ReadForWidgetRealtimeArgs, RealtimePoint, WidgetRealtimeResult, WidgetRealtimeStatus, readForWidgetRealtime } from "../widgets/readForWidgetRealtime.js";
|
|
4
|
+
import { TrackerConfig, TrackerSlotConfig } from "../capture/trackerConfig.js";
|
|
5
|
+
import { getTrackerConfig } from "../capture/getTrackerConfig.js";
|
|
4
6
|
import { AnalyticsStatField } from "../fields/AnalyticsStatField.js";
|
|
5
7
|
import { AnalyticsPanelField } from "../fields/AnalyticsPanelField.js";
|
|
6
8
|
import { formatMetricValue } from "../fields/format.js";
|
|
7
9
|
import { ReadForWidgetArgs, WidgetReadResult, WidgetReadStatus, readForWidget } from "../widgets/readForWidget.js";
|
|
8
10
|
import { ReadForWidgetSeriesArgs, SeriesPoint, WidgetSeriesResult, readForWidgetSeries } from "../widgets/readForWidgetSeries.js";
|
|
9
11
|
import { FieldReadResult, FieldReadStatus, ReadForFieldArgs, readForField } from "../fields/readForDocument.js";
|
|
12
|
+
import { AnalyticsScripts, AnalyticsScriptsProps } from "../rsc/AnalyticsScripts.js";
|
|
10
13
|
import { AnalyticsBreakdownWidget } from "../widgets/AnalyticsBreakdownWidget.js";
|
|
11
14
|
import { AnalyticsMetricWidget } from "../widgets/AnalyticsMetricWidget.js";
|
|
12
15
|
import { AnalyticsRealtimeWidget } from "../widgets/AnalyticsRealtimeWidget.js";
|
|
13
16
|
import { AnalyticsTrendWidget } from "../widgets/AnalyticsTrendWidget.js";
|
|
14
17
|
import { cardStyle, labelStyle } from "../widgets/cardChrome.js";
|
|
15
18
|
import { BreakdownRow, ReadForWidgetBreakdownArgs, WidgetBreakdownResult, readForWidgetBreakdown } from "../widgets/readForWidgetBreakdown.js";
|
|
16
|
-
export { AnalyticsBreakdownWidget, type AnalyticsFilter, AnalyticsMetricWidget, AnalyticsPanelField, AnalyticsRealtimeWidget, AnalyticsStatField, AnalyticsTrendWidget, type BreakdownRow, type CapabilityRequirement, type DateRange, type DimensionKey, type FieldReadResult, type FieldReadStatus, type MetricKey, type ReadForFieldArgs, type ReadForWidgetArgs, type ReadForWidgetBreakdownArgs, type ReadForWidgetRealtimeArgs, type ReadForWidgetSeriesArgs, type RealtimePoint, type SeriesPoint, type WidgetBreakdownResult, type WidgetReadResult, type WidgetReadStatus, type WidgetRealtimeResult, type WidgetRealtimeStatus, type WidgetSeriesResult, formatMetricValue, readForField, readForWidget, readForWidgetBreakdown, readForWidgetRealtime, readForWidgetSeries, cardStyle as widgetCardStyle, labelStyle as widgetLabelStyle };
|
|
19
|
+
export { AnalyticsBreakdownWidget, type AnalyticsFilter, AnalyticsMetricWidget, AnalyticsPanelField, AnalyticsRealtimeWidget, AnalyticsScripts, type AnalyticsScriptsProps, AnalyticsStatField, AnalyticsTrendWidget, type BreakdownRow, type CapabilityRequirement, type DateRange, type DimensionKey, type FieldReadResult, type FieldReadStatus, type MetricKey, type ReadForFieldArgs, type ReadForWidgetArgs, type ReadForWidgetBreakdownArgs, type ReadForWidgetRealtimeArgs, type ReadForWidgetSeriesArgs, type RealtimePoint, type SeriesPoint, type TrackerConfig, type TrackerSlotConfig, type WidgetBreakdownResult, type WidgetReadResult, type WidgetReadStatus, type WidgetRealtimeResult, type WidgetRealtimeStatus, type WidgetSeriesResult, formatMetricValue, getTrackerConfig, readForField, readForWidget, readForWidgetBreakdown, readForWidgetRealtime, readForWidgetSeries, cardStyle as widgetCardStyle, labelStyle as widgetLabelStyle };
|
package/dist/exports/rsc.js
CHANGED
|
@@ -3,12 +3,14 @@ import { readForField } from "../fields/readForDocument.js";
|
|
|
3
3
|
import { readForWidgetRealtime } from "../widgets/readForWidgetRealtime.js";
|
|
4
4
|
import { readForWidget } from "../widgets/readForWidget.js";
|
|
5
5
|
import { readForWidgetBreakdown } from "../widgets/readForWidgetBreakdown.js";
|
|
6
|
+
import { getTrackerConfig } from "../capture/getTrackerConfig.js";
|
|
6
7
|
import { formatMetricValue } from "../fields/format.js";
|
|
7
8
|
import { AnalyticsStatField } from "../fields/AnalyticsStatField.js";
|
|
8
9
|
import { AnalyticsPanelField } from "../fields/AnalyticsPanelField.js";
|
|
10
|
+
import { AnalyticsScripts } from "../rsc/AnalyticsScripts.js";
|
|
9
11
|
import { cardStyle, labelStyle } from "../widgets/cardChrome.js";
|
|
10
12
|
import AnalyticsBreakdownWidget from "../widgets/AnalyticsBreakdownWidget.js";
|
|
11
13
|
import AnalyticsMetricWidget from "../widgets/AnalyticsMetricWidget.js";
|
|
12
14
|
import AnalyticsRealtimeWidget from "../widgets/AnalyticsRealtimeWidget.js";
|
|
13
15
|
import AnalyticsTrendWidget from "../widgets/AnalyticsTrendWidget.js";
|
|
14
|
-
export { AnalyticsBreakdownWidget, AnalyticsMetricWidget, AnalyticsPanelField, AnalyticsRealtimeWidget, AnalyticsStatField, AnalyticsTrendWidget, formatMetricValue, readForField, readForWidget, readForWidgetBreakdown, readForWidgetRealtime, readForWidgetSeries, cardStyle as widgetCardStyle, labelStyle as widgetLabelStyle };
|
|
16
|
+
export { AnalyticsBreakdownWidget, AnalyticsMetricWidget, AnalyticsPanelField, AnalyticsRealtimeWidget, AnalyticsScripts, AnalyticsStatField, AnalyticsTrendWidget, formatMetricValue, getTrackerConfig, readForField, readForWidget, readForWidgetBreakdown, readForWidgetRealtime, readForWidgetSeries, cardStyle as widgetCardStyle, labelStyle as widgetLabelStyle };
|