@10x-media/analytics 0.1.0-beta.5 → 1.0.0-beta.11
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 +277 -0
- package/README.md +15 -4
- package/dist/adapters/ga4/disableKey.d.ts +9 -0
- package/dist/adapters/ga4/disableKey.js +21 -0
- package/dist/adapters/ga4/disableKey.js.map +1 -0
- package/dist/adapters/ga4/eventName.d.ts +15 -0
- package/dist/adapters/ga4/eventName.js +19 -0
- package/dist/adapters/ga4/eventName.js.map +1 -0
- package/dist/adapters/ga4/ga4.d.ts +5 -0
- package/dist/adapters/ga4/ga4.js +186 -58
- package/dist/adapters/ga4/ga4.js.map +1 -1
- package/dist/adapters/ga4/measurementId.js +15 -0
- package/dist/adapters/ga4/measurementId.js.map +1 -0
- package/dist/adapters/goalRead.js +126 -0
- package/dist/adapters/goalRead.js.map +1 -0
- package/dist/adapters/http/fetchJson.js +1 -1
- package/dist/adapters/plausible/plausible.d.ts +25 -0
- package/dist/adapters/plausible/plausible.js +159 -38
- package/dist/adapters/plausible/plausible.js.map +1 -1
- package/dist/adapters/posthog/posthog.d.ts +10 -1
- package/dist/adapters/posthog/posthog.js +130 -21
- package/dist/adapters/posthog/posthog.js.map +1 -1
- package/dist/adapters/series.js +11 -1
- package/dist/adapters/series.js.map +1 -1
- package/dist/adapters/umami/umami.d.ts +13 -1
- package/dist/adapters/umami/umami.js +278 -26
- package/dist/adapters/umami/umami.js.map +1 -1
- package/dist/binding/resolvePath.js +18 -2
- package/dist/binding/resolvePath.js.map +1 -1
- package/dist/capture/getTrackerConfig.d.ts +20 -0
- package/dist/capture/getTrackerConfig.js +31 -0
- package/dist/capture/getTrackerConfig.js.map +1 -0
- package/dist/capture/mountPath.js +14 -0
- package/dist/capture/mountPath.js.map +1 -0
- package/dist/capture/proxyEndpoint.js +127 -0
- package/dist/capture/proxyEndpoint.js.map +1 -0
- package/dist/capture/proxyRoutes.js +108 -0
- package/dist/capture/proxyRoutes.js.map +1 -0
- package/dist/capture/requestBody.js +68 -0
- package/dist/capture/requestBody.js.map +1 -0
- package/dist/capture/slots.d.ts +8 -0
- package/dist/capture/slots.js +54 -0
- package/dist/capture/slots.js.map +1 -0
- package/dist/capture/trackerConfig.d.ts +33 -0
- package/dist/capture/trackerConfig.js +95 -0
- package/dist/capture/trackerConfig.js.map +1 -0
- package/dist/capture/trackerEndpoint.js +35 -0
- package/dist/capture/trackerEndpoint.js.map +1 -0
- package/dist/charts/BarList.d.ts +16 -1
- package/dist/charts/BarList.js +41 -19
- package/dist/charts/BarList.js.map +1 -1
- package/dist/charts/TrendChart.d.ts +16 -3
- package/dist/charts/TrendChart.js +172 -106
- package/dist/charts/TrendChart.js.map +1 -1
- package/dist/charts/bars.d.ts +4 -0
- package/dist/charts/bars.js +3 -1
- package/dist/charts/bars.js.map +1 -1
- package/dist/charts/bucket.js +10 -1
- package/dist/charts/bucket.js.map +1 -1
- package/dist/charts/spline.js +2 -2
- package/dist/charts/spline.js.map +1 -1
- package/dist/charts/styles.js +18 -1
- package/dist/charts/styles.js.map +1 -1
- package/dist/core/cacheKey.js +26 -3
- package/dist/core/cacheKey.js.map +1 -1
- package/dist/core/capabilities.d.ts +5 -1
- package/dist/core/capabilities.js +11 -2
- package/dist/core/capabilities.js.map +1 -1
- package/dist/core/capture.d.ts +49 -0
- package/dist/core/contract.d.ts +74 -5
- package/dist/core/contract.js +30 -1
- package/dist/core/contract.js.map +1 -1
- package/dist/core/granularity.js +1 -1
- package/dist/core/options.d.ts +164 -6
- package/dist/core/options.js +126 -3
- package/dist/core/options.js.map +1 -1
- package/dist/core/registry.d.ts +1 -0
- package/dist/core/scopeList.js +32 -0
- package/dist/core/scopeList.js.map +1 -0
- package/dist/core/scopedRead.js +101 -30
- package/dist/core/scopedRead.js.map +1 -1
- package/dist/core/serverEvent.d.ts +60 -0
- package/dist/core/serverEvent.js +12 -0
- package/dist/core/serverEvent.js.map +1 -0
- package/dist/exports/adapters/ga4.d.ts +2 -1
- package/dist/exports/adapters/ga4.js +2 -1
- package/dist/exports/adapters/native.d.ts +3 -1
- package/dist/exports/adapters/native.js +2 -1
- package/dist/exports/client.d.ts +13 -3
- package/dist/exports/client.js +10 -1
- package/dist/exports/geo.d.ts +2 -2
- package/dist/exports/next.d.ts +2 -1
- package/dist/exports/next.js +2 -1
- package/dist/exports/react.d.ts +4 -0
- package/dist/exports/react.js +5 -0
- package/dist/exports/rsc.d.ts +11 -3
- package/dist/exports/rsc.js +7 -2
- package/dist/exports/tracker.d.ts +21 -0
- package/dist/exports/tracker.js +15 -0
- package/dist/exports/types.d.ts +16 -3
- package/dist/exports/types.js +4 -2
- package/dist/fields/AnalyticsPanelClient.js +2 -2
- package/dist/fields/AnalyticsPanelField.js +1 -1
- package/dist/fields/AnalyticsStatField.js +2 -2
- package/dist/fields/config/FilterDimensionSelectField.d.ts +14 -0
- package/dist/fields/config/FilterDimensionSelectField.js +77 -0
- package/dist/fields/config/FilterDimensionSelectField.js.map +1 -0
- package/dist/fields/config/FilterOperatorSelectField.d.ts +14 -0
- package/dist/fields/config/FilterOperatorSelectField.js +75 -0
- package/dist/fields/config/FilterOperatorSelectField.js.map +1 -0
- package/dist/fields/config/MetricSelectField.js +3 -3
- package/dist/fields/config/MetricSelectField.js.map +1 -1
- package/dist/fields/config/SourceSelectField.js +3 -3
- package/dist/fields/config/SourceSelectField.js.map +1 -1
- package/dist/fields/config/fetchSources.d.ts +5 -1
- package/dist/fields/config/fetchSources.js +7 -3
- package/dist/fields/config/fetchSources.js.map +1 -1
- package/dist/fields/config/narrow.js +2 -0
- package/dist/fields/config/narrow.js.map +1 -1
- package/dist/fields/config/sourcesState.js +19 -3
- package/dist/fields/config/sourcesState.js.map +1 -1
- package/dist/fields/config/useAnalyticsSources.d.ts +8 -3
- package/dist/fields/config/useAnalyticsSources.js +9 -6
- package/dist/fields/config/useAnalyticsSources.js.map +1 -1
- package/dist/fields/config/useFilterCapabilities.d.ts +28 -0
- package/dist/fields/config/useFilterCapabilities.js +52 -0
- package/dist/fields/config/useFilterCapabilities.js.map +1 -0
- package/dist/fields/readForDocument.d.ts +5 -0
- package/dist/fields/readForDocument.js +22 -10
- package/dist/fields/readForDocument.js.map +1 -1
- package/dist/goals/GoalSelectField.d.ts +7 -0
- package/dist/goals/GoalSelectField.js +77 -0
- package/dist/goals/GoalSelectField.js.map +1 -0
- package/dist/goals/collection.js +254 -0
- package/dist/goals/collection.js.map +1 -0
- package/dist/goals/currency.js +14 -0
- package/dist/goals/currency.js.map +1 -0
- package/dist/goals/fetchGoals.d.ts +18 -0
- package/dist/goals/fetchGoals.js +33 -0
- package/dist/goals/fetchGoals.js.map +1 -0
- package/dist/goals/goalField.d.ts +31 -0
- package/dist/goals/goalField.js +56 -0
- package/dist/goals/goalField.js.map +1 -0
- package/dist/goals/goalsEndpoint.d.ts +1 -0
- package/dist/goals/goalsEndpoint.js +58 -0
- package/dist/goals/goalsEndpoint.js.map +1 -0
- package/dist/goals/match.js +64 -0
- package/dist/goals/match.js.map +1 -0
- package/dist/goals/resolver.d.ts +8 -0
- package/dist/goals/resolver.js +147 -0
- package/dist/goals/resolver.js.map +1 -0
- package/dist/goals/trackGoalAction.d.ts +76 -0
- package/dist/goals/trackGoalAction.js +158 -0
- package/dist/goals/trackGoalAction.js.map +1 -0
- package/dist/goals/types.d.ts +33 -0
- package/dist/goals/types.js +7 -0
- package/dist/goals/types.js.map +1 -0
- package/dist/goals/useAnalyticsGoals.d.ts +20 -0
- package/dist/goals/useAnalyticsGoals.js +67 -0
- package/dist/goals/useAnalyticsGoals.js.map +1 -0
- package/dist/index.d.ts +14 -3
- package/dist/index.js +174 -19
- package/dist/index.js.map +1 -1
- package/dist/native/collections/events.js +65 -1
- package/dist/native/collections/events.js.map +1 -1
- package/dist/native/collections/rollups.js +39 -3
- package/dist/native/collections/rollups.js.map +1 -1
- package/dist/native/eventScan.js +25 -0
- package/dist/native/eventScan.js.map +1 -0
- package/dist/native/geo/composeGeoResolvers.js +2 -2
- package/dist/native/geo/composeGeoResolvers.js.map +1 -1
- package/dist/native/geo/geoResolver.d.ts +9 -2
- package/dist/native/geo/geoResolver.js.map +1 -1
- package/dist/native/geo/maxmindResolver.js +3 -5
- package/dist/native/geo/maxmindResolver.js.map +1 -1
- package/dist/native/ingest/bots.d.ts +11 -0
- package/dist/native/ingest/bots.js +71 -0
- package/dist/native/ingest/bots.js.map +1 -0
- package/dist/native/ingest/browser.js +47 -0
- package/dist/native/ingest/browser.js.map +1 -0
- package/dist/native/ingest/clientIp.js +20 -0
- package/dist/native/ingest/clientIp.js.map +1 -0
- package/dist/native/ingest/device.js +11 -3
- package/dist/native/ingest/device.js.map +1 -1
- package/dist/native/ingest/endpoint.d.ts +1 -0
- package/dist/native/ingest/endpoint.js +107 -21
- package/dist/native/ingest/endpoint.js.map +1 -1
- package/dist/native/ingest/flushBatch.js +29 -38
- package/dist/native/ingest/flushBatch.js.map +1 -1
- package/dist/native/ingest/language.js +14 -0
- package/dist/native/ingest/language.js.map +1 -0
- package/dist/native/ingest/normalizeEvent.d.ts +30 -0
- package/dist/native/ingest/normalizeEvent.js +115 -16
- package/dist/native/ingest/normalizeEvent.js.map +1 -1
- package/dist/native/ingest/referrer.js +48 -0
- package/dist/native/ingest/referrer.js.map +1 -0
- package/dist/native/ingest/requestHost.js +57 -0
- package/dist/native/ingest/requestHost.js.map +1 -0
- package/dist/native/ingest/resolveHostname.d.ts +29 -0
- package/dist/native/ingest/resolveHostname.js +52 -0
- package/dist/native/ingest/resolveHostname.js.map +1 -0
- package/dist/native/ingest/salt.js +27 -2
- package/dist/native/ingest/salt.js.map +1 -1
- package/dist/native/ingest/serverTrack.d.ts +20 -0
- package/dist/native/ingest/serverTrack.js +109 -0
- package/dist/native/ingest/serverTrack.js.map +1 -0
- package/dist/native/ingest/source.d.ts +11 -0
- package/dist/native/ingest/source.js +264 -16
- package/dist/native/ingest/source.js.map +1 -1
- package/dist/native/ingest/utm.js +33 -0
- package/dist/native/ingest/utm.js.map +1 -0
- package/dist/native/ingest/validate.js +26 -0
- package/dist/native/ingest/validate.js.map +1 -0
- package/dist/native/nativeAdapter.d.ts +37 -1
- package/dist/native/nativeAdapter.js +175 -22
- package/dist/native/nativeAdapter.js.map +1 -1
- package/dist/native/query/eventAgg.js +175 -0
- package/dist/native/query/eventAgg.js.map +1 -0
- package/dist/native/retention/pruneTask.js +53 -13
- package/dist/native/retention/pruneTask.js.map +1 -1
- package/dist/native/rollupAcc.js +12 -1
- package/dist/native/rollupAcc.js.map +1 -1
- package/dist/native/rollups/bucketKey.js +15 -0
- package/dist/native/rollups/bucketKey.js.map +1 -0
- package/dist/native/rollups/bumpRollups.js +116 -0
- package/dist/native/rollups/bumpRollups.js.map +1 -0
- package/dist/native/rollups/deltas.js +86 -11
- package/dist/native/rollups/deltas.js.map +1 -1
- package/dist/native/rollups/insertManyIfNew.js +93 -0
- package/dist/native/rollups/insertManyIfNew.js.map +1 -0
- package/dist/next/captureRewrites.d.ts +42 -0
- package/dist/next/captureRewrites.js +57 -0
- package/dist/next/captureRewrites.js.map +1 -0
- package/dist/next/posthogProxyRewrites.d.ts +5 -0
- package/dist/next/posthogProxyRewrites.js +16 -21
- package/dist/next/posthogProxyRewrites.js.map +1 -1
- package/dist/plugin/documentEndpoint.js +71 -24
- package/dist/plugin/documentEndpoint.js.map +1 -1
- package/dist/plugin/errors.d.ts +31 -0
- package/dist/plugin/errors.js +79 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/goalHint.d.ts +1 -0
- package/dist/plugin/goalHint.js +24 -0
- package/dist/plugin/goalHint.js.map +1 -0
- package/dist/plugin/paths.js +17 -1
- package/dist/plugin/paths.js.map +1 -1
- package/dist/plugin/queryEndpoint.js +124 -0
- package/dist/plugin/queryEndpoint.js.map +1 -0
- package/dist/plugin/readContextForRequest.js +73 -0
- package/dist/plugin/readContextForRequest.js.map +1 -0
- package/dist/plugin/realtimeEndpoint.js +37 -16
- package/dist/plugin/realtimeEndpoint.js.map +1 -1
- package/dist/plugin/refreshEndpoint.js +113 -0
- package/dist/plugin/refreshEndpoint.js.map +1 -0
- package/dist/plugin/runtime.d.ts +1 -0
- package/dist/plugin/runtime.js +33 -1
- package/dist/plugin/runtime.js.map +1 -1
- package/dist/plugin/scopeChange.js +22 -0
- package/dist/plugin/scopeChange.js.map +1 -0
- package/dist/plugin/scopeFieldBoot.js +22 -0
- package/dist/plugin/scopeFieldBoot.js.map +1 -0
- package/dist/plugin/sourcesEndpoint.js +16 -41
- package/dist/plugin/sourcesEndpoint.js.map +1 -1
- package/dist/plugin/warmTask.js +0 -0
- package/dist/plugin/warmTask.js.map +1 -1
- package/dist/providers/collection.js +89 -29
- package/dist/providers/collection.js.map +1 -1
- package/dist/providers/factory.js +11 -3
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/resolver.js.map +1 -1
- package/dist/query/dates.js +64 -0
- package/dist/query/dates.js.map +1 -0
- package/dist/query/errors.d.ts +14 -0
- package/dist/query/fetchQuery.d.ts +79 -0
- package/dist/query/fetchQuery.js +117 -0
- package/dist/query/fetchQuery.js.map +1 -0
- package/dist/query/parse.d.ts +22 -0
- package/dist/query/parse.js +168 -0
- package/dist/query/parse.js.map +1 -0
- package/dist/query/response.d.ts +39 -0
- package/dist/query/response.js +11 -0
- package/dist/query/response.js.map +1 -0
- package/dist/react/AnalyticsProvider.d.ts +50 -0
- package/dist/react/AnalyticsProvider.js +67 -0
- package/dist/react/AnalyticsProvider.js.map +1 -0
- package/dist/react/TrackerBoot.d.ts +22 -0
- package/dist/react/TrackerBoot.js +30 -0
- package/dist/react/TrackerBoot.js.map +1 -0
- package/dist/react/useAnalytics.d.ts +20 -0
- package/dist/react/useAnalytics.js +52 -0
- package/dist/react/useAnalytics.js.map +1 -0
- package/dist/rsc/AnalyticsScripts.d.ts +30 -0
- package/dist/rsc/AnalyticsScripts.js +41 -0
- package/dist/rsc/AnalyticsScripts.js.map +1 -0
- package/dist/surfacing/cacheStore.d.ts +1 -0
- package/dist/surfacing/cacheStore.js +18 -2
- package/dist/surfacing/cacheStore.js.map +1 -1
- package/dist/surfacing/engine.d.ts +1 -0
- package/dist/surfacing/engine.js +47 -6
- package/dist/surfacing/engine.js.map +1 -1
- package/dist/surfacing/epoch.d.ts +1 -0
- package/dist/surfacing/epoch.js +72 -0
- package/dist/surfacing/epoch.js.map +1 -0
- package/dist/surfacing/queue.js +22 -6
- package/dist/surfacing/queue.js.map +1 -1
- package/dist/surfacing/rateLimiter.js +130 -0
- package/dist/surfacing/rateLimiter.js.map +1 -0
- package/dist/surfacing/retryPolicy.js +15 -0
- package/dist/surfacing/retryPolicy.js.map +1 -0
- package/dist/sync/collection.js +23 -7
- package/dist/sync/collection.js.map +1 -1
- package/dist/sync/syncTask.js +68 -33
- package/dist/sync/syncTask.js.map +1 -1
- package/dist/testing/memoryAdapter.d.ts +2 -0
- package/dist/testing/memoryAdapter.js +17 -1
- package/dist/testing/memoryAdapter.js.map +1 -1
- package/dist/timeframe/tz.js +17 -6
- package/dist/timeframe/tz.js.map +1 -1
- package/dist/tracker/autoCapture.d.ts +48 -0
- package/dist/tracker/autoCapture.js +129 -0
- package/dist/tracker/autoCapture.js.map +1 -0
- package/dist/tracker/consent.d.ts +24 -0
- package/dist/tracker/consent.js +48 -0
- package/dist/tracker/consent.js.map +1 -0
- package/dist/tracker/createTracker.d.ts +18 -0
- package/dist/tracker/createTracker.js +215 -0
- package/dist/tracker/createTracker.js.map +1 -0
- package/dist/tracker/exclusion.d.ts +28 -0
- package/dist/tracker/exclusion.js +50 -0
- package/dist/tracker/exclusion.js.map +1 -0
- package/dist/tracker/initTracker.d.ts +22 -0
- package/dist/tracker/initTracker.js +33 -0
- package/dist/tracker/initTracker.js.map +1 -0
- package/dist/tracker/loadScript.d.ts +14 -0
- package/dist/tracker/loadScript.js +41 -0
- package/dist/tracker/loadScript.js.map +1 -0
- package/dist/tracker/pageTracking.d.ts +17 -0
- package/dist/tracker/pageTracking.js +38 -0
- package/dist/tracker/pageTracking.js.map +1 -0
- package/dist/tracker/registry.d.ts +27 -0
- package/dist/tracker/registry.js +73 -0
- package/dist/tracker/registry.js.map +1 -0
- package/dist/tracker/sinks/ga4.d.ts +29 -0
- package/dist/tracker/sinks/ga4.js +30 -0
- package/dist/tracker/sinks/ga4.js.map +1 -0
- package/dist/tracker/sinks/native.d.ts +22 -0
- package/dist/tracker/sinks/native.js +56 -0
- package/dist/tracker/sinks/native.js.map +1 -0
- package/dist/tracker/sinks/plausible.d.ts +20 -0
- package/dist/tracker/sinks/plausible.js +32 -0
- package/dist/tracker/sinks/plausible.js.map +1 -0
- package/dist/tracker/sinks/posthog.d.ts +18 -0
- package/dist/tracker/sinks/posthog.js +30 -0
- package/dist/tracker/sinks/posthog.js.map +1 -0
- package/dist/tracker/sinks/umami.d.ts +18 -0
- package/dist/tracker/sinks/umami.js +23 -0
- package/dist/tracker/sinks/umami.js.map +1 -0
- package/dist/tracker/sinks/vendor.d.ts +14 -0
- package/dist/tracker/sinks/vendor.js +81 -0
- package/dist/tracker/sinks/vendor.js.map +1 -0
- package/dist/tracker/transport.js +28 -0
- package/dist/tracker/transport.js.map +1 -0
- package/dist/tracker/types.d.ts +91 -0
- package/dist/translations/ar.js +221 -0
- package/dist/translations/ar.js.map +1 -0
- package/dist/translations/de.js +145 -1
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +145 -1
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +221 -0
- package/dist/translations/es.js.map +1 -0
- package/dist/translations/fr.js +221 -0
- package/dist/translations/fr.js.map +1 -0
- package/dist/translations/id.js +221 -0
- package/dist/translations/id.js.map +1 -0
- package/dist/translations/index.d.ts +10 -1
- package/dist/translations/index.js +19 -1
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/keys.d.ts +144 -0
- package/dist/translations/keys.js +145 -1
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +221 -0
- package/dist/translations/ko.js.map +1 -0
- package/dist/translations/metricKeys.js +8 -2
- package/dist/translations/metricKeys.js.map +1 -1
- package/dist/translations/pt.js +221 -0
- package/dist/translations/pt.js.map +1 -0
- package/dist/translations/ru.js +221 -0
- package/dist/translations/ru.js.map +1 -0
- package/dist/translations/server.js.map +1 -1
- package/dist/translations/uk.js +221 -0
- package/dist/translations/uk.js.map +1 -0
- package/dist/translations/zh.js +221 -0
- package/dist/translations/zh.js.map +1 -0
- package/dist/view/AnalyticsNavLink.d.ts +19 -0
- package/dist/view/AnalyticsNavLink.js +40 -0
- package/dist/view/AnalyticsNavLink.js.map +1 -0
- package/dist/view/AnalyticsView.d.ts +23 -0
- package/dist/view/AnalyticsView.js +45 -0
- package/dist/view/AnalyticsView.js.map +1 -0
- package/dist/view/AnalyticsViewClient.d.ts +15 -0
- package/dist/view/AnalyticsViewClient.js +244 -0
- package/dist/view/AnalyticsViewClient.js.map +1 -0
- package/dist/view/authRedirect.js +32 -0
- package/dist/view/authRedirect.js.map +1 -0
- package/dist/view/conversionRate.js +18 -0
- package/dist/view/conversionRate.js.map +1 -0
- package/dist/view/dayRange.js +68 -0
- package/dist/view/dayRange.js.map +1 -0
- package/dist/view/gating.d.ts +1 -0
- package/dist/view/gating.js +142 -0
- package/dist/view/gating.js.map +1 -0
- package/dist/view/labels.js +76 -0
- package/dist/view/labels.js.map +1 -0
- package/dist/view/registerView.js +48 -0
- package/dist/view/registerView.js.map +1 -0
- package/dist/view/sections/Breakdowns.js +198 -0
- package/dist/view/sections/Breakdowns.js.map +1 -0
- package/dist/view/sections/EmptyStates.js +92 -0
- package/dist/view/sections/EmptyStates.js.map +1 -0
- package/dist/view/sections/FilterChips.js +46 -0
- package/dist/view/sections/FilterChips.js.map +1 -0
- package/dist/view/sections/GoalsPanel.js +82 -0
- package/dist/view/sections/GoalsPanel.js.map +1 -0
- package/dist/view/sections/OverviewCards.js +65 -0
- package/dist/view/sections/OverviewCards.js.map +1 -0
- package/dist/view/sections/RealtimeStrip.js +80 -0
- package/dist/view/sections/RealtimeStrip.js.map +1 -0
- package/dist/view/sections/Toolbar.js +207 -0
- package/dist/view/sections/Toolbar.js.map +1 -0
- package/dist/view/sections/Trend.js +125 -0
- package/dist/view/sections/Trend.js.map +1 -0
- package/dist/view/sections/styles.js +76 -0
- package/dist/view/sections/styles.js.map +1 -0
- package/dist/view/state.js +211 -0
- package/dist/view/state.js.map +1 -0
- package/dist/view/useViewQueries.js +153 -0
- package/dist/view/useViewQueries.js.map +1 -0
- package/dist/view/viewProps.d.ts +40 -0
- package/dist/view/viewProps.js +90 -0
- package/dist/view/viewProps.js.map +1 -0
- package/dist/widgets/AnalyticsBreakdownWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsBreakdownWidget.js +78 -11
- package/dist/widgets/AnalyticsBreakdownWidget.js.map +1 -1
- package/dist/widgets/AnalyticsGoalsWidget.d.ts +14 -0
- package/dist/widgets/AnalyticsGoalsWidget.js +196 -0
- package/dist/widgets/AnalyticsGoalsWidget.js.map +1 -0
- package/dist/widgets/AnalyticsMetricWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsMetricWidget.js +63 -13
- package/dist/widgets/AnalyticsMetricWidget.js.map +1 -1
- package/dist/widgets/AnalyticsRealtimeWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsRealtimeWidget.js +44 -22
- package/dist/widgets/AnalyticsRealtimeWidget.js.map +1 -1
- package/dist/widgets/AnalyticsTrendWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsTrendWidget.js +79 -16
- package/dist/widgets/AnalyticsTrendWidget.js.map +1 -1
- package/dist/widgets/RealtimeCounter.d.ts +4 -0
- package/dist/widgets/RealtimeCounter.js +18 -4
- package/dist/widgets/RealtimeCounter.js.map +1 -1
- package/dist/widgets/WidgetViewLink.js +17 -0
- package/dist/widgets/WidgetViewLink.js.map +1 -0
- package/dist/widgets/breakdownTypes.js +38 -0
- package/dist/widgets/breakdownTypes.js.map +1 -1
- package/dist/widgets/cardChrome.js +31 -7
- package/dist/widgets/cardChrome.js.map +1 -1
- package/dist/widgets/comparison.js +15 -1
- package/dist/widgets/comparison.js.map +1 -1
- package/dist/widgets/defaults.d.ts +6 -2
- package/dist/widgets/defaults.js +78 -23
- package/dist/widgets/defaults.js.map +1 -1
- package/dist/widgets/filterCaption.js +27 -0
- package/dist/widgets/filterCaption.js.map +1 -0
- package/dist/widgets/filterField.d.ts +19 -0
- package/dist/widgets/filterField.js +75 -0
- package/dist/widgets/filterField.js.map +1 -0
- package/dist/widgets/prepareWidgetRead.d.ts +7 -0
- package/dist/widgets/prepareWidgetRead.js +74 -0
- package/dist/widgets/prepareWidgetRead.js.map +1 -0
- package/dist/widgets/range.js +43 -12
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/readForWidget.d.ts +26 -3
- package/dist/widgets/readForWidget.js +48 -44
- package/dist/widgets/readForWidget.js.map +1 -1
- package/dist/widgets/readForWidgetBreakdown.d.ts +34 -2
- package/dist/widgets/readForWidgetBreakdown.js +53 -49
- package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
- package/dist/widgets/readForWidgetGoals.d.ts +67 -0
- package/dist/widgets/readForWidgetGoals.js +140 -0
- package/dist/widgets/readForWidgetGoals.js.map +1 -0
- package/dist/widgets/readForWidgetRealtime.d.ts +8 -0
- package/dist/widgets/readForWidgetRealtime.js +23 -21
- package/dist/widgets/readForWidgetRealtime.js.map +1 -1
- package/dist/widgets/readForWidgetSeries.d.ts +26 -2
- package/dist/widgets/readForWidgetSeries.js +78 -53
- package/dist/widgets/readForWidgetSeries.js.map +1 -1
- package/dist/widgets/readMeta.js +18 -0
- package/dist/widgets/readMeta.js.map +1 -0
- package/dist/widgets/realtimePoll.js +13 -1
- package/dist/widgets/realtimePoll.js.map +1 -1
- package/dist/widgets/registerWidgets.js +62 -10
- package/dist/widgets/registerWidgets.js.map +1 -1
- package/dist/widgets/types.d.ts +15 -0
- package/dist/widgets/types.js +16 -2
- package/dist/widgets/types.js.map +1 -1
- package/dist/widgets/viewLink.d.ts +22 -0
- package/dist/widgets/viewLink.js +86 -0
- package/dist/widgets/viewLink.js.map +1 -0
- package/package.json +27 -7
- package/dist/native/rollups/applyDistinctDeltas.js +0 -9
- package/dist/native/rollups/applyDistinctDeltas.js.map +0 -1
- package/dist/native/rollups/bumpRollup.js +0 -68
- package/dist/native/rollups/bumpRollup.js.map +0 -1
- package/dist/native/rollups/insertIfNew.js +0 -19
- package/dist/native/rollups/insertIfNew.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TrackerConfig } from "../capture/trackerConfig.js";
|
|
2
|
+
|
|
3
|
+
//#region src/react/TrackerBoot.d.ts
|
|
4
|
+
interface TrackerBootProps {
|
|
5
|
+
config: TrackerConfig;
|
|
6
|
+
/** CSP nonce for any script this component injects. */
|
|
7
|
+
nonce?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Boots the browser tracker from a server-resolved config and renders nothing. This is the
|
|
11
|
+
* RSC path: `<AnalyticsScripts />` renders it after the slot snippets, so a page gets
|
|
12
|
+
* pageviews and auto-capture with no provider and no client state. Wrap the tree in
|
|
13
|
+
* `<AnalyticsProvider>` as well when components need to call `track` themselves: both take
|
|
14
|
+
* a lease on the window's one tracker, so neither double-counts.
|
|
15
|
+
*/
|
|
16
|
+
declare const TrackerBoot: ({
|
|
17
|
+
config,
|
|
18
|
+
nonce
|
|
19
|
+
}: TrackerBootProps) => null;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { TrackerBoot, TrackerBootProps };
|
|
22
|
+
//# sourceMappingURL=TrackerBoot.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { acquireTracker } from "../tracker/registry.js";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
//#region src/react/TrackerBoot.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Boots the browser tracker from a server-resolved config and renders nothing. This is the
|
|
7
|
+
* RSC path: `<AnalyticsScripts />` renders it after the slot snippets, so a page gets
|
|
8
|
+
* pageviews and auto-capture with no provider and no client state. Wrap the tree in
|
|
9
|
+
* `<AnalyticsProvider>` as well when components need to call `track` themselves: both take
|
|
10
|
+
* a lease on the window's one tracker, so neither double-counts.
|
|
11
|
+
*/
|
|
12
|
+
const TrackerBoot = ({ config, nonce }) => {
|
|
13
|
+
const boot = useRef({
|
|
14
|
+
config,
|
|
15
|
+
nonce
|
|
16
|
+
});
|
|
17
|
+
boot.current = {
|
|
18
|
+
config,
|
|
19
|
+
nonce
|
|
20
|
+
};
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const lease = acquireTracker(boot.current.config, { nonce: boot.current.nonce });
|
|
23
|
+
return () => lease.release();
|
|
24
|
+
}, []);
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { TrackerBoot };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=TrackerBoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrackerBoot.js","names":[],"sources":["../../src/react/TrackerBoot.tsx"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef } from 'react'\nimport type { TrackerConfig } from '../capture/trackerConfig'\nimport { acquireTracker } from '../tracker/registry'\n\nexport interface TrackerBootProps {\n\tconfig: TrackerConfig\n\t/** CSP nonce for any script this component injects. */\n\tnonce?: string\n}\n\n/**\n * Boots the browser tracker from a server-resolved config and renders nothing. This is the\n * RSC path: `<AnalyticsScripts />` renders it after the slot snippets, so a page gets\n * pageviews and auto-capture with no provider and no client state. Wrap the tree in\n * `<AnalyticsProvider>` as well when components need to call `track` themselves: both take\n * a lease on the window's one tracker, so neither double-counts.\n */\nexport const TrackerBoot = ({ config, nonce }: TrackerBootProps): null => {\n\tconst boot = useRef({ config, nonce })\n\tboot.current = { config, nonce }\n\n\tuseEffect(() => {\n\t\tconst lease = acquireTracker(boot.current.config, { nonce: boot.current.nonce })\n\t\treturn () => lease.release()\n\t}, [])\n\n\treturn null\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,eAAe,EAAE,QAAQ,YAAoC;CACzE,MAAM,OAAO,OAAO;EAAE;EAAQ;CAAM,CAAC;CACrC,KAAK,UAAU;EAAE;EAAQ;CAAM;CAE/B,gBAAgB;EACf,MAAM,QAAQ,eAAe,KAAK,QAAQ,QAAQ,EAAE,OAAO,KAAK,QAAQ,MAAM,CAAC;EAC/E,aAAa,MAAM,QAAQ;CAC5B,GAAG,CAAC,CAAC;CAEL,OAAO;AACR"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AnalyticsApi } from "./AnalyticsProvider.js";
|
|
2
|
+
|
|
3
|
+
//#region src/react/useAnalytics.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The window's tracker: the surrounding `<AnalyticsProvider>`'s when there is one, else
|
|
6
|
+
* whichever instance `<AnalyticsScripts />` booted, so the RSC path alone is enough for a
|
|
7
|
+
* client component to send its own events.
|
|
8
|
+
*
|
|
9
|
+
* The tracker is resolved per call, not per render: `<TrackerBoot />`'s effect may not have
|
|
10
|
+
* run when a sibling renders, and an eagerly resolved null would never recover. A call that
|
|
11
|
+
* finds neither a provider nor a booted tracker throws, because a silently dead `track` is
|
|
12
|
+
* worse than a build-time mistake.
|
|
13
|
+
*
|
|
14
|
+
* `excluded` is read from the tracker rather than held in state, so every component sees the
|
|
15
|
+
* same flag however it was flipped.
|
|
16
|
+
*/
|
|
17
|
+
declare const useAnalytics: () => AnalyticsApi;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useAnalytics };
|
|
20
|
+
//# sourceMappingURL=useAnalytics.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { readExclusion, subscribeExclusion } from "../tracker/exclusion.js";
|
|
3
|
+
import { liveTracker } from "../tracker/registry.js";
|
|
4
|
+
import { AnalyticsContext } from "./AnalyticsProvider.js";
|
|
5
|
+
import { useContext, useMemo, useSyncExternalStore } from "react";
|
|
6
|
+
//#region src/react/useAnalytics.tsx
|
|
7
|
+
const NO_TRACKER = "analytics: useAnalytics found no tracker. Render <AnalyticsScripts /> (or <AnalyticsProvider>) above this component.";
|
|
8
|
+
/** The live tracker's flag, so a blocked storage still reports this page's exclusion. */
|
|
9
|
+
const exclusionSnapshot = () => {
|
|
10
|
+
if (typeof window === "undefined") return false;
|
|
11
|
+
return liveTracker(window)?.excluded ?? readExclusion(window);
|
|
12
|
+
};
|
|
13
|
+
const serverSnapshot = () => false;
|
|
14
|
+
/**
|
|
15
|
+
* The window's tracker: the surrounding `<AnalyticsProvider>`'s when there is one, else
|
|
16
|
+
* whichever instance `<AnalyticsScripts />` booted, so the RSC path alone is enough for a
|
|
17
|
+
* client component to send its own events.
|
|
18
|
+
*
|
|
19
|
+
* The tracker is resolved per call, not per render: `<TrackerBoot />`'s effect may not have
|
|
20
|
+
* run when a sibling renders, and an eagerly resolved null would never recover. A call that
|
|
21
|
+
* finds neither a provider nor a booted tracker throws, because a silently dead `track` is
|
|
22
|
+
* worse than a build-time mistake.
|
|
23
|
+
*
|
|
24
|
+
* `excluded` is read from the tracker rather than held in state, so every component sees the
|
|
25
|
+
* same flag however it was flipped.
|
|
26
|
+
*/
|
|
27
|
+
const useAnalytics = () => {
|
|
28
|
+
const provided = useContext(AnalyticsContext);
|
|
29
|
+
const excluded = useSyncExternalStore(subscribeExclusion, exclusionSnapshot, serverSnapshot);
|
|
30
|
+
const commands = useMemo(() => {
|
|
31
|
+
if (provided) return provided;
|
|
32
|
+
const tracker = () => {
|
|
33
|
+
const live = liveTracker();
|
|
34
|
+
if (!live) throw new Error(NO_TRACKER);
|
|
35
|
+
return live;
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
track: (name, props) => tracker().track(name, props),
|
|
39
|
+
trackGoal: (slug, opts) => tracker().trackGoal(slug, opts),
|
|
40
|
+
consent: (state) => tracker().consent(state),
|
|
41
|
+
setExcluded: (next) => tracker().exclude(next)
|
|
42
|
+
};
|
|
43
|
+
}, [provided]);
|
|
44
|
+
return useMemo(() => ({
|
|
45
|
+
...commands,
|
|
46
|
+
excluded
|
|
47
|
+
}), [commands, excluded]);
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { useAnalytics };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=useAnalytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAnalytics.js","names":[],"sources":["../../src/react/useAnalytics.tsx"],"sourcesContent":["'use client'\n\nimport { useContext, useMemo, useSyncExternalStore } from 'react'\nimport { readExclusion, subscribeExclusion } from '../tracker/exclusion'\nimport { liveTracker } from '../tracker/registry'\nimport type { Tracker } from '../tracker/types'\nimport { type AnalyticsApi, type AnalyticsCommands, AnalyticsContext } from './AnalyticsProvider'\n\nconst NO_TRACKER =\n\t'analytics: useAnalytics found no tracker. Render <AnalyticsScripts /> (or <AnalyticsProvider>) above this component.'\n\n/** The live tracker's flag, so a blocked storage still reports this page's exclusion. */\nconst exclusionSnapshot = (): boolean => {\n\tif (typeof window === 'undefined') {\n\t\treturn false\n\t}\n\treturn liveTracker(window)?.excluded ?? readExclusion(window)\n}\n\nconst serverSnapshot = (): boolean => false\n\n/**\n * The window's tracker: the surrounding `<AnalyticsProvider>`'s when there is one, else\n * whichever instance `<AnalyticsScripts />` booted, so the RSC path alone is enough for a\n * client component to send its own events.\n *\n * The tracker is resolved per call, not per render: `<TrackerBoot />`'s effect may not have\n * run when a sibling renders, and an eagerly resolved null would never recover. A call that\n * finds neither a provider nor a booted tracker throws, because a silently dead `track` is\n * worse than a build-time mistake.\n *\n * `excluded` is read from the tracker rather than held in state, so every component sees the\n * same flag however it was flipped.\n */\nexport const useAnalytics = (): AnalyticsApi => {\n\tconst provided = useContext(AnalyticsContext)\n\tconst excluded = useSyncExternalStore(subscribeExclusion, exclusionSnapshot, serverSnapshot)\n\tconst commands = useMemo<AnalyticsCommands>(() => {\n\t\tif (provided) {\n\t\t\treturn provided\n\t\t}\n\t\tconst tracker = (): Tracker => {\n\t\t\tconst live = liveTracker()\n\t\t\tif (!live) {\n\t\t\t\tthrow new Error(NO_TRACKER)\n\t\t\t}\n\t\t\treturn live\n\t\t}\n\t\treturn {\n\t\t\ttrack: (name, props) => tracker().track(name, props),\n\t\t\ttrackGoal: (slug, opts) => tracker().trackGoal(slug, opts),\n\t\t\tconsent: (state) => tracker().consent(state),\n\t\t\tsetExcluded: (next) => tracker().exclude(next),\n\t\t}\n\t}, [provided])\n\n\treturn useMemo<AnalyticsApi>(() => ({ ...commands, excluded }), [commands, excluded])\n}\n"],"mappings":";;;;;;AAQA,MAAM,aACL;;AAGD,MAAM,0BAAmC;CACxC,IAAI,OAAO,WAAW,aACrB,OAAO;CAER,OAAO,YAAY,MAAM,GAAG,YAAY,cAAc,MAAM;AAC7D;AAEA,MAAM,uBAAgC;;;;;;;;;;;;;;AAetC,MAAa,qBAAmC;CAC/C,MAAM,WAAW,WAAW,gBAAgB;CAC5C,MAAM,WAAW,qBAAqB,oBAAoB,mBAAmB,cAAc;CAC3F,MAAM,WAAW,cAAiC;EACjD,IAAI,UACH,OAAO;EAER,MAAM,gBAAyB;GAC9B,MAAM,OAAO,YAAY;GACzB,IAAI,CAAC,MACJ,MAAM,IAAI,MAAM,UAAU;GAE3B,OAAO;EACR;EACA,OAAO;GACN,QAAQ,MAAM,UAAU,QAAQ,EAAE,MAAM,MAAM,KAAK;GACnD,YAAY,MAAM,SAAS,QAAQ,EAAE,UAAU,MAAM,IAAI;GACzD,UAAU,UAAU,QAAQ,EAAE,QAAQ,KAAK;GAC3C,cAAc,SAAS,QAAQ,EAAE,QAAQ,IAAI;EAC9C;CACD,GAAG,CAAC,QAAQ,CAAC;CAEb,OAAO,eAA6B;EAAE,GAAG;EAAU;CAAS,IAAI,CAAC,UAAU,QAAQ,CAAC;AACrF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TrackerConfig } from "../capture/trackerConfig.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/rsc/AnalyticsScripts.d.ts
|
|
5
|
+
interface AnalyticsScriptsProps {
|
|
6
|
+
/** Resolved server-side, by `getTrackerConfig` or the tracker endpoint. */
|
|
7
|
+
config: TrackerConfig;
|
|
8
|
+
/** CSP nonce, applied to every script this renders. */
|
|
9
|
+
nonce?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Renders each capture slot's vendor snippet, then boots the tracker over them. Snippet
|
|
13
|
+
* scripts come from the slot adapter's own `capture.snippet`, so they are plugin-authored
|
|
14
|
+
* strings rather than anything a request supplied; the inline ones are injected verbatim
|
|
15
|
+
* because a vendor init call has to parse as script, not as text.
|
|
16
|
+
*
|
|
17
|
+
* A slot that waits for consent renders nothing: shipping its script in the HTML would run
|
|
18
|
+
* the vendor's tracker before the visitor answered, which is the whole point of the gate.
|
|
19
|
+
* Its sink injects the same snippet once consent is granted (or immediately, when a granted
|
|
20
|
+
* decision was already persisted), and the loader skips scripts the page already carries.
|
|
21
|
+
*
|
|
22
|
+
* A native-only install renders no snippet at all: the tracker is the client.
|
|
23
|
+
*/
|
|
24
|
+
declare const AnalyticsScripts: ({
|
|
25
|
+
config,
|
|
26
|
+
nonce
|
|
27
|
+
}: AnalyticsScriptsProps) => ReactElement;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { AnalyticsScripts, AnalyticsScriptsProps };
|
|
30
|
+
//# sourceMappingURL=AnalyticsScripts.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TrackerBoot } from "../react/TrackerBoot.js";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/rsc/AnalyticsScripts.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Renders each capture slot's vendor snippet, then boots the tracker over them. Snippet
|
|
6
|
+
* scripts come from the slot adapter's own `capture.snippet`, so they are plugin-authored
|
|
7
|
+
* strings rather than anything a request supplied; the inline ones are injected verbatim
|
|
8
|
+
* because a vendor init call has to parse as script, not as text.
|
|
9
|
+
*
|
|
10
|
+
* A slot that waits for consent renders nothing: shipping its script in the HTML would run
|
|
11
|
+
* the vendor's tracker before the visitor answered, which is the whole point of the gate.
|
|
12
|
+
* Its sink injects the same snippet once consent is granted (or immediately, when a granted
|
|
13
|
+
* decision was already persisted), and the loader skips scripts the page already carries.
|
|
14
|
+
*
|
|
15
|
+
* A native-only install renders no snippet at all: the tracker is the client.
|
|
16
|
+
*/
|
|
17
|
+
const AnalyticsScripts = ({ config, nonce }) => /* @__PURE__ */ jsxs(Fragment, { children: [config.slots.flatMap((slot) => slot.requiresConsent ? [] : slot.snippet.scripts.map((script, index) => {
|
|
18
|
+
const key = `${slot.slot}-${index}`;
|
|
19
|
+
return script.inline ? /* @__PURE__ */ jsx("script", {
|
|
20
|
+
...script.attrs,
|
|
21
|
+
async: script.async,
|
|
22
|
+
defer: script.defer,
|
|
23
|
+
dangerouslySetInnerHTML: { __html: script.inline },
|
|
24
|
+
nonce,
|
|
25
|
+
type: script.type
|
|
26
|
+
}, key) : /* @__PURE__ */ jsx("script", {
|
|
27
|
+
...script.attrs,
|
|
28
|
+
async: script.async,
|
|
29
|
+
defer: script.defer,
|
|
30
|
+
nonce,
|
|
31
|
+
src: script.src,
|
|
32
|
+
type: script.type
|
|
33
|
+
}, key);
|
|
34
|
+
})), /* @__PURE__ */ jsx(TrackerBoot, {
|
|
35
|
+
config,
|
|
36
|
+
nonce
|
|
37
|
+
})] });
|
|
38
|
+
//#endregion
|
|
39
|
+
export { AnalyticsScripts };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=AnalyticsScripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnalyticsScripts.js","names":[],"sources":["../../src/rsc/AnalyticsScripts.tsx"],"sourcesContent":["import type { ReactElement } from 'react'\nimport type { TrackerConfig } from '../capture/trackerConfig'\nimport { TrackerBoot } from '../react/TrackerBoot'\n\nexport interface AnalyticsScriptsProps {\n\t/** Resolved server-side, by `getTrackerConfig` or the tracker endpoint. */\n\tconfig: TrackerConfig\n\t/** CSP nonce, applied to every script this renders. */\n\tnonce?: string\n}\n\n/**\n * Renders each capture slot's vendor snippet, then boots the tracker over them. Snippet\n * scripts come from the slot adapter's own `capture.snippet`, so they are plugin-authored\n * strings rather than anything a request supplied; the inline ones are injected verbatim\n * because a vendor init call has to parse as script, not as text.\n *\n * A slot that waits for consent renders nothing: shipping its script in the HTML would run\n * the vendor's tracker before the visitor answered, which is the whole point of the gate.\n * Its sink injects the same snippet once consent is granted (or immediately, when a granted\n * decision was already persisted), and the loader skips scripts the page already carries.\n *\n * A native-only install renders no snippet at all: the tracker is the client.\n */\nexport const AnalyticsScripts = ({ config, nonce }: AnalyticsScriptsProps): ReactElement => (\n\t<>\n\t\t{config.slots.flatMap((slot) =>\n\t\t\tslot.requiresConsent\n\t\t\t\t? []\n\t\t\t\t: slot.snippet.scripts.map((script, index) => {\n\t\t\t\t\t\tconst key = `${slot.slot}-${index}`\n\t\t\t\t\t\treturn script.inline ? (\n\t\t\t\t\t\t\t<script\n\t\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\t\t{...script.attrs}\n\t\t\t\t\t\t\t\tasync={script.async}\n\t\t\t\t\t\t\t\tdefer={script.defer}\n\t\t\t\t\t\t\t\t// biome-ignore lint/security/noDangerouslySetInnerHtml: adapter-authored vendor init\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{ __html: script.inline }}\n\t\t\t\t\t\t\t\tnonce={nonce}\n\t\t\t\t\t\t\t\ttype={script.type}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<script\n\t\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\t\t{...script.attrs}\n\t\t\t\t\t\t\t\tasync={script.async}\n\t\t\t\t\t\t\t\tdefer={script.defer}\n\t\t\t\t\t\t\t\tnonce={nonce}\n\t\t\t\t\t\t\t\tsrc={script.src}\n\t\t\t\t\t\t\t\ttype={script.type}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})\n\t\t)}\n\t\t<TrackerBoot config={config} nonce={nonce} />\n\t</>\n)\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,oBAAoB,EAAE,QAAQ,YAC1C,qBAAA,UAAA,EAAA,UAAA,CACE,OAAO,MAAM,SAAS,SACtB,KAAK,kBACF,CAAC,IACD,KAAK,QAAQ,QAAQ,KAAK,QAAQ,UAAU;CAC5C,MAAM,MAAM,GAAG,KAAK,KAAK,GAAG;CAC5B,OAAO,OAAO,SACb,oBAAC,UAAD;EAEC,GAAI,OAAO;EACX,OAAO,OAAO;EACd,OAAO,OAAO;EAEd,yBAAyB,EAAE,QAAQ,OAAO,OAAO;EAC1C;EACP,MAAM,OAAO;CACb,GARK,GAQL,IAED,oBAAC,UAAD;EAEC,GAAI,OAAO;EACX,OAAO,OAAO;EACd,OAAO,OAAO;EACP;EACP,KAAK,OAAO;EACZ,MAAM,OAAO;CACb,GAPK,GAOL;AAEH,CAAC,CACJ,GACA,oBAAC,aAAD;CAAqB;CAAe;AAAQ,CAAA,CAC3C,EAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
//#region src/surfacing/cacheStore.ts
|
|
2
|
+
/** How long past expiry a value stays eligible for stale-while-error serving. */
|
|
3
|
+
const STALE_WINDOW_SECONDS = 86400;
|
|
2
4
|
function kvCacheStore(kv) {
|
|
3
5
|
const store = {
|
|
4
6
|
now: () => Date.now(),
|
|
5
7
|
async get(key) {
|
|
6
8
|
const hit = await kv.get(key);
|
|
7
9
|
if (!hit) return null;
|
|
8
|
-
if (hit.expiresAt <= store.now()) {
|
|
10
|
+
if ((hit.staleUntil ?? hit.expiresAt) <= store.now()) {
|
|
9
11
|
await kv.delete(key);
|
|
10
12
|
return null;
|
|
11
13
|
}
|
|
14
|
+
if (hit.expiresAt <= store.now()) return null;
|
|
15
|
+
return hit.value;
|
|
16
|
+
},
|
|
17
|
+
async getStale(key) {
|
|
18
|
+
const hit = await kv.get(key);
|
|
19
|
+
if (!hit) return null;
|
|
20
|
+
const now = store.now();
|
|
21
|
+
if ((hit.staleUntil ?? hit.expiresAt) <= now) {
|
|
22
|
+
await kv.delete(key);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (hit.expiresAt > now) return null;
|
|
12
26
|
return hit.value;
|
|
13
27
|
},
|
|
14
28
|
async set(key, value, ttlSeconds) {
|
|
29
|
+
const expiresAt = store.now() + ttlSeconds * 1e3;
|
|
15
30
|
await kv.set(key, {
|
|
16
31
|
value,
|
|
17
|
-
expiresAt
|
|
32
|
+
expiresAt,
|
|
33
|
+
staleUntil: expiresAt + STALE_WINDOW_SECONDS * 1e3
|
|
18
34
|
});
|
|
19
35
|
}
|
|
20
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheStore.js","names":[],"sources":["../../src/surfacing/cacheStore.ts"],"sourcesContent":["import type { KVAdapter } from 'payload'\n\nexport interface CacheStore {\n\tget<T>(key: string): Promise<T | null>\n\tset<T>(key: string, value: T, ttlSeconds: number): Promise<void>\n\t// Injected for testing; defaults to Date.now\n\tnow: () => number\n}\n\ninterface Wrapped<T> {\n\tvalue: T\n\texpiresAt: number\n}\n\nexport function kvCacheStore(kv: KVAdapter): CacheStore {\n\tconst store: CacheStore = {\n\t\tnow: () => Date.now(),\n\t\tasync get<T>(key: string): Promise<T | null> {\n\t\t\tconst hit = await kv.get<Wrapped<T>>(key)\n\t\t\tif (!hit) return null\n\t\t\tif (hit.expiresAt <= store.now()) {\n\t\t\t\tawait kv.delete(key)\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn hit.value\n\t\t},\n\t\tasync set<T>(key: string, value: T, ttlSeconds: number): Promise<void> {\n\t\t\tawait kv.set(key, {
|
|
1
|
+
{"version":3,"file":"cacheStore.js","names":[],"sources":["../../src/surfacing/cacheStore.ts"],"sourcesContent":["import type { KVAdapter } from 'payload'\n\nexport interface CacheStore {\n\tget<T>(key: string): Promise<T | null>\n\t/** Serves a value past `expiresAt` but still within the stale window; null once cold or past it. */\n\tgetStale<T>(key: string): Promise<T | null>\n\tset<T>(key: string, value: T, ttlSeconds: number): Promise<void>\n\t// Injected for testing; defaults to Date.now\n\tnow: () => number\n}\n\n/** How long past expiry a value stays eligible for stale-while-error serving. */\nexport const STALE_WINDOW_SECONDS = 86_400\n\ninterface Wrapped<T> {\n\tvalue: T\n\texpiresAt: number\n\t// Absent on entries written before stale-while-error shipped; treated as expiresAt (never stale-served).\n\tstaleUntil?: number\n}\n\nexport function kvCacheStore(kv: KVAdapter): CacheStore {\n\tconst store: CacheStore = {\n\t\tnow: () => Date.now(),\n\t\tasync get<T>(key: string): Promise<T | null> {\n\t\t\tconst hit = await kv.get<Wrapped<T>>(key)\n\t\t\tif (!hit) return null\n\t\t\tconst staleUntil = hit.staleUntil ?? hit.expiresAt\n\t\t\tif (staleUntil <= store.now()) {\n\t\t\t\tawait kv.delete(key)\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (hit.expiresAt <= store.now()) return null\n\t\t\treturn hit.value\n\t\t},\n\t\tasync getStale<T>(key: string): Promise<T | null> {\n\t\t\tconst hit = await kv.get<Wrapped<T>>(key)\n\t\t\tif (!hit) return null\n\t\t\tconst now = store.now()\n\t\t\tconst staleUntil = hit.staleUntil ?? hit.expiresAt\n\t\t\tif (staleUntil <= now) {\n\t\t\t\tawait kv.delete(key)\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (hit.expiresAt > now) return null\n\t\t\treturn hit.value\n\t\t},\n\t\tasync set<T>(key: string, value: T, ttlSeconds: number): Promise<void> {\n\t\t\tconst expiresAt = store.now() + ttlSeconds * 1000\n\t\t\tawait kv.set(key, {\n\t\t\t\tvalue,\n\t\t\t\texpiresAt,\n\t\t\t\tstaleUntil: expiresAt + STALE_WINDOW_SECONDS * 1000,\n\t\t\t} satisfies Wrapped<T>)\n\t\t},\n\t}\n\treturn store\n}\n"],"mappings":";;AAYA,MAAa,uBAAuB;AASpC,SAAgB,aAAa,IAA2B;CACvD,MAAM,QAAoB;EACzB,WAAW,KAAK,IAAI;EACpB,MAAM,IAAO,KAAgC;GAC5C,MAAM,MAAM,MAAM,GAAG,IAAgB,GAAG;GACxC,IAAI,CAAC,KAAK,OAAO;GAEjB,KADmB,IAAI,cAAc,IAAI,cACvB,MAAM,IAAI,GAAG;IAC9B,MAAM,GAAG,OAAO,GAAG;IACnB,OAAO;GACR;GACA,IAAI,IAAI,aAAa,MAAM,IAAI,GAAG,OAAO;GACzC,OAAO,IAAI;EACZ;EACA,MAAM,SAAY,KAAgC;GACjD,MAAM,MAAM,MAAM,GAAG,IAAgB,GAAG;GACxC,IAAI,CAAC,KAAK,OAAO;GACjB,MAAM,MAAM,MAAM,IAAI;GAEtB,KADmB,IAAI,cAAc,IAAI,cACvB,KAAK;IACtB,MAAM,GAAG,OAAO,GAAG;IACnB,OAAO;GACR;GACA,IAAI,IAAI,YAAY,KAAK,OAAO;GAChC,OAAO,IAAI;EACZ;EACA,MAAM,IAAO,KAAa,OAAU,YAAmC;GACtE,MAAM,YAAY,MAAM,IAAI,IAAI,aAAa;GAC7C,MAAM,GAAG,IAAI,KAAK;IACjB;IACA;IACA,YAAY,YAAY,uBAAuB;GAChD,CAAsB;EACvB;CACD;CACA,OAAO;AACR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/surfacing/engine.js
CHANGED
|
@@ -2,6 +2,8 @@ import { startOfDayInTz } from "../timeframe/tz.js";
|
|
|
2
2
|
import { buildCacheKey } from "../core/cacheKey.js";
|
|
3
3
|
import { createCoalescer } from "./coalesce.js";
|
|
4
4
|
import { createQueue } from "./queue.js";
|
|
5
|
+
import { limiterFor } from "./rateLimiter.js";
|
|
6
|
+
import { PROVIDER_READ_TIMEOUT_MESSAGE, shouldRetryProviderError } from "./retryPolicy.js";
|
|
5
7
|
//#region src/surfacing/engine.ts
|
|
6
8
|
const DAY_MS = 864e5;
|
|
7
9
|
const clampRange = (range, maxLookbackDays, tz = "UTC") => {
|
|
@@ -31,7 +33,12 @@ const emptyResult = (provider, q) => ({
|
|
|
31
33
|
});
|
|
32
34
|
function createEngine(opts) {
|
|
33
35
|
const coalesce = createCoalescer();
|
|
34
|
-
const
|
|
36
|
+
const limiters = /* @__PURE__ */ new Map();
|
|
37
|
+
const queue = createQueue({
|
|
38
|
+
...opts.queue,
|
|
39
|
+
shouldRetry: shouldRetryProviderError,
|
|
40
|
+
baseDelayMs: 500
|
|
41
|
+
});
|
|
35
42
|
return { async read(adapter, query) {
|
|
36
43
|
if (!adapter.isConfigured()) return emptyResult(adapter.id, query);
|
|
37
44
|
const { range, clamped } = clampRange(query.dateRange, adapter.capabilities.maxLookbackDays, query.timezone);
|
|
@@ -39,11 +46,45 @@ function createEngine(opts) {
|
|
|
39
46
|
...query,
|
|
40
47
|
dateRange: range
|
|
41
48
|
} : query;
|
|
42
|
-
const
|
|
49
|
+
const epoch = await opts.epoch?.get(q.scope) ?? "0";
|
|
50
|
+
const key = buildCacheKey(adapter.id, q, { epoch });
|
|
43
51
|
return coalesce(key, async () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
52
|
+
let fresh;
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const timer = setTimeout(() => controller.abort(new Error(PROVIDER_READ_TIMEOUT_MESSAGE)), opts.timeoutMs);
|
|
55
|
+
timer.unref?.();
|
|
56
|
+
try {
|
|
57
|
+
const cached = await opts.store.get(key);
|
|
58
|
+
if (cached) return cached;
|
|
59
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
60
|
+
controller.signal.addEventListener("abort", () => reject(controller.signal.reason), { once: true });
|
|
61
|
+
});
|
|
62
|
+
const attempt = queue.run(async () => {
|
|
63
|
+
const release = await limiterFor(limiters, adapter).take(controller.signal);
|
|
64
|
+
try {
|
|
65
|
+
return await adapter.query(q, { signal: controller.signal });
|
|
66
|
+
} finally {
|
|
67
|
+
release();
|
|
68
|
+
}
|
|
69
|
+
}, controller.signal);
|
|
70
|
+
attempt.catch(() => {});
|
|
71
|
+
fresh = await Promise.race([attempt, aborted]);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
opts.onError?.(err, adapter.id);
|
|
74
|
+
try {
|
|
75
|
+
const stale = await opts.store.getStale(key);
|
|
76
|
+
if (stale) return {
|
|
77
|
+
...stale,
|
|
78
|
+
meta: {
|
|
79
|
+
...stale.meta,
|
|
80
|
+
stale: true
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
} catch {}
|
|
84
|
+
throw err;
|
|
85
|
+
} finally {
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
}
|
|
47
88
|
const result = clamped ? {
|
|
48
89
|
...fresh,
|
|
49
90
|
meta: {
|
|
@@ -51,7 +92,7 @@ function createEngine(opts) {
|
|
|
51
92
|
clamped: true
|
|
52
93
|
}
|
|
53
94
|
} : fresh;
|
|
54
|
-
const ttl = opts.ttl.aggregate ?? adapter.capabilities.recommendedTtl.aggregate;
|
|
95
|
+
const ttl = result.meta.goalsUnresolved === true ? opts.ttl.realtime ?? adapter.capabilities.recommendedTtl.realtime : opts.ttl.aggregate ?? adapter.capabilities.recommendedTtl.aggregate;
|
|
55
96
|
await opts.store.set(key, result, ttl);
|
|
56
97
|
return result;
|
|
57
98
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","names":[],"sources":["../../src/surfacing/engine.ts"],"sourcesContent":["import { buildCacheKey } from '../core/cacheKey'\nimport type { AnalyticsAdapter, AnalyticsQuery, AnalyticsResult } from '../core/contract'\nimport { DEFAULT_TIMEZONE, startOfDayInTz } from '../timeframe/tz'\nimport type { CacheStore } from './cacheStore'\nimport { createCoalescer } from './coalesce'\nimport { createQueue, type QueueOptions } from './queue'\n\nconst DAY_MS = 86_400_000\n\nconst clampRange = (\n\trange: AnalyticsQuery['dateRange'],\n\tmaxLookbackDays: number | null,\n\ttz: string = DEFAULT_TIMEZONE\n): { range: AnalyticsQuery['dateRange']; clamped: boolean } => {\n\tif (maxLookbackDays == null) {\n\t\treturn { range, clamped: false }\n\t}\n\tconst floor = new Date(startOfDayInTz(range.end, tz).getTime() - maxLookbackDays * DAY_MS)\n\tif (range.start.getTime() >= floor.getTime()) {\n\t\treturn { range, clamped: false }\n\t}\n\treturn { range: { start: floor, end: range.end }, clamped: true }\n}\n\nexport interface EngineOptions {\n\tstore: CacheStore\n\tqueue: QueueOptions\n\t/** Explicit TTL overrides; when a value is unset the adapter's recommendedTtl applies. */\n\tttl: { aggregate?: number; realtime?: number }\n}\n\nexport interface Engine {\n\tread(adapter: AnalyticsAdapter, query: AnalyticsQuery): Promise<AnalyticsResult>\n}\n\nconst emptyResult = (provider: string, q: AnalyticsQuery): AnalyticsResult => ({\n\trows: [],\n\tmeta: { provider, fetchedAt: q.dateRange.end.toISOString() },\n})\n\nexport function createEngine(opts: EngineOptions): Engine {\n\tconst coalesce = createCoalescer<AnalyticsResult>()\n\tconst queue = createQueue(opts.queue)\n\n\treturn {\n\t\tasync read(adapter, query) {\n\t\t\tif (!adapter.isConfigured()) return emptyResult(adapter.id, query)\n\n\t\t\tconst { range, clamped } = clampRange(\n\t\t\t\tquery.dateRange,\n\t\t\t\tadapter.capabilities.maxLookbackDays,\n\t\t\t\tquery.timezone\n\t\t\t)\n\t\t\tconst q = clamped ? { ...query, dateRange: range } : query\n\t\t\tconst key = buildCacheKey(adapter.id, q)\n\t\t\treturn coalesce(key, async () => {\n\t\t\t\tconst cached = await opts.store.get<AnalyticsResult>(key)\n\t\t\t\tif (cached) return cached\n\n\t\t\t\tconst
|
|
1
|
+
{"version":3,"file":"engine.js","names":[],"sources":["../../src/surfacing/engine.ts"],"sourcesContent":["import { buildCacheKey } from '../core/cacheKey'\nimport type { AnalyticsAdapter, AnalyticsQuery, AnalyticsResult } from '../core/contract'\nimport { DEFAULT_TIMEZONE, startOfDayInTz } from '../timeframe/tz'\nimport type { CacheStore } from './cacheStore'\nimport { createCoalescer } from './coalesce'\nimport { type EpochStore, INITIAL_EPOCH } from './epoch'\nimport { createQueue, type QueueOptions } from './queue'\nimport { limiterFor, type RateLimiter } from './rateLimiter'\nimport { PROVIDER_READ_TIMEOUT_MESSAGE, shouldRetryProviderError } from './retryPolicy'\n\nconst DAY_MS = 86_400_000\n\nconst clampRange = (\n\trange: AnalyticsQuery['dateRange'],\n\tmaxLookbackDays: number | null,\n\ttz: string = DEFAULT_TIMEZONE\n): { range: AnalyticsQuery['dateRange']; clamped: boolean } => {\n\tif (maxLookbackDays == null) {\n\t\treturn { range, clamped: false }\n\t}\n\tconst floor = new Date(startOfDayInTz(range.end, tz).getTime() - maxLookbackDays * DAY_MS)\n\tif (range.start.getTime() >= floor.getTime()) {\n\t\treturn { range, clamped: false }\n\t}\n\treturn { range: { start: floor, end: range.end }, clamped: true }\n}\n\nexport interface EngineOptions {\n\tstore: CacheStore\n\tqueue: QueueOptions\n\t/** Explicit TTL overrides; when a value is unset the adapter's recommendedTtl applies. */\n\tttl: { aggregate?: number; realtime?: number }\n\t/** Budget for a single adapter read; the in-flight request is aborted past this. */\n\ttimeoutMs: number\n\t/** Called once per failed adapter fetch, before falling back to a stale cache entry. */\n\tonError?: (err: unknown, adapterId: string) => void\n\t/**\n\t * Per-scope cache epoch carried by every key. Absent, every read keys on the initial\n\t * token and a provider change only clears the in-process maps, as it did before the\n\t * epoch shipped.\n\t */\n\tepoch?: Pick<EpochStore, 'get'>\n}\n\nexport interface Engine {\n\tread(adapter: AnalyticsAdapter, query: AnalyticsQuery): Promise<AnalyticsResult>\n}\n\nconst emptyResult = (provider: string, q: AnalyticsQuery): AnalyticsResult => ({\n\trows: [],\n\tmeta: { provider, fetchedAt: q.dateRange.end.toISOString() },\n})\n\nexport function createEngine(opts: EngineOptions): Engine {\n\tconst coalesce = createCoalescer<AnalyticsResult>()\n\tconst limiters = new Map<string, RateLimiter>()\n\tconst queue = createQueue({\n\t\t...opts.queue,\n\t\tshouldRetry: shouldRetryProviderError,\n\t\tbaseDelayMs: 500,\n\t})\n\n\treturn {\n\t\tasync read(adapter, query) {\n\t\t\tif (!adapter.isConfigured()) return emptyResult(adapter.id, query)\n\n\t\t\tconst { range, clamped } = clampRange(\n\t\t\t\tquery.dateRange,\n\t\t\t\tadapter.capabilities.maxLookbackDays,\n\t\t\t\tquery.timezone\n\t\t\t)\n\t\t\tconst q = clamped ? { ...query, dateRange: range } : query\n\t\t\t// Resolved before the key so the coalescer key carries the epoch too: two reads\n\t\t\t// across a bump must not share one in-flight answer.\n\t\t\tconst epoch = (await opts.epoch?.get(q.scope)) ?? INITIAL_EPOCH\n\t\t\tconst key = buildCacheKey(adapter.id, q, { epoch })\n\t\t\treturn coalesce(key, async () => {\n\t\t\t\tlet fresh: AnalyticsResult\n\t\t\t\tconst controller = new AbortController()\n\t\t\t\tconst timer = setTimeout(\n\t\t\t\t\t() => controller.abort(new Error(PROVIDER_READ_TIMEOUT_MESSAGE)),\n\t\t\t\t\topts.timeoutMs\n\t\t\t\t)\n\t\t\t\ttimer.unref?.()\n\t\t\t\ttry {\n\t\t\t\t\tconst cached = await opts.store.get<AnalyticsResult>(key)\n\t\t\t\t\tif (cached) return cached\n\n\t\t\t\t\t// Races the queued attempt itself, not just its backoff waits, so a signal-blind\n\t\t\t\t\t// adapter (one that never checks ctx.signal) still bounds the read at timeoutMs.\n\t\t\t\t\t// The orphaned attempt keeps its queue slot until the underlying client gives up;\n\t\t\t\t\t// this only bounds how long read() waits for it.\n\t\t\t\t\tconst aborted = new Promise<never>((_resolve, reject) => {\n\t\t\t\t\t\tcontroller.signal.addEventListener('abort', () => reject(controller.signal.reason), {\n\t\t\t\t\t\t\tonce: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t\tconst attempt = queue.run(async () => {\n\t\t\t\t\t\tconst release = await limiterFor(limiters, adapter).take(controller.signal)\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn await adapter.query(q, { signal: controller.signal })\n\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\trelease()\n\t\t\t\t\t\t}\n\t\t\t\t\t}, controller.signal)\n\t\t\t\t\tattempt.catch(() => {})\n\t\t\t\t\tfresh = await Promise.race([attempt, aborted])\n\t\t\t\t} catch (err) {\n\t\t\t\t\topts.onError?.(err, adapter.id)\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst stale = await opts.store.getStale<AnalyticsResult>(key)\n\t\t\t\t\t\tif (stale) return { ...stale, meta: { ...stale.meta, stale: true } }\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// A broken store fails getStale too; surface the original read error, not this one.\n\t\t\t\t\t}\n\t\t\t\t\tthrow err\n\t\t\t\t} finally {\n\t\t\t\t\tclearTimeout(timer)\n\t\t\t\t}\n\t\t\t\tconst result: AnalyticsResult = clamped\n\t\t\t\t\t? { ...fresh, meta: { ...fresh.meta, clamped: true } }\n\t\t\t\t\t: fresh\n\t\t\t\t// `goalsUnresolved` is always a failure to resolve, whatever hint the read carried:\n\t\t\t\t// a scope with no goals answers empty rows unflagged. At the aggregate TTL one\n\t\t\t\t// transient error would pin \"no conversions\" for an hour. A direct engine caller\n\t\t\t\t// that never hints is flagged on every read and so stays at the short TTL.\n\t\t\t\tconst degraded = result.meta.goalsUnresolved === true\n\t\t\t\tconst ttl = degraded\n\t\t\t\t\t? (opts.ttl.realtime ?? adapter.capabilities.recommendedTtl.realtime)\n\t\t\t\t\t: (opts.ttl.aggregate ?? adapter.capabilities.recommendedTtl.aggregate)\n\t\t\t\tawait opts.store.set(key, result, ttl)\n\t\t\t\treturn result\n\t\t\t})\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;AAUA,MAAM,SAAS;AAEf,MAAM,cACL,OACA,iBACA,KAAA,UAC8D;CAC9D,IAAI,mBAAmB,MACtB,OAAO;EAAE;EAAO,SAAS;CAAM;CAEhC,MAAM,wBAAQ,IAAI,KAAK,eAAe,MAAM,KAAK,EAAE,EAAE,QAAQ,IAAI,kBAAkB,MAAM;CACzF,IAAI,MAAM,MAAM,QAAQ,KAAK,MAAM,QAAQ,GAC1C,OAAO;EAAE;EAAO,SAAS;CAAM;CAEhC,OAAO;EAAE,OAAO;GAAE,OAAO;GAAO,KAAK,MAAM;EAAI;EAAG,SAAS;CAAK;AACjE;AAuBA,MAAM,eAAe,UAAkB,OAAwC;CAC9E,MAAM,CAAC;CACP,MAAM;EAAE;EAAU,WAAW,EAAE,UAAU,IAAI,YAAY;CAAE;AAC5D;AAEA,SAAgB,aAAa,MAA6B;CACzD,MAAM,WAAW,gBAAiC;CAClD,MAAM,2BAAW,IAAI,IAAyB;CAC9C,MAAM,QAAQ,YAAY;EACzB,GAAG,KAAK;EACR,aAAa;EACb,aAAa;CACd,CAAC;CAED,OAAO,EACN,MAAM,KAAK,SAAS,OAAO;EAC1B,IAAI,CAAC,QAAQ,aAAa,GAAG,OAAO,YAAY,QAAQ,IAAI,KAAK;EAEjE,MAAM,EAAE,OAAO,YAAY,WAC1B,MAAM,WACN,QAAQ,aAAa,iBACrB,MAAM,QACP;EACA,MAAM,IAAI,UAAU;GAAE,GAAG;GAAO,WAAW;EAAM,IAAI;EAGrD,MAAM,QAAS,MAAM,KAAK,OAAO,IAAI,EAAE,KAAK,KAAA;EAC5C,MAAM,MAAM,cAAc,QAAQ,IAAI,GAAG,EAAE,MAAM,CAAC;EAClD,OAAO,SAAS,KAAK,YAAY;GAChC,IAAI;GACJ,MAAM,aAAa,IAAI,gBAAgB;GACvC,MAAM,QAAQ,iBACP,WAAW,MAAM,IAAI,MAAM,6BAA6B,CAAC,GAC/D,KAAK,SACN;GACA,MAAM,QAAQ;GACd,IAAI;IACH,MAAM,SAAS,MAAM,KAAK,MAAM,IAAqB,GAAG;IACxD,IAAI,QAAQ,OAAO;IAMnB,MAAM,UAAU,IAAI,SAAgB,UAAU,WAAW;KACxD,WAAW,OAAO,iBAAiB,eAAe,OAAO,WAAW,OAAO,MAAM,GAAG,EACnF,MAAM,KACP,CAAC;IACF,CAAC;IACD,MAAM,UAAU,MAAM,IAAI,YAAY;KACrC,MAAM,UAAU,MAAM,WAAW,UAAU,OAAO,EAAE,KAAK,WAAW,MAAM;KAC1E,IAAI;MACH,OAAO,MAAM,QAAQ,MAAM,GAAG,EAAE,QAAQ,WAAW,OAAO,CAAC;KAC5D,UAAU;MACT,QAAQ;KACT;IACD,GAAG,WAAW,MAAM;IACpB,QAAQ,YAAY,CAAC,CAAC;IACtB,QAAQ,MAAM,QAAQ,KAAK,CAAC,SAAS,OAAO,CAAC;GAC9C,SAAS,KAAK;IACb,KAAK,UAAU,KAAK,QAAQ,EAAE;IAC9B,IAAI;KACH,MAAM,QAAQ,MAAM,KAAK,MAAM,SAA0B,GAAG;KAC5D,IAAI,OAAO,OAAO;MAAE,GAAG;MAAO,MAAM;OAAE,GAAG,MAAM;OAAM,OAAO;MAAK;KAAE;IACpE,QAAQ,CAER;IACA,MAAM;GACP,UAAU;IACT,aAAa,KAAK;GACnB;GACA,MAAM,SAA0B,UAC7B;IAAE,GAAG;IAAO,MAAM;KAAE,GAAG,MAAM;KAAM,SAAS;IAAK;GAAE,IACnD;GAMH,MAAM,MADW,OAAO,KAAK,oBAAoB,OAE7C,KAAK,IAAI,YAAY,QAAQ,aAAa,eAAe,WACzD,KAAK,IAAI,aAAa,QAAQ,aAAa,eAAe;GAC9D,MAAM,KAAK,MAAM,IAAI,KAAK,QAAQ,GAAG;GACrC,OAAO;EACR,CAAC;CACF,EACD;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Payload } from "payload";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/surfacing/epoch.ts
|
|
2
|
+
const DEFAULT_MEMO_MS = 1e4;
|
|
3
|
+
/**
|
|
4
|
+
* KV key for a scope's token. A null, undefined or empty scope is the install-wide token;
|
|
5
|
+
* every other scope, the platform wildcard included, is keyed under its own `s:` prefix, so
|
|
6
|
+
* a scope literally named `global` cannot reach the install-wide token. The scope is encoded
|
|
7
|
+
* so no value can forge another key.
|
|
8
|
+
*/
|
|
9
|
+
const epochKeyFor = (scope) => scope === null || scope === void 0 || scope === "" ? "analytics:epoch:global" : `analytics:epoch:s:${encodeURIComponent(scope)}`;
|
|
10
|
+
const readValue = (stored) => {
|
|
11
|
+
const value = stored?.value;
|
|
12
|
+
return typeof value === "string" && value !== "" ? value : "0";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Per-scope cache epoch in `payload.kv`. Every cached analytics read carries its scope's
|
|
16
|
+
* token in the key, so bumping retires that scope's entries at once on every instance
|
|
17
|
+
* without deleting anything: the old keys simply stop being asked for and expire.
|
|
18
|
+
*
|
|
19
|
+
* The token is opaque and a bump writes a fresh one rather than incrementing. A
|
|
20
|
+
* read-modify-write counter can move backwards under concurrent bumps and land on a value
|
|
21
|
+
* whose entries are still live; a value never used before is always safe, and nothing reads
|
|
22
|
+
* the token as a count of how many changes happened.
|
|
23
|
+
*/
|
|
24
|
+
function createEpochStore(payload, opts = {}) {
|
|
25
|
+
const memoMs = opts.memoMs ?? DEFAULT_MEMO_MS;
|
|
26
|
+
const now = opts.now ?? Date.now;
|
|
27
|
+
const memo = /* @__PURE__ */ new Map();
|
|
28
|
+
let warned = false;
|
|
29
|
+
const freshToken = (at) => `${at.toString(36)}-${crypto.randomUUID().slice(0, 8)}`;
|
|
30
|
+
return {
|
|
31
|
+
async get(scope) {
|
|
32
|
+
const key = epochKeyFor(scope);
|
|
33
|
+
const at = now();
|
|
34
|
+
const hit = memo.get(key);
|
|
35
|
+
if (hit && hit.expiresAt > at) return hit.value;
|
|
36
|
+
let value = "0";
|
|
37
|
+
try {
|
|
38
|
+
value = readValue(await payload.kv.get(key));
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (!warned) {
|
|
41
|
+
warned = true;
|
|
42
|
+
payload.logger?.warn(`analytics: cache epoch read failed, falling back to epoch 0: ${String(err)}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
memo.set(key, {
|
|
46
|
+
value,
|
|
47
|
+
expiresAt: at + memoMs
|
|
48
|
+
});
|
|
49
|
+
return value;
|
|
50
|
+
},
|
|
51
|
+
async bump(scope) {
|
|
52
|
+
const key = epochKeyFor(scope);
|
|
53
|
+
const at = now();
|
|
54
|
+
const next = freshToken(at);
|
|
55
|
+
try {
|
|
56
|
+
await payload.kv.set(key, { value: next });
|
|
57
|
+
memo.set(key, {
|
|
58
|
+
value: next,
|
|
59
|
+
expiresAt: at + memoMs
|
|
60
|
+
});
|
|
61
|
+
return next;
|
|
62
|
+
} catch (err) {
|
|
63
|
+
payload.logger?.warn(`analytics: cache epoch bump failed for "${key}": ${String(err)}`);
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { createEpochStore, epochKeyFor };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=epoch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epoch.js","names":[],"sources":["../../src/surfacing/epoch.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nexport interface EpochStore {\n\t/** The scope's current epoch token, served from an in-process memo inside the window. */\n\tget(scope?: string | null): Promise<string>\n\t/** Retires the scope's cached reads by storing a token nothing has used before. */\n\tbump(scope?: string | null): Promise<string>\n}\n\nexport interface EpochStoreOptions {\n\t/** How long a read epoch is trusted in process; the upper bound on bump propagation. */\n\tmemoMs?: number\n\tnow?: () => number\n}\n\nconst DEFAULT_MEMO_MS = 10_000\n\n/** The token a scope reads as until something bumps it, and after an unreadable get. */\nexport const INITIAL_EPOCH = '0'\n\n/**\n * KV key for a scope's token. A null, undefined or empty scope is the install-wide token;\n * every other scope, the platform wildcard included, is keyed under its own `s:` prefix, so\n * a scope literally named `global` cannot reach the install-wide token. The scope is encoded\n * so no value can forge another key.\n */\nexport const epochKeyFor = (scope?: string | null): string =>\n\tscope === null || scope === undefined || scope === ''\n\t\t? 'analytics:epoch:global'\n\t\t: `analytics:epoch:s:${encodeURIComponent(scope)}`\n\ninterface StoredEpoch {\n\tvalue: string\n}\n\nconst readValue = (stored: StoredEpoch | null): string => {\n\tconst value = stored?.value\n\treturn typeof value === 'string' && value !== '' ? value : INITIAL_EPOCH\n}\n\n/**\n * Per-scope cache epoch in `payload.kv`. Every cached analytics read carries its scope's\n * token in the key, so bumping retires that scope's entries at once on every instance\n * without deleting anything: the old keys simply stop being asked for and expire.\n *\n * The token is opaque and a bump writes a fresh one rather than incrementing. A\n * read-modify-write counter can move backwards under concurrent bumps and land on a value\n * whose entries are still live; a value never used before is always safe, and nothing reads\n * the token as a count of how many changes happened.\n */\nexport function createEpochStore(payload: Payload, opts: EpochStoreOptions = {}): EpochStore {\n\tconst memoMs = opts.memoMs ?? DEFAULT_MEMO_MS\n\tconst now = opts.now ?? Date.now\n\tconst memo = new Map<string, { value: string; expiresAt: number }>()\n\tlet warned = false\n\n\tconst freshToken = (at: number): string => `${at.toString(36)}-${crypto.randomUUID().slice(0, 8)}`\n\n\treturn {\n\t\tasync get(scope) {\n\t\t\tconst key = epochKeyFor(scope)\n\t\t\tconst at = now()\n\t\t\tconst hit = memo.get(key)\n\t\t\tif (hit && hit.expiresAt > at) {\n\t\t\t\treturn hit.value\n\t\t\t}\n\t\t\tlet value = INITIAL_EPOCH\n\t\t\ttry {\n\t\t\t\tvalue = readValue(await payload.kv.get<StoredEpoch>(key))\n\t\t\t} catch (err) {\n\t\t\t\t// A read must never fail over an unreachable token. The failure is memoized like a\n\t\t\t\t// hit, so a broken KV is asked once per window rather than once per read; for that\n\t\t\t\t// window this instance may serve entries written before the last bump.\n\t\t\t\tif (!warned) {\n\t\t\t\t\twarned = true\n\t\t\t\t\tpayload.logger?.warn(\n\t\t\t\t\t\t`analytics: cache epoch read failed, falling back to epoch ${INITIAL_EPOCH}: ${String(err)}`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemo.set(key, { value, expiresAt: at + memoMs })\n\t\t\treturn value\n\t\t},\n\t\tasync bump(scope) {\n\t\t\tconst key = epochKeyFor(scope)\n\t\t\tconst at = now()\n\t\t\tconst next = freshToken(at)\n\t\t\ttry {\n\t\t\t\tawait payload.kv.set(key, { value: next })\n\t\t\t\tmemo.set(key, { value: next, expiresAt: at + memoMs })\n\t\t\t\treturn next\n\t\t\t} catch (err) {\n\t\t\t\t// Rethrown, unlike a failed get: a caller asking to invalidate has to learn that\n\t\t\t\t// the old numbers are still being served.\n\t\t\t\tpayload.logger?.warn(`analytics: cache epoch bump failed for \"${key}\": ${String(err)}`)\n\t\t\t\tthrow err\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";AAeA,MAAM,kBAAkB;;;;;;;AAWxB,MAAa,eAAe,UAC3B,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU,KAChD,2BACA,qBAAqB,mBAAmB,KAAK;AAMjD,MAAM,aAAa,WAAuC;CACzD,MAAM,QAAQ,QAAQ;CACtB,OAAO,OAAO,UAAU,YAAY,UAAU,KAAK,QAAA;AACpD;;;;;;;;;;;AAYA,SAAgB,iBAAiB,SAAkB,OAA0B,CAAC,GAAe;CAC5F,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,MAAM,KAAK,OAAO,KAAK;CAC7B,MAAM,uBAAO,IAAI,IAAkD;CACnE,IAAI,SAAS;CAEb,MAAM,cAAc,OAAuB,GAAG,GAAG,SAAS,EAAE,EAAE,GAAG,OAAO,WAAW,EAAE,MAAM,GAAG,CAAC;CAE/F,OAAO;EACN,MAAM,IAAI,OAAO;GAChB,MAAM,MAAM,YAAY,KAAK;GAC7B,MAAM,KAAK,IAAI;GACf,MAAM,MAAM,KAAK,IAAI,GAAG;GACxB,IAAI,OAAO,IAAI,YAAY,IAC1B,OAAO,IAAI;GAEZ,IAAI,QAAA;GACJ,IAAI;IACH,QAAQ,UAAU,MAAM,QAAQ,GAAG,IAAiB,GAAG,CAAC;GACzD,SAAS,KAAK;IAIb,IAAI,CAAC,QAAQ;KACZ,SAAS;KACT,QAAQ,QAAQ,KACf,gEAA+E,OAAO,GAAG,GAC1F;IACD;GACD;GACA,KAAK,IAAI,KAAK;IAAE;IAAO,WAAW,KAAK;GAAO,CAAC;GAC/C,OAAO;EACR;EACA,MAAM,KAAK,OAAO;GACjB,MAAM,MAAM,YAAY,KAAK;GAC7B,MAAM,KAAK,IAAI;GACf,MAAM,OAAO,WAAW,EAAE;GAC1B,IAAI;IACH,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAE,OAAO,KAAK,CAAC;IACzC,KAAK,IAAI,KAAK;KAAE,OAAO;KAAM,WAAW,KAAK;IAAO,CAAC;IACrD,OAAO;GACR,SAAS,KAAK;IAGb,QAAQ,QAAQ,KAAK,2CAA2C,IAAI,KAAK,OAAO,GAAG,GAAG;IACtF,MAAM;GACP;EACD;CACD;AACD"}
|
package/dist/surfacing/queue.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
//#region src/surfacing/queue.ts
|
|
2
|
-
|
|
2
|
+
/** Resolves after ms, or rethrows the original task error early if signal aborts first. */
|
|
3
|
+
const wait = (ms, taskErr, signal) => {
|
|
4
|
+
if (!signal) return new Promise((r) => setTimeout(r, ms));
|
|
5
|
+
if (signal.aborted) return Promise.reject(taskErr);
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const timer = setTimeout(() => {
|
|
8
|
+
signal.removeEventListener("abort", onAbort);
|
|
9
|
+
resolve();
|
|
10
|
+
}, ms);
|
|
11
|
+
const onAbort = () => {
|
|
12
|
+
clearTimeout(timer);
|
|
13
|
+
reject(taskErr);
|
|
14
|
+
};
|
|
15
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
16
|
+
});
|
|
17
|
+
};
|
|
3
18
|
function createQueue(opts) {
|
|
4
19
|
const maxRetries = opts.maxRetries ?? 0;
|
|
5
20
|
const baseDelayMs = opts.baseDelayMs ?? 200;
|
|
@@ -18,21 +33,22 @@ function createQueue(opts) {
|
|
|
18
33
|
active--;
|
|
19
34
|
pending.shift()?.();
|
|
20
35
|
};
|
|
21
|
-
const withRetry = async (task) => {
|
|
36
|
+
const withRetry = async (task, signal) => {
|
|
22
37
|
let attempt = 0;
|
|
23
38
|
for (;;) try {
|
|
24
39
|
return await task();
|
|
25
40
|
} catch (err) {
|
|
26
|
-
if (attempt
|
|
41
|
+
if (!(opts.shouldRetry ? opts.shouldRetry(err, attempt) : attempt < maxRetries)) throw err;
|
|
27
42
|
const jitter = baseDelayMs * .5;
|
|
28
|
-
await wait(baseDelayMs * 2 ** attempt + jitter * attempt);
|
|
43
|
+
await wait(baseDelayMs * 2 ** attempt + jitter * attempt, err, signal);
|
|
29
44
|
attempt++;
|
|
30
45
|
}
|
|
31
46
|
};
|
|
32
|
-
return { async run(task) {
|
|
47
|
+
return { async run(task, signal) {
|
|
48
|
+
if (signal?.aborted) throw signal.reason;
|
|
33
49
|
await acquire();
|
|
34
50
|
try {
|
|
35
|
-
return await withRetry(task);
|
|
51
|
+
return await withRetry(task, signal);
|
|
36
52
|
} finally {
|
|
37
53
|
release();
|
|
38
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","names":[],"sources":["../../src/surfacing/queue.ts"],"sourcesContent":["export interface QueueOptions {\n\tconcurrency: number\n\tmaxRetries?: number\n\tbaseDelayMs?: number\n}\n\nexport interface Queue {\n\trun<T>(task: () => Promise<T
|
|
1
|
+
{"version":3,"file":"queue.js","names":[],"sources":["../../src/surfacing/queue.ts"],"sourcesContent":["export interface QueueOptions {\n\tconcurrency: number\n\tmaxRetries?: number\n\tbaseDelayMs?: number\n\t/** Consulted per attempt in place of the maxRetries check when provided. */\n\tshouldRetry?: (err: unknown, attempt: number) => boolean\n}\n\nexport interface Queue {\n\trun<T>(task: () => Promise<T>, signal?: AbortSignal): Promise<T>\n}\n\n/** Resolves after ms, or rethrows the original task error early if signal aborts first. */\nconst wait = (ms: number, taskErr: unknown, signal?: AbortSignal): Promise<void> => {\n\tif (!signal) return new Promise((r) => setTimeout(r, ms))\n\t// An abort that already fired won't fire its event again, so a listener added\n\t// after the fact never triggers; check the already-aborted case up front.\n\tif (signal.aborted) return Promise.reject(taskErr)\n\treturn new Promise<void>((resolve, reject) => {\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal.removeEventListener('abort', onAbort)\n\t\t\tresolve()\n\t\t}, ms)\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timer)\n\t\t\treject(taskErr)\n\t\t}\n\t\tsignal.addEventListener('abort', onAbort, { once: true })\n\t})\n}\n\nexport function createQueue(opts: QueueOptions): Queue {\n\tconst maxRetries = opts.maxRetries ?? 0\n\tconst baseDelayMs = opts.baseDelayMs ?? 200\n\tlet active = 0\n\tconst pending: Array<() => void> = []\n\n\tconst acquire = (): Promise<void> => {\n\t\tif (active < opts.concurrency) {\n\t\t\tactive++\n\t\t\treturn Promise.resolve()\n\t\t}\n\t\treturn new Promise<void>((resolve) => pending.push(resolve)).then(() => {\n\t\t\tactive++\n\t\t})\n\t}\n\n\tconst release = (): void => {\n\t\tactive--\n\t\tpending.shift()?.()\n\t}\n\n\tconst withRetry = async <T>(task: () => Promise<T>, signal?: AbortSignal): Promise<T> => {\n\t\tlet attempt = 0\n\t\tfor (;;) {\n\t\t\ttry {\n\t\t\t\treturn await task()\n\t\t\t} catch (err) {\n\t\t\t\tconst canRetry = opts.shouldRetry ? opts.shouldRetry(err, attempt) : attempt < maxRetries\n\t\t\t\tif (!canRetry) throw err\n\t\t\t\t// Jitter derived from attempt count, not Math.random, to keep tests deterministic\n\t\t\t\tconst jitter = baseDelayMs * 0.5\n\t\t\t\tawait wait(baseDelayMs * 2 ** attempt + jitter * attempt, err, signal)\n\t\t\t\tattempt++\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tasync run<T>(task: () => Promise<T>, signal?: AbortSignal): Promise<T> {\n\t\t\tif (signal?.aborted) throw signal.reason\n\t\t\tawait acquire()\n\t\t\ttry {\n\t\t\t\treturn await withRetry(task, signal)\n\t\t\t} finally {\n\t\t\t\trelease()\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;AAaA,MAAM,QAAQ,IAAY,SAAkB,WAAwC;CACnF,IAAI,CAAC,QAAQ,OAAO,IAAI,SAAS,MAAM,WAAW,GAAG,EAAE,CAAC;CAGxD,IAAI,OAAO,SAAS,OAAO,QAAQ,OAAO,OAAO;CACjD,OAAO,IAAI,SAAe,SAAS,WAAW;EAC7C,MAAM,QAAQ,iBAAiB;GAC9B,OAAO,oBAAoB,SAAS,OAAO;GAC3C,QAAQ;EACT,GAAG,EAAE;EACL,MAAM,gBAAgB;GACrB,aAAa,KAAK;GAClB,OAAO,OAAO;EACf;EACA,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CACzD,CAAC;AACF;AAEA,SAAgB,YAAY,MAA2B;CACtD,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,cAAc,KAAK,eAAe;CACxC,IAAI,SAAS;CACb,MAAM,UAA6B,CAAC;CAEpC,MAAM,gBAA+B;EACpC,IAAI,SAAS,KAAK,aAAa;GAC9B;GACA,OAAO,QAAQ,QAAQ;EACxB;EACA,OAAO,IAAI,SAAe,YAAY,QAAQ,KAAK,OAAO,CAAC,EAAE,WAAW;GACvE;EACD,CAAC;CACF;CAEA,MAAM,gBAAsB;EAC3B;EACA,QAAQ,MAAM,IAAI;CACnB;CAEA,MAAM,YAAY,OAAU,MAAwB,WAAqC;EACxF,IAAI,UAAU;EACd,SACC,IAAI;GACH,OAAO,MAAM,KAAK;EACnB,SAAS,KAAK;GAEb,IAAI,EADa,KAAK,cAAc,KAAK,YAAY,KAAK,OAAO,IAAI,UAAU,aAChE,MAAM;GAErB,MAAM,SAAS,cAAc;GAC7B,MAAM,KAAK,cAAc,KAAK,UAAU,SAAS,SAAS,KAAK,MAAM;GACrE;EACD;CAEF;CAEA,OAAO,EACN,MAAM,IAAO,MAAwB,QAAkC;EACtE,IAAI,QAAQ,SAAS,MAAM,OAAO;EAClC,MAAM,QAAQ;EACd,IAAI;GACH,OAAO,MAAM,UAAU,MAAM,MAAM;EACpC,UAAU;GACT,QAAQ;EACT;CACD,EACD;AACD"}
|