@10x-media/analytics 1.0.0-beta.15 → 1.0.0-beta.17
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 +56 -0
- package/README.md +1 -1
- package/dist/adapters/ga4/ga4.js +33 -2
- package/dist/adapters/ga4/ga4.js.map +1 -1
- package/dist/adapters/ga4/measurementId.js +4 -1
- package/dist/adapters/ga4/measurementId.js.map +1 -1
- package/dist/adapters/ga4/propertyId.js +17 -0
- package/dist/adapters/ga4/propertyId.js.map +1 -0
- package/dist/adapters/http/fetchJson.js +24 -1
- package/dist/adapters/http/fetchJson.js.map +1 -1
- package/dist/adapters/plausible/plausible.js +16 -1
- package/dist/adapters/plausible/plausible.js.map +1 -1
- package/dist/adapters/plausible/siteId.js +31 -0
- package/dist/adapters/plausible/siteId.js.map +1 -0
- package/dist/adapters/posthog/cloud.js +20 -0
- package/dist/adapters/posthog/cloud.js.map +1 -0
- package/dist/adapters/posthog/credentials.js +20 -0
- package/dist/adapters/posthog/credentials.js.map +1 -0
- package/dist/adapters/posthog/posthog.d.ts +3 -3
- package/dist/adapters/posthog/posthog.js +24 -10
- package/dist/adapters/posthog/posthog.js.map +1 -1
- package/dist/adapters/umami/umami.js +34 -7
- package/dist/adapters/umami/umami.js.map +1 -1
- package/dist/charts/series.js +1 -1
- package/dist/core/contract.d.ts +16 -1
- package/dist/core/contract.js.map +1 -1
- package/dist/core/options.d.ts +1 -1
- package/dist/core/options.js +1 -1
- package/dist/core/options.js.map +1 -1
- package/dist/core/scopedRead.js +62 -14
- package/dist/core/scopedRead.js.map +1 -1
- package/dist/core/sourceErrors.js +12 -1
- package/dist/core/sourceErrors.js.map +1 -1
- package/dist/core/sourceOptions.js +1 -1
- package/dist/core/sourceOptions.js.map +1 -1
- package/dist/core/sourcePolicy.d.ts +8 -1
- package/dist/core/sourcePolicy.js.map +1 -1
- package/dist/core/throttle.js +3 -1
- package/dist/core/throttle.js.map +1 -1
- package/dist/exports/adapters/contract.d.ts +1 -1
- package/dist/exports/adapters/ga4.d.ts +2 -2
- package/dist/exports/adapters/native.d.ts +2 -2
- package/dist/exports/adapters/plausible.d.ts +2 -2
- package/dist/exports/adapters/posthog.d.ts +2 -2
- package/dist/exports/adapters/umami.d.ts +2 -2
- package/dist/exports/client.d.ts +3 -1
- package/dist/exports/client.js +3 -1
- package/dist/exports/next.d.ts +2 -2
- package/dist/exports/testing.d.ts +2 -2
- package/dist/exports/types.d.ts +3 -3
- package/dist/fields/config/fetchSources.js +1 -1
- package/dist/fields/config/fetchSources.js.map +1 -1
- package/dist/goals/collection.js +3 -2
- package/dist/goals/collection.js.map +1 -1
- package/dist/goals/resolver.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +50 -4
- package/dist/index.js.map +1 -1
- package/dist/native/geo/maxmindResolver.js +1 -1
- package/dist/native/nativeAdapter.js +1 -1
- package/dist/plugin/createRuntime.js +57 -13
- package/dist/plugin/createRuntime.js.map +1 -1
- package/dist/plugin/pluginCollections.js +4 -1
- package/dist/plugin/pluginCollections.js.map +1 -1
- package/dist/plugin/providerStatusEndpoint.js +80 -0
- package/dist/plugin/providerStatusEndpoint.js.map +1 -0
- package/dist/plugin/queryEndpoint.js +1 -1
- package/dist/plugin/queryEndpoint.js.map +1 -1
- package/dist/plugin/readContextForRequest.d.ts +4 -3
- package/dist/plugin/readContextForRequest.js +2 -2
- package/dist/plugin/readContextForRequest.js.map +1 -1
- package/dist/plugin/refreshEndpoint.js +1 -1
- package/dist/plugin/routes.d.ts +5 -0
- package/dist/plugin/routes.js +1 -0
- package/dist/plugin/routes.js.map +1 -1
- package/dist/plugin/runtime.js.map +1 -1
- package/dist/providers/ProviderConnection.d.ts +12 -0
- package/dist/providers/ProviderConnection.js +105 -0
- package/dist/providers/ProviderConnection.js.map +1 -0
- package/dist/providers/ProviderConnectionTest.d.ts +12 -0
- package/dist/providers/ProviderConnectionTest.js +55 -0
- package/dist/providers/ProviderConnectionTest.js.map +1 -0
- package/dist/providers/ProvidersListNotice.d.ts +1 -1
- package/dist/providers/ProvidersListNotice.js +3 -2
- package/dist/providers/ProvidersListNotice.js.map +1 -1
- package/dist/providers/collection.d.ts +1 -1
- package/dist/providers/collection.js +106 -41
- package/dist/providers/collection.js.map +1 -1
- package/dist/providers/connectionCheck.d.ts +1 -0
- package/dist/providers/connectionCheck.js +80 -0
- package/dist/providers/connectionCheck.js.map +1 -0
- package/dist/providers/connectionState.js +53 -0
- package/dist/providers/connectionState.js.map +1 -0
- package/dist/providers/factory.d.ts +1 -3
- package/dist/providers/factory.js +18 -21
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/hosts.js +31 -9
- package/dist/providers/hosts.js.map +1 -1
- package/dist/providers/ids.d.ts +6 -0
- package/dist/providers/ids.js +32 -0
- package/dist/providers/ids.js.map +1 -0
- package/dist/providers/providerStatusClient.js +60 -0
- package/dist/providers/providerStatusClient.js.map +1 -0
- package/dist/providers/registry.js +56 -20
- package/dist/providers/registry.js.map +1 -1
- package/dist/providers/retarget.js +39 -8
- package/dist/providers/retarget.js.map +1 -1
- package/dist/providers/secrets.d.ts +1 -1
- package/dist/providers/secrets.js.map +1 -1
- package/dist/providers/status.d.ts +1 -0
- package/dist/providers/status.js +181 -0
- package/dist/providers/status.js.map +1 -0
- package/dist/surfacing/classifyError.js +37 -5
- package/dist/surfacing/classifyError.js.map +1 -1
- package/dist/surfacing/engine.js +2 -2
- package/dist/surfacing/engine.js.map +1 -1
- package/dist/surfacing/lanes.js +29 -22
- package/dist/surfacing/lanes.js.map +1 -1
- package/dist/surfacing/rebucket.js +1 -1
- package/dist/testing/settle.d.ts +2 -1
- package/dist/testing/settle.js +6 -2
- package/dist/testing/settle.js.map +1 -1
- package/dist/tracker/sinks/ga4.js +2 -2
- package/dist/translations/ar.js +43 -8
- package/dist/translations/ar.js.map +1 -1
- package/dist/translations/de.js +43 -8
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +43 -8
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +43 -8
- package/dist/translations/es.js.map +1 -1
- package/dist/translations/fr.js +43 -8
- package/dist/translations/fr.js.map +1 -1
- package/dist/translations/id.js +43 -8
- package/dist/translations/id.js.map +1 -1
- package/dist/translations/keys.d.ts +35 -0
- package/dist/translations/keys.js +35 -0
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +43 -8
- package/dist/translations/ko.js.map +1 -1
- package/dist/translations/pt.js +43 -8
- package/dist/translations/pt.js.map +1 -1
- package/dist/translations/ru.js +43 -8
- package/dist/translations/ru.js.map +1 -1
- package/dist/translations/uk.js +43 -8
- package/dist/translations/uk.js.map +1 -1
- package/dist/translations/zh.js +43 -8
- package/dist/translations/zh.js.map +1 -1
- package/dist/ui/analytics.css +63 -0
- package/dist/ui/components/SourcesNoticeBanner.js +4 -3
- package/dist/ui/components/SourcesNoticeBanner.js.map +1 -1
- package/dist/view/ViewSections.js +9 -2
- package/dist/view/ViewSections.js.map +1 -1
- package/dist/view/sections/EmptyStates.js +5 -4
- package/dist/view/sections/EmptyStates.js.map +1 -1
- package/dist/view/sections/OverviewCards.js +6 -2
- package/dist/view/sections/OverviewCards.js.map +1 -1
- package/dist/view/sections/SourceConnectionNote.js +56 -0
- package/dist/view/sections/SourceConnectionNote.js.map +1 -0
- package/dist/view/viewProps.d.ts +2 -0
- package/dist/view/viewProps.js +2 -1
- package/dist/view/viewProps.js.map +1 -1
- package/package.json +5 -5
package/dist/exports/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { HitMode, HitType } from "../native/store/types.js";
|
|
|
13
13
|
import { GOAL_ACTION_TYPE } from "../goals/constants.js";
|
|
14
14
|
import { RawEventInput } from "../native/ingest/normalizeEvent.js";
|
|
15
15
|
import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../core/serverEvent.js";
|
|
16
|
-
import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsAdapterFactory, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, PLATFORM_SCOPE, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
|
|
16
|
+
import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsAdapterFactory, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, PLATFORM_SCOPE, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
|
|
17
17
|
import { AnalyticsSourceOptions, DefaultSourceFunction, DefaultSourceRule, OwnSource, SourcePolicy, SourcePolicyFunction, SourceRef } from "../core/sourcePolicy.js";
|
|
18
18
|
import { AdapterLabelOption } from "../core/sourceLabel.js";
|
|
19
19
|
import { CapabilityRequirement, FilterPair, SerializedCapabilities } from "../core/capabilities.js";
|
|
@@ -26,7 +26,7 @@ import { PluralCategory, PluralName, PluralVariant, SingularKey, TranslationKey,
|
|
|
26
26
|
import { TranslationsOption } from "../translations/index.js";
|
|
27
27
|
import { GoalCollectionFieldOverrides, GoalFieldOverride } from "../goals/collection.js";
|
|
28
28
|
import { HostPattern, ProviderHostPolicy } from "../providers/hosts.js";
|
|
29
|
-
import { ProviderId } from "../providers/
|
|
29
|
+
import { ProviderId } from "../providers/ids.js";
|
|
30
30
|
import { ConnectionAccess, ConnectionFieldAccess, ProviderCollectionFieldOverrides, ProviderFieldOverride } from "../providers/collection.js";
|
|
31
31
|
import { AfterReadAnswer, AfterReadArgs, AfterReadHook, ReadOrigin } from "../surfacing/afterRead.js";
|
|
32
32
|
import { TIMEFRAME_PRESETS, TimeframePreset } from "../timeframe/presets.js";
|
|
@@ -47,4 +47,4 @@ import { GoalActionDefinition, GoalActionRunArgs, TrackGoalActionOptions } from
|
|
|
47
47
|
import { TRAFFIC_CHANNELS, TrafficChannel } from "../native/ingest/source.js";
|
|
48
48
|
import { ParseResult, ParsedQuery } from "../query/parse.js";
|
|
49
49
|
import { ExclusionResponse, ExclusionSite } from "../view/exclusionLink.js";
|
|
50
|
-
export { ANALYTICS_ERROR_CODES, AdapterContext, type AdapterJobs, AdapterLabelArgs, type AdapterLabelOption, AdapterRegisterContext, AdapterSchemaContext, type AdminDigest, type AfterReadAnswer, type AfterReadArgs, type AfterReadHook, type AnalyticsAccessOptions, AnalyticsAdapter, AnalyticsAdapterFactory, type AnalyticsBinding, type AnalyticsCacheCollectionOptions, type AnalyticsCacheOptions, AnalyticsCapabilities, type AnalyticsCaptureOptions, type AnalyticsCollectionOptions, type AnalyticsComponent, type AnalyticsConcurrencyOptions, type AnalyticsCountryFlags, type AnalyticsCrossScopeOptions, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsExclusionOptions, type AnalyticsFieldsOptions, AnalyticsFilter, type AnalyticsGoalsCollectionOptions, type AnalyticsGoalsOptions, type AnalyticsHooksOptions, type AnalyticsJobsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, AnalyticsQuery, type AnalyticsReadAccess, AnalyticsResult, type AnalyticsRevenueOptions, type AnalyticsRoutesOptions, AnalyticsRow, type AnalyticsScopeOptions, type AnalyticsSdks, type AnalyticsSourceOptions, type AnalyticsStatBaseOptions, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsSyncCollectionOptions, type AnalyticsSyncOptions, type AnalyticsTabOptions, type AnalyticsTaskName, type AnalyticsTaskOptions, type AnalyticsViewAccess, type AnalyticsViewClientProps, type AnalyticsViewOptions, type AnalyticsWarmOptions, type AnalyticsWidgetOverride, type AnalyticsWidgetOverrides, type AnalyticsWidgetsOptions, type AutoCaptureOptions, BUILT_IN_WIDGET_SLUGS, type BindingContext, type BindingDoc, type BrowserAmounts, type BuiltInWidgetSlug, type CacheEntry, type CacheSetOptions, type CacheStore, type CapabilityRequirement, type CaptureClientKind, type CaptureGate, type CaptureGateArgs, type CaptureSlot, type CaptureSlotOption, type CaptureSnippet, CaptureSupport, type CollectionFieldOverride, type CollectionOverrides, type ConnectionAccess, type ConnectionFieldAccess, type ConsentPhase, CookielessSupport, type CountryFlagProps, type CountryFlags, type CrossScopeAccess, type CurrencyConverter, type CurrencyResolver, type CustomWidgetDef, DIMENSION_KEYS, DateRange, type DefaultSourceFunction, type DefaultSourceRule, DimensionKey, type ExclusionResponse, type ExclusionSite, type ExclusionSitesResolver, FILTER_OPERATORS, type FetchInit, type FetchLike, type FetchQueryInit, FilterOperator, FilterOperatorMap, type FilterPair, GOAL_ACTION_TYPE, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalActionDefinition, type GoalActionRunArgs, type GoalCollectionFieldOverrides, type GoalFieldOptions, type GoalFieldOverride, type GoalMatch, Granularity, type HeldSlotMode, type HitMode, type HitType, type HostCountryFlag, type HostPattern, type HostnameResolver, type IngestHostnameResolver, type ItemCaptureOptions, type ItemLabels, type MaxmindReader, type MaxmindSdk, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, type OrderSignatureMode, type OwnSource, PLATFORM_SCOPE, type ParseResult, type ParsedQuery, type PathResolver, type PluralCategory, type PluralName, type PluralVariant, type ProviderCollectionFieldOverrides, type ProviderFieldOverride, type ProviderHostPolicy, type ProviderHostsOptions, type ProviderId, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type ProvidersResolveArgs, ProxyDescriptor, ProxyRoute, ProxyRouteKind, type QueryError, type QueryErrorCode, type QueryErrorResponse, type QueryRequest, type QueryResponse, type QuerySourceRef, RateLimitDescriptor, type RawEventInput, type ReadOrigin, type ReadRecipe, type RecipeWindow, type RefreshRequest, type RefreshResponse, type ReportMode, type ReportOption, type ResolvedAutoCapture, type ResolvedItemCapture, type RouteBase, type RoutePaths, type ScheduledTask, type ScopeCallSite, type ScopeLabelResolver, type ScopeListResolver, type ScopeMemberAccess, type ScopeResolver, type SerializedAnalyticsQuery, type SerializedCapabilities, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SingularKey, type SlotMode, type SlotWithoutConsent, SnippetArgs, SnippetMode, type SnippetScript, SourceErrorKind, type SourcePolicy, type SourcePolicyFunction, type SourceRef, type SourcesNotice, type SourcesResponse, type TASK_NAMES, TIMEFRAME_PRESETS, TRAFFIC_CHANNELS, type TimeframePreset, type TimezoneResolver, type TrackGoalActionOptions, type TrackerConfig, type TrackerExclusion, type TrackerGoal, type TrackerSkip, type TrackerSlotConfig, type TrafficChannel, type TranslationKey, type TranslationsOption, type TrustedPlatform, type ViewEndpoints, type ViewGoal, type ViewScopes, VisitorCounting, type WidgetView, type WidgetViewProps, type WireSource, type WithoutConsentArgs, type WithoutConsentFunction, type WithoutConsentLevel, type WithoutConsentOption, keys, pluralKeys, readErrorCode };
|
|
50
|
+
export { ANALYTICS_ERROR_CODES, AdapterContext, type AdapterJobs, AdapterLabelArgs, type AdapterLabelOption, AdapterRegisterContext, AdapterSchemaContext, type AdminDigest, type AfterReadAnswer, type AfterReadArgs, type AfterReadHook, type AnalyticsAccessOptions, AnalyticsAdapter, AnalyticsAdapterFactory, type AnalyticsBinding, type AnalyticsCacheCollectionOptions, type AnalyticsCacheOptions, AnalyticsCapabilities, type AnalyticsCaptureOptions, type AnalyticsCollectionOptions, type AnalyticsComponent, type AnalyticsConcurrencyOptions, type AnalyticsCountryFlags, type AnalyticsCrossScopeOptions, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsExclusionOptions, type AnalyticsFieldsOptions, AnalyticsFilter, type AnalyticsGoalsCollectionOptions, type AnalyticsGoalsOptions, type AnalyticsHooksOptions, type AnalyticsJobsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, AnalyticsQuery, type AnalyticsReadAccess, AnalyticsResult, type AnalyticsRevenueOptions, type AnalyticsRoutesOptions, AnalyticsRow, type AnalyticsScopeOptions, type AnalyticsSdks, type AnalyticsSourceOptions, type AnalyticsStatBaseOptions, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsSyncCollectionOptions, type AnalyticsSyncOptions, type AnalyticsTabOptions, type AnalyticsTaskName, type AnalyticsTaskOptions, type AnalyticsViewAccess, type AnalyticsViewClientProps, type AnalyticsViewOptions, type AnalyticsWarmOptions, type AnalyticsWidgetOverride, type AnalyticsWidgetOverrides, type AnalyticsWidgetsOptions, type AutoCaptureOptions, BUILT_IN_WIDGET_SLUGS, type BindingContext, type BindingDoc, type BrowserAmounts, type BuiltInWidgetSlug, type CacheEntry, type CacheSetOptions, type CacheStore, type CapabilityRequirement, type CaptureClientKind, type CaptureGate, type CaptureGateArgs, type CaptureSlot, type CaptureSlotOption, type CaptureSnippet, CaptureSupport, type CollectionFieldOverride, type CollectionOverrides, type ConnectionAccess, ConnectionCheckContext, type ConnectionFieldAccess, type ConsentPhase, CookielessSupport, type CountryFlagProps, type CountryFlags, type CrossScopeAccess, type CurrencyConverter, type CurrencyResolver, type CustomWidgetDef, DIMENSION_KEYS, DateRange, type DefaultSourceFunction, type DefaultSourceRule, DimensionKey, type ExclusionResponse, type ExclusionSite, type ExclusionSitesResolver, FILTER_OPERATORS, type FetchInit, type FetchLike, type FetchQueryInit, FilterOperator, FilterOperatorMap, type FilterPair, GOAL_ACTION_TYPE, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalActionDefinition, type GoalActionRunArgs, type GoalCollectionFieldOverrides, type GoalFieldOptions, type GoalFieldOverride, type GoalMatch, Granularity, type HeldSlotMode, type HitMode, type HitType, type HostCountryFlag, type HostPattern, type HostnameResolver, type IngestHostnameResolver, type ItemCaptureOptions, type ItemLabels, type MaxmindReader, type MaxmindSdk, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, type OrderSignatureMode, type OwnSource, PLATFORM_SCOPE, type ParseResult, type ParsedQuery, type PathResolver, type PluralCategory, type PluralName, type PluralVariant, type ProviderCollectionFieldOverrides, type ProviderFieldOverride, type ProviderHostPolicy, type ProviderHostsOptions, type ProviderId, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type ProvidersResolveArgs, ProxyDescriptor, ProxyRoute, ProxyRouteKind, type QueryError, type QueryErrorCode, type QueryErrorResponse, type QueryRequest, type QueryResponse, type QuerySourceRef, RateLimitDescriptor, type RawEventInput, type ReadOrigin, type ReadRecipe, type RecipeWindow, type RefreshRequest, type RefreshResponse, type ReportMode, type ReportOption, type ResolvedAutoCapture, type ResolvedItemCapture, type RouteBase, type RoutePaths, type ScheduledTask, type ScopeCallSite, type ScopeLabelResolver, type ScopeListResolver, type ScopeMemberAccess, type ScopeResolver, type SerializedAnalyticsQuery, type SerializedCapabilities, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SingularKey, type SlotMode, type SlotWithoutConsent, SnippetArgs, SnippetMode, type SnippetScript, SourceErrorKind, type SourcePolicy, type SourcePolicyFunction, type SourceRef, type SourcesNotice, type SourcesResponse, type TASK_NAMES, TIMEFRAME_PRESETS, TRAFFIC_CHANNELS, type TimeframePreset, type TimezoneResolver, type TrackGoalActionOptions, type TrackerConfig, type TrackerExclusion, type TrackerGoal, type TrackerSkip, type TrackerSlotConfig, type TrafficChannel, type TranslationKey, type TranslationsOption, type TrustedPlatform, type ViewEndpoints, type ViewGoal, type ViewScopes, VisitorCounting, type WidgetView, type WidgetViewProps, type WireSource, type WithoutConsentArgs, type WithoutConsentFunction, type WithoutConsentLevel, type WithoutConsentOption, keys, pluralKeys, readErrorCode };
|
|
@@ -5,7 +5,7 @@ import { requestShaped } from "../../ui/data/request.js";
|
|
|
5
5
|
const isStringList = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
6
6
|
/** The parts of a source the pickers read: who it is and the lists its capabilities gate on. */
|
|
7
7
|
const isWireSource = (value) => isRecord(value) && typeof value.id === "string" && typeof value.label === "string" && (value.kind === "config" || value.kind === "runtime") && isRecord(value.capabilities) && isStringList(value.capabilities.metrics) && isStringList(value.capabilities.dimensions) && isRecord(value.capabilities.filters);
|
|
8
|
-
const isSourcesResponse = (value) => isRecord(value) && (value.defaultId === null || typeof value.defaultId === "string") && (value.notice === void 0 || value.notice === "platformFallback") && Array.isArray(value.sources) && value.sources.every(isWireSource);
|
|
8
|
+
const isSourcesResponse = (value) => isRecord(value) && (value.defaultId === null || typeof value.defaultId === "string") && (value.notice === void 0 || value.notice === "platformFallback" || value.notice === "ownSourceFailing") && Array.isArray(value.sources) && value.sources.every(isWireSource);
|
|
9
9
|
/** The listing read fresh, past the shared cache, for a surface that must not show a stale one. */
|
|
10
10
|
const requestSources = (url, signal) => requestShaped(url, isSourcesResponse, { signal });
|
|
11
11
|
const cache = createSharedCache();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSources.js","names":[],"sources":["../../../src/fields/config/fetchSources.ts"],"sourcesContent":["import type { SerializedCapabilities } from '../../core/capabilities'\nimport { isRecord } from '../../core/values'\nimport type { SourcesNotice } from '../../plugin/readContextForRequest'\nimport { requestShaped } from '../../ui/data/request'\nimport { createSharedCache } from '../../ui/data/sharedCache'\n\nexport interface WireSource {\n\tid: string\n\tlabel: string\n\tkind: 'config' | 'runtime'\n\tcapabilities: SerializedCapabilities\n}\n\nexport type { SourcesNotice }\n\nexport interface SourcesResponse {\n\tdefaultId: string | null\n\tsources: WireSource[]\n\t/** What the reader should be told about the listing itself; absent, nothing. */\n\tnotice?: SourcesNotice\n}\n\nconst isStringList = (value: unknown): value is string[] =>\n\tArray.isArray(value) && value.every((entry) => typeof entry === 'string')\n\n/** The parts of a source the pickers read: who it is and the lists its capabilities gate on. */\nconst isWireSource = (value: unknown): value is WireSource =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\ttypeof value.label === 'string' &&\n\t(value.kind === 'config' || value.kind === 'runtime') &&\n\tisRecord(value.capabilities) &&\n\tisStringList(value.capabilities.metrics) &&\n\tisStringList(value.capabilities.dimensions) &&\n\tisRecord(value.capabilities.filters)\n\nconst isSourcesResponse = (value: unknown): value is SourcesResponse =>\n\tisRecord(value) &&\n\t(value.defaultId === null || typeof value.defaultId === 'string') &&\n\t(value.notice === undefined
|
|
1
|
+
{"version":3,"file":"fetchSources.js","names":[],"sources":["../../../src/fields/config/fetchSources.ts"],"sourcesContent":["import type { SerializedCapabilities } from '../../core/capabilities'\nimport { isRecord } from '../../core/values'\nimport type { SourcesNotice } from '../../plugin/readContextForRequest'\nimport { requestShaped } from '../../ui/data/request'\nimport { createSharedCache } from '../../ui/data/sharedCache'\n\nexport interface WireSource {\n\tid: string\n\tlabel: string\n\tkind: 'config' | 'runtime'\n\tcapabilities: SerializedCapabilities\n}\n\nexport type { SourcesNotice }\n\nexport interface SourcesResponse {\n\tdefaultId: string | null\n\tsources: WireSource[]\n\t/** What the reader should be told about the listing itself; absent, nothing. */\n\tnotice?: SourcesNotice\n}\n\nconst isStringList = (value: unknown): value is string[] =>\n\tArray.isArray(value) && value.every((entry) => typeof entry === 'string')\n\n/** The parts of a source the pickers read: who it is and the lists its capabilities gate on. */\nconst isWireSource = (value: unknown): value is WireSource =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\ttypeof value.label === 'string' &&\n\t(value.kind === 'config' || value.kind === 'runtime') &&\n\tisRecord(value.capabilities) &&\n\tisStringList(value.capabilities.metrics) &&\n\tisStringList(value.capabilities.dimensions) &&\n\tisRecord(value.capabilities.filters)\n\nconst isSourcesResponse = (value: unknown): value is SourcesResponse =>\n\tisRecord(value) &&\n\t(value.defaultId === null || typeof value.defaultId === 'string') &&\n\t(value.notice === undefined ||\n\t\tvalue.notice === 'platformFallback' ||\n\t\tvalue.notice === 'ownSourceFailing') &&\n\tArray.isArray(value.sources) &&\n\tvalue.sources.every(isWireSource)\n\n/** The listing read fresh, past the shared cache, for a surface that must not show a stale one. */\nexport const requestSources = (url: string, signal?: AbortSignal): Promise<SourcesResponse> =>\n\trequestShaped(url, isSourcesResponse, { signal })\n\nconst cache = createSharedCache<SourcesResponse>()\n\n/**\n * Source list shared by every picker on the page, keyed by scope so a login or tenant switch reads\n * again. A refusal or misshapen answer rejects and drops the entry, so a later mount retries.\n */\nexport const fetchSources = (url: string, scope: string): Promise<SourcesResponse> =>\n\tcache.read({ route: url, scope }, () => requestSources(url))\n"],"mappings":";;;;AAsBA,MAAM,gBAAgB,UACrB,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO,UAAU,OAAO,UAAU,QAAQ;;AAGzE,MAAM,gBAAgB,UACrB,SAAS,KAAK,KACd,OAAO,MAAM,OAAO,YACpB,OAAO,MAAM,UAAU,aACtB,MAAM,SAAS,YAAY,MAAM,SAAS,cAC3C,SAAS,MAAM,YAAY,KAC3B,aAAa,MAAM,aAAa,OAAO,KACvC,aAAa,MAAM,aAAa,UAAU,KAC1C,SAAS,MAAM,aAAa,OAAO;AAEpC,MAAM,qBAAqB,UAC1B,SAAS,KAAK,MACb,MAAM,cAAc,QAAQ,OAAO,MAAM,cAAc,cACvD,MAAM,WAAW,KAAA,KACjB,MAAM,WAAW,sBACjB,MAAM,WAAW,uBAClB,MAAM,QAAQ,MAAM,OAAO,KAC3B,MAAM,QAAQ,MAAM,YAAY;;AAGjC,MAAa,kBAAkB,KAAa,WAC3C,cAAc,KAAK,mBAAmB,EAAE,OAAO,CAAC;AAEjD,MAAM,QAAQ,kBAAmC;;;;;AAMjD,MAAa,gBAAgB,KAAa,UACzC,MAAM,KAAK;CAAE,OAAO;CAAK;AAAM,SAAS,eAAe,GAAG,CAAC"}
|
package/dist/goals/collection.js
CHANGED
|
@@ -27,8 +27,9 @@ const slugError = (collection, req, key) => new ValidationError({
|
|
|
27
27
|
label: labelForKey(keys.goalFieldSlug),
|
|
28
28
|
message: asTranslate(req.t)(key),
|
|
29
29
|
path: "slug"
|
|
30
|
-
}]
|
|
31
|
-
|
|
30
|
+
}],
|
|
31
|
+
req
|
|
32
|
+
}, req.t);
|
|
32
33
|
/**
|
|
33
34
|
* Slug shape and per-scope uniqueness at collection level, so a replaced slug field without its own
|
|
34
35
|
* `validate` keeps them; the index cannot cover install-wide Postgres rows or host scope fields.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","names":[],"sources":["../../src/goals/collection.ts"],"sourcesContent":["import type {\n\tCollectionBeforeValidateHook,\n\tCollectionConfig,\n\tCompoundIndex,\n\tField,\n\tPayloadRequest,\n\tTextFieldSingleValidation,\n} from 'payload'\nimport { ValidationError } from 'payload'\nimport { valueAt } from '../core/values'\nimport {\n\ttype CollectionFieldOverride,\n\thasNamedField,\n\toverrideField,\n\tpairInRow,\n} from '../plugin/collectionFields'\nimport { docScope, type ScopeChange } from '../plugin/scopeChange'\nimport type { ProviderAccessArgs } from '../providers/access'\nimport { providerCreateAccess, providerRowAccess } from '../providers/access'\nimport { takenInScope } from '../providers/scopeUnique'\nimport { stampScope } from '../providers/stampScope'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { asTranslate, labelForKey } from '../translations/server'\nimport { builtInStaticLabel, type StaticLabelFor } from '../translations/staticLabel'\nimport { amountField } from './amountField'\nimport { type AmountOf, amountCurrencyField } from './currency'\nimport { hiddenAdmin } from './moneyFields'\nimport { MAX_PATTERN_GLOBSTARS, MAX_PATTERN_SEGMENTS, patternProblem } from './pathMatch'\nimport { GOAL_SLUG_PATTERN } from './types'\n\nexport const GOALS_SLUG = 'analytics-goals'\n\n/**\n * Replaces one default field, receiving the plugin's own to spread. Any field type may come back, a\n * `row` included, as long as the slug override still holds a field named `slug`.\n */\nexport type GoalFieldOverride = CollectionFieldOverride\n\nexport interface GoalCollectionFieldOverrides {\n\tname?: GoalFieldOverride\n\tslug?: GoalFieldOverride\n\tenabled?: GoalFieldOverride\n\tbrowser?: GoalFieldOverride\n\tmatch?: GoalFieldOverride\n\tvalue?: GoalFieldOverride\n\tcurrency?: GoalFieldOverride\n}\n\nexport interface BuildGoalsCollectionArgs extends ProviderAccessArgs {\n\tslug: string\n\taccess?: Partial<CollectionConfig['access']>\n\t/** Per-field overrides, applied before the whole-collection `overrides`. */\n\tfields?: GoalCollectionFieldOverrides\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t/**\n\t * Whether the install measures money, default on. False hides the amount and currency rather than\n\t * removing them, so existing amounts survive and show again when it is turned back on.\n\t */\n\trevenue?: boolean\n\t/**\n\t * The install's reporting currency when it is one fixed code. The Amount control fills it\n\t * in once an amount is set on a goal that has no currency yet.\n\t */\n\tdefaultCurrency?: string\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\t/** The install's static labels; the built-in strings alone when absent. */\n\tstaticLabel?: StaticLabelFor\n}\n\nconst validateSlug: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && GOAL_SLUG_PATTERN.test(value)\n\t\t? true\n\t\t: asTranslate(req.t)(keys.goalErrorSlug)\n\n/** The matcher's caps, refused here so an editor hears about them rather than a goal never matching. */\nconst validatePattern: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && patternProblem(value) !== null\n\t\t? asTranslate(req.t)(keys.goalErrorPatternLimits, {\n\t\t\t\tsegments: MAX_PATTERN_SEGMENTS,\n\t\t\t\tglobstars: MAX_PATTERN_GLOBSTARS,\n\t\t\t})\n\t\t: true\n\nconst slugError = (collection: string, req: PayloadRequest, key: TranslationKey) =>\n\tnew ValidationError({\n\t\tcollection,\n\t\terrors: [\n\t\t\t{\n\t\t\t\tlabel: labelForKey(keys.goalFieldSlug),\n\t\t\t\tmessage: asTranslate(req.t)(key),\n\t\t\t\tpath: 'slug',\n\t\t\t},\n\t\t],\n\t})\n\n/**\n * Slug shape and per-scope uniqueness at collection level, so a replaced slug field without its own\n * `validate` keeps them; the index cannot cover install-wide Postgres rows or host scope fields.\n */\nconst checkSlug = (args: BuildGoalsCollectionArgs): CollectionBeforeValidateHook => {\n\treturn async ({ data, originalDoc, req }) => {\n\t\tconst slug = data?.slug\n\t\tif (typeof slug !== 'string' || slug === '') {\n\t\t\treturn data\n\t\t}\n\t\tif (!GOAL_SLUG_PATTERN.test(slug)) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlug)\n\t\t}\n\t\tif (await takenInScope(args, { data, originalDoc, req }, { slug: { equals: slug } })) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlugTaken)\n\t\t}\n\t\treturn data\n\t}\n}\n\n/**\n * Database backstop for the hook, only where the plugin owns the scope field. Postgres treats a NULL\n * scope as distinct, so install-wide rows stay hook-guarded.\n */\nconst uniqueSlugIndex = (args: BuildGoalsCollectionArgs): CompoundIndex | undefined => {\n\tif (!args.scoped) {\n\t\treturn { fields: ['slug'], unique: true }\n\t}\n\treturn args.scopeField === 'scope' ? { fields: ['slug', 'scope'], unique: true } : undefined\n}\n\n/**\n * The plugin's scope field, only while `scopeField` names it: a host-owned field is the host's to\n * register, and a hidden twin would store the scope twice.\n */\nconst scopeField = (args: BuildGoalsCollectionArgs): Field[] =>\n\targs.scopeField === 'scope'\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 nameField = (): Field => ({\n\tname: 'name',\n\ttype: 'text',\n\trequired: true,\n\tlabel: labelForKey(keys.goalFieldName),\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldNameHelp) },\n})\n\nconst slugField = (indexed: boolean): Field => ({\n\tname: 'slug',\n\ttype: 'text',\n\trequired: true,\n\t// Mongoose refuses a field index and a compound index that share a key spec, and the\n\t// compound one already covers a lookup by slug.\n\tindex: indexed,\n\tlabel: labelForKey(keys.goalFieldSlug),\n\tvalidate: validateSlug,\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldSlugHelp) },\n})\n\nconst enabledField = (): Field => ({\n\tname: 'enabled',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldEnabled),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldEnabledHelp) },\n})\n\n/** Off for a goal only server code completes: a browser's completion of it is then ignored. */\nconst browserField = (): Field => ({\n\tname: 'browser',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldBrowser),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldBrowserHelp) },\n})\n\nconst matchField = (staticLabel: StaticLabelFor): Field => ({\n\tname: 'match',\n\ttype: 'group',\n\tlabel: labelForKey(keys.goalFieldMatch),\n\tfields: [\n\t\t{\n\t\t\tname: 'kind',\n\t\t\ttype: 'select',\n\t\t\trequired: true,\n\t\t\tdefaultValue: 'goal',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchKind),\n\t\t\t// `admin.description` on a select is read where a label function never runs, so the\n\t\t\t// three kinds are explained through the locale map instead.\n\t\t\tadmin: { description: staticLabel(keys.goalFieldMatchKindHelp) },\n\t\t\toptions: [\n\t\t\t\t{ label: labelForKey(keys.goalKindGoal), value: 'goal' },\n\t\t\t\t{ label: labelForKey(keys.goalKindEvent), value: 'event' },\n\t\t\t\t{ label: labelForKey(keys.goalKindPath), value: 'path' },\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tname: 'name',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchEventName),\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'event',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchEventNameHelp),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'pattern',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchPathPattern),\n\t\t\tvalidate: validatePattern,\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'path',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchPathPatternHelp),\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The amount and where else it may come from, with no heading of their own so they read as\n * part of the goal. The currency is the sibling `currency` field, edited in the Amount control.\n */\nconst valueField = (defaultCurrency: string | undefined): Field => ({\n\tname: 'value',\n\ttype: 'group',\n\tlabel: false,\n\tadmin: { hideGutter: true },\n\tfields: [\n\t\tamountField(\n\t\t\t{\n\t\t\t\tname: 'fixed',\n\t\t\t\ttype: 'number',\n\t\t\t\tmin: 0,\n\t\t\t\tlabel: labelForKey(keys.goalFieldAmount),\n\t\t\t\tadmin: { description: labelForKey(keys.goalFieldAmountHelp) },\n\t\t\t},\n\t\t\t{ currencyPath: '../currency', defaultCurrency }\n\t\t),\n\t\t{\n\t\t\tname: 'prop',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldAmountProp),\n\t\t\tadmin: {\n\t\t\t\tdescription: labelForKey(keys.goalFieldAmountPropHelp),\n\t\t\t\t// Only an action's own details can carry an amount to read.\n\t\t\t\tcondition: (data) => data?.match?.kind === 'event',\n\t\t\t},\n\t\t},\n\t],\n})\n\n/** The amount a goal's currency belongs to: its fixed amount. */\nconst fixedAmount: AmountOf = ({ data }) => valueAt(data, 'value.fixed')\n\n/**\n * Hidden rather than removed while the install measures no money, a replacement included: the\n * field stays in the schema, so a goal that already carries an amount keeps it.\n */\nconst moneyOnly = (field: Field, revenue: boolean | undefined): Field =>\n\trevenue === false ? Object.assign({}, field, { admin: hiddenAdmin(field) }) : field\n\n/**\n * Name and slug share the first row while both are plain named fields; a layout or sidebar\n * replacement cannot live in a row, so it goes top level at its declared position.\n */\nconst layout = (args: BuildGoalsCollectionArgs, indexed: boolean): Field[] => [\n\t...pairInRow(\n\t\toverrideField(nameField(), args.fields?.name),\n\t\toverrideField(slugField(indexed), args.fields?.slug)\n\t),\n\toverrideField(enabledField(), args.fields?.enabled),\n\toverrideField(browserField(), args.fields?.browser),\n\toverrideField(matchField(args.staticLabel ?? builtInStaticLabel), args.fields?.match),\n\tmoneyOnly(overrideField(valueField(args.defaultCurrency), args.fields?.value), args.revenue),\n\tmoneyOnly(overrideField(amountCurrencyField(fixedAmount), args.fields?.currency), args.revenue),\n\t...scopeField(args),\n]\n\n/**\n * The editor-managed goals collection, one document per goal and scope, merged over config goals.\n * Admin-only by default; `access`, `fields` and finally `overrides` reshape it.\n */\nexport const buildGoalsCollection = (args: BuildGoalsCollectionArgs): CollectionConfig => {\n\tconst unique = uniqueSlugIndex(args)\n\tconst fields = layout(args, unique === undefined)\n\tif (!hasNamedField(fields, 'slug')) {\n\t\tthrow new Error(\n\t\t\t`analytics: goals.collection.fields.slug must return a field named \"slug\" (a row or group containing one is fine); the goals collection \"${args.slug}\" keys every report on that value`\n\t\t)\n\t}\n\tconst collection: CollectionConfig = {\n\t\tslug: args.slug,\n\t\t...(unique ? { indexes: [unique] } : {}),\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.goalsCollectionSingular),\n\t\t\tplural: labelForKey(keys.goalsCollectionPlural),\n\t\t},\n\t\t// A duplicate would carry the slug over, which the uniqueness hook refuses anyway.\n\t\tdisableDuplicate: true,\n\t\tadmin: {\n\t\t\tuseAsTitle: 'name',\n\t\t\tdefaultColumns: ['name', 'slug', 'match.kind', 'enabled'],\n\t\t\tgroup: (args.staticLabel ?? builtInStaticLabel)(keys.adminGroup),\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\tbeforeValidate: [checkSlug(args)],\n\t\t\tbeforeChange: [stampScope(args)],\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,\n\t}\n\treturn args.overrides ? args.overrides(collection) : collection\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAa,aAAa;AA2C1B,MAAM,gBAA2C,OAAO,EAAE,UACzD,OAAO,UAAU,YAAY,kBAAkB,KAAK,KAAK,IACtD,OACA,YAAY,IAAI,CAAC,EAAE,KAAK,aAAa;;AAGzC,MAAM,mBAA8C,OAAO,EAAE,UAC5D,OAAO,UAAU,YAAY,eAAe,KAAK,MAAM,OACpD,YAAY,IAAI,CAAC,EAAE,KAAK,wBAAwB;CAChD,UAAA;CACA,WAAA;AACD,CAAC,IACA;AAEJ,MAAM,aAAa,YAAoB,KAAqB,QAC3D,IAAI,gBAAgB;CACnB;CACA,QAAQ,CACP;EACC,OAAO,YAAY,KAAK,aAAa;EACrC,SAAS,YAAY,IAAI,CAAC,EAAE,GAAG;EAC/B,MAAM;CACP,CACD;AACD,CAAC;;;;;AAMF,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AAQ;IAAQ;IAAc;GAAS;GACxD,QAAQ,KAAK,eAAe,oBAAoB,KAAK,UAAU;EAChE;EACA,QAAQ;GACP,MAAM,kBAAkB,IAAI;GAC5B,QAAQ,qBAAqB,IAAI;GACjC,QAAQ,kBAAkB,IAAI;GAC9B,QAAQ,kBAAkB,IAAI;GAC9B,GAAG,KAAK;EACT;EACA,OAAO;GACN,gBAAgB,CAAC,UAAU,IAAI,CAAC;GAChC,cAAc,CAAC,WAAW,IAAI,CAAC;GAC/B,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;CACD;CACA,OAAO,KAAK,YAAY,KAAK,UAAU,UAAU,IAAI;AACtD"}
|
|
1
|
+
{"version":3,"file":"collection.js","names":[],"sources":["../../src/goals/collection.ts"],"sourcesContent":["import type {\n\tCollectionBeforeValidateHook,\n\tCollectionConfig,\n\tCompoundIndex,\n\tField,\n\tPayloadRequest,\n\tTextFieldSingleValidation,\n} from 'payload'\nimport { ValidationError } from 'payload'\nimport { valueAt } from '../core/values'\nimport {\n\ttype CollectionFieldOverride,\n\thasNamedField,\n\toverrideField,\n\tpairInRow,\n} from '../plugin/collectionFields'\nimport { docScope, type ScopeChange } from '../plugin/scopeChange'\nimport type { ProviderAccessArgs } from '../providers/access'\nimport { providerCreateAccess, providerRowAccess } from '../providers/access'\nimport { takenInScope } from '../providers/scopeUnique'\nimport { stampScope } from '../providers/stampScope'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { asTranslate, labelForKey } from '../translations/server'\nimport { builtInStaticLabel, type StaticLabelFor } from '../translations/staticLabel'\nimport { amountField } from './amountField'\nimport { type AmountOf, amountCurrencyField } from './currency'\nimport { hiddenAdmin } from './moneyFields'\nimport { MAX_PATTERN_GLOBSTARS, MAX_PATTERN_SEGMENTS, patternProblem } from './pathMatch'\nimport { GOAL_SLUG_PATTERN } from './types'\n\nexport const GOALS_SLUG = 'analytics-goals'\n\n/**\n * Replaces one default field, receiving the plugin's own to spread. Any field type may come back, a\n * `row` included, as long as the slug override still holds a field named `slug`.\n */\nexport type GoalFieldOverride = CollectionFieldOverride\n\nexport interface GoalCollectionFieldOverrides {\n\tname?: GoalFieldOverride\n\tslug?: GoalFieldOverride\n\tenabled?: GoalFieldOverride\n\tbrowser?: GoalFieldOverride\n\tmatch?: GoalFieldOverride\n\tvalue?: GoalFieldOverride\n\tcurrency?: GoalFieldOverride\n}\n\nexport interface BuildGoalsCollectionArgs extends ProviderAccessArgs {\n\tslug: string\n\taccess?: Partial<CollectionConfig['access']>\n\t/** Per-field overrides, applied before the whole-collection `overrides`. */\n\tfields?: GoalCollectionFieldOverrides\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t/**\n\t * Whether the install measures money, default on. False hides the amount and currency rather than\n\t * removing them, so existing amounts survive and show again when it is turned back on.\n\t */\n\trevenue?: boolean\n\t/**\n\t * The install's reporting currency when it is one fixed code. The Amount control fills it\n\t * in once an amount is set on a goal that has no currency yet.\n\t */\n\tdefaultCurrency?: string\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\t/** The install's static labels; the built-in strings alone when absent. */\n\tstaticLabel?: StaticLabelFor\n}\n\nconst validateSlug: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && GOAL_SLUG_PATTERN.test(value)\n\t\t? true\n\t\t: asTranslate(req.t)(keys.goalErrorSlug)\n\n/** The matcher's caps, refused here so an editor hears about them rather than a goal never matching. */\nconst validatePattern: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && patternProblem(value) !== null\n\t\t? asTranslate(req.t)(keys.goalErrorPatternLimits, {\n\t\t\t\tsegments: MAX_PATTERN_SEGMENTS,\n\t\t\t\tglobstars: MAX_PATTERN_GLOBSTARS,\n\t\t\t})\n\t\t: true\n\nconst slugError = (collection: string, req: PayloadRequest, key: TranslationKey) =>\n\tnew ValidationError(\n\t\t{\n\t\t\tcollection,\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tlabel: labelForKey(keys.goalFieldSlug),\n\t\t\t\t\tmessage: asTranslate(req.t)(key),\n\t\t\t\t\tpath: 'slug',\n\t\t\t\t},\n\t\t\t],\n\t\t\treq,\n\t\t},\n\t\treq.t\n\t)\n\n/**\n * Slug shape and per-scope uniqueness at collection level, so a replaced slug field without its own\n * `validate` keeps them; the index cannot cover install-wide Postgres rows or host scope fields.\n */\nconst checkSlug = (args: BuildGoalsCollectionArgs): CollectionBeforeValidateHook => {\n\treturn async ({ data, originalDoc, req }) => {\n\t\tconst slug = data?.slug\n\t\tif (typeof slug !== 'string' || slug === '') {\n\t\t\treturn data\n\t\t}\n\t\tif (!GOAL_SLUG_PATTERN.test(slug)) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlug)\n\t\t}\n\t\tif (await takenInScope(args, { data, originalDoc, req }, { slug: { equals: slug } })) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlugTaken)\n\t\t}\n\t\treturn data\n\t}\n}\n\n/**\n * Database backstop for the hook, only where the plugin owns the scope field. Postgres treats a NULL\n * scope as distinct, so install-wide rows stay hook-guarded.\n */\nconst uniqueSlugIndex = (args: BuildGoalsCollectionArgs): CompoundIndex | undefined => {\n\tif (!args.scoped) {\n\t\treturn { fields: ['slug'], unique: true }\n\t}\n\treturn args.scopeField === 'scope' ? { fields: ['slug', 'scope'], unique: true } : undefined\n}\n\n/**\n * The plugin's scope field, only while `scopeField` names it: a host-owned field is the host's to\n * register, and a hidden twin would store the scope twice.\n */\nconst scopeField = (args: BuildGoalsCollectionArgs): Field[] =>\n\targs.scopeField === 'scope'\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 nameField = (): Field => ({\n\tname: 'name',\n\ttype: 'text',\n\trequired: true,\n\tlabel: labelForKey(keys.goalFieldName),\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldNameHelp) },\n})\n\nconst slugField = (indexed: boolean): Field => ({\n\tname: 'slug',\n\ttype: 'text',\n\trequired: true,\n\t// Mongoose refuses a field index and a compound index that share a key spec, and the\n\t// compound one already covers a lookup by slug.\n\tindex: indexed,\n\tlabel: labelForKey(keys.goalFieldSlug),\n\tvalidate: validateSlug,\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldSlugHelp) },\n})\n\nconst enabledField = (): Field => ({\n\tname: 'enabled',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldEnabled),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldEnabledHelp) },\n})\n\n/** Off for a goal only server code completes: a browser's completion of it is then ignored. */\nconst browserField = (): Field => ({\n\tname: 'browser',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldBrowser),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldBrowserHelp) },\n})\n\nconst matchField = (staticLabel: StaticLabelFor): Field => ({\n\tname: 'match',\n\ttype: 'group',\n\tlabel: labelForKey(keys.goalFieldMatch),\n\tfields: [\n\t\t{\n\t\t\tname: 'kind',\n\t\t\ttype: 'select',\n\t\t\trequired: true,\n\t\t\tdefaultValue: 'goal',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchKind),\n\t\t\t// `admin.description` on a select is read where a label function never runs, so the\n\t\t\t// three kinds are explained through the locale map instead.\n\t\t\tadmin: { description: staticLabel(keys.goalFieldMatchKindHelp) },\n\t\t\toptions: [\n\t\t\t\t{ label: labelForKey(keys.goalKindGoal), value: 'goal' },\n\t\t\t\t{ label: labelForKey(keys.goalKindEvent), value: 'event' },\n\t\t\t\t{ label: labelForKey(keys.goalKindPath), value: 'path' },\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tname: 'name',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchEventName),\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'event',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchEventNameHelp),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'pattern',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchPathPattern),\n\t\t\tvalidate: validatePattern,\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'path',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchPathPatternHelp),\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The amount and where else it may come from, with no heading of their own so they read as\n * part of the goal. The currency is the sibling `currency` field, edited in the Amount control.\n */\nconst valueField = (defaultCurrency: string | undefined): Field => ({\n\tname: 'value',\n\ttype: 'group',\n\tlabel: false,\n\tadmin: { hideGutter: true },\n\tfields: [\n\t\tamountField(\n\t\t\t{\n\t\t\t\tname: 'fixed',\n\t\t\t\ttype: 'number',\n\t\t\t\tmin: 0,\n\t\t\t\tlabel: labelForKey(keys.goalFieldAmount),\n\t\t\t\tadmin: { description: labelForKey(keys.goalFieldAmountHelp) },\n\t\t\t},\n\t\t\t{ currencyPath: '../currency', defaultCurrency }\n\t\t),\n\t\t{\n\t\t\tname: 'prop',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldAmountProp),\n\t\t\tadmin: {\n\t\t\t\tdescription: labelForKey(keys.goalFieldAmountPropHelp),\n\t\t\t\t// Only an action's own details can carry an amount to read.\n\t\t\t\tcondition: (data) => data?.match?.kind === 'event',\n\t\t\t},\n\t\t},\n\t],\n})\n\n/** The amount a goal's currency belongs to: its fixed amount. */\nconst fixedAmount: AmountOf = ({ data }) => valueAt(data, 'value.fixed')\n\n/**\n * Hidden rather than removed while the install measures no money, a replacement included: the\n * field stays in the schema, so a goal that already carries an amount keeps it.\n */\nconst moneyOnly = (field: Field, revenue: boolean | undefined): Field =>\n\trevenue === false ? Object.assign({}, field, { admin: hiddenAdmin(field) }) : field\n\n/**\n * Name and slug share the first row while both are plain named fields; a layout or sidebar\n * replacement cannot live in a row, so it goes top level at its declared position.\n */\nconst layout = (args: BuildGoalsCollectionArgs, indexed: boolean): Field[] => [\n\t...pairInRow(\n\t\toverrideField(nameField(), args.fields?.name),\n\t\toverrideField(slugField(indexed), args.fields?.slug)\n\t),\n\toverrideField(enabledField(), args.fields?.enabled),\n\toverrideField(browserField(), args.fields?.browser),\n\toverrideField(matchField(args.staticLabel ?? builtInStaticLabel), args.fields?.match),\n\tmoneyOnly(overrideField(valueField(args.defaultCurrency), args.fields?.value), args.revenue),\n\tmoneyOnly(overrideField(amountCurrencyField(fixedAmount), args.fields?.currency), args.revenue),\n\t...scopeField(args),\n]\n\n/**\n * The editor-managed goals collection, one document per goal and scope, merged over config goals.\n * Admin-only by default; `access`, `fields` and finally `overrides` reshape it.\n */\nexport const buildGoalsCollection = (args: BuildGoalsCollectionArgs): CollectionConfig => {\n\tconst unique = uniqueSlugIndex(args)\n\tconst fields = layout(args, unique === undefined)\n\tif (!hasNamedField(fields, 'slug')) {\n\t\tthrow new Error(\n\t\t\t`analytics: goals.collection.fields.slug must return a field named \"slug\" (a row or group containing one is fine); the goals collection \"${args.slug}\" keys every report on that value`\n\t\t)\n\t}\n\tconst collection: CollectionConfig = {\n\t\tslug: args.slug,\n\t\t...(unique ? { indexes: [unique] } : {}),\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.goalsCollectionSingular),\n\t\t\tplural: labelForKey(keys.goalsCollectionPlural),\n\t\t},\n\t\t// A duplicate would carry the slug over, which the uniqueness hook refuses anyway.\n\t\tdisableDuplicate: true,\n\t\tadmin: {\n\t\t\tuseAsTitle: 'name',\n\t\t\tdefaultColumns: ['name', 'slug', 'match.kind', 'enabled'],\n\t\t\tgroup: (args.staticLabel ?? builtInStaticLabel)(keys.adminGroup),\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\tbeforeValidate: [checkSlug(args)],\n\t\t\tbeforeChange: [stampScope(args)],\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,\n\t}\n\treturn args.overrides ? args.overrides(collection) : collection\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAa,aAAa;AA2C1B,MAAM,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als/resolver.js
CHANGED
|
@@ -4,9 +4,9 @@ import { currentTime } from "../core/clock.js";
|
|
|
4
4
|
import { recall, remember } from "../surfacing/bounded.js";
|
|
5
5
|
import { createEpochFallback } from "../surfacing/epoch.js";
|
|
6
6
|
import { asTranslate } from "../translations/server.js";
|
|
7
|
-
import { GOAL_SLUG_PATTERN } from "./types.js";
|
|
8
7
|
import { isCollectionSlug } from "../core/collectionSlug.js";
|
|
9
8
|
import { PROBE_MEMO_MS, createCollectionProbe } from "../providers/probe.js";
|
|
9
|
+
import { GOAL_SLUG_PATTERN } from "./types.js";
|
|
10
10
|
import "./constants.js";
|
|
11
11
|
import { builtinPurchaseGoal } from "./builtin.js";
|
|
12
12
|
//#region src/goals/resolver.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { AnalyticsAttributes } from "./exports/attributes.js";
|
|
|
15
15
|
import { ItemSignatureMode, itemAttributesFor, signItemRef } from "./native/ingest/itemSignature.js";
|
|
16
16
|
import { RawEventInput } from "./native/ingest/normalizeEvent.js";
|
|
17
17
|
import { AnalyticsTrackError, IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "./core/serverEvent.js";
|
|
18
|
-
import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, PLATFORM_SCOPE, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "./core/contract.js";
|
|
18
|
+
import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, PLATFORM_SCOPE, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "./core/contract.js";
|
|
19
19
|
import { AnalyticsSourceOptions, DefaultSourceFunction, DefaultSourceRule, OwnSource, SourcePolicy, SourcePolicyFunction, SourceRef } from "./core/sourcePolicy.js";
|
|
20
20
|
import { AdapterLabelOption } from "./core/sourceLabel.js";
|
|
21
21
|
import { STATE_SLUG } from "./native/collections/slugs.js";
|
|
@@ -31,7 +31,7 @@ import { PluralCategory, PluralName, PluralVariant, SingularKey, TranslationKey,
|
|
|
31
31
|
import { TranslationsOption } from "./translations/index.js";
|
|
32
32
|
import { GOALS_SLUG, GoalCollectionFieldOverrides, GoalFieldOverride } from "./goals/collection.js";
|
|
33
33
|
import { HostPattern, ProviderHostPolicy, resolveHostPolicy } from "./providers/hosts.js";
|
|
34
|
-
import { PROVIDER_IDS,
|
|
34
|
+
import { PROVIDER_IDS, ProviderId } from "./providers/ids.js";
|
|
35
35
|
import { BuildSecretField, ConnectionAccess, ConnectionFieldAccess, PROVIDERS_SLUG, ProviderCollectionFieldOverrides, ProviderFieldOverride, ProviderFieldsOptions, analyticsProviderFields } from "./providers/collection.js";
|
|
36
36
|
import { AfterReadAnswer, AfterReadArgs, AfterReadHook, ReadOrigin } from "./surfacing/afterRead.js";
|
|
37
37
|
import { TIMEFRAME_PRESETS, TimeframePreset } from "./timeframe/presets.js";
|
|
@@ -64,6 +64,7 @@ import { signOrderId } from "./native/ingest/orderSignature.js";
|
|
|
64
64
|
import { trackServerEvent } from "./native/ingest/serverTrack.js";
|
|
65
65
|
import { rebuildDays } from "./native/rebuildDays.js";
|
|
66
66
|
import { GuardedFetch, GuardedFetchOptions, createGuardedFetch } from "./net/guardedFetch.js";
|
|
67
|
+
import { ProviderDoc, ProviderFactoryContext, adapterFromProviderDoc } from "./providers/factory.js";
|
|
67
68
|
import { RefreshProvidersOptions, refreshProviders } from "./providers/refresh.js";
|
|
68
69
|
import { CONNECTION_PATHS, SECRET_PATHS } from "./providers/secrets.js";
|
|
69
70
|
import { CACHE_SLUG } from "./surfacing/cacheCollection.js";
|
|
@@ -80,5 +81,5 @@ declare module 'payload' {
|
|
|
80
81
|
}
|
|
81
82
|
declare const analytics: (options: AnalyticsPluginOptions) => import("payload").Plugin;
|
|
82
83
|
//#endregion
|
|
83
|
-
export { ANALYTICS_ERROR_CODES, type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AfterReadAnswer, type AfterReadArgs, type AfterReadHook, type AnalyticsAccessOptions, type AnalyticsAdapter, type AnalyticsAttributes, type AnalyticsBinding, type AnalyticsCacheCollectionOptions, type AnalyticsCacheOptions, type AnalyticsCapabilities, type AnalyticsCaptureOptions, type AnalyticsCollectionOptions, type AnalyticsComponent, type AnalyticsConcurrencyOptions, type AnalyticsCountryFlags, type AnalyticsCrossScopeOptions, type AnalyticsDefaultLayoutOptions, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsExclusionOptions, type AnalyticsFieldsOptions, type AnalyticsFilter, type AnalyticsGoalsCollectionOptions, type AnalyticsGoalsOptions, type AnalyticsHooksOptions, type AnalyticsJobsOptions, type AnalyticsLinkFieldsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, type AnalyticsQuery, type AnalyticsReadAccess, type AnalyticsResult, type AnalyticsRevenueOptions, type AnalyticsRoutesOptions, type AnalyticsRow, type AnalyticsScopeOptions, type AnalyticsSdks, type AnalyticsSourceOptions, type AnalyticsStatBaseOptions, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsSyncCollectionOptions, type AnalyticsSyncOptions, type AnalyticsTabOptions, type AnalyticsTaskName, type AnalyticsTaskOptions, AnalyticsTrackError, type AnalyticsViewAccess, type AnalyticsViewOptions, type AnalyticsWarmOptions, type AnalyticsWidgetOverride, type AnalyticsWidgetOverrides, type AnalyticsWidgetsOptions, type AutoCaptureOptions, BUILT_IN_WIDGET_SLUGS, type BindingContext, type BindingDoc, type BreakdownRow, type BrowserAmounts, type BuildSecretField, type BuiltInWidgetSlug, CACHE_SLUG, CONNECTION_PATHS, CURRENCY_ATTRIBUTE, type CacheEntry, type CacheSetOptions, type CacheStore, type CapabilityRequirement, type CaptureClientKind, type CaptureGate, type CaptureGateArgs, type CaptureSlot, type CaptureSlotOption, type CaptureSnippet, type CaptureSupport, type CollectionFieldOverride, type CollectionOverrides, type ConnectionAccess, type ConnectionFieldAccess, type ConsentPhase, type CookielessSupport, type CrossScopeAccess, type CurrencyConverter, type CurrencyResolver, type CustomWidgetDef, DEFAULT_ROUTE_BASE, type DIMENSION_KEYS, type DateRange, type DefaultSourceFunction, type DefaultSourceRule, type DimensionKey, EVENT_ATTRIBUTE, EVENT_PROP_PREFIX, type ExclusionSitesResolver, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FieldBreakdown, type FieldBreakdownRow, type FieldReadResult, type FieldReadStatus, type FilterOperator, type FilterOperatorMap, type FilterPair, GOALS_SLUG, GOAL_ACTION_TYPE, GOAL_ATTRIBUTE, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type GatedScope, type Goal, type GoalActionDefinition, type GoalActionRunArgs, type GoalCollectionFieldOverrides, type GoalFieldOptions, type GoalFieldOverride, type GoalMatch, type GoalRow, type GoalSource, type GoalsResponse, type Granularity, type GuardedFetch, type GuardedFetchOptions, type HeldSlotMode, type HitMode, type HitType, type HostPattern, type HostnameResolver, ITEM_ATTRIBUTE, ITEM_CLICK_EVENT, ITEM_NAME_ATTRIBUTE, type IngestHostnameResolver, type ItemCaptureOptions, type ItemLabels, type ItemSignatureMode, MAX_ITEMS_PER_BEACON, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type OwnSource, PLATFORM_SCOPE, PROVIDERS_SLUG, PROVIDER_IDS, PURCHASE_GOAL_SLUG, type PathResolver, type AnalyticsPluginOptions as PluginOptions, type PluralCategory, type PluralName, type PluralVariant, type ProviderCollectionFieldOverrides, type ProviderDoc, type ProviderFactoryContext, type ProviderFieldOverride, type ProviderFieldsOptions, type ProviderHostPolicy, type ProviderHostsOptions, ProviderHttpError, type ProviderId, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type ProvidersResolveArgs, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type QueryError, type QueryErrorCode, type QueryErrorResponse, type QueryResponse, type QuerySourceRef, type RateLimitDescriptor, type RawEventInput, type ReadForFieldArgs, type ReadForWidgetArgs, type ReadForWidgetBreakdownArgs, type ReadForWidgetGoalsArgs, type ReadForWidgetRealtimeArgs, type ReadForWidgetSeriesArgs, type ReadNotices, type ReadOrigin, type ReadPrincipal, type ReadRecipe, type RealtimePoint, type RebuildDaysInput, type RebuildDaysReport, type RecipeWindow, type RefreshProvidersOptions, type ReportMode, type ReportOption, type RevenueItem, type RouteBase, type RoutePaths, type RoutesConfigSource, SECRET_PATHS, STATE_SLUG, SYNC_SLUG, SYSTEM, type ScheduledTask, type ScopeCallSite, type ScopeLabelResolver, type ScopeListResolver, type ScopeMemberAccess, type ScopeResolver, type SerializedAnalyticsQuery, type SerializedCapabilities, type SeriesGranularity, type SeriesPoint, type ServerEventInput, type PurchaseInput as ServerPurchaseInput, type RefundInput as ServerRefundInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SingularKey, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type SourcePolicy, type SourcePolicyFunction, type SourceRef, type StoredSourceRead, type SubstitutedSource, type TASK_NAMES, TIMEFRAME_PRESETS, type TenantMembershipOptions, type TimeframePreset, type TimezoneResolver, type TrackGoalActionOptions, type TrackerGoal, type TrackerSlotConfig, type TranslationKey, type TranslationsOption, type TrustedPlatform, VALUE_ATTRIBUTE, type VisitorCounting, type WidgetBreakdownResult, type WidgetFilter, type WidgetGoalsResult, type WidgetReadResult, type WidgetReadStatus, type WidgetRealtimeResult, type WidgetRealtimeStatus, type WidgetSeriesResult, type WireGoal, type WithoutConsentArgs, type WithoutConsentFunction, type WithoutConsentLevel, type WithoutConsentOption, adapterFromProviderDoc, analytics, analyticsDefaultLayout, analyticsDefaultWidgets, analyticsError, analyticsFields, analyticsLinkFields, analyticsProviderFields, analyticsRoutes, analyticsStat, analyticsStatRow, analyticsTab, analyticsTabsField, createGuardedFetch, goalField, goalSlug, isAdminUser, itemAttributesFor, keys, parseRetryAfter, pluralKeys, purchase, readErrorCode, readForField, readForWidget, readForWidgetBreakdown, readForWidgetGoals, readForWidgetRealtime, readForWidgetSeries, rebuildDays, refreshProviders, refund, resolveHostPolicy, routePaths, signItemRef, signOrderId, tenantMembership, trackGoalAction, trackServerEvent, widgetFilters };
|
|
84
|
+
export { ANALYTICS_ERROR_CODES, type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AfterReadAnswer, type AfterReadArgs, type AfterReadHook, type AnalyticsAccessOptions, type AnalyticsAdapter, type AnalyticsAttributes, type AnalyticsBinding, type AnalyticsCacheCollectionOptions, type AnalyticsCacheOptions, type AnalyticsCapabilities, type AnalyticsCaptureOptions, type AnalyticsCollectionOptions, type AnalyticsComponent, type AnalyticsConcurrencyOptions, type AnalyticsCountryFlags, type AnalyticsCrossScopeOptions, type AnalyticsDefaultLayoutOptions, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsExclusionOptions, type AnalyticsFieldsOptions, type AnalyticsFilter, type AnalyticsGoalsCollectionOptions, type AnalyticsGoalsOptions, type AnalyticsHooksOptions, type AnalyticsJobsOptions, type AnalyticsLinkFieldsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, type AnalyticsQuery, type AnalyticsReadAccess, type AnalyticsResult, type AnalyticsRevenueOptions, type AnalyticsRoutesOptions, type AnalyticsRow, type AnalyticsScopeOptions, type AnalyticsSdks, type AnalyticsSourceOptions, type AnalyticsStatBaseOptions, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsSyncCollectionOptions, type AnalyticsSyncOptions, type AnalyticsTabOptions, type AnalyticsTaskName, type AnalyticsTaskOptions, AnalyticsTrackError, type AnalyticsViewAccess, type AnalyticsViewOptions, type AnalyticsWarmOptions, type AnalyticsWidgetOverride, type AnalyticsWidgetOverrides, type AnalyticsWidgetsOptions, type AutoCaptureOptions, BUILT_IN_WIDGET_SLUGS, type BindingContext, type BindingDoc, type BreakdownRow, type BrowserAmounts, type BuildSecretField, type BuiltInWidgetSlug, CACHE_SLUG, CONNECTION_PATHS, CURRENCY_ATTRIBUTE, type CacheEntry, type CacheSetOptions, type CacheStore, type CapabilityRequirement, type CaptureClientKind, type CaptureGate, type CaptureGateArgs, type CaptureSlot, type CaptureSlotOption, type CaptureSnippet, type CaptureSupport, type CollectionFieldOverride, type CollectionOverrides, type ConnectionAccess, type ConnectionCheckContext, type ConnectionFieldAccess, type ConsentPhase, type CookielessSupport, type CrossScopeAccess, type CurrencyConverter, type CurrencyResolver, type CustomWidgetDef, DEFAULT_ROUTE_BASE, type DIMENSION_KEYS, type DateRange, type DefaultSourceFunction, type DefaultSourceRule, type DimensionKey, EVENT_ATTRIBUTE, EVENT_PROP_PREFIX, type ExclusionSitesResolver, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FieldBreakdown, type FieldBreakdownRow, type FieldReadResult, type FieldReadStatus, type FilterOperator, type FilterOperatorMap, type FilterPair, GOALS_SLUG, GOAL_ACTION_TYPE, GOAL_ATTRIBUTE, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type GatedScope, type Goal, type GoalActionDefinition, type GoalActionRunArgs, type GoalCollectionFieldOverrides, type GoalFieldOptions, type GoalFieldOverride, type GoalMatch, type GoalRow, type GoalSource, type GoalsResponse, type Granularity, type GuardedFetch, type GuardedFetchOptions, type HeldSlotMode, type HitMode, type HitType, type HostPattern, type HostnameResolver, ITEM_ATTRIBUTE, ITEM_CLICK_EVENT, ITEM_NAME_ATTRIBUTE, type IngestHostnameResolver, type ItemCaptureOptions, type ItemLabels, type ItemSignatureMode, MAX_ITEMS_PER_BEACON, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type OwnSource, PLATFORM_SCOPE, PROVIDERS_SLUG, PROVIDER_IDS, PURCHASE_GOAL_SLUG, type PathResolver, type AnalyticsPluginOptions as PluginOptions, type PluralCategory, type PluralName, type PluralVariant, type ProviderCollectionFieldOverrides, type ProviderDoc, type ProviderFactoryContext, type ProviderFieldOverride, type ProviderFieldsOptions, type ProviderHostPolicy, type ProviderHostsOptions, ProviderHttpError, type ProviderId, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type ProvidersResolveArgs, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type QueryError, type QueryErrorCode, type QueryErrorResponse, type QueryResponse, type QuerySourceRef, type RateLimitDescriptor, type RawEventInput, type ReadForFieldArgs, type ReadForWidgetArgs, type ReadForWidgetBreakdownArgs, type ReadForWidgetGoalsArgs, type ReadForWidgetRealtimeArgs, type ReadForWidgetSeriesArgs, type ReadNotices, type ReadOrigin, type ReadPrincipal, type ReadRecipe, type RealtimePoint, type RebuildDaysInput, type RebuildDaysReport, type RecipeWindow, type RefreshProvidersOptions, type ReportMode, type ReportOption, type RevenueItem, type RouteBase, type RoutePaths, type RoutesConfigSource, SECRET_PATHS, STATE_SLUG, SYNC_SLUG, SYSTEM, type ScheduledTask, type ScopeCallSite, type ScopeLabelResolver, type ScopeListResolver, type ScopeMemberAccess, type ScopeResolver, type SerializedAnalyticsQuery, type SerializedCapabilities, type SeriesGranularity, type SeriesPoint, type ServerEventInput, type PurchaseInput as ServerPurchaseInput, type RefundInput as ServerRefundInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SingularKey, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type SourcePolicy, type SourcePolicyFunction, type SourceRef, type StoredSourceRead, type SubstitutedSource, type TASK_NAMES, TIMEFRAME_PRESETS, type TenantMembershipOptions, type TimeframePreset, type TimezoneResolver, type TrackGoalActionOptions, type TrackerGoal, type TrackerSlotConfig, type TranslationKey, type TranslationsOption, type TrustedPlatform, VALUE_ATTRIBUTE, type VisitorCounting, type WidgetBreakdownResult, type WidgetFilter, type WidgetGoalsResult, type WidgetReadResult, type WidgetReadStatus, type WidgetRealtimeResult, type WidgetRealtimeStatus, type WidgetSeriesResult, type WireGoal, type WithoutConsentArgs, type WithoutConsentFunction, type WithoutConsentLevel, type WithoutConsentOption, adapterFromProviderDoc, analytics, analyticsDefaultLayout, analyticsDefaultWidgets, analyticsError, analyticsFields, analyticsLinkFields, analyticsProviderFields, analyticsRoutes, analyticsStat, analyticsStatRow, analyticsTab, analyticsTabsField, createGuardedFetch, goalField, goalSlug, isAdminUser, itemAttributesFor, keys, parseRetryAfter, pluralKeys, purchase, readErrorCode, readForField, readForWidget, readForWidgetBreakdown, readForWidgetGoals, readForWidgetRealtime, readForWidgetSeries, rebuildDays, refreshProviders, refund, resolveHostPolicy, routePaths, signItemRef, signOrderId, tenantMembership, trackGoalAction, trackServerEvent, widgetFilters };
|
|
84
85
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createRegistry, withoutRevenue } from "./core/registry.js";
|
|
|
8
8
|
import { keys, pluralKeys } from "./translations/keys.js";
|
|
9
9
|
import { ANALYTICS_CONFIG_KEY, DEFAULT_ROUTE_BASE, analyticsRoutes, pluginEndpoint, routePaths } from "./plugin/routes.js";
|
|
10
10
|
import { getRuntime, resolveGoalsFor, resolveRegistryFor, runtimeFactoryOf } from "./plugin/runtime.js";
|
|
11
|
+
import { PROVIDER_IDS } from "./providers/ids.js";
|
|
11
12
|
import { ANALYTICS_ERROR_CODES, analyticsError, readErrorCode } from "./plugin/errors.js";
|
|
12
13
|
import { makeExclusionHandler } from "./capture/exclusionEndpoint.js";
|
|
13
14
|
import { proxyEndpoints } from "./capture/proxyEndpoint.js";
|
|
@@ -21,9 +22,8 @@ import { createStaticLabels } from "./translations/staticLabel.js";
|
|
|
21
22
|
import { SYNC_SLUG } from "./sync/collection.js";
|
|
22
23
|
import { CURRENCY_PATTERN } from "./goals/currency.js";
|
|
23
24
|
import { changedScopes } from "./plugin/scopeChange.js";
|
|
24
|
-
import { ProviderHttpError, parseRetryAfter } from "./adapters/http/fetchJson.js";
|
|
25
25
|
import { resolveHostPolicy } from "./providers/hosts.js";
|
|
26
|
-
import {
|
|
26
|
+
import { afterTransaction, openTransactionOf } from "./db/openTransaction.js";
|
|
27
27
|
import { CONNECTION_PATHS, SECRET_PATHS } from "./providers/secrets.js";
|
|
28
28
|
import { PROVIDERS_SLUG, analyticsProviderFields } from "./providers/collection.js";
|
|
29
29
|
import { adapterCountsWithoutConsent } from "./core/captureOptions.js";
|
|
@@ -48,15 +48,18 @@ import { addTask, schemaOnly } from "./plugin/schemaOnly.js";
|
|
|
48
48
|
import { signOrderId } from "./native/ingest/orderSignature.js";
|
|
49
49
|
import { createGuardedFetch } from "./net/guardedFetch.js";
|
|
50
50
|
import { refreshProviders } from "./providers/refresh.js";
|
|
51
|
+
import { ProviderHttpError, parseRetryAfter } from "./adapters/http/fetchJson.js";
|
|
52
|
+
import { adapterFromProviderDoc } from "./providers/factory.js";
|
|
51
53
|
import { assertRoutesReachable } from "./plugin/routeChecks.js";
|
|
52
54
|
import { createRuntimeFactory } from "./plugin/createRuntime.js";
|
|
53
55
|
import { readForField } from "./fields/readForDocument.js";
|
|
54
56
|
import { makeDocumentHandler } from "./plugin/documentEndpoint.js";
|
|
55
57
|
import { makeFlagsHandler } from "./plugin/flagsEndpoint.js";
|
|
58
|
+
import { makeRefreshHandler } from "./plugin/refreshEndpoint.js";
|
|
59
|
+
import { makeProviderStatusHandler } from "./plugin/providerStatusEndpoint.js";
|
|
56
60
|
import { makeQueryHandler } from "./plugin/queryEndpoint.js";
|
|
57
61
|
import { readForWidgetRealtime } from "./widgets/readForWidgetRealtime.js";
|
|
58
62
|
import { makeRealtimeHandler } from "./plugin/realtimeEndpoint.js";
|
|
59
|
-
import { makeRefreshHandler } from "./plugin/refreshEndpoint.js";
|
|
60
63
|
import { makeSourcesHandler } from "./plugin/sourcesEndpoint.js";
|
|
61
64
|
import { warmTask } from "./plugin/warmTask.js";
|
|
62
65
|
import { syncTask } from "./sync/syncTask.js";
|
|
@@ -84,6 +87,35 @@ import { definePlugin } from "payload";
|
|
|
84
87
|
const configChanged = (collection) => (change, req) => {
|
|
85
88
|
getRuntime(req.payload)?.configChanged?.(collection, changedScopes(change));
|
|
86
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Runs a status write of a saved or deleted provider document once the save's own transaction is
|
|
92
|
+
* over: a write outside it would wait on the locks it holds. The save goes on whatever happens
|
|
93
|
+
* here; the next read or check writes the row again.
|
|
94
|
+
*/
|
|
95
|
+
const afterProviderSave = async (req, { docId, failed, write }) => {
|
|
96
|
+
const runtime = getRuntime(req.payload);
|
|
97
|
+
const store = runtime?.providerStatus;
|
|
98
|
+
if (!runtime || !store) return;
|
|
99
|
+
const run = () => write(store).catch((err) => {
|
|
100
|
+
runtime.providerStatusWarning?.(`analytics: the connection status of provider document "${docId}" could not be ${failed}: ${String(err)}`);
|
|
101
|
+
});
|
|
102
|
+
const open = await openTransactionOf(req.payload, req);
|
|
103
|
+
if (!open) {
|
|
104
|
+
await run();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
runtime.engine.keep?.(afterTransaction(open, run));
|
|
108
|
+
};
|
|
109
|
+
const forgetProviderStatus = (docId, req) => afterProviderSave(req, {
|
|
110
|
+
docId,
|
|
111
|
+
failed: "cleared",
|
|
112
|
+
write: (store) => store.forget(docId)
|
|
113
|
+
});
|
|
114
|
+
const carryProviderStatus = (docId, { from, to }, req) => afterProviderSave(req, {
|
|
115
|
+
docId,
|
|
116
|
+
failed: "kept",
|
|
117
|
+
write: (store) => store.carry(docId, from, to)
|
|
118
|
+
});
|
|
87
119
|
const addEndpoints = (config, ...endpoints) => {
|
|
88
120
|
config.endpoints = [...config.endpoints ?? [], ...endpoints];
|
|
89
121
|
};
|
|
@@ -112,7 +144,9 @@ const analytics = definePlugin({
|
|
|
112
144
|
};
|
|
113
145
|
const collections = await configCollections(resolved, {
|
|
114
146
|
resolveAdminScope,
|
|
115
|
-
onChange: configChanged
|
|
147
|
+
onChange: configChanged,
|
|
148
|
+
forgetProviderStatus,
|
|
149
|
+
carryProviderStatus
|
|
116
150
|
}, context);
|
|
117
151
|
const sync = syncCollectionOf(resolved, resolveAdminScope, context);
|
|
118
152
|
if (disabled) return schemaOnly(config, {
|
|
@@ -232,6 +266,18 @@ const analytics = definePlugin({
|
|
|
232
266
|
path: routes.refresh,
|
|
233
267
|
handler: makeRefreshHandler()
|
|
234
268
|
});
|
|
269
|
+
if (resolved.providers.collection.enabled) {
|
|
270
|
+
const providerStatus = makeProviderStatusHandler();
|
|
271
|
+
addEndpoints(config, {
|
|
272
|
+
method: "get",
|
|
273
|
+
path: routes.providerStatus,
|
|
274
|
+
handler: providerStatus
|
|
275
|
+
}, {
|
|
276
|
+
method: "post",
|
|
277
|
+
path: routes.providerStatus,
|
|
278
|
+
handler: providerStatus
|
|
279
|
+
});
|
|
280
|
+
}
|
|
235
281
|
if (resolved.capture.exclusion) addEndpoints(config, {
|
|
236
282
|
method: "get",
|
|
237
283
|
path: routes.exclusion,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Config, definePlugin, type Endpoint, type PayloadRequest } from 'payload'\n\nimport { itemCollectionsOf } from './binding/report'\nimport { captureRequest } from './capture/captureRequest'\nimport { makeExclusionHandler } from './capture/exclusionEndpoint'\nimport { proxyEndpoints } from './capture/proxyEndpoint'\nimport { trackerEndpoint } from './capture/trackerEndpoint'\nimport { assertMaintainRegistered, TASK_SLUGS } from './core/jobs'\nimport {\n\ttype AnalyticsPluginOptions,\n\tadapterCountsWithoutConsent,\n\tresolveOptions,\n\ttype ScopeCallSite,\n} from './core/options'\nimport { createRegistry, withoutRevenue } from './core/registry'\nimport { CURRENCY_PATTERN } from './goals/currency'\nimport { makeGoalsHandler } from './goals/goalsEndpoint'\nimport { applyConfigRevenueVisibility } from './goals/moneyFields'\nimport { configGoalsResolver } from './goals/resolver'\nimport type { Goal } from './goals/types'\nimport { addComponentDependency, FLAG_DEPENDENCY } from './plugin/adminDependencies'\nimport { expectedCollections } from './plugin/collectionChecks'\nimport { createRuntimeFactory } from './plugin/createRuntime'\nimport { makeDocumentHandler } from './plugin/documentEndpoint'\nimport { makeFlagsHandler } from './plugin/flagsEndpoint'\nimport { restrictJobControls } from './plugin/jobsAccess'\nimport {\n\taddStateCollection,\n\ttype CollectionContext,\n\tcacheCollectionOf,\n\tconfigCollections,\n\tsyncCollectionOf,\n} from './plugin/pluginCollections'\nimport { makeQueryHandler } from './plugin/queryEndpoint'\nimport { makeRealtimeHandler } from './plugin/realtimeEndpoint'\nimport { makeRefreshHandler } from './plugin/refreshEndpoint'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { relabelFactoryFields } from './plugin/relabelFields'\nimport { assertRoutesReachable } from './plugin/routeChecks'\nimport {\n\tANALYTICS_CONFIG_KEY,\n\ttype AnalyticsAdminCustom,\n\tpluginEndpoint,\n\troutePaths,\n} from './plugin/routes'\nimport { getRuntime, resolveGoalsFor, resolveRegistryFor, runtimeFactoryOf } from './plugin/runtime'\nimport { addTask, schemaOnly } from './plugin/schemaOnly'\nimport { changedScopes, type ScopeChange } from './plugin/scopeChange'\nimport { makeSourcesHandler } from './plugin/sourcesEndpoint'\nimport { fillUnbundledLanguages, unbundledLanguages } from './plugin/unbundledLanguages'\nimport { warmTask } from './plugin/warmTask'\nimport { syncTask } from './sync/syncTask'\nimport { createStrictTimezoneResolver, createTimezoneResolver } from './timeframe/reportingTimezone'\nimport { keys } from './translations/keys'\nimport { createStaticLabels } from './translations/staticLabel'\nimport { registerView } from './view/registerView'\nimport { registerWidgets } from './widgets/registerWidgets'\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/analytics': AnalyticsPluginOptions\n\t}\n}\n\n/**\n * Rereads the scopes a providers or goals save touched, on the instance that wrote; every other\n * instance catches up through its own probe.\n */\nconst configChanged =\n\t(collection: 'providers' | 'goals') =>\n\t(change: ScopeChange, req: PayloadRequest): void => {\n\t\tgetRuntime(req.payload)?.configChanged?.(collection, changedScopes(change))\n\t}\n\nconst addEndpoints = (config: Config, ...endpoints: Endpoint[]): void => {\n\tconfig.endpoints = [...(config.endpoints ?? []), ...endpoints]\n}\n\nexport const analytics = definePlugin<AnalyticsPluginOptions>({\n\tslug: '@10x-media/analytics',\n\tplugin: async ({ config, plugins: _plugins, ...options }): Promise<Config> => {\n\t\tconst disabled = options.disabled === true\n\t\t// Switched off, nothing reads through the adapters: they are only asked for their schema.\n\t\tconst resolved = resolveOptions(options, { requireAdapters: !disabled })\n\t\tconst resolveScope = async (req: PayloadRequest, callSite: ScopeCallSite) =>\n\t\t\tresolved.scope.resolve({ req, callSite })\n\t\tconst resolveAdminScope = (req: PayloadRequest) => resolveScope(req, 'admin')\n\t\t// What the collection checks warn about waits for the instance's logger, at init.\n\t\tconst notices: string[] = []\n\t\t// Read before the plugin merges its own strings in, so the app's own still win.\n\t\tconst staticLabel = createStaticLabels({\n\t\t\tapp: config.i18n?.translations,\n\t\t\tplugin: options.translations,\n\t\t\tunbundled: unbundledLanguages(config),\n\t\t})\n\t\tconst context: CollectionContext = {\n\t\t\tdb: config.db?.name,\n\t\t\tnotice: (message) => {\n\t\t\t\tnotices.push(message)\n\t\t\t},\n\t\t\tstaticLabel,\n\t\t}\n\t\tconst collections = await configCollections(\n\t\t\tresolved,\n\t\t\t{ resolveAdminScope, onChange: configChanged },\n\t\t\tcontext\n\t\t)\n\t\tconst sync = syncCollectionOf(resolved, resolveAdminScope, context)\n\t\tif (disabled) {\n\t\t\treturn schemaOnly(config, {\n\t\t\t\tresolved,\n\t\t\t\tcollections,\n\t\t\t\tcontext,\n\t\t\t\t...(sync ? { sync } : {}),\n\t\t\t\t...(options.translations ? { translations: options.translations } : {}),\n\t\t\t})\n\t\t}\n\t\tconst routes = routePaths(resolved.routes.base)\n\t\t// Whatever is mounted before the plugin runs belongs to the host or an earlier plugin.\n\t\tconst earlierEndpoints = new Set(config.endpoints ?? [])\n\t\tconst money = resolved.revenue.enabled\n\t\t// A runtime provider's capabilities are unknown at config time, so providers open the\n\t\t// widget and endpoint gates that otherwise follow the config adapters' capabilities.\n\t\tconst providersEnabled =\n\t\t\tresolved.providers.collection.enabled || Boolean(resolved.providers.resolve)\n\t\t// Read before the adapters register: only a host that turned it on may carry concurrency keys.\n\t\tconst jobsConcurrency = config.jobs?.enableConcurrencyControl === true\n\t\tregisterTranslations(config, options.translations)\n\t\tfillUnbundledLanguages(config)\n\t\tconst registry = createRegistry(resolved.adapters, resolved.defaultAdapter)\n\t\t// Adapters ask for a scope to stamp a visitor's hit with, so theirs is the capture call\n\t\t// site, asked without the signed-in user or their cookies.\n\t\tconst resolveCaptureScope = (req: PayloadRequest) =>\n\t\t\tresolveScope(captureRequest(req), 'capture')\n\t\t/**\n\t\t * Whether a scope's own committed provider documents grant it this adapter (a beacon decrypts\n\t\t * nothing). Handed to adapters only when `scope.resolve` and the providers collection both run.\n\t\t */\n\t\tconst adapterGrantedForScope = async (\n\t\t\treq: PayloadRequest,\n\t\t\tscope: string | null,\n\t\t\tadapterId: string\n\t\t): Promise<boolean> => {\n\t\t\tconst runtime = getRuntime(req.payload)\n\t\t\tif (!runtime) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (runtime.providerGranted) {\n\t\t\t\treturn runtime.providerGranted(scope, adapterId)\n\t\t\t}\n\t\t\tconst { grants } = await resolveRegistryFor(runtime, { payload: req.payload, req, scope })\n\t\t\treturn grants.has(adapterId)\n\t\t}\n\t\tconst configGoals = configGoalsResolver(resolved.goals, resolved.purchaseGoal)\n\t\t/** The goals of the instance a request reached, which adapters resolve at ingest. */\n\t\tconst resolveGoals = (req: PayloadRequest, scope?: string | null): Promise<Goal[]> => {\n\t\t\tconst runtime = getRuntime(req.payload)\n\t\t\treturn runtime ? resolveGoalsFor(runtime, req, scope) : configGoals.resolve(req, scope)\n\t\t}\n\t\tconfig.collections = [...(config.collections ?? []), ...collections]\n\t\tconst timezoneArgs = { option: resolved.reportingTimezone, resolveScope: resolveAdminScope }\n\t\tconst resolveTimezone = createTimezoneResolver(timezoneArgs)\n\t\tconst resolveTimezoneStrict = createStrictTimezoneResolver(timezoneArgs)\n\t\tconst resolveCurrency = async (\n\t\t\treq: PayloadRequest,\n\t\t\tscope?: string | null\n\t\t): Promise<string | undefined> => {\n\t\t\tconst opt = resolved.revenue.currency\n\t\t\tif (opt === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof opt === 'string'\n\t\t\t\t\t\t? opt\n\t\t\t\t\t\t: await opt({ req, scope: scope !== undefined ? scope : await resolveAdminScope(req) })\n\t\t\t\treturn code && CURRENCY_PATTERN.test(code) ? code : undefined\n\t\t\t} catch (err) {\n\t\t\t\treq.payload?.logger?.warn?.(\n\t\t\t\t\t`analytics: revenue.currency resolution failed, reporting revenue unformatted: ${String(err)}`\n\t\t\t\t)\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t}\n\t\tconst itemCollections = itemCollectionsOf(resolved.bindings)\n\t\tfor (const adapter of resolved.adapters) {\n\t\t\tadapter.register?.(config, {\n\t\t\t\tscoped: resolved.scoped,\n\t\t\t\tresolveScope: resolveCaptureScope,\n\t\t\t\tresolveTimezone,\n\t\t\t\tresolveTimezoneStrict,\n\t\t\t\trevenue: {\n\t\t\t\t\tenabled: money,\n\t\t\t\t\tdimension: resolved.revenue.dimension,\n\t\t\t\t\tcurrency: resolveCurrency,\n\t\t\t\t\tconvert: resolved.revenue.convert,\n\t\t\t\t\tbrowserAmounts: resolved.revenue.browserAmounts,\n\t\t\t\t\torderSignature: resolved.revenue.orderSignature,\n\t\t\t\t},\n\t\t\t\tresolveGoals,\n\t\t\t\t...(resolved.scoped && resolved.providers.collection.enabled\n\t\t\t\t\t? { adapterGrantedForScope }\n\t\t\t\t\t: {}),\n\t\t\t\ttrustedProxyHops: resolved.trustedProxyHops,\n\t\t\t\ttrustedPlatform: resolved.trustedPlatform,\n\t\t\t\tallowedOrigins: resolved.capture.allowedOrigins,\n\t\t\t\tadapterCountsWithoutConsent: adapterCountsWithoutConsent(resolved, adapter),\n\t\t\t\t...(itemCollections.size > 0\n\t\t\t\t\t? {\n\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\tcollections: itemCollections,\n\t\t\t\t\t\t\t\tpages: resolved.capture.autoCapture.items.pages,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\troutes,\n\t\t\t\tsdks: resolved.sdks,\n\t\t\t\tjobs: resolved.jobs,\n\t\t\t\tjobsConcurrency,\n\t\t\t\tnotice: context.notice,\n\t\t\t})\n\t\t}\n\t\tassertMaintainRegistered(\n\t\t\tresolved.jobs,\n\t\t\t(config.jobs?.tasks ?? []).some((task) => task.slug === TASK_SLUGS.maintain)\n\t\t)\n\t\t// After registration: an adapter declares what the install measures once it is registered,\n\t\t// and one that declares no revenue then is read as it is rather than as a copy.\n\t\tconst readRegistry = money ? registry : withoutRevenue(registry)\n\t\tif (\n\t\t\tresolved.adapters.some((a) => a.capabilities.realtime && typeof a.realtime === 'function') ||\n\t\t\tprovidersEnabled\n\t\t) {\n\t\t\taddEndpoints(config, { method: 'get', path: routes.live, handler: makeRealtimeHandler() })\n\t\t}\n\t\tif (Object.keys(resolved.bindings).length > 0) {\n\t\t\taddEndpoints(config, { method: 'get', path: routes.document, handler: makeDocumentHandler() })\n\t\t}\n\t\taddEndpoints(\n\t\t\tconfig,\n\t\t\t{ method: 'get', path: routes.sources, handler: makeSourcesHandler() },\n\t\t\t{ method: 'get', path: routes.goals, handler: makeGoalsHandler() },\n\t\t\t{ method: 'get', path: routes.query, handler: makeQueryHandler() },\n\t\t\t{ method: 'post', path: routes.refresh, handler: makeRefreshHandler() }\n\t\t)\n\t\tif (resolved.capture.exclusion) {\n\t\t\taddEndpoints(config, {\n\t\t\t\tmethod: 'get',\n\t\t\t\tpath: routes.exclusion,\n\t\t\t\thandler: makeExclusionHandler(),\n\t\t\t})\n\t\t}\n\t\t// One answer serves the view, the widgets and the route, so the flags an install draws and\n\t\t// the route serving them cannot diverge. A host's own flag needs no route, only the import map.\n\t\tconst countryFlags = resolved.countryFlags\n\t\tif (countryFlags === true) {\n\t\t\taddEndpoints(config, {\n\t\t\t\tmethod: 'get',\n\t\t\t\tpath: routes.flagsPattern,\n\t\t\t\thandler: makeFlagsHandler(),\n\t\t\t})\n\t\t} else if (countryFlags !== false) {\n\t\t\taddComponentDependency(config, FLAG_DEPENDENCY, countryFlags.Component)\n\t\t}\n\t\t// A runtime provider's capture support is unknown at config time, so providers\n\t\t// alone are enough to mount the proxy; every slot is still resolved per request.\n\t\tif (resolved.adapters.some((a) => a.capture) || providersEnabled) {\n\t\t\taddEndpoints(config, ...proxyEndpoints(routes), trackerEndpoint(routes))\n\t\t}\n\t\tif (resolved.widgets.enabled) {\n\t\t\tconst multiProvider = registry.isMultiProvider() || providersEnabled\n\t\t\tregisterWidgets(config, {\n\t\t\t\tadapters: resolved.adapters,\n\t\t\t\tmultiProvider,\n\t\t\t\tprovidersEnabled,\n\t\t\t\trevenue: money,\n\t\t\t\tdisabled: resolved.widgets.disabled,\n\t\t\t\tregister: resolved.widgets.register,\n\t\t\t\tlocalizeText: resolved.widgets.localizeText,\n\t\t\t\tdefaultId: resolved.defaultAdapter,\n\t\t\t\tcomparison: resolved.widgets.comparison,\n\t\t\t\tcountryFlags,\n\t\t\t\tstaticLabel,\n\t\t\t\toverrides: resolved.widgets.overrides,\n\t\t\t\tview:\n\t\t\t\t\tresolved.view === false\n\t\t\t\t\t\t? false\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tpath: resolved.view.path,\n\t\t\t\t\t\t\t\tdefaultRange: resolved.view.defaultRange,\n\t\t\t\t\t\t\t\tdefaultMetric: resolved.view.defaultMetric,\n\t\t\t\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tregisterView(config, { view: resolved.view, title: staticLabel(keys.viewTitle) })\n\t\tconst { jobs } = resolved\n\t\tif (jobs !== false && resolved.cache.warm.enabled) {\n\t\t\taddTask(\n\t\t\t\tconfig,\n\t\t\t\twarmTask({\n\t\t\t\t\tschedule: jobs.warm,\n\t\t\t\t\twindowHours: resolved.cache.warm.windowHours,\n\t\t\t\t\tmaxReads: resolved.cache.warm.maxReads,\n\t\t\t\t\tconcurrency: jobsConcurrency,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\t\tif (sync) {\n\t\t\tconfig.collections = [...(config.collections ?? []), sync]\n\t\t\tif (jobs !== false) {\n\t\t\t\taddTask(\n\t\t\t\t\tconfig,\n\t\t\t\t\tsyncTask({\n\t\t\t\t\t\tschedule: jobs.sync,\n\t\t\t\t\t\tlookbackDays: resolved.sync.lookbackDays,\n\t\t\t\t\t\tcollectionSlug: resolved.sync.collection.slug,\n\t\t\t\t\t\tadapterIds: resolved.sync.adapters,\n\t\t\t\t\t\tscopes: resolved.scope.list,\n\t\t\t\t\t\tconcurrency: jobsConcurrency,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tconst cache = cacheCollectionOf(resolved, context)\n\t\tif (cache) {\n\t\t\tconfig.collections = [...(config.collections ?? []), cache]\n\t\t}\n\t\taddStateCollection(config, resolved, context)\n\t\trestrictJobControls(config)\n\t\t// Hidden per config rather than per process, so two instances answer for themselves; a later\n\t\t// plugin's fields (form-builder's action blocks) take their factory's own `revenue` option.\n\t\tapplyConfigRevenueVisibility(config, money)\n\t\trelabelFactoryFields(config, staticLabel)\n\t\tconfig.endpoints = (config.endpoints ?? []).map((endpoint) =>\n\t\t\tearlierEndpoints.has(endpoint) ? endpoint : pluginEndpoint(endpoint)\n\t\t)\n\t\t// Checked against everything registered so far, the plugin's own collections included; what a\n\t\t// later plugin adds is caught when a runtime is built from the assembled config.\n\t\tassertRoutesReachable(resolved.routes.base, {\n\t\t\tcollections: config.collections ?? [],\n\t\t\tendpoints: config.endpoints,\n\t\t})\n\t\tconst factory = createRuntimeFactory({\n\t\t\tresolved,\n\t\t\tnotices,\n\t\t\tcollections: expectedCollections(config.collections),\n\t\t\tregistry: readRegistry,\n\t\t\tresolveScope,\n\t\t\tresolveTimezone,\n\t\t\tresolveCurrency,\n\t\t})\n\t\tconst adminCustom: AnalyticsAdminCustom = { routes: { base: resolved.routes.base } }\n\t\tconfig.custom = { ...config.custom, [ANALYTICS_CONFIG_KEY]: factory }\n\t\tconfig.admin = {\n\t\t\t...config.admin,\n\t\t\tcustom: { ...config.admin?.custom, [ANALYTICS_CONFIG_KEY]: adminCustom },\n\t\t}\n\t\tconst prevOnInit = config.onInit\n\t\t// Validation only: the runtime builds on first use either way, and is built here so consumer\n\t\t// init code (seeding, cache warming, sync passes) runs against a warm one.\n\t\tconfig.onInit = async (payload) => {\n\t\t\t// Without the factory every endpoint answers 503; a boot error names the cause instead.\n\t\t\tif (runtimeFactoryOf(payload.config) !== factory) {\n\t\t\t\tthrow new Error(RUNTIME_FACTORY_LOST)\n\t\t\t}\n\t\t\tawait factory.validate(payload)\n\t\t\tgetRuntime(payload)\n\t\t\tawait prevOnInit?.(payload)\n\t\t}\n\t\treturn config\n\t},\n})\n\n/** Said at boot when a step after the plugin dropped its runtime from `config.custom`. */\nconst RUNTIME_FACTORY_LOST = `analytics: config.custom[\"${ANALYTICS_CONFIG_KEY}\"] no longer holds the analytics runtime: a plugin or config step that runs after analytics replaced config.custom instead of spreading it. Spread the existing value there ({ ...config.custom, ... }), or list analytics after that plugin.`\n\nexport { isAdminUser } from './access/adminUser'\nexport { type TenantMembershipOptions, tenantMembership } from './access/membership'\nexport { type GatedScope, type ReadPrincipal, SYSTEM } from './access/principal'\nexport { ProviderHttpError, parseRetryAfter } from './adapters/http/fetchJson'\nexport type { ReportMode, ReportOption } from './binding/report'\nexport type {\n\tAnalyticsBinding,\n\tBindingContext,\n\tBindingDoc,\n\tHostnameResolver,\n\tPathResolver,\n} from './binding/types'\nexport type { CapabilityRequirement, FilterPair, SerializedCapabilities } from './core/capabilities'\nexport {\n\ttype AnalyticsQuery,\n\ttype AnalyticsResult,\n\tPLATFORM_SCOPE,\n} from './core/contract'\nexport type {\n\tAnalyticsAccessOptions,\n\tAnalyticsCacheCollectionOptions,\n\tAnalyticsCacheOptions,\n\tAnalyticsCaptureOptions,\n\tAnalyticsCollectionOptions,\n\tAnalyticsComponent,\n\tAnalyticsConcurrencyOptions,\n\tAnalyticsCountryFlags,\n\tAnalyticsCrossScopeOptions,\n\tAnalyticsExclusionOptions,\n\tAnalyticsGoalsCollectionOptions,\n\tAnalyticsGoalsOptions,\n\tAnalyticsHooksOptions,\n\tAnalyticsJobsOptions,\n\tAnalyticsPluginOptions,\n\tAnalyticsPluginOptions as PluginOptions,\n\tAnalyticsReadAccess,\n\tAnalyticsRevenueOptions,\n\tAnalyticsRoutesOptions,\n\tAnalyticsScopeOptions,\n\tAnalyticsSourceOptions,\n\tAnalyticsSyncCollectionOptions,\n\tAnalyticsSyncOptions,\n\tAnalyticsTaskOptions,\n\tAnalyticsViewAccess,\n\tAnalyticsViewOptions,\n\tAnalyticsWarmOptions,\n\tAnalyticsWidgetOverride,\n\tAnalyticsWidgetOverrides,\n\tAnalyticsWidgetsOptions,\n\tAutoCaptureOptions,\n\tCaptureGate,\n\tCaptureGateArgs,\n\tCaptureSlotOption,\n\tCollectionOverrides,\n\tCrossScopeAccess,\n\tCurrencyConverter,\n\tCurrencyResolver,\n\tDefaultSourceFunction,\n\tDefaultSourceRule,\n\tExclusionSitesResolver,\n\tItemCaptureOptions,\n\tOwnSource,\n\tProviderHostsOptions,\n\tProvidersCollectionOptions,\n\tProvidersOptions,\n\tProvidersResolve,\n\tProvidersResolveArgs,\n\tScopeCallSite,\n\tScopeLabelResolver,\n\tScopeListResolver,\n\tScopeMemberAccess,\n\tScopeResolver,\n\tSourcePolicy,\n\tSourcePolicyFunction,\n\tSourceRef,\n\tTimezoneResolver,\n\tWithoutConsentArgs,\n\tWithoutConsentFunction,\n\tWithoutConsentOption,\n} from './core/options'\nexport type {\n\tAnalyticsSdks,\n\tGa4Client,\n\tGa4ClientOptions,\n\tGa4ReportResponse,\n\tGa4ReportRow,\n\tGa4Sdk,\n\tMaxmindReader,\n\tMaxmindSdk,\n} from './core/sdks'\nexport type {\n\tServerEventInput,\n\tServerTrack,\n\tServerTrackIdentity,\n\tServerTrackOptions,\n} from './core/serverEvent'\nexport { AnalyticsTrackError } from './core/serverEvent'\nexport { BUILT_IN_WIDGET_SLUGS, type BuiltInWidgetSlug } from './core/widgetSlugs'\nexport type * from './exports/adapters/contract'\nexport type { AnalyticsAttributes } from './exports/attributes'\nexport type {\n\tAnalyticsFieldsOptions,\n\tAnalyticsMetricLabel,\n\tAnalyticsMetricLabels,\n\tAnalyticsStatBaseOptions,\n\tAnalyticsStatOptions,\n\tAnalyticsStatRowOptions,\n\tAnalyticsTabOptions,\n} from './fields/factories'\nexport {\n\tanalyticsFields,\n\tanalyticsStat,\n\tanalyticsStatRow,\n\tanalyticsTab,\n\tanalyticsTabsField,\n} from './fields/factories'\nexport type {\n\tFieldBreakdown,\n\tFieldBreakdownRow,\n\tFieldReadResult,\n\tFieldReadStatus,\n\tReadForFieldArgs,\n} from './fields/readForDocument'\nexport { readForField } from './fields/readForDocument'\nexport type {\n\tGoalCollectionFieldOverrides,\n\tGoalFieldOverride,\n} from './goals/collection'\nexport { GOALS_SLUG } from './goals/collection'\nexport {\n\tCURRENCY_ATTRIBUTE,\n\tEVENT_ATTRIBUTE,\n\tEVENT_PROP_PREFIX,\n\tGOAL_ATTRIBUTE,\n\tITEM_ATTRIBUTE,\n\tITEM_CLICK_EVENT,\n\tITEM_NAME_ATTRIBUTE,\n\tMAX_ITEMS_PER_BEACON,\n\tPURCHASE_GOAL_SLUG,\n\tVALUE_ATTRIBUTE,\n} from './goals/constants'\nexport type { GoalFieldOptions } from './goals/goalField'\nexport { goalField, goalSlug } from './goals/goalField'\nexport type { GoalsResponse, WireGoal } from './goals/goalsEndpoint'\nexport type { AnalyticsLinkFieldsOptions } from './goals/linkFields'\nexport { analyticsLinkFields } from './goals/linkFields'\nexport type { BrowserAmounts, OrderSignatureMode } from './goals/match'\nexport type { GoalSource } from './goals/resolver'\nexport type {\n\tPurchaseInput as ServerPurchaseInput,\n\tRefundInput as ServerRefundInput,\n} from './goals/serverRevenue'\nexport { purchase, refund } from './goals/serverRevenue'\nexport type {\n\tGoalActionDefinition,\n\tGoalActionRunArgs,\n\tTrackGoalActionOptions,\n} from './goals/trackGoalAction'\nexport { GOAL_ACTION_TYPE, trackGoalAction } from './goals/trackGoalAction'\nexport type { Goal } from './goals/types'\nexport { STATE_SLUG } from './native/collections/slugs'\nexport type { RebuildDaysInput, RebuildDaysReport } from './native/engine/rebuild'\nexport {\n\ttype ItemSignatureMode,\n\titemAttributesFor,\n\tsignItemRef,\n} from './native/ingest/itemSignature'\nexport { signOrderId } from './native/ingest/orderSignature'\nexport { trackServerEvent } from './native/ingest/serverTrack'\nexport { rebuildDays } from './native/rebuildDays'\nexport {\n\tcreateGuardedFetch,\n\ttype GuardedFetch,\n\ttype GuardedFetchOptions,\n} from './net/guardedFetch'\nexport type { TrustedPlatform } from './net/platform'\nexport type { CollectionFieldOverride } from './plugin/collectionFields'\nexport {\n\tANALYTICS_ERROR_CODES,\n\ttype AnalyticsError,\n\ttype AnalyticsErrorCode,\n\tanalyticsError,\n\treadErrorCode,\n} from './plugin/errors'\nexport type { RoutesConfigSource } from './plugin/routes'\nexport {\n\tanalyticsRoutes,\n\tDEFAULT_ROUTE_BASE,\n\ttype RouteBase,\n\ttype RoutePaths,\n\troutePaths,\n} from './plugin/routes'\nexport type {\n\tBuildSecretField,\n\tConnectionAccess,\n\tConnectionFieldAccess,\n\tProviderCollectionFieldOverrides,\n\tProviderFieldOverride,\n\tProviderFieldsOptions,\n} from './providers/collection'\nexport { analyticsProviderFields, PROVIDERS_SLUG } from './providers/collection'\nexport type { ProviderDoc, ProviderFactoryContext, ProviderId } from './providers/factory'\nexport { adapterFromProviderDoc, PROVIDER_IDS } from './providers/factory'\nexport type { HostPattern } from './providers/hosts'\nexport { type ProviderHostPolicy, resolveHostPolicy } from './providers/hosts'\nexport { type RefreshProvidersOptions, refreshProviders } from './providers/refresh'\nexport { CONNECTION_PATHS, SECRET_PATHS } from './providers/secrets'\nexport type { QueryError, QueryErrorCode } from './query/errors'\nexport type {\n\tItemLabels,\n\tQueryErrorResponse,\n\tQueryResponse,\n\tQuerySourceRef,\n\tSerializedAnalyticsQuery,\n} from './query/response'\nexport type {\n\tAfterReadAnswer,\n\tAfterReadArgs,\n\tAfterReadHook,\n\tReadOrigin,\n} from './surfacing/afterRead'\nexport { CACHE_SLUG } from './surfacing/cacheCollection'\nexport type {\n\tCacheEntry,\n\tCacheSetOptions,\n\tCacheStore,\n\tReadRecipe,\n\tRecipeWindow,\n} from './surfacing/cacheStore'\nexport { SYNC_SLUG } from './sync/collection'\nexport { TIMEFRAME_PRESETS, type TimeframePreset } from './timeframe/presets'\nexport type { GoalMatch, RevenueItem, TrackerGoal } from './tracker/config'\nexport type { TranslationsOption } from './translations'\nexport {\n\tkeys,\n\ttype PluralCategory,\n\ttype PluralName,\n\ttype PluralVariant,\n\tpluralKeys,\n\ttype SingularKey,\n\ttype TranslationKey,\n} from './translations/keys'\nexport type { CustomWidgetDef } from './widgets/customWidget'\nexport {\n\ttype AnalyticsDefaultLayoutOptions,\n\tanalyticsDefaultLayout,\n} from './widgets/defaultLayout'\nexport { analyticsDefaultWidgets } from './widgets/defaults'\nexport { widgetFilters } from './widgets/filterField'\nexport type { StoredSourceRead, SubstitutedSource } from './widgets/prepareWidgetRead'\nexport type {\n\tReadForWidgetArgs,\n\tWidgetReadResult,\n\tWidgetReadStatus,\n} from './widgets/readForWidget'\nexport { readForWidget } from './widgets/readForWidget'\nexport type {\n\tBreakdownRow,\n\tReadForWidgetBreakdownArgs,\n\tWidgetBreakdownResult,\n} from './widgets/readForWidgetBreakdown'\nexport { readForWidgetBreakdown } from './widgets/readForWidgetBreakdown'\nexport type {\n\tGoalRow,\n\tReadForWidgetGoalsArgs,\n\tWidgetGoalsResult,\n} from './widgets/readForWidgetGoals'\nexport { readForWidgetGoals } from './widgets/readForWidgetGoals'\nexport type {\n\tReadForWidgetRealtimeArgs,\n\tRealtimePoint,\n\tWidgetRealtimeResult,\n\tWidgetRealtimeStatus,\n} from './widgets/readForWidgetRealtime'\nexport { readForWidgetRealtime } from './widgets/readForWidgetRealtime'\nexport type {\n\tReadForWidgetSeriesArgs,\n\tSeriesGranularity,\n\tSeriesPoint,\n\tWidgetSeriesResult,\n} from './widgets/readForWidgetSeries'\nexport { readForWidgetSeries } from './widgets/readForWidgetSeries'\nexport type { ReadNotices } from './widgets/readMeta'\nexport type { WidgetFilter } from './widgets/types'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,iBACJ,gBACA,QAAqB,QAA8B;CACnD,WAAW,IAAI,OAAO,GAAG,gBAAgB,YAAY,cAAc,MAAM,CAAC;AAC3E;AAED,MAAM,gBAAgB,QAAgB,GAAG,cAAgC;CACxE,OAAO,YAAY,CAAC,GAAI,OAAO,aAAa,CAAC,GAAI,GAAG,SAA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","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Config, definePlugin, type Endpoint, type PayloadRequest } from 'payload'\n\nimport { itemCollectionsOf } from './binding/report'\nimport { captureRequest } from './capture/captureRequest'\nimport { makeExclusionHandler } from './capture/exclusionEndpoint'\nimport { proxyEndpoints } from './capture/proxyEndpoint'\nimport { trackerEndpoint } from './capture/trackerEndpoint'\nimport { assertMaintainRegistered, TASK_SLUGS } from './core/jobs'\nimport {\n\ttype AnalyticsPluginOptions,\n\tadapterCountsWithoutConsent,\n\tresolveOptions,\n\ttype ScopeCallSite,\n} from './core/options'\nimport { createRegistry, withoutRevenue } from './core/registry'\nimport { afterTransaction, openTransactionOf } from './db/openTransaction'\nimport { CURRENCY_PATTERN } from './goals/currency'\nimport { makeGoalsHandler } from './goals/goalsEndpoint'\nimport { applyConfigRevenueVisibility } from './goals/moneyFields'\nimport { configGoalsResolver } from './goals/resolver'\nimport type { Goal } from './goals/types'\nimport { addComponentDependency, FLAG_DEPENDENCY } from './plugin/adminDependencies'\nimport { expectedCollections } from './plugin/collectionChecks'\nimport { createRuntimeFactory } from './plugin/createRuntime'\nimport { makeDocumentHandler } from './plugin/documentEndpoint'\nimport { makeFlagsHandler } from './plugin/flagsEndpoint'\nimport { restrictJobControls } from './plugin/jobsAccess'\nimport {\n\taddStateCollection,\n\ttype CollectionContext,\n\tcacheCollectionOf,\n\tconfigCollections,\n\tsyncCollectionOf,\n} from './plugin/pluginCollections'\nimport { makeProviderStatusHandler } from './plugin/providerStatusEndpoint'\nimport { makeQueryHandler } from './plugin/queryEndpoint'\nimport { makeRealtimeHandler } from './plugin/realtimeEndpoint'\nimport { makeRefreshHandler } from './plugin/refreshEndpoint'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { relabelFactoryFields } from './plugin/relabelFields'\nimport { assertRoutesReachable } from './plugin/routeChecks'\nimport {\n\tANALYTICS_CONFIG_KEY,\n\ttype AnalyticsAdminCustom,\n\tpluginEndpoint,\n\troutePaths,\n} from './plugin/routes'\nimport { getRuntime, resolveGoalsFor, resolveRegistryFor, runtimeFactoryOf } from './plugin/runtime'\nimport { addTask, schemaOnly } from './plugin/schemaOnly'\nimport { changedScopes, type ScopeChange } from './plugin/scopeChange'\nimport { makeSourcesHandler } from './plugin/sourcesEndpoint'\nimport { fillUnbundledLanguages, unbundledLanguages } from './plugin/unbundledLanguages'\nimport { warmTask } from './plugin/warmTask'\nimport type { ProviderStatusStore } from './providers/status'\nimport { syncTask } from './sync/syncTask'\nimport { createStrictTimezoneResolver, createTimezoneResolver } from './timeframe/reportingTimezone'\nimport { keys } from './translations/keys'\nimport { createStaticLabels } from './translations/staticLabel'\nimport { registerView } from './view/registerView'\nimport { registerWidgets } from './widgets/registerWidgets'\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/analytics': AnalyticsPluginOptions\n\t}\n}\n\n/**\n * Rereads the scopes a providers or goals save touched, on the instance that wrote; every other\n * instance catches up through its own probe.\n */\nconst configChanged =\n\t(collection: 'providers' | 'goals') =>\n\t(change: ScopeChange, req: PayloadRequest): void => {\n\t\tgetRuntime(req.payload)?.configChanged?.(collection, changedScopes(change))\n\t}\n\n/**\n * Runs a status write of a saved or deleted provider document once the save's own transaction is\n * over: a write outside it would wait on the locks it holds. The save goes on whatever happens\n * here; the next read or check writes the row again.\n */\nconst afterProviderSave = async (\n\treq: PayloadRequest,\n\t{\n\t\tdocId,\n\t\tfailed,\n\t\twrite,\n\t}: { docId: string; failed: string; write: (store: ProviderStatusStore) => Promise<void> }\n): Promise<void> => {\n\tconst runtime = getRuntime(req.payload)\n\tconst store = runtime?.providerStatus\n\tif (!runtime || !store) {\n\t\treturn\n\t}\n\tconst run = () =>\n\t\twrite(store).catch((err: unknown) => {\n\t\t\truntime.providerStatusWarning?.(\n\t\t\t\t`analytics: the connection status of provider document \"${docId}\" could not be ${failed}: ${String(err)}`\n\t\t\t)\n\t\t})\n\tconst open = await openTransactionOf(req.payload, req)\n\tif (!open) {\n\t\tawait run()\n\t\treturn\n\t}\n\truntime.engine.keep?.(afterTransaction(open, run))\n}\n\nconst forgetProviderStatus = (docId: string, req: PayloadRequest): Promise<void> =>\n\tafterProviderSave(req, { docId, failed: 'cleared', write: (store) => store.forget(docId) })\n\nconst carryProviderStatus = (\n\tdocId: string,\n\t{ from, to }: { from: string; to: string },\n\treq: PayloadRequest\n): Promise<void> =>\n\tafterProviderSave(req, { docId, failed: 'kept', write: (store) => store.carry(docId, from, to) })\n\nconst addEndpoints = (config: Config, ...endpoints: Endpoint[]): void => {\n\tconfig.endpoints = [...(config.endpoints ?? []), ...endpoints]\n}\n\nexport const analytics = definePlugin<AnalyticsPluginOptions>({\n\tslug: '@10x-media/analytics',\n\tplugin: async ({ config, plugins: _plugins, ...options }): Promise<Config> => {\n\t\tconst disabled = options.disabled === true\n\t\t// Switched off, nothing reads through the adapters: they are only asked for their schema.\n\t\tconst resolved = resolveOptions(options, { requireAdapters: !disabled })\n\t\tconst resolveScope = async (req: PayloadRequest, callSite: ScopeCallSite) =>\n\t\t\tresolved.scope.resolve({ req, callSite })\n\t\tconst resolveAdminScope = (req: PayloadRequest) => resolveScope(req, 'admin')\n\t\t// What the collection checks warn about waits for the instance's logger, at init.\n\t\tconst notices: string[] = []\n\t\t// Read before the plugin merges its own strings in, so the app's own still win.\n\t\tconst staticLabel = createStaticLabels({\n\t\t\tapp: config.i18n?.translations,\n\t\t\tplugin: options.translations,\n\t\t\tunbundled: unbundledLanguages(config),\n\t\t})\n\t\tconst context: CollectionContext = {\n\t\t\tdb: config.db?.name,\n\t\t\tnotice: (message) => {\n\t\t\t\tnotices.push(message)\n\t\t\t},\n\t\t\tstaticLabel,\n\t\t}\n\t\tconst collections = await configCollections(\n\t\t\tresolved,\n\t\t\t{ resolveAdminScope, onChange: configChanged, forgetProviderStatus, carryProviderStatus },\n\t\t\tcontext\n\t\t)\n\t\tconst sync = syncCollectionOf(resolved, resolveAdminScope, context)\n\t\tif (disabled) {\n\t\t\treturn schemaOnly(config, {\n\t\t\t\tresolved,\n\t\t\t\tcollections,\n\t\t\t\tcontext,\n\t\t\t\t...(sync ? { sync } : {}),\n\t\t\t\t...(options.translations ? { translations: options.translations } : {}),\n\t\t\t})\n\t\t}\n\t\tconst routes = routePaths(resolved.routes.base)\n\t\t// Whatever is mounted before the plugin runs belongs to the host or an earlier plugin.\n\t\tconst earlierEndpoints = new Set(config.endpoints ?? [])\n\t\tconst money = resolved.revenue.enabled\n\t\t// A runtime provider's capabilities are unknown at config time, so providers open the\n\t\t// widget and endpoint gates that otherwise follow the config adapters' capabilities.\n\t\tconst providersEnabled =\n\t\t\tresolved.providers.collection.enabled || Boolean(resolved.providers.resolve)\n\t\t// Read before the adapters register: only a host that turned it on may carry concurrency keys.\n\t\tconst jobsConcurrency = config.jobs?.enableConcurrencyControl === true\n\t\tregisterTranslations(config, options.translations)\n\t\tfillUnbundledLanguages(config)\n\t\tconst registry = createRegistry(resolved.adapters, resolved.defaultAdapter)\n\t\t// Adapters ask for a scope to stamp a visitor's hit with, so theirs is the capture call\n\t\t// site, asked without the signed-in user or their cookies.\n\t\tconst resolveCaptureScope = (req: PayloadRequest) =>\n\t\t\tresolveScope(captureRequest(req), 'capture')\n\t\t/**\n\t\t * Whether a scope's own committed provider documents grant it this adapter (a beacon decrypts\n\t\t * nothing). Handed to adapters only when `scope.resolve` and the providers collection both run.\n\t\t */\n\t\tconst adapterGrantedForScope = async (\n\t\t\treq: PayloadRequest,\n\t\t\tscope: string | null,\n\t\t\tadapterId: string\n\t\t): Promise<boolean> => {\n\t\t\tconst runtime = getRuntime(req.payload)\n\t\t\tif (!runtime) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (runtime.providerGranted) {\n\t\t\t\treturn runtime.providerGranted(scope, adapterId)\n\t\t\t}\n\t\t\tconst { grants } = await resolveRegistryFor(runtime, { payload: req.payload, req, scope })\n\t\t\treturn grants.has(adapterId)\n\t\t}\n\t\tconst configGoals = configGoalsResolver(resolved.goals, resolved.purchaseGoal)\n\t\t/** The goals of the instance a request reached, which adapters resolve at ingest. */\n\t\tconst resolveGoals = (req: PayloadRequest, scope?: string | null): Promise<Goal[]> => {\n\t\t\tconst runtime = getRuntime(req.payload)\n\t\t\treturn runtime ? resolveGoalsFor(runtime, req, scope) : configGoals.resolve(req, scope)\n\t\t}\n\t\tconfig.collections = [...(config.collections ?? []), ...collections]\n\t\tconst timezoneArgs = { option: resolved.reportingTimezone, resolveScope: resolveAdminScope }\n\t\tconst resolveTimezone = createTimezoneResolver(timezoneArgs)\n\t\tconst resolveTimezoneStrict = createStrictTimezoneResolver(timezoneArgs)\n\t\tconst resolveCurrency = async (\n\t\t\treq: PayloadRequest,\n\t\t\tscope?: string | null\n\t\t): Promise<string | undefined> => {\n\t\t\tconst opt = resolved.revenue.currency\n\t\t\tif (opt === undefined) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof opt === 'string'\n\t\t\t\t\t\t? opt\n\t\t\t\t\t\t: await opt({ req, scope: scope !== undefined ? scope : await resolveAdminScope(req) })\n\t\t\t\treturn code && CURRENCY_PATTERN.test(code) ? code : undefined\n\t\t\t} catch (err) {\n\t\t\t\treq.payload?.logger?.warn?.(\n\t\t\t\t\t`analytics: revenue.currency resolution failed, reporting revenue unformatted: ${String(err)}`\n\t\t\t\t)\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t}\n\t\tconst itemCollections = itemCollectionsOf(resolved.bindings)\n\t\tfor (const adapter of resolved.adapters) {\n\t\t\tadapter.register?.(config, {\n\t\t\t\tscoped: resolved.scoped,\n\t\t\t\tresolveScope: resolveCaptureScope,\n\t\t\t\tresolveTimezone,\n\t\t\t\tresolveTimezoneStrict,\n\t\t\t\trevenue: {\n\t\t\t\t\tenabled: money,\n\t\t\t\t\tdimension: resolved.revenue.dimension,\n\t\t\t\t\tcurrency: resolveCurrency,\n\t\t\t\t\tconvert: resolved.revenue.convert,\n\t\t\t\t\tbrowserAmounts: resolved.revenue.browserAmounts,\n\t\t\t\t\torderSignature: resolved.revenue.orderSignature,\n\t\t\t\t},\n\t\t\t\tresolveGoals,\n\t\t\t\t...(resolved.scoped && resolved.providers.collection.enabled\n\t\t\t\t\t? { adapterGrantedForScope }\n\t\t\t\t\t: {}),\n\t\t\t\ttrustedProxyHops: resolved.trustedProxyHops,\n\t\t\t\ttrustedPlatform: resolved.trustedPlatform,\n\t\t\t\tallowedOrigins: resolved.capture.allowedOrigins,\n\t\t\t\tadapterCountsWithoutConsent: adapterCountsWithoutConsent(resolved, adapter),\n\t\t\t\t...(itemCollections.size > 0\n\t\t\t\t\t? {\n\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\tcollections: itemCollections,\n\t\t\t\t\t\t\t\tpages: resolved.capture.autoCapture.items.pages,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\troutes,\n\t\t\t\tsdks: resolved.sdks,\n\t\t\t\tjobs: resolved.jobs,\n\t\t\t\tjobsConcurrency,\n\t\t\t\tnotice: context.notice,\n\t\t\t})\n\t\t}\n\t\tassertMaintainRegistered(\n\t\t\tresolved.jobs,\n\t\t\t(config.jobs?.tasks ?? []).some((task) => task.slug === TASK_SLUGS.maintain)\n\t\t)\n\t\t// After registration: an adapter declares what the install measures once it is registered,\n\t\t// and one that declares no revenue then is read as it is rather than as a copy.\n\t\tconst readRegistry = money ? registry : withoutRevenue(registry)\n\t\tif (\n\t\t\tresolved.adapters.some((a) => a.capabilities.realtime && typeof a.realtime === 'function') ||\n\t\t\tprovidersEnabled\n\t\t) {\n\t\t\taddEndpoints(config, { method: 'get', path: routes.live, handler: makeRealtimeHandler() })\n\t\t}\n\t\tif (Object.keys(resolved.bindings).length > 0) {\n\t\t\taddEndpoints(config, { method: 'get', path: routes.document, handler: makeDocumentHandler() })\n\t\t}\n\t\taddEndpoints(\n\t\t\tconfig,\n\t\t\t{ method: 'get', path: routes.sources, handler: makeSourcesHandler() },\n\t\t\t{ method: 'get', path: routes.goals, handler: makeGoalsHandler() },\n\t\t\t{ method: 'get', path: routes.query, handler: makeQueryHandler() },\n\t\t\t{ method: 'post', path: routes.refresh, handler: makeRefreshHandler() }\n\t\t)\n\t\tif (resolved.providers.collection.enabled) {\n\t\t\tconst providerStatus = makeProviderStatusHandler()\n\t\t\taddEndpoints(\n\t\t\t\tconfig,\n\t\t\t\t{ method: 'get', path: routes.providerStatus, handler: providerStatus },\n\t\t\t\t{ method: 'post', path: routes.providerStatus, handler: providerStatus }\n\t\t\t)\n\t\t}\n\t\tif (resolved.capture.exclusion) {\n\t\t\taddEndpoints(config, {\n\t\t\t\tmethod: 'get',\n\t\t\t\tpath: routes.exclusion,\n\t\t\t\thandler: makeExclusionHandler(),\n\t\t\t})\n\t\t}\n\t\t// One answer serves the view, the widgets and the route, so the flags an install draws and\n\t\t// the route serving them cannot diverge. A host's own flag needs no route, only the import map.\n\t\tconst countryFlags = resolved.countryFlags\n\t\tif (countryFlags === true) {\n\t\t\taddEndpoints(config, {\n\t\t\t\tmethod: 'get',\n\t\t\t\tpath: routes.flagsPattern,\n\t\t\t\thandler: makeFlagsHandler(),\n\t\t\t})\n\t\t} else if (countryFlags !== false) {\n\t\t\taddComponentDependency(config, FLAG_DEPENDENCY, countryFlags.Component)\n\t\t}\n\t\t// A runtime provider's capture support is unknown at config time, so providers\n\t\t// alone are enough to mount the proxy; every slot is still resolved per request.\n\t\tif (resolved.adapters.some((a) => a.capture) || providersEnabled) {\n\t\t\taddEndpoints(config, ...proxyEndpoints(routes), trackerEndpoint(routes))\n\t\t}\n\t\tif (resolved.widgets.enabled) {\n\t\t\tconst multiProvider = registry.isMultiProvider() || providersEnabled\n\t\t\tregisterWidgets(config, {\n\t\t\t\tadapters: resolved.adapters,\n\t\t\t\tmultiProvider,\n\t\t\t\tprovidersEnabled,\n\t\t\t\trevenue: money,\n\t\t\t\tdisabled: resolved.widgets.disabled,\n\t\t\t\tregister: resolved.widgets.register,\n\t\t\t\tlocalizeText: resolved.widgets.localizeText,\n\t\t\t\tdefaultId: resolved.defaultAdapter,\n\t\t\t\tcomparison: resolved.widgets.comparison,\n\t\t\t\tcountryFlags,\n\t\t\t\tstaticLabel,\n\t\t\t\toverrides: resolved.widgets.overrides,\n\t\t\t\tview:\n\t\t\t\t\tresolved.view === false\n\t\t\t\t\t\t? false\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tpath: resolved.view.path,\n\t\t\t\t\t\t\t\tdefaultRange: resolved.view.defaultRange,\n\t\t\t\t\t\t\t\tdefaultMetric: resolved.view.defaultMetric,\n\t\t\t\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tregisterView(config, { view: resolved.view, title: staticLabel(keys.viewTitle) })\n\t\tconst { jobs } = resolved\n\t\tif (jobs !== false && resolved.cache.warm.enabled) {\n\t\t\taddTask(\n\t\t\t\tconfig,\n\t\t\t\twarmTask({\n\t\t\t\t\tschedule: jobs.warm,\n\t\t\t\t\twindowHours: resolved.cache.warm.windowHours,\n\t\t\t\t\tmaxReads: resolved.cache.warm.maxReads,\n\t\t\t\t\tconcurrency: jobsConcurrency,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\t\tif (sync) {\n\t\t\tconfig.collections = [...(config.collections ?? []), sync]\n\t\t\tif (jobs !== false) {\n\t\t\t\taddTask(\n\t\t\t\t\tconfig,\n\t\t\t\t\tsyncTask({\n\t\t\t\t\t\tschedule: jobs.sync,\n\t\t\t\t\t\tlookbackDays: resolved.sync.lookbackDays,\n\t\t\t\t\t\tcollectionSlug: resolved.sync.collection.slug,\n\t\t\t\t\t\tadapterIds: resolved.sync.adapters,\n\t\t\t\t\t\tscopes: resolved.scope.list,\n\t\t\t\t\t\tconcurrency: jobsConcurrency,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tconst cache = cacheCollectionOf(resolved, context)\n\t\tif (cache) {\n\t\t\tconfig.collections = [...(config.collections ?? []), cache]\n\t\t}\n\t\taddStateCollection(config, resolved, context)\n\t\trestrictJobControls(config)\n\t\t// Hidden per config rather than per process, so two instances answer for themselves; a later\n\t\t// plugin's fields (form-builder's action blocks) take their factory's own `revenue` option.\n\t\tapplyConfigRevenueVisibility(config, money)\n\t\trelabelFactoryFields(config, staticLabel)\n\t\tconfig.endpoints = (config.endpoints ?? []).map((endpoint) =>\n\t\t\tearlierEndpoints.has(endpoint) ? endpoint : pluginEndpoint(endpoint)\n\t\t)\n\t\t// Checked against everything registered so far, the plugin's own collections included; what a\n\t\t// later plugin adds is caught when a runtime is built from the assembled config.\n\t\tassertRoutesReachable(resolved.routes.base, {\n\t\t\tcollections: config.collections ?? [],\n\t\t\tendpoints: config.endpoints,\n\t\t})\n\t\tconst factory = createRuntimeFactory({\n\t\t\tresolved,\n\t\t\tnotices,\n\t\t\tcollections: expectedCollections(config.collections),\n\t\t\tregistry: readRegistry,\n\t\t\tresolveScope,\n\t\t\tresolveTimezone,\n\t\t\tresolveCurrency,\n\t\t})\n\t\tconst adminCustom: AnalyticsAdminCustom = { routes: { base: resolved.routes.base } }\n\t\tconfig.custom = { ...config.custom, [ANALYTICS_CONFIG_KEY]: factory }\n\t\tconfig.admin = {\n\t\t\t...config.admin,\n\t\t\tcustom: { ...config.admin?.custom, [ANALYTICS_CONFIG_KEY]: adminCustom },\n\t\t}\n\t\tconst prevOnInit = config.onInit\n\t\t// Validation only: the runtime builds on first use either way, and is built here so consumer\n\t\t// init code (seeding, cache warming, sync passes) runs against a warm one.\n\t\tconfig.onInit = async (payload) => {\n\t\t\t// Without the factory every endpoint answers 503; a boot error names the cause instead.\n\t\t\tif (runtimeFactoryOf(payload.config) !== factory) {\n\t\t\t\tthrow new Error(RUNTIME_FACTORY_LOST)\n\t\t\t}\n\t\t\tawait factory.validate(payload)\n\t\t\tgetRuntime(payload)\n\t\t\tawait prevOnInit?.(payload)\n\t\t}\n\t\treturn config\n\t},\n})\n\n/** Said at boot when a step after the plugin dropped its runtime from `config.custom`. */\nconst RUNTIME_FACTORY_LOST = `analytics: config.custom[\"${ANALYTICS_CONFIG_KEY}\"] no longer holds the analytics runtime: a plugin or config step that runs after analytics replaced config.custom instead of spreading it. Spread the existing value there ({ ...config.custom, ... }), or list analytics after that plugin.`\n\nexport { isAdminUser } from './access/adminUser'\nexport { type TenantMembershipOptions, tenantMembership } from './access/membership'\nexport { type GatedScope, type ReadPrincipal, SYSTEM } from './access/principal'\nexport { ProviderHttpError, parseRetryAfter } from './adapters/http/fetchJson'\nexport type { ReportMode, ReportOption } from './binding/report'\nexport type {\n\tAnalyticsBinding,\n\tBindingContext,\n\tBindingDoc,\n\tHostnameResolver,\n\tPathResolver,\n} from './binding/types'\nexport type { CapabilityRequirement, FilterPair, SerializedCapabilities } from './core/capabilities'\nexport {\n\ttype AnalyticsQuery,\n\ttype AnalyticsResult,\n\tPLATFORM_SCOPE,\n} from './core/contract'\nexport type {\n\tAnalyticsAccessOptions,\n\tAnalyticsCacheCollectionOptions,\n\tAnalyticsCacheOptions,\n\tAnalyticsCaptureOptions,\n\tAnalyticsCollectionOptions,\n\tAnalyticsComponent,\n\tAnalyticsConcurrencyOptions,\n\tAnalyticsCountryFlags,\n\tAnalyticsCrossScopeOptions,\n\tAnalyticsExclusionOptions,\n\tAnalyticsGoalsCollectionOptions,\n\tAnalyticsGoalsOptions,\n\tAnalyticsHooksOptions,\n\tAnalyticsJobsOptions,\n\tAnalyticsPluginOptions,\n\tAnalyticsPluginOptions as PluginOptions,\n\tAnalyticsReadAccess,\n\tAnalyticsRevenueOptions,\n\tAnalyticsRoutesOptions,\n\tAnalyticsScopeOptions,\n\tAnalyticsSourceOptions,\n\tAnalyticsSyncCollectionOptions,\n\tAnalyticsSyncOptions,\n\tAnalyticsTaskOptions,\n\tAnalyticsViewAccess,\n\tAnalyticsViewOptions,\n\tAnalyticsWarmOptions,\n\tAnalyticsWidgetOverride,\n\tAnalyticsWidgetOverrides,\n\tAnalyticsWidgetsOptions,\n\tAutoCaptureOptions,\n\tCaptureGate,\n\tCaptureGateArgs,\n\tCaptureSlotOption,\n\tCollectionOverrides,\n\tCrossScopeAccess,\n\tCurrencyConverter,\n\tCurrencyResolver,\n\tDefaultSourceFunction,\n\tDefaultSourceRule,\n\tExclusionSitesResolver,\n\tItemCaptureOptions,\n\tOwnSource,\n\tProviderHostsOptions,\n\tProvidersCollectionOptions,\n\tProvidersOptions,\n\tProvidersResolve,\n\tProvidersResolveArgs,\n\tScopeCallSite,\n\tScopeLabelResolver,\n\tScopeListResolver,\n\tScopeMemberAccess,\n\tScopeResolver,\n\tSourcePolicy,\n\tSourcePolicyFunction,\n\tSourceRef,\n\tTimezoneResolver,\n\tWithoutConsentArgs,\n\tWithoutConsentFunction,\n\tWithoutConsentOption,\n} from './core/options'\nexport type {\n\tAnalyticsSdks,\n\tGa4Client,\n\tGa4ClientOptions,\n\tGa4ReportResponse,\n\tGa4ReportRow,\n\tGa4Sdk,\n\tMaxmindReader,\n\tMaxmindSdk,\n} from './core/sdks'\nexport type {\n\tServerEventInput,\n\tServerTrack,\n\tServerTrackIdentity,\n\tServerTrackOptions,\n} from './core/serverEvent'\nexport { AnalyticsTrackError } from './core/serverEvent'\nexport { BUILT_IN_WIDGET_SLUGS, type BuiltInWidgetSlug } from './core/widgetSlugs'\nexport type * from './exports/adapters/contract'\nexport type { AnalyticsAttributes } from './exports/attributes'\nexport type {\n\tAnalyticsFieldsOptions,\n\tAnalyticsMetricLabel,\n\tAnalyticsMetricLabels,\n\tAnalyticsStatBaseOptions,\n\tAnalyticsStatOptions,\n\tAnalyticsStatRowOptions,\n\tAnalyticsTabOptions,\n} from './fields/factories'\nexport {\n\tanalyticsFields,\n\tanalyticsStat,\n\tanalyticsStatRow,\n\tanalyticsTab,\n\tanalyticsTabsField,\n} from './fields/factories'\nexport type {\n\tFieldBreakdown,\n\tFieldBreakdownRow,\n\tFieldReadResult,\n\tFieldReadStatus,\n\tReadForFieldArgs,\n} from './fields/readForDocument'\nexport { readForField } from './fields/readForDocument'\nexport type {\n\tGoalCollectionFieldOverrides,\n\tGoalFieldOverride,\n} from './goals/collection'\nexport { GOALS_SLUG } from './goals/collection'\nexport {\n\tCURRENCY_ATTRIBUTE,\n\tEVENT_ATTRIBUTE,\n\tEVENT_PROP_PREFIX,\n\tGOAL_ATTRIBUTE,\n\tITEM_ATTRIBUTE,\n\tITEM_CLICK_EVENT,\n\tITEM_NAME_ATTRIBUTE,\n\tMAX_ITEMS_PER_BEACON,\n\tPURCHASE_GOAL_SLUG,\n\tVALUE_ATTRIBUTE,\n} from './goals/constants'\nexport type { GoalFieldOptions } from './goals/goalField'\nexport { goalField, goalSlug } from './goals/goalField'\nexport type { GoalsResponse, WireGoal } from './goals/goalsEndpoint'\nexport type { AnalyticsLinkFieldsOptions } from './goals/linkFields'\nexport { analyticsLinkFields } from './goals/linkFields'\nexport type { BrowserAmounts, OrderSignatureMode } from './goals/match'\nexport type { GoalSource } from './goals/resolver'\nexport type {\n\tPurchaseInput as ServerPurchaseInput,\n\tRefundInput as ServerRefundInput,\n} from './goals/serverRevenue'\nexport { purchase, refund } from './goals/serverRevenue'\nexport type {\n\tGoalActionDefinition,\n\tGoalActionRunArgs,\n\tTrackGoalActionOptions,\n} from './goals/trackGoalAction'\nexport { GOAL_ACTION_TYPE, trackGoalAction } from './goals/trackGoalAction'\nexport type { Goal } from './goals/types'\nexport { STATE_SLUG } from './native/collections/slugs'\nexport type { RebuildDaysInput, RebuildDaysReport } from './native/engine/rebuild'\nexport {\n\ttype ItemSignatureMode,\n\titemAttributesFor,\n\tsignItemRef,\n} from './native/ingest/itemSignature'\nexport { signOrderId } from './native/ingest/orderSignature'\nexport { trackServerEvent } from './native/ingest/serverTrack'\nexport { rebuildDays } from './native/rebuildDays'\nexport {\n\tcreateGuardedFetch,\n\ttype GuardedFetch,\n\ttype GuardedFetchOptions,\n} from './net/guardedFetch'\nexport type { TrustedPlatform } from './net/platform'\nexport type { CollectionFieldOverride } from './plugin/collectionFields'\nexport {\n\tANALYTICS_ERROR_CODES,\n\ttype AnalyticsError,\n\ttype AnalyticsErrorCode,\n\tanalyticsError,\n\treadErrorCode,\n} from './plugin/errors'\nexport type { RoutesConfigSource } from './plugin/routes'\nexport {\n\tanalyticsRoutes,\n\tDEFAULT_ROUTE_BASE,\n\ttype RouteBase,\n\ttype RoutePaths,\n\troutePaths,\n} from './plugin/routes'\nexport type {\n\tBuildSecretField,\n\tConnectionAccess,\n\tConnectionFieldAccess,\n\tProviderCollectionFieldOverrides,\n\tProviderFieldOverride,\n\tProviderFieldsOptions,\n} from './providers/collection'\nexport { analyticsProviderFields, PROVIDERS_SLUG } from './providers/collection'\nexport type { ProviderDoc, ProviderFactoryContext } from './providers/factory'\nexport { adapterFromProviderDoc } from './providers/factory'\nexport type { HostPattern } from './providers/hosts'\nexport { type ProviderHostPolicy, resolveHostPolicy } from './providers/hosts'\nexport { PROVIDER_IDS, type ProviderId } from './providers/ids'\nexport { type RefreshProvidersOptions, refreshProviders } from './providers/refresh'\nexport { CONNECTION_PATHS, SECRET_PATHS } from './providers/secrets'\nexport type { QueryError, QueryErrorCode } from './query/errors'\nexport type {\n\tItemLabels,\n\tQueryErrorResponse,\n\tQueryResponse,\n\tQuerySourceRef,\n\tSerializedAnalyticsQuery,\n} from './query/response'\nexport type {\n\tAfterReadAnswer,\n\tAfterReadArgs,\n\tAfterReadHook,\n\tReadOrigin,\n} from './surfacing/afterRead'\nexport { CACHE_SLUG } from './surfacing/cacheCollection'\nexport type {\n\tCacheEntry,\n\tCacheSetOptions,\n\tCacheStore,\n\tReadRecipe,\n\tRecipeWindow,\n} from './surfacing/cacheStore'\nexport { SYNC_SLUG } from './sync/collection'\nexport { TIMEFRAME_PRESETS, type TimeframePreset } from './timeframe/presets'\nexport type { GoalMatch, RevenueItem, TrackerGoal } from './tracker/config'\nexport type { TranslationsOption } from './translations'\nexport {\n\tkeys,\n\ttype PluralCategory,\n\ttype PluralName,\n\ttype PluralVariant,\n\tpluralKeys,\n\ttype SingularKey,\n\ttype TranslationKey,\n} from './translations/keys'\nexport type { CustomWidgetDef } from './widgets/customWidget'\nexport {\n\ttype AnalyticsDefaultLayoutOptions,\n\tanalyticsDefaultLayout,\n} from './widgets/defaultLayout'\nexport { analyticsDefaultWidgets } from './widgets/defaults'\nexport { widgetFilters } from './widgets/filterField'\nexport type { StoredSourceRead, SubstitutedSource } from './widgets/prepareWidgetRead'\nexport type {\n\tReadForWidgetArgs,\n\tWidgetReadResult,\n\tWidgetReadStatus,\n} from './widgets/readForWidget'\nexport { readForWidget } from './widgets/readForWidget'\nexport type {\n\tBreakdownRow,\n\tReadForWidgetBreakdownArgs,\n\tWidgetBreakdownResult,\n} from './widgets/readForWidgetBreakdown'\nexport { readForWidgetBreakdown } from './widgets/readForWidgetBreakdown'\nexport type {\n\tGoalRow,\n\tReadForWidgetGoalsArgs,\n\tWidgetGoalsResult,\n} from './widgets/readForWidgetGoals'\nexport { readForWidgetGoals } from './widgets/readForWidgetGoals'\nexport type {\n\tReadForWidgetRealtimeArgs,\n\tRealtimePoint,\n\tWidgetRealtimeResult,\n\tWidgetRealtimeStatus,\n} from './widgets/readForWidgetRealtime'\nexport { readForWidgetRealtime } from './widgets/readForWidgetRealtime'\nexport type {\n\tReadForWidgetSeriesArgs,\n\tSeriesGranularity,\n\tSeriesPoint,\n\tWidgetSeriesResult,\n} from './widgets/readForWidgetSeries'\nexport { readForWidgetSeries } from './widgets/readForWidgetSeries'\nexport type { ReadNotices } from './widgets/readMeta'\nexport type { WidgetFilter } from './widgets/types'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAM,iBACJ,gBACA,QAAqB,QAA8B;CACnD,WAAW,IAAI,OAAO,GAAG,gBAAgB,YAAY,cAAc,MAAM,CAAC;AAC3E;;;;;;AAOD,MAAM,oBAAoB,OACzB,KACA,EACC,OACA,QACA,YAEkB;CACnB,MAAM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AAK;EAE3D,mBAAmB,QAAQ,UAAU,OAAO;EAC5C,oBAAoB,MAAM;EAG1B,6BAA6B,QAAQ,KAAK;EAC1C,qBAAqB,QAAQ,WAAW;EACxC,OAAO,aAAa,OAAO,aAAa,CAAC,GAAG,KAAK,aAChD,iBAAiB,IAAI,QAAQ,IAAI,WAAW,eAAe,QAAQ,CACpE;EAGA,sBAAsB,SAAS,OAAO,MAAM;GAC3C,aAAa,OAAO,eAAe,CAAC;GACpC,WAAW,OAAO;EACnB,CAAC;EACD,MAAM,UAAU,qBAAqB;GACpC;GACA;GACA,aAAa,oBAAoB,OAAO,WAAW;GACnD,UAAU;GACV;GACA;GACA;EACD,CAAC;EACD,MAAM,cAAoC,EAAE,QAAQ,EAAE,MAAM,SAAS,OAAO,KAAK,EAAE;EACnF,OAAO,SAAS;GAAE,GAAG,OAAO;IAAS,uBAAuB;EAAQ;EACpE,OAAO,QAAQ;GACd,GAAG,OAAO;GACV,QAAQ;IAAE,GAAG,OAAO,OAAO;KAAS,uBAAuB;GAAY;EACxE;EACA,MAAM,aAAa,OAAO;EAG1B,OAAO,SAAS,OAAO,YAAY;GAElC,IAAI,iBAAiB,QAAQ,MAAM,MAAM,SACxC,MAAM,IAAI,MAAM,oBAAoB;GAErC,MAAM,QAAQ,SAAS,OAAO;GAC9B,WAAW,OAAO;GAClB,MAAM,aAAa,OAAO;EAC3B;EACA,OAAO;CACR;AACD,CAAC;;AAGD,MAAM,uBAAuB,6BAA6B,qBAAqB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { valueAt } from "../../core/values.js";
|
|
2
2
|
import { clientIpFromHeaders } from "../ingest/clientIp.js";
|
|
3
|
-
import { loadMaxmind } from "../../plugin/peers.js";
|
|
4
3
|
import { geoOf, loadsMaxmindAtRuntime } from "./geoResolver.js";
|
|
4
|
+
import { loadMaxmind } from "../../plugin/peers.js";
|
|
5
5
|
//#region src/native/geo/maxmindResolver.ts
|
|
6
6
|
/**
|
|
7
7
|
* MaxMind GeoLite2 resolver, opened on first use. Any failure degrades to empty geo after one
|
|
@@ -9,7 +9,6 @@ import { adapterWithoutConsent, cookielessCapture } from "../capture/withoutCons
|
|
|
9
9
|
import { DEFAULT_STORE_SLUGS } from "./collections/slugs.js";
|
|
10
10
|
import { resolveCollectionOption } from "../core/collectionOption.js";
|
|
11
11
|
import { DEFAULT_JOBS } from "../core/jobs.js";
|
|
12
|
-
import { MAXMIND_SDK_WARNING, isProductionBuild } from "../plugin/peers.js";
|
|
13
12
|
import "../goals/match.js";
|
|
14
13
|
import { LEGACY_NATIVE_OPTIONS, assertNoLegacyOptions } from "../core/legacyOptions.js";
|
|
15
14
|
import { dbKind, isD1 } from "../db/kind.js";
|
|
@@ -30,6 +29,7 @@ import { itemIdTypes } from "../items/collectionIdType.js";
|
|
|
30
29
|
import { itemRefKey } from "./ingest/itemSignature.js";
|
|
31
30
|
import { makeServerTrack } from "./ingest/serverTrack.js";
|
|
32
31
|
import { createKeepAlive } from "../plugin/keepAlive.js";
|
|
32
|
+
import { MAXMIND_SDK_WARNING, isProductionBuild } from "../plugin/peers.js";
|
|
33
33
|
import { stateCollection } from "./collections/state.js";
|
|
34
34
|
import { addTask, schemaOnlyTask } from "../plugin/schemaOnly.js";
|
|
35
35
|
import { aggregatesCollection } from "./collections/aggregates.js";
|