@10x-media/analytics 1.0.0-beta.8 → 4.0.0-alpha.1
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 +780 -0
- package/LICENSE +21 -21
- package/README.md +35 -36
- package/dist/access/adminUser.d.ts +15 -0
- package/dist/access/adminUser.js +13 -0
- package/dist/access/adminUser.js.map +1 -0
- package/dist/access/decideOnce.js +16 -0
- package/dist/access/decideOnce.js.map +1 -0
- package/dist/access/membership.d.ts +23 -0
- package/dist/access/membership.js +63 -0
- package/dist/access/membership.js.map +1 -0
- package/dist/access/principal.d.ts +37 -0
- package/dist/access/principal.js +29 -0
- package/dist/access/principal.js.map +1 -0
- package/dist/access/readGate.js +16 -0
- package/dist/access/readGate.js.map +1 -0
- package/dist/adapters/ga4/disableKey.js +19 -0
- package/dist/adapters/ga4/disableKey.js.map +1 -0
- package/dist/adapters/ga4/eventName.d.ts +9 -0
- package/dist/adapters/ga4/eventName.js +13 -0
- package/dist/adapters/ga4/eventName.js.map +1 -0
- package/dist/adapters/ga4/ga4.d.ts +29 -0
- package/dist/adapters/ga4/ga4.js +324 -112
- package/dist/adapters/ga4/ga4.js.map +1 -1
- package/dist/adapters/ga4/measurementId.js +14 -0
- package/dist/adapters/ga4/measurementId.js.map +1 -0
- package/dist/adapters/goalRead.js +112 -0
- package/dist/adapters/goalRead.js.map +1 -0
- package/dist/adapters/http/baseUrl.js +15 -0
- package/dist/adapters/http/baseUrl.js.map +1 -0
- package/dist/adapters/http/fetchJson.d.ts +19 -0
- package/dist/adapters/http/fetchJson.js +27 -8
- package/dist/adapters/http/fetchJson.js.map +1 -1
- package/dist/adapters/mapping.js +52 -0
- package/dist/adapters/mapping.js.map +1 -0
- package/dist/adapters/plausible/plausible.d.ts +30 -3
- package/dist/adapters/plausible/plausible.js +198 -110
- package/dist/adapters/plausible/plausible.js.map +1 -1
- package/dist/adapters/plausible/scriptId.js +19 -0
- package/dist/adapters/plausible/scriptId.js.map +1 -0
- package/dist/adapters/posthog/posthog.d.ts +33 -9
- package/dist/adapters/posthog/posthog.js +307 -127
- package/dist/adapters/posthog/posthog.js.map +1 -1
- package/dist/adapters/posthog/projectCheck.js +56 -0
- package/dist/adapters/posthog/projectCheck.js.map +1 -0
- package/dist/adapters/readTime.js +7 -0
- package/dist/adapters/readTime.js.map +1 -0
- package/dist/adapters/series.js +14 -8
- package/dist/adapters/series.js.map +1 -1
- package/dist/adapters/umami/umami.d.ts +21 -3
- package/dist/adapters/umami/umami.js +334 -95
- package/dist/adapters/umami/umami.js.map +1 -1
- package/dist/adapters/upstream.js +16 -0
- package/dist/adapters/upstream.js.map +1 -0
- package/dist/binding/report.d.ts +8 -0
- package/dist/binding/report.js +24 -0
- package/dist/binding/report.js.map +1 -0
- package/dist/binding/resolvePath.js +28 -25
- package/dist/binding/resolvePath.js.map +1 -1
- package/dist/binding/types.d.ts +14 -29
- package/dist/capture/captureRequest.js +28 -0
- package/dist/capture/captureRequest.js.map +1 -0
- package/dist/capture/exclusionEndpoint.js +98 -0
- package/dist/capture/exclusionEndpoint.js.map +1 -0
- package/dist/capture/exclusionPrelude.js +14 -0
- package/dist/capture/exclusionPrelude.js.map +1 -0
- package/dist/capture/exclusionToken.js +23 -0
- package/dist/capture/exclusionToken.js.map +1 -0
- package/dist/capture/jsLiteral.js +19 -0
- package/dist/capture/jsLiteral.js.map +1 -0
- package/dist/capture/mountPath.js +2 -3
- package/dist/capture/mountPath.js.map +1 -1
- package/dist/capture/proxyEndpoint.js +49 -92
- package/dist/capture/proxyEndpoint.js.map +1 -1
- package/dist/capture/proxyRoutes.js +58 -21
- package/dist/capture/proxyRoutes.js.map +1 -1
- package/dist/capture/relay.js +91 -0
- package/dist/capture/relay.js.map +1 -0
- package/dist/capture/requestBody.js +2 -6
- package/dist/capture/requestBody.js.map +1 -1
- package/dist/capture/requestTrust.js +45 -0
- package/dist/capture/requestTrust.js.map +1 -0
- package/dist/capture/sameSite.js +40 -0
- package/dist/capture/sameSite.js.map +1 -0
- package/dist/capture/slots.js +50 -25
- package/dist/capture/slots.js.map +1 -1
- package/dist/capture/trackerConfig.js +131 -36
- package/dist/capture/trackerConfig.js.map +1 -1
- package/dist/capture/trackerEndpoint.js +22 -21
- package/dist/capture/trackerEndpoint.js.map +1 -1
- package/dist/capture/withoutConsent.js +91 -0
- package/dist/capture/withoutConsent.js.map +1 -0
- package/dist/charts/BarList.d.ts +27 -13
- package/dist/charts/BarList.js +38 -77
- package/dist/charts/BarList.js.map +1 -1
- package/dist/charts/TrendChart.d.ts +40 -7
- package/dist/charts/TrendChart.js +243 -215
- package/dist/charts/TrendChart.js.map +1 -1
- package/dist/charts/bars.d.ts +17 -1
- package/dist/charts/bars.js +12 -11
- package/dist/charts/bars.js.map +1 -1
- package/dist/charts/bucket.js +106 -73
- package/dist/charts/bucket.js.map +1 -1
- package/dist/charts/inProgress.js +22 -0
- package/dist/charts/inProgress.js.map +1 -0
- package/dist/charts/series.d.ts +15 -0
- package/dist/charts/series.js +123 -0
- package/dist/charts/series.js.map +1 -0
- package/dist/charts/spline.js +91 -25
- package/dist/charts/spline.js.map +1 -1
- package/dist/charts/trendGeometry.js +91 -0
- package/dist/charts/trendGeometry.js.map +1 -0
- package/dist/core/adminOptions.d.ts +1 -0
- package/dist/core/adminOptions.js +198 -0
- package/dist/core/adminOptions.js.map +1 -0
- package/dist/core/budget.js +24 -0
- package/dist/core/budget.js.map +1 -0
- package/dist/core/cacheKey.d.ts +1 -0
- package/dist/core/cacheKey.js +51 -29
- package/dist/core/cacheKey.js.map +1 -1
- package/dist/core/cacheOptions.js +165 -0
- package/dist/core/cacheOptions.js.map +1 -0
- package/dist/core/capabilities.d.ts +24 -11
- package/dist/core/capabilities.js +101 -17
- package/dist/core/capabilities.js.map +1 -1
- package/dist/core/capture.d.ts +59 -26
- package/dist/core/captureOptions.d.ts +1 -0
- package/dist/core/captureOptions.js +347 -0
- package/dist/core/captureOptions.js.map +1 -0
- package/dist/core/clock.js +13 -0
- package/dist/core/clock.js.map +1 -0
- package/dist/core/collectionOption.d.ts +17 -0
- package/dist/core/collectionOption.js +105 -0
- package/dist/core/collectionOption.js.map +1 -0
- package/dist/core/collectionSlug.js +7 -0
- package/dist/core/collectionSlug.js.map +1 -0
- package/dist/core/contract.d.ts +340 -49
- package/dist/core/contract.js +7 -4
- package/dist/core/contract.js.map +1 -1
- package/dist/core/cron.js +57 -0
- package/dist/core/cron.js.map +1 -0
- package/dist/core/fetch.d.ts +17 -0
- package/dist/core/goalOptions.d.ts +1 -0
- package/dist/core/goalOptions.js +166 -0
- package/dist/core/goalOptions.js.map +1 -0
- package/dist/core/granularity.js +3 -2
- package/dist/core/granularity.js.map +1 -1
- package/dist/core/guards.js +17 -0
- package/dist/core/guards.js.map +1 -0
- package/dist/core/jobs.d.ts +40 -0
- package/dist/core/jobs.js +132 -0
- package/dist/core/jobs.js.map +1 -0
- package/dist/core/legacyOptions.js +145 -0
- package/dist/core/legacyOptions.js.map +1 -0
- package/dist/core/metricAliases.js +81 -0
- package/dist/core/metricAliases.js.map +1 -0
- package/dist/core/metricValues.js +57 -0
- package/dist/core/metricValues.js.map +1 -0
- package/dist/core/monotonic.js +10 -0
- package/dist/core/monotonic.js.map +1 -0
- package/dist/core/optionChecks.js +51 -0
- package/dist/core/optionChecks.js.map +1 -0
- package/dist/core/options.d.ts +535 -151
- package/dist/core/options.js +158 -214
- package/dist/core/options.js.map +1 -1
- package/dist/core/registry.js +45 -5
- package/dist/core/registry.js.map +1 -1
- package/dist/core/scopeList.js +7 -9
- package/dist/core/scopeList.js.map +1 -1
- package/dist/core/scopeOptions.d.ts +1 -0
- package/dist/core/scopeOptions.js +114 -0
- package/dist/core/scopeOptions.js.map +1 -0
- package/dist/core/scopedRead.js +349 -36
- package/dist/core/scopedRead.js.map +1 -1
- package/dist/core/sdks.d.ts +81 -0
- package/dist/core/sdks.js +23 -0
- package/dist/core/sdks.js.map +1 -0
- package/dist/core/serverEvent.d.ts +50 -14
- package/dist/core/serverEvent.js.map +1 -1
- package/dist/core/siteAddress.js +20 -0
- package/dist/core/siteAddress.js.map +1 -0
- package/dist/core/sourceErrors.js +109 -0
- package/dist/core/sourceErrors.js.map +1 -0
- package/dist/core/sourceLabel.d.ts +10 -0
- package/dist/core/sourceLabel.js +63 -0
- package/dist/core/sourceLabel.js.map +1 -0
- package/dist/core/sourceOptions.js +107 -0
- package/dist/core/sourceOptions.js.map +1 -0
- package/dist/core/sourcePolicy.d.ts +55 -0
- package/dist/core/sourcePolicy.js +51 -0
- package/dist/core/sourcePolicy.js.map +1 -0
- package/dist/core/throttle.js +18 -0
- package/dist/core/throttle.js.map +1 -0
- package/dist/core/values.js +61 -0
- package/dist/core/values.js.map +1 -0
- package/dist/core/widgetSlugs.d.ts +17 -0
- package/dist/core/widgetSlugs.js +29 -0
- package/dist/core/widgetSlugs.js.map +1 -0
- package/dist/db/detachedWrite.js +36 -0
- package/dist/db/detachedWrite.js.map +1 -0
- package/dist/db/errors.js +182 -0
- package/dist/db/errors.js.map +1 -0
- package/dist/db/kind.js +32 -0
- package/dist/db/kind.js.map +1 -0
- package/dist/db/openTransaction.js +51 -0
- package/dist/db/openTransaction.js.map +1 -0
- package/dist/exports/adapters/contract.d.ts +15 -0
- package/dist/exports/adapters/ga4.d.ts +17 -1
- package/dist/exports/adapters/ga4.js +2 -1
- package/dist/exports/adapters/native.d.ts +29 -2
- package/dist/exports/adapters/native.js +5 -1
- package/dist/exports/adapters/plausible.d.ts +16 -1
- package/dist/exports/adapters/posthog.d.ts +16 -1
- package/dist/exports/adapters/umami.d.ts +16 -1
- package/dist/exports/attributes.d.ts +42 -0
- package/dist/exports/attributes.js +83 -0
- package/dist/exports/attributes.js.map +1 -0
- package/dist/exports/client.d.ts +45 -11
- package/dist/exports/client.js +23 -6
- package/dist/exports/geo.d.ts +4 -2
- package/dist/exports/geo.js +1 -1
- package/dist/exports/i18n.d.ts +2 -2
- package/dist/exports/i18n.js +2 -2
- package/dist/exports/migrations.d.ts +2 -0
- package/dist/exports/migrations.js +2 -0
- package/dist/exports/react.d.ts +5 -3
- package/dist/exports/react.js +1 -2
- package/dist/exports/routes.d.ts +19 -0
- package/dist/exports/routes.js +3 -0
- package/dist/exports/rsc.d.ts +33 -14
- package/dist/exports/rsc.js +11 -6
- package/dist/exports/site.d.ts +5 -0
- package/dist/exports/site.js +3 -0
- package/dist/exports/testing.d.ts +18 -0
- package/dist/exports/testing.js +3 -0
- package/dist/exports/tracker.d.ts +6 -17
- package/dist/exports/tracker.js +3 -11
- package/dist/exports/types.d.ts +46 -14
- package/dist/exports/types.js +7 -1
- package/dist/fields/AnalyticsPanelClient.js +265 -154
- package/dist/fields/AnalyticsPanelClient.js.map +1 -1
- package/dist/fields/AnalyticsPanelField.d.ts +19 -7
- package/dist/fields/AnalyticsPanelField.js +123 -30
- package/dist/fields/AnalyticsPanelField.js.map +1 -1
- package/dist/fields/AnalyticsStatField.d.ts +17 -6
- package/dist/fields/AnalyticsStatField.js +98 -63
- package/dist/fields/AnalyticsStatField.js.map +1 -1
- package/dist/fields/FieldShimmer.js +15 -0
- package/dist/fields/FieldShimmer.js.map +1 -0
- package/dist/fields/PanelContent.js +222 -0
- package/dist/fields/PanelContent.js.map +1 -0
- package/dist/fields/PanelList.js +82 -0
- package/dist/fields/PanelList.js.map +1 -0
- package/dist/fields/PanelLiveCounter.js +63 -0
- package/dist/fields/PanelLiveCounter.js.map +1 -0
- package/dist/fields/PanelSkeleton.js +63 -0
- package/dist/fields/PanelSkeleton.js.map +1 -0
- package/dist/fields/componentPaths.js +8 -0
- package/dist/fields/componentPaths.js.map +1 -0
- package/dist/fields/config/FilterDimensionSelectField.d.ts +14 -0
- package/dist/fields/config/FilterDimensionSelectField.js +49 -0
- package/dist/fields/config/FilterDimensionSelectField.js.map +1 -0
- package/dist/fields/config/FilterKeySelect.js +66 -0
- package/dist/fields/config/FilterKeySelect.js.map +1 -0
- package/dist/fields/config/FilterOperatorSelectField.d.ts +19 -0
- package/dist/fields/config/FilterOperatorSelectField.js +59 -0
- package/dist/fields/config/FilterOperatorSelectField.js.map +1 -0
- package/dist/fields/config/FilterValueField.d.ts +17 -0
- package/dist/fields/config/FilterValueField.js +130 -0
- package/dist/fields/config/FilterValueField.js.map +1 -0
- package/dist/fields/config/MetricSelectField.d.ts +5 -12
- package/dist/fields/config/MetricSelectField.js +19 -31
- package/dist/fields/config/MetricSelectField.js.map +1 -1
- package/dist/fields/config/OptionSelect.js +52 -0
- package/dist/fields/config/OptionSelect.js.map +1 -0
- package/dist/fields/config/SourceSelectField.js +16 -31
- package/dist/fields/config/SourceSelectField.js.map +1 -1
- package/dist/fields/config/fetchSources.d.ts +3 -0
- package/dist/fields/config/fetchSources.js +17 -23
- package/dist/fields/config/fetchSources.js.map +1 -1
- package/dist/fields/config/filterValues.js +106 -0
- package/dist/fields/config/filterValues.js.map +1 -0
- package/dist/fields/config/narrow.js +8 -10
- package/dist/fields/config/narrow.js.map +1 -1
- package/dist/fields/config/retiredPickers.d.ts +45 -0
- package/dist/fields/config/retiredPickers.js +46 -0
- package/dist/fields/config/retiredPickers.js.map +1 -0
- package/dist/fields/config/scopedFields.d.ts +40 -0
- package/dist/fields/config/scopedFields.js +68 -0
- package/dist/fields/config/scopedFields.js.map +1 -0
- package/dist/fields/config/sourcesState.js +19 -3
- package/dist/fields/config/sourcesState.js.map +1 -1
- package/dist/fields/config/toSelectOption.js +13 -7
- package/dist/fields/config/toSelectOption.js.map +1 -1
- package/dist/fields/config/useAnalyticsSources.d.ts +10 -7
- package/dist/fields/config/useAnalyticsSources.js +23 -24
- package/dist/fields/config/useAnalyticsSources.js.map +1 -1
- package/dist/fields/config/useFilterCapabilities.d.ts +31 -0
- package/dist/fields/config/useFilterCapabilities.js +60 -0
- package/dist/fields/config/useFilterCapabilities.js.map +1 -0
- package/dist/fields/config/useFormString.js +12 -0
- package/dist/fields/config/useFormString.js.map +1 -0
- package/dist/fields/dateRange/field.js +7 -19
- package/dist/fields/dateRange/field.js.map +1 -1
- package/dist/fields/dateRange/types.d.ts +5 -1
- package/dist/fields/dateRange/ui.d.ts +3 -2
- package/dist/fields/dateRange/ui.js +57 -319
- package/dist/fields/dateRange/ui.js.map +1 -1
- package/dist/fields/documentScope.js +21 -0
- package/dist/fields/documentScope.js.map +1 -0
- package/dist/fields/emptyState.js +30 -26
- package/dist/fields/emptyState.js.map +1 -1
- package/dist/fields/factories.d.ts +35 -16
- package/dist/fields/factories.js +67 -38
- package/dist/fields/factories.js.map +1 -1
- package/dist/fields/format.d.ts +12 -3
- package/dist/fields/format.js +77 -13
- package/dist/fields/format.js.map +1 -1
- package/dist/fields/itemReport.js +45 -0
- package/dist/fields/itemReport.js.map +1 -0
- package/dist/fields/readForDocument.d.ts +79 -26
- package/dist/fields/readForDocument.js +451 -105
- package/dist/fields/readForDocument.js.map +1 -1
- package/dist/fields/stateKeys.js +20 -0
- package/dist/fields/stateKeys.js.map +1 -0
- package/dist/goals/GoalAmountField.d.ts +10 -0
- package/dist/goals/GoalAmountField.js +179 -0
- package/dist/goals/GoalAmountField.js.map +1 -0
- package/dist/goals/GoalSelectField.js +89 -40
- package/dist/goals/GoalSelectField.js.map +1 -1
- package/dist/goals/GoalSelectFieldServer.d.ts +13 -0
- package/dist/goals/GoalSelectFieldServer.js +21 -0
- package/dist/goals/GoalSelectFieldServer.js.map +1 -0
- package/dist/goals/amountField.d.ts +20 -0
- package/dist/goals/amountField.js +37 -0
- package/dist/goals/amountField.js.map +1 -0
- package/dist/goals/builtin.js +17 -0
- package/dist/goals/builtin.js.map +1 -0
- package/dist/goals/collection.d.ts +22 -0
- package/dist/goals/collection.js +143 -124
- package/dist/goals/collection.js.map +1 -1
- package/dist/goals/constants.d.ts +38 -0
- package/dist/goals/constants.js +49 -0
- package/dist/goals/constants.js.map +1 -0
- package/dist/goals/currency.d.ts +16 -0
- package/dist/goals/currency.js +46 -4
- package/dist/goals/currency.js.map +1 -1
- package/dist/goals/currencyOptions.js +70 -0
- package/dist/goals/currencyOptions.js.map +1 -0
- package/dist/goals/fetchGoals.d.ts +10 -0
- package/dist/goals/fetchGoals.js +12 -22
- package/dist/goals/fetchGoals.js.map +1 -1
- package/dist/goals/goalField.d.ts +4 -6
- package/dist/goals/goalField.js +9 -19
- package/dist/goals/goalField.js.map +1 -1
- package/dist/goals/goalsEndpoint.js +40 -38
- package/dist/goals/goalsEndpoint.js.map +1 -1
- package/dist/goals/items.js +35 -0
- package/dist/goals/items.js.map +1 -0
- package/dist/goals/latent.js +9 -0
- package/dist/goals/latent.js.map +1 -0
- package/dist/goals/linkFields.d.ts +35 -0
- package/dist/goals/linkFields.js +31 -0
- package/dist/goals/linkFields.js.map +1 -0
- package/dist/goals/match.d.ts +14 -0
- package/dist/goals/match.js +67 -46
- package/dist/goals/match.js.map +1 -1
- package/dist/goals/moneyFields.js +56 -0
- package/dist/goals/moneyFields.js.map +1 -0
- package/dist/goals/pathMatch.js +122 -0
- package/dist/goals/pathMatch.js.map +1 -0
- package/dist/goals/placeholder.js +12 -0
- package/dist/goals/placeholder.js.map +1 -0
- package/dist/goals/resolver.d.ts +3 -3
- package/dist/goals/resolver.js +155 -47
- package/dist/goals/resolver.js.map +1 -1
- package/dist/goals/serverRevenue.d.ts +60 -0
- package/dist/goals/serverRevenue.js +41 -0
- package/dist/goals/serverRevenue.js.map +1 -0
- package/dist/goals/trackGoalAction.d.ts +26 -25
- package/dist/goals/trackGoalAction.js +71 -66
- package/dist/goals/trackGoalAction.js.map +1 -1
- package/dist/goals/types.d.ts +13 -28
- package/dist/goals/types.js +1 -1
- package/dist/goals/types.js.map +1 -1
- package/dist/goals/useAnalyticsGoals.d.ts +6 -5
- package/dist/goals/useAnalyticsGoals.js +17 -18
- package/dist/goals/useAnalyticsGoals.js.map +1 -1
- package/dist/index.d.ts +69 -11
- package/dist/index.js +262 -192
- package/dist/index.js.map +1 -1
- package/dist/items/collectionIdType.js +20 -0
- package/dist/items/collectionIdType.js.map +1 -0
- package/dist/items/idType.js +31 -0
- package/dist/items/idType.js.map +1 -0
- package/dist/items/ref.js +73 -0
- package/dist/items/ref.js.map +1 -0
- package/dist/maintenance/apiTaskState.js +141 -0
- package/dist/maintenance/apiTaskState.js.map +1 -0
- package/dist/maintenance/heartbeat.js +51 -0
- package/dist/maintenance/heartbeat.js.map +1 -0
- package/dist/maintenance/lease.d.ts +1 -0
- package/dist/maintenance/lease.js +79 -0
- package/dist/maintenance/lease.js.map +1 -0
- package/dist/maintenance/taskSchedule.js +27 -0
- package/dist/maintenance/taskSchedule.js.map +1 -0
- package/dist/maintenance/underLease.js +35 -0
- package/dist/maintenance/underLease.js.map +1 -0
- package/dist/migrations/legacy.d.ts +54 -0
- package/dist/migrations/legacy.js +117 -0
- package/dist/migrations/legacy.js.map +1 -0
- package/dist/migrations/predefined/dropLegacyMongo.d.ts +11 -0
- package/dist/migrations/predefined/dropLegacyMongo.js +12 -0
- package/dist/migrations/predefined/dropLegacyMongo.js.map +1 -0
- package/dist/native/collections/aggregates.js +54 -0
- package/dist/native/collections/aggregates.js.map +1 -0
- package/dist/native/collections/hits.js +103 -0
- package/dist/native/collections/hits.js.map +1 -0
- package/dist/native/collections/slugs.d.ts +10 -0
- package/dist/native/collections/slugs.js +16 -0
- package/dist/native/collections/slugs.js.map +1 -0
- package/dist/native/collections/state.js +84 -0
- package/dist/native/collections/state.js.map +1 -0
- package/dist/native/collections/storeCollection.js +31 -0
- package/dist/native/collections/storeCollection.js.map +1 -0
- package/dist/native/engine/buckets.d.ts +1 -0
- package/dist/native/engine/buckets.js +53 -0
- package/dist/native/engine/buckets.js.map +1 -0
- package/dist/native/engine/capabilities.js +87 -0
- package/dist/native/engine/capabilities.js.map +1 -0
- package/dist/native/engine/cost.js +72 -0
- package/dist/native/engine/cost.js.map +1 -0
- package/dist/native/engine/days.d.ts +1 -0
- package/dist/native/engine/days.js +182 -0
- package/dist/native/engine/days.js.map +1 -0
- package/dist/native/engine/engine.d.ts +1 -0
- package/dist/native/engine/engine.js +1627 -0
- package/dist/native/engine/engine.js.map +1 -0
- package/dist/native/engine/instance.js +58 -0
- package/dist/native/engine/instance.js.map +1 -0
- package/dist/native/engine/maintenance.d.ts +1 -0
- package/dist/native/engine/maintenance.js +677 -0
- package/dist/native/engine/maintenance.js.map +1 -0
- package/dist/native/engine/merge.js +41 -0
- package/dist/native/engine/merge.js.map +1 -0
- package/dist/native/engine/nudge.js +26 -0
- package/dist/native/engine/nudge.js.map +1 -0
- package/dist/native/engine/planner.js +199 -0
- package/dist/native/engine/planner.js.map +1 -0
- package/dist/native/engine/rebuild.d.ts +22 -0
- package/dist/native/engine/rebuild.js +76 -0
- package/dist/native/engine/rebuild.js.map +1 -0
- package/dist/native/engine/recent.js +17 -0
- package/dist/native/engine/recent.js.map +1 -0
- package/dist/native/engine/salt.d.ts +1 -0
- package/dist/native/engine/salt.js +98 -0
- package/dist/native/engine/salt.js.map +1 -0
- package/dist/native/engine/siteHosts.d.ts +1 -0
- package/dist/native/engine/siteHosts.js +58 -0
- package/dist/native/engine/siteHosts.js.map +1 -0
- package/dist/native/engine/toHit.js +110 -0
- package/dist/native/engine/toHit.js.map +1 -0
- package/dist/native/engine/writeBuffer.d.ts +14 -0
- package/dist/native/engine/writeBuffer.js +317 -0
- package/dist/native/engine/writeBuffer.js.map +1 -0
- package/dist/native/geo/composeGeoResolvers.d.ts +1 -0
- package/dist/native/geo/composeGeoResolvers.js +5 -2
- package/dist/native/geo/composeGeoResolvers.js.map +1 -1
- package/dist/native/geo/geoResolver.d.ts +27 -2
- package/dist/native/geo/geoResolver.js +42 -6
- package/dist/native/geo/geoResolver.js.map +1 -1
- package/dist/native/geo/maxmindResolver.d.ts +8 -4
- package/dist/native/geo/maxmindResolver.js +20 -16
- package/dist/native/geo/maxmindResolver.js.map +1 -1
- package/dist/native/geo/resolveGeo.js +31 -0
- package/dist/native/geo/resolveGeo.js.map +1 -0
- package/dist/native/ingest/bots.d.ts +10 -0
- package/dist/native/ingest/bots.js +66 -0
- package/dist/native/ingest/bots.js.map +1 -0
- package/dist/native/ingest/browser.js +45 -0
- package/dist/native/ingest/browser.js.map +1 -0
- package/dist/native/ingest/clientIp.js +34 -8
- package/dist/native/ingest/clientIp.js.map +1 -1
- package/dist/native/ingest/device.js +4 -6
- package/dist/native/ingest/device.js.map +1 -1
- package/dist/native/ingest/endpoint.d.ts +1 -1
- package/dist/native/ingest/endpoint.js +185 -32
- package/dist/native/ingest/endpoint.js.map +1 -1
- package/dist/native/ingest/itemSignature.d.ts +26 -0
- package/dist/native/ingest/itemSignature.js +45 -0
- package/dist/native/ingest/itemSignature.js.map +1 -0
- package/dist/native/ingest/language.js +13 -0
- package/dist/native/ingest/language.js.map +1 -0
- package/dist/native/ingest/normalizeEvent.d.ts +73 -5
- package/dist/native/ingest/normalizeEvent.js +257 -51
- package/dist/native/ingest/normalizeEvent.js.map +1 -1
- package/dist/native/ingest/orderSignature.d.ts +13 -0
- package/dist/native/ingest/orderSignature.js +50 -0
- package/dist/native/ingest/orderSignature.js.map +1 -0
- package/dist/native/ingest/referrer.js +46 -0
- package/dist/native/ingest/referrer.js.map +1 -0
- package/dist/native/ingest/requestHost.js +44 -0
- package/dist/native/ingest/requestHost.js.map +1 -0
- package/dist/native/ingest/resolveHostname.d.ts +20 -0
- package/dist/native/ingest/resolveHostname.js +51 -0
- package/dist/native/ingest/resolveHostname.js.map +1 -0
- package/dist/native/ingest/revenue.d.ts +1 -0
- package/dist/native/ingest/revenue.js +121 -0
- package/dist/native/ingest/revenue.js.map +1 -0
- package/dist/native/ingest/route.d.ts +10 -0
- package/dist/native/ingest/route.js +85 -0
- package/dist/native/ingest/route.js.map +1 -0
- package/dist/native/ingest/serverTrack.d.ts +2 -10
- package/dist/native/ingest/serverTrack.js +188 -68
- package/dist/native/ingest/serverTrack.js.map +1 -1
- package/dist/native/ingest/signature.js +28 -0
- package/dist/native/ingest/signature.js.map +1 -0
- package/dist/native/ingest/source.d.ts +10 -0
- package/dist/native/ingest/source.js +245 -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 +25 -13
- package/dist/native/ingest/validate.js.map +1 -1
- package/dist/native/ingest/visitorHash.js +6 -8
- package/dist/native/ingest/visitorHash.js.map +1 -1
- package/dist/native/nativeAdapter.d.ts +128 -9
- package/dist/native/nativeAdapter.js +395 -281
- package/dist/native/nativeAdapter.js.map +1 -1
- package/dist/native/rebuildDays.d.ts +12 -0
- package/dist/native/rebuildDays.js +16 -0
- package/dist/native/rebuildDays.js.map +1 -0
- package/dist/native/store/aggregate.js +450 -0
- package/dist/native/store/aggregate.js.map +1 -0
- package/dist/native/store/caps.d.ts +18 -0
- package/dist/native/store/caps.js +76 -0
- package/dist/native/store/caps.js.map +1 -0
- package/dist/native/store/chunks.js +34 -0
- package/dist/native/store/chunks.js.map +1 -0
- package/dist/native/store/columnValues.js +31 -0
- package/dist/native/store/columnValues.js.map +1 -0
- package/dist/native/store/dialect.js +106 -0
- package/dist/native/store/dialect.js.map +1 -0
- package/dist/native/store/eventStore.js +44 -0
- package/dist/native/store/eventStore.js.map +1 -0
- package/dist/native/store/hitRow.js +119 -0
- package/dist/native/store/hitRow.js.map +1 -0
- package/dist/native/store/hits.js +65 -0
- package/dist/native/store/hits.js.map +1 -0
- package/dist/native/store/ids.js +105 -0
- package/dist/native/store/ids.js.map +1 -0
- package/dist/native/store/mongo/aggregatePipelines.js +438 -0
- package/dist/native/store/mongo/aggregatePipelines.js.map +1 -0
- package/dist/native/store/mongo/mongoState.js +375 -0
- package/dist/native/store/mongo/mongoState.js.map +1 -0
- package/dist/native/store/mongo/mongoStore.js +618 -0
- package/dist/native/store/mongo/mongoStore.js.map +1 -0
- package/dist/native/store/mongo/pipelines.js +705 -0
- package/dist/native/store/mongo/pipelines.js.map +1 -0
- package/dist/native/store/mongo/results.js +20 -0
- package/dist/native/store/mongo/results.js.map +1 -0
- package/dist/native/store/parts.d.ts +1 -0
- package/dist/native/store/parts.js +101 -0
- package/dist/native/store/parts.js.map +1 -0
- package/dist/native/store/pattern.js +213 -0
- package/dist/native/store/pattern.js.map +1 -0
- package/dist/native/store/rawRead.d.ts +23 -0
- package/dist/native/store/rawRead.js +387 -0
- package/dist/native/store/rawRead.js.map +1 -0
- package/dist/native/store/reclassify.js +53 -0
- package/dist/native/store/reclassify.js.map +1 -0
- package/dist/native/store/sql/aggregateSql.js +349 -0
- package/dist/native/store/sql/aggregateSql.js.map +1 -0
- package/dist/native/store/sql/columns.js +49 -0
- package/dist/native/store/sql/columns.js.map +1 -0
- package/dist/native/store/sql/compile.js +668 -0
- package/dist/native/store/sql/compile.js.map +1 -0
- package/dist/native/store/sql/drivers.js +218 -0
- package/dist/native/store/sql/drivers.js.map +1 -0
- package/dist/native/store/sql/executor.js +132 -0
- package/dist/native/store/sql/executor.js.map +1 -0
- package/dist/native/store/sql/fragment.js +104 -0
- package/dist/native/store/sql/fragment.js.map +1 -0
- package/dist/native/store/sql/maintenanceSql.js +59 -0
- package/dist/native/store/sql/maintenanceSql.js.map +1 -0
- package/dist/native/store/sql/ownConnection.js +107 -0
- package/dist/native/store/sql/ownConnection.js.map +1 -0
- package/dist/native/store/sql/poolShare.js +101 -0
- package/dist/native/store/sql/poolShare.js.map +1 -0
- package/dist/native/store/sql/sqlState.js +325 -0
- package/dist/native/store/sql/sqlState.js.map +1 -0
- package/dist/native/store/sql/sqlStore.js +355 -0
- package/dist/native/store/sql/sqlStore.js.map +1 -0
- package/dist/native/store/sql/sqliteThread.d.ts +9 -0
- package/dist/native/store/sql/sqliteThread.js +314 -0
- package/dist/native/store/sql/sqliteThread.js.map +1 -0
- package/dist/native/store/sql/sqliteWorker.js +327 -0
- package/dist/native/store/sql/sqliteWorker.js.map +1 -0
- package/dist/native/store/sql/sqliteWorkerSource.js +347 -0
- package/dist/native/store/sql/sqliteWorkerSource.js.map +1 -0
- package/dist/native/store/state.js +151 -0
- package/dist/native/store/state.js.map +1 -0
- package/dist/native/store/stateStore.js +29 -0
- package/dist/native/store/stateStore.js.map +1 -0
- package/dist/native/store/types.d.ts +15 -0
- package/dist/native/store/types.js +10 -0
- package/dist/native/store/types.js.map +1 -0
- package/dist/native/tasks/maintainTask.d.ts +19 -0
- package/dist/native/tasks/maintainTask.js +57 -0
- package/dist/native/tasks/maintainTask.js.map +1 -0
- package/dist/net/guardedFetch.d.ts +32 -0
- package/dist/net/guardedFetch.js +220 -0
- package/dist/net/guardedFetch.js.map +1 -0
- package/dist/net/origin.js +40 -0
- package/dist/net/origin.js.map +1 -0
- package/dist/net/platform.d.ts +9 -0
- package/dist/net/platform.js +35 -0
- package/dist/net/platform.js.map +1 -0
- package/dist/plugin/adminDependencies.js +34 -0
- package/dist/plugin/adminDependencies.js.map +1 -0
- package/dist/plugin/apiPath.js +23 -0
- package/dist/plugin/apiPath.js.map +1 -0
- package/dist/plugin/boundDocument.js +58 -0
- package/dist/plugin/boundDocument.js.map +1 -0
- package/dist/plugin/buildPhase.js +10 -0
- package/dist/plugin/buildPhase.js.map +1 -0
- package/dist/plugin/collectionChecks.js +232 -0
- package/dist/plugin/collectionChecks.js.map +1 -0
- package/dist/plugin/collectionFields.d.ts +13 -0
- package/dist/plugin/collectionFields.js +22 -0
- package/dist/plugin/collectionFields.js.map +1 -0
- package/dist/plugin/createRuntime.js +346 -0
- package/dist/plugin/createRuntime.js.map +1 -0
- package/dist/plugin/destroy.js +58 -0
- package/dist/plugin/destroy.js.map +1 -0
- package/dist/plugin/documentEndpoint.js +106 -53
- package/dist/plugin/documentEndpoint.js.map +1 -1
- package/dist/plugin/documentScopes.js +37 -0
- package/dist/plugin/documentScopes.js.map +1 -0
- package/dist/plugin/encrypted.js +25 -0
- package/dist/plugin/encrypted.js.map +1 -0
- package/dist/plugin/errors.d.ts +24 -0
- package/dist/plugin/errors.js +86 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/flagsEndpoint.js +41 -0
- package/dist/plugin/flagsEndpoint.js.map +1 -0
- package/dist/plugin/goalHint.d.ts +1 -0
- package/dist/plugin/goalHint.js +35 -0
- package/dist/plugin/goalHint.js.map +1 -0
- package/dist/plugin/itemLabels.js +114 -0
- package/dist/plugin/itemLabels.js.map +1 -0
- package/dist/plugin/keepAlive.js +48 -0
- package/dist/plugin/keepAlive.js.map +1 -0
- package/dist/plugin/peerImportError.js +3 -6
- package/dist/plugin/peerImportError.js.map +1 -1
- package/dist/plugin/peers.js +64 -0
- package/dist/plugin/peers.js.map +1 -0
- package/dist/plugin/pluginCollections.js +161 -0
- package/dist/plugin/pluginCollections.js.map +1 -0
- package/dist/plugin/queryEndpoint.js +88 -52
- package/dist/plugin/queryEndpoint.js.map +1 -1
- package/dist/plugin/queryParams.js +7 -0
- package/dist/plugin/queryParams.js.map +1 -0
- package/dist/plugin/readContextForRequest.d.ts +11 -0
- package/dist/plugin/readContextForRequest.js +79 -32
- package/dist/plugin/readContextForRequest.js.map +1 -1
- package/dist/plugin/readFailure.js +22 -0
- package/dist/plugin/readFailure.js.map +1 -0
- package/dist/plugin/readableProviders.js +67 -0
- package/dist/plugin/readableProviders.js.map +1 -0
- package/dist/plugin/realtimeEndpoint.js +91 -21
- package/dist/plugin/realtimeEndpoint.js.map +1 -1
- package/dist/plugin/refreshEndpoint.js +138 -0
- package/dist/plugin/refreshEndpoint.js.map +1 -0
- package/dist/plugin/relabelFields.js +36 -0
- package/dist/plugin/relabelFields.js.map +1 -0
- package/dist/plugin/requestMemo.js +35 -0
- package/dist/plugin/requestMemo.js.map +1 -0
- package/dist/plugin/routeChecks.js +39 -0
- package/dist/plugin/routeChecks.js.map +1 -0
- package/dist/plugin/routes.d.ts +53 -0
- package/dist/plugin/routes.js +92 -0
- package/dist/plugin/routes.js.map +1 -0
- package/dist/plugin/runtime.d.ts +1 -1
- package/dist/plugin/runtime.js +235 -29
- package/dist/plugin/runtime.js.map +1 -1
- package/dist/plugin/schemaOnly.js +61 -0
- package/dist/plugin/schemaOnly.js.map +1 -0
- package/dist/plugin/scopeChange.js +23 -0
- package/dist/plugin/scopeChange.js.map +1 -0
- package/dist/plugin/scopeFieldBoot.js +4 -4
- package/dist/plugin/scopeFieldBoot.js.map +1 -1
- package/dist/plugin/scopeToken.js +33 -0
- package/dist/plugin/scopeToken.js.map +1 -0
- package/dist/plugin/sourcesEndpoint.js +50 -16
- package/dist/plugin/sourcesEndpoint.js.map +1 -1
- package/dist/plugin/unbundledLanguages.js +25 -0
- package/dist/plugin/unbundledLanguages.js.map +1 -0
- package/dist/plugin/walkFields.js +24 -0
- package/dist/plugin/walkFields.js.map +1 -0
- package/dist/plugin/warmTask.js +0 -0
- package/dist/plugin/warmTask.js.map +1 -1
- package/dist/providers/ProvidersListNotice.d.ts +11 -0
- package/dist/providers/ProvidersListNotice.js +36 -0
- package/dist/providers/ProvidersListNotice.js.map +1 -0
- package/dist/providers/access.d.ts +1 -0
- package/dist/providers/access.js +35 -26
- package/dist/providers/access.js.map +1 -1
- package/dist/providers/adapterPool.js +121 -0
- package/dist/providers/adapterPool.js.map +1 -0
- package/dist/providers/collection.d.ts +63 -0
- package/dist/providers/collection.js +372 -143
- package/dist/providers/collection.js.map +1 -1
- package/dist/providers/factory.d.ts +84 -0
- package/dist/providers/factory.js +86 -25
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/hosts.d.ts +25 -0
- package/dist/providers/hosts.js +128 -0
- package/dist/providers/hosts.js.map +1 -0
- package/dist/providers/probe.d.ts +1 -0
- package/dist/providers/probe.js +105 -0
- package/dist/providers/probe.js.map +1 -0
- package/dist/providers/refresh.d.ts +18 -0
- package/dist/providers/refresh.js +49 -0
- package/dist/providers/refresh.js.map +1 -0
- package/dist/providers/registry.js +329 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/resolver.js +26 -88
- package/dist/providers/resolver.js.map +1 -1
- package/dist/providers/retarget.js +45 -0
- package/dist/providers/retarget.js.map +1 -0
- package/dist/providers/scopeUnique.js +41 -0
- package/dist/providers/scopeUnique.js.map +1 -0
- package/dist/providers/secrets.d.ts +26 -0
- package/dist/providers/secrets.js +61 -4
- package/dist/providers/secrets.js.map +1 -1
- package/dist/providers/stampScope.js +9 -6
- package/dist/providers/stampScope.js.map +1 -1
- package/dist/query/dates.js +10 -12
- package/dist/query/dates.js.map +1 -1
- package/dist/query/errors.d.ts +6 -13
- package/dist/query/fetchQuery.d.ts +36 -23
- package/dist/query/fetchQuery.js +96 -89
- package/dist/query/fetchQuery.js.map +1 -1
- package/dist/query/limits.js +8 -0
- package/dist/query/limits.js.map +1 -0
- package/dist/query/parse.d.ts +8 -2
- package/dist/query/parse.js +155 -108
- package/dist/query/parse.js.map +1 -1
- package/dist/query/response.d.ts +27 -4
- package/dist/query/response.js +18 -0
- package/dist/query/response.js.map +1 -0
- package/dist/react/AnalyticsProvider.d.ts +42 -20
- package/dist/react/AnalyticsProvider.js +24 -22
- package/dist/react/AnalyticsProvider.js.map +1 -1
- package/dist/react/TrackerBoot.js +15 -9
- package/dist/react/TrackerBoot.js.map +1 -1
- package/dist/react/useAnalytics.d.ts +2 -8
- package/dist/react/useAnalytics.js +31 -13
- package/dist/react/useAnalytics.js.map +1 -1
- package/dist/routes/captureRoute.d.ts +28 -0
- package/dist/routes/captureRoute.js +67 -0
- package/dist/routes/captureRoute.js.map +1 -0
- package/dist/routes/ingestRoute.d.ts +17 -0
- package/dist/routes/ingestRoute.js +17 -0
- package/dist/routes/ingestRoute.js.map +1 -0
- package/dist/site/AnalyticsScripts.d.ts +35 -0
- package/dist/site/AnalyticsScripts.js +44 -0
- package/dist/site/AnalyticsScripts.js.map +1 -0
- package/dist/site/getTrackerConfig.d.ts +15 -0
- package/dist/site/getTrackerConfig.js +43 -0
- package/dist/site/getTrackerConfig.js.map +1 -0
- package/dist/surfacing/afterRead.d.ts +37 -0
- package/dist/surfacing/bounded.js +38 -0
- package/dist/surfacing/bounded.js.map +1 -0
- package/dist/surfacing/breaker.js +107 -0
- package/dist/surfacing/breaker.js.map +1 -0
- package/dist/surfacing/cacheCollection.d.ts +8 -0
- package/dist/surfacing/cacheCollection.js +71 -0
- package/dist/surfacing/cacheCollection.js.map +1 -0
- package/dist/surfacing/cacheStore.d.ts +71 -1
- package/dist/surfacing/cacheStore.js +16 -37
- package/dist/surfacing/cacheStore.js.map +1 -1
- package/dist/surfacing/cacheSweep.d.ts +1 -0
- package/dist/surfacing/cacheSweep.js +59 -0
- package/dist/surfacing/cacheSweep.js.map +1 -0
- package/dist/surfacing/classifyError.js +282 -0
- package/dist/surfacing/classifyError.js.map +1 -0
- package/dist/surfacing/coalesce.js +2 -1
- package/dist/surfacing/coalesce.js.map +1 -1
- package/dist/surfacing/coldBudget.js +60 -0
- package/dist/surfacing/coldBudget.js.map +1 -0
- package/dist/surfacing/collectionCacheStore.js +183 -0
- package/dist/surfacing/collectionCacheStore.js.map +1 -0
- package/dist/surfacing/engine.d.ts +1 -1
- package/dist/surfacing/engine.js +514 -71
- package/dist/surfacing/engine.js.map +1 -1
- package/dist/surfacing/epoch.d.ts +1 -0
- package/dist/surfacing/epoch.js +116 -0
- package/dist/surfacing/epoch.js.map +1 -0
- package/dist/surfacing/lanes.d.ts +1 -0
- package/dist/surfacing/lanes.js +297 -0
- package/dist/surfacing/lanes.js.map +1 -0
- package/dist/surfacing/memo.js +40 -0
- package/dist/surfacing/memo.js.map +1 -0
- package/dist/surfacing/rateLimiter.d.ts +1 -0
- package/dist/surfacing/rateLimiter.js +69 -94
- package/dist/surfacing/rateLimiter.js.map +1 -1
- package/dist/surfacing/rebucket.js +178 -0
- package/dist/surfacing/rebucket.js.map +1 -0
- package/dist/surfacing/recipe.js +28 -0
- package/dist/surfacing/recipe.js.map +1 -0
- package/dist/surfacing/shape.js +22 -0
- package/dist/surfacing/shape.js.map +1 -0
- package/dist/surfacing/todaySplit.js +119 -0
- package/dist/surfacing/todaySplit.js.map +1 -0
- package/dist/sync/collection.d.ts +8 -0
- package/dist/sync/collection.js +30 -18
- package/dist/sync/collection.js.map +1 -1
- package/dist/sync/rekeyDurations.js +70 -0
- package/dist/sync/rekeyDurations.js.map +1 -0
- package/dist/sync/syncTask.js +222 -109
- package/dist/sync/syncTask.js.map +1 -1
- package/dist/testing/memoryAdapter.d.ts +6 -3
- package/dist/testing/memoryAdapter.js +12 -11
- package/dist/testing/memoryAdapter.js.map +1 -1
- package/dist/testing/settle.d.ts +11 -0
- package/dist/testing/settle.js +19 -0
- package/dist/testing/settle.js.map +1 -0
- package/dist/timeframe/calendar.js +65 -0
- package/dist/timeframe/calendar.js.map +1 -0
- package/dist/timeframe/comparison.js +46 -0
- package/dist/timeframe/comparison.js.map +1 -0
- package/dist/timeframe/presets.d.ts +1 -1
- package/dist/timeframe/presets.js +5 -5
- package/dist/timeframe/presets.js.map +1 -1
- package/dist/timeframe/reportingTimezone.d.ts +1 -0
- package/dist/timeframe/reportingTimezone.js +64 -0
- package/dist/timeframe/reportingTimezone.js.map +1 -0
- package/dist/timeframe/tz.js +55 -39
- package/dist/timeframe/tz.js.map +1 -1
- package/dist/tracker/autoCapture.js +125 -38
- package/dist/tracker/autoCapture.js.map +1 -1
- package/dist/tracker/campaign.js +52 -0
- package/dist/tracker/campaign.js.map +1 -0
- package/dist/tracker/config.d.ts +174 -0
- package/dist/tracker/config.js +25 -0
- package/dist/tracker/config.js.map +1 -0
- package/dist/tracker/createTracker.d.ts +5 -10
- package/dist/tracker/createTracker.js +437 -82
- package/dist/tracker/createTracker.js.map +1 -1
- package/dist/tracker/digest.js +28 -0
- package/dist/tracker/digest.js.map +1 -0
- package/dist/tracker/engagement.js +100 -0
- package/dist/tracker/engagement.js.map +1 -0
- package/dist/tracker/events.js +37 -0
- package/dist/tracker/events.js.map +1 -0
- package/dist/tracker/exclusion.d.ts +8 -0
- package/dist/tracker/exclusion.js +82 -0
- package/dist/tracker/exclusion.js.map +1 -0
- package/dist/tracker/gate.d.ts +8 -0
- package/dist/tracker/gate.js +244 -0
- package/dist/tracker/gate.js.map +1 -0
- package/dist/tracker/initTracker.d.ts +5 -8
- package/dist/tracker/initTracker.js +42 -14
- package/dist/tracker/initTracker.js.map +1 -1
- package/dist/tracker/itemCapture.js +224 -0
- package/dist/tracker/itemCapture.js.map +1 -0
- package/dist/tracker/loadScript.js +23 -15
- package/dist/tracker/loadScript.js.map +1 -1
- package/dist/tracker/pageTracking.js +6 -6
- package/dist/tracker/pageTracking.js.map +1 -1
- package/dist/tracker/registry.js +129 -30
- package/dist/tracker/registry.js.map +1 -1
- package/dist/tracker/sinks/createSink.js +60 -0
- package/dist/tracker/sinks/createSink.js.map +1 -0
- package/dist/tracker/sinks/ga4.js +106 -0
- package/dist/tracker/sinks/ga4.js.map +1 -0
- package/dist/tracker/sinks/native.js +21 -42
- package/dist/tracker/sinks/native.js.map +1 -1
- package/dist/tracker/sinks/plausible.js +36 -18
- package/dist/tracker/sinks/plausible.js.map +1 -1
- package/dist/tracker/sinks/posthog.js +145 -9
- package/dist/tracker/sinks/posthog.js.map +1 -1
- package/dist/tracker/sinks/umami.js +18 -10
- package/dist/tracker/sinks/umami.js.map +1 -1
- package/dist/tracker/sinks/vendor.js +54 -22
- package/dist/tracker/sinks/vendor.js.map +1 -1
- package/dist/tracker/skip.js +81 -0
- package/dist/tracker/skip.js.map +1 -0
- package/dist/tracker/storage.js +23 -0
- package/dist/tracker/storage.js.map +1 -0
- package/dist/tracker/transport.js +2 -5
- package/dist/tracker/transport.js.map +1 -1
- package/dist/tracker/types.d.ts +99 -44
- package/dist/tracker/window.js +7 -0
- package/dist/tracker/window.js.map +1 -0
- package/dist/translations/ar.js +266 -56
- package/dist/translations/ar.js.map +1 -1
- package/dist/translations/de.js +256 -55
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +253 -56
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +261 -57
- package/dist/translations/es.js.map +1 -1
- package/dist/translations/fr.js +265 -61
- package/dist/translations/fr.js.map +1 -1
- package/dist/translations/id.js +256 -56
- package/dist/translations/id.js.map +1 -1
- package/dist/translations/index.d.ts +1 -1
- package/dist/translations/index.js +5 -7
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/intl.js +71 -0
- package/dist/translations/intl.js.map +1 -0
- package/dist/translations/keys.d.ts +240 -14
- package/dist/translations/keys.js +245 -14
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +258 -58
- package/dist/translations/ko.js.map +1 -1
- package/dist/translations/labelMap.d.ts +10 -0
- package/dist/translations/labelMap.js +22 -0
- package/dist/translations/labelMap.js.map +1 -0
- package/dist/translations/metricKeys.js +16 -2
- package/dist/translations/metricKeys.js.map +1 -1
- package/dist/translations/parts.js +20 -0
- package/dist/translations/parts.js.map +1 -0
- package/dist/translations/plural.js +61 -0
- package/dist/translations/plural.js.map +1 -0
- package/dist/translations/pt.js +270 -66
- package/dist/translations/pt.js.map +1 -1
- package/dist/translations/ru.js +261 -55
- package/dist/translations/ru.js.map +1 -1
- package/dist/translations/server.d.ts +1 -0
- package/dist/translations/server.js +2 -3
- package/dist/translations/server.js.map +1 -1
- package/dist/translations/staticLabel.js +69 -0
- package/dist/translations/staticLabel.js.map +1 -0
- package/dist/translations/uk.js +261 -55
- package/dist/translations/uk.js.map +1 -1
- package/dist/translations/zh.js +256 -56
- package/dist/translations/zh.js.map +1 -1
- package/dist/ui/RangePicker.js +110 -0
- package/dist/ui/RangePicker.js.map +1 -0
- package/dist/ui/analytics.css +1667 -0
- package/dist/ui/calendarDays.js +27 -0
- package/dist/ui/calendarDays.js.map +1 -0
- package/dist/ui/classNames.js +7 -0
- package/dist/ui/classNames.js.map +1 -0
- package/dist/ui/components/Card.d.ts +28 -0
- package/dist/ui/components/Card.js +21 -0
- package/dist/ui/components/Card.js.map +1 -0
- package/dist/ui/components/ChartDataTable.d.ts +41 -0
- package/dist/ui/components/ChartDataTable.js +48 -0
- package/dist/ui/components/ChartDataTable.js.map +1 -0
- package/dist/ui/components/ChoiceMenu.js +48 -0
- package/dist/ui/components/ChoiceMenu.js.map +1 -0
- package/dist/ui/components/DataTable.d.ts +82 -0
- package/dist/ui/components/DataTable.js +214 -0
- package/dist/ui/components/DataTable.js.map +1 -0
- package/dist/ui/components/LabeledSelect.js +62 -0
- package/dist/ui/components/LabeledSelect.js.map +1 -0
- package/dist/ui/components/LiveAnnouncement.js +21 -0
- package/dist/ui/components/LiveAnnouncement.js.map +1 -0
- package/dist/ui/components/MetricCard.d.ts +38 -0
- package/dist/ui/components/MetricCard.js +39 -0
- package/dist/ui/components/MetricCard.js.map +1 -0
- package/dist/ui/components/NoValue.js +22 -0
- package/dist/ui/components/NoValue.js.map +1 -0
- package/dist/ui/components/ReadState.js +27 -0
- package/dist/ui/components/ReadState.js.map +1 -0
- package/dist/ui/components/RefreshButton.js +25 -0
- package/dist/ui/components/RefreshButton.js.map +1 -0
- package/dist/ui/components/SourcesNoticeBanner.js +20 -0
- package/dist/ui/components/SourcesNoticeBanner.js.map +1 -0
- package/dist/ui/cssVars.js +7 -0
- package/dist/ui/cssVars.js.map +1 -0
- package/dist/ui/data/WithScopeToken.d.ts +20 -0
- package/dist/ui/data/WithScopeToken.js +20 -0
- package/dist/ui/data/WithScopeToken.js.map +1 -0
- package/dist/ui/data/clientFieldProps.js +16 -0
- package/dist/ui/data/clientFieldProps.js.map +1 -0
- package/dist/ui/data/request.d.ts +46 -0
- package/dist/ui/data/request.js +119 -0
- package/dist/ui/data/request.js.map +1 -0
- package/dist/ui/data/scopeTokenContext.js +18 -0
- package/dist/ui/data/scopeTokenContext.js.map +1 -0
- package/dist/ui/data/sharedCache.js +48 -0
- package/dist/ui/data/sharedCache.js.map +1 -0
- package/dist/ui/data/useRequest.d.ts +19 -0
- package/dist/ui/data/useRequest.js +123 -0
- package/dist/ui/data/useRequest.js.map +1 -0
- package/dist/ui/data/useRequestScope.js +25 -0
- package/dist/ui/data/useRequestScope.js.map +1 -0
- package/dist/ui/hooks/useDirection.js +47 -0
- package/dist/ui/hooks/useDirection.js.map +1 -0
- package/dist/ui/hooks/useDismissOnEscape.js +25 -0
- package/dist/ui/hooks/useDismissOnEscape.js.map +1 -0
- package/dist/ui/hooks/useLiveAnnouncement.js +57 -0
- package/dist/ui/hooks/useLiveAnnouncement.js.map +1 -0
- package/dist/ui/hooks/useRealtimePoll.js +112 -0
- package/dist/ui/hooks/useRealtimePoll.js.map +1 -0
- package/dist/ui/readState.js +19 -0
- package/dist/ui/readState.js.map +1 -0
- package/dist/ui/rows/toDisplayRows.js +49 -0
- package/dist/ui/rows/toDisplayRows.js.map +1 -0
- package/dist/ui/viewerClock.js +7 -0
- package/dist/ui/viewerClock.js.map +1 -0
- package/dist/view/AnalyticsNavLink.d.ts +5 -3
- package/dist/view/AnalyticsNavLink.js +12 -8
- package/dist/view/AnalyticsNavLink.js.map +1 -1
- package/dist/view/AnalyticsView.d.ts +9 -10
- package/dist/view/AnalyticsView.js +47 -19
- package/dist/view/AnalyticsView.js.map +1 -1
- package/dist/view/AnalyticsViewClient.d.ts +4 -7
- package/dist/view/AnalyticsViewClient.js +15 -174
- package/dist/view/AnalyticsViewClient.js.map +1 -1
- package/dist/view/CountryFlag.d.ts +27 -0
- package/dist/view/CountryFlag.js +44 -0
- package/dist/view/CountryFlag.js.map +1 -0
- package/dist/view/DocumentTitle.js +27 -0
- package/dist/view/DocumentTitle.js.map +1 -0
- package/dist/view/ViewRoot.d.ts +21 -0
- package/dist/view/ViewRoot.js +155 -0
- package/dist/view/ViewRoot.js.map +1 -0
- package/dist/view/ViewSections.d.ts +38 -0
- package/dist/view/ViewSections.js +190 -0
- package/dist/view/ViewSections.js.map +1 -0
- package/dist/view/authRedirect.js +2 -4
- package/dist/view/authRedirect.js.map +1 -1
- package/dist/view/consentShare.js +15 -0
- package/dist/view/consentShare.js.map +1 -0
- package/dist/view/conversionRate.js +9 -7
- package/dist/view/conversionRate.js.map +1 -1
- package/dist/view/dayRange.js +6 -10
- package/dist/view/dayRange.js.map +1 -1
- package/dist/view/exclusionLink.d.ts +27 -0
- package/dist/view/exclusionLink.js +46 -0
- package/dist/view/exclusionLink.js.map +1 -0
- package/dist/view/flagSrc.js +14 -0
- package/dist/view/flagSrc.js.map +1 -0
- package/dist/view/gating.d.ts +15 -1
- package/dist/view/gating.js +92 -20
- package/dist/view/gating.js.map +1 -1
- package/dist/view/hostCountryFlag.js +41 -0
- package/dist/view/hostCountryFlag.js.map +1 -0
- package/dist/view/labels.js +120 -3
- package/dist/view/labels.js.map +1 -1
- package/dist/view/metricAliases.js +10 -0
- package/dist/view/metricAliases.js.map +1 -0
- package/dist/view/navLabel.js +15 -0
- package/dist/view/navLabel.js.map +1 -0
- package/dist/view/registerView.js +13 -11
- package/dist/view/registerView.js.map +1 -1
- package/dist/view/scopeLabel.js +21 -0
- package/dist/view/scopeLabel.js.map +1 -0
- package/dist/view/sections/Breakdowns.js +221 -118
- package/dist/view/sections/Breakdowns.js.map +1 -1
- package/dist/view/sections/EmptyStates.js +120 -32
- package/dist/view/sections/EmptyStates.js.map +1 -1
- package/dist/view/sections/ExcludeBrowser.js +188 -0
- package/dist/view/sections/ExcludeBrowser.js.map +1 -0
- package/dist/view/sections/FilterChips.js +130 -25
- package/dist/view/sections/FilterChips.js.map +1 -1
- package/dist/view/sections/GoalsPanel.js +68 -59
- package/dist/view/sections/GoalsPanel.js.map +1 -1
- package/dist/view/sections/OverviewCards.js +42 -36
- package/dist/view/sections/OverviewCards.js.map +1 -1
- package/dist/view/sections/RealtimeStrip.js +70 -56
- package/dist/view/sections/RealtimeStrip.js.map +1 -1
- package/dist/view/sections/SectionBoundary.js +34 -0
- package/dist/view/sections/SectionBoundary.js.map +1 -0
- package/dist/view/sections/Toolbar.d.ts +11 -0
- package/dist/view/sections/Toolbar.js +182 -116
- package/dist/view/sections/Toolbar.js.map +1 -1
- package/dist/view/sections/Trend.js +179 -73
- package/dist/view/sections/Trend.js.map +1 -1
- package/dist/view/state.d.ts +42 -0
- package/dist/view/state.js +97 -53
- package/dist/view/state.js.map +1 -1
- package/dist/view/useViewClock.js +31 -0
- package/dist/view/useViewClock.js.map +1 -0
- package/dist/view/useViewQueries.d.ts +21 -0
- package/dist/view/useViewQueries.js +50 -79
- package/dist/view/useViewQueries.js.map +1 -1
- package/dist/view/useViewState.js +42 -0
- package/dist/view/useViewState.js.map +1 -0
- package/dist/view/useViewUrl.js +52 -0
- package/dist/view/useViewUrl.js.map +1 -0
- package/dist/view/viewBody.js +30 -0
- package/dist/view/viewBody.js.map +1 -0
- package/dist/view/viewContext.d.ts +81 -0
- package/dist/view/viewContext.js +49 -0
- package/dist/view/viewContext.js.map +1 -0
- package/dist/view/viewProps.d.ts +65 -8
- package/dist/view/viewProps.js +123 -36
- package/dist/view/viewProps.js.map +1 -1
- package/dist/widgets/AnalyticsBreakdownWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsBreakdownWidget.js +153 -78
- package/dist/widgets/AnalyticsBreakdownWidget.js.map +1 -1
- package/dist/widgets/AnalyticsGoalsWidget.d.ts +6 -7
- package/dist/widgets/AnalyticsGoalsWidget.js +126 -159
- package/dist/widgets/AnalyticsGoalsWidget.js.map +1 -1
- package/dist/widgets/AnalyticsMetricWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsMetricWidget.js +85 -83
- package/dist/widgets/AnalyticsMetricWidget.js.map +1 -1
- package/dist/widgets/AnalyticsRealtimeWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsRealtimeWidget.js +81 -61
- package/dist/widgets/AnalyticsRealtimeWidget.js.map +1 -1
- package/dist/widgets/AnalyticsTrendWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsTrendWidget.js +134 -100
- package/dist/widgets/AnalyticsTrendWidget.js.map +1 -1
- package/dist/widgets/ComparisonDelta.js +33 -42
- package/dist/widgets/ComparisonDelta.js.map +1 -1
- package/dist/widgets/RealtimeCounter.d.ts +27 -3
- package/dist/widgets/RealtimeCounter.js +90 -62
- package/dist/widgets/RealtimeCounter.js.map +1 -1
- package/dist/widgets/WidgetCard.d.ts +80 -0
- package/dist/widgets/WidgetCard.js +99 -0
- package/dist/widgets/WidgetCard.js.map +1 -0
- package/dist/widgets/WidgetFrame.js +42 -0
- package/dist/widgets/WidgetFrame.js.map +1 -0
- package/dist/widgets/WidgetShimmer.d.ts +55 -0
- package/dist/widgets/WidgetShimmer.js +86 -0
- package/dist/widgets/WidgetShimmer.js.map +1 -0
- package/dist/widgets/breakdownTypes.js +18 -2
- package/dist/widgets/breakdownTypes.js.map +1 -1
- package/dist/widgets/customWidget.d.ts +5 -1
- package/dist/widgets/customWidget.js +6 -7
- package/dist/widgets/customWidget.js.map +1 -1
- package/dist/widgets/defaultLayout.d.ts +26 -0
- package/dist/widgets/defaultLayout.js +51 -0
- package/dist/widgets/defaultLayout.js.map +1 -0
- package/dist/widgets/defaults.d.ts +4 -3
- package/dist/widgets/defaults.js +76 -24
- package/dist/widgets/defaults.js.map +1 -1
- package/dist/widgets/fieldRows.js +14 -0
- package/dist/widgets/fieldRows.js.map +1 -0
- package/dist/widgets/filterCaption.js +26 -0
- package/dist/widgets/filterCaption.js.map +1 -0
- package/dist/widgets/filterField.d.ts +15 -0
- package/dist/widgets/filterField.js +86 -0
- package/dist/widgets/filterField.js.map +1 -0
- package/dist/widgets/filterValueLabel.d.ts +1 -0
- package/dist/widgets/filterValueLabel.js +45 -0
- package/dist/widgets/filterValueLabel.js.map +1 -0
- package/dist/widgets/notices.js +79 -0
- package/dist/widgets/notices.js.map +1 -0
- package/dist/widgets/prepareWidgetRead.d.ts +24 -0
- package/dist/widgets/prepareWidgetRead.js +110 -0
- package/dist/widgets/prepareWidgetRead.js.map +1 -0
- package/dist/widgets/range.js +26 -21
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/readForWidget.d.ts +32 -13
- package/dist/widgets/readForWidget.js +52 -63
- package/dist/widgets/readForWidget.js.map +1 -1
- package/dist/widgets/readForWidgetBreakdown.d.ts +45 -18
- package/dist/widgets/readForWidgetBreakdown.js +71 -58
- package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
- package/dist/widgets/readForWidgetGoals.d.ts +21 -17
- package/dist/widgets/readForWidgetGoals.js +72 -52
- package/dist/widgets/readForWidgetGoals.js.map +1 -1
- package/dist/widgets/readForWidgetRealtime.d.ts +24 -11
- package/dist/widgets/readForWidgetRealtime.js +69 -41
- package/dist/widgets/readForWidgetRealtime.js.map +1 -1
- package/dist/widgets/readForWidgetSeries.d.ts +29 -24
- package/dist/widgets/readForWidgetSeries.js +66 -114
- package/dist/widgets/readForWidgetSeries.js.map +1 -1
- package/dist/widgets/readMeta.d.ts +48 -0
- package/dist/widgets/readMeta.js +66 -0
- package/dist/widgets/readMeta.js.map +1 -0
- package/dist/widgets/realtimePoll.d.ts +1 -0
- package/dist/widgets/realtimePoll.js +56 -16
- package/dist/widgets/realtimePoll.js.map +1 -1
- package/dist/widgets/registerWidgets.js +207 -124
- package/dist/widgets/registerWidgets.js.map +1 -1
- package/dist/widgets/stateKeys.js +30 -0
- package/dist/widgets/stateKeys.js.map +1 -0
- package/dist/widgets/titleForecast.js +89 -0
- package/dist/widgets/titleForecast.js.map +1 -0
- package/dist/widgets/types.d.ts +16 -0
- package/dist/widgets/types.js +2 -0
- package/dist/widgets/types.js.map +1 -1
- package/dist/widgets/viewLink.d.ts +24 -6
- package/dist/widgets/viewLink.js +36 -26
- package/dist/widgets/viewLink.js.map +1 -1
- package/dist/widgets/widgetData.js +34 -0
- package/dist/widgets/widgetData.js.map +1 -0
- package/dist/widgets/widgetWindow.d.ts +1 -0
- package/dist/widgets/widgetWindow.js +51 -0
- package/dist/widgets/widgetWindow.js.map +1 -0
- package/package.json +61 -42
- package/dist/capture/getTrackerConfig.d.ts +0 -20
- package/dist/capture/getTrackerConfig.js +0 -31
- package/dist/capture/getTrackerConfig.js.map +0 -1
- package/dist/capture/slots.d.ts +0 -8
- package/dist/capture/trackerConfig.d.ts +0 -33
- package/dist/charts/styles.js +0 -59
- package/dist/charts/styles.js.map +0 -1
- package/dist/exports/next.d.ts +0 -3
- package/dist/exports/next.js +0 -3
- package/dist/fields/config/SourceSelectField.d.ts +0 -14
- package/dist/fields/dateRange/styles.js +0 -23
- package/dist/fields/dateRange/styles.js.map +0 -1
- package/dist/goals/GoalSelectField.d.ts +0 -7
- package/dist/native/collections/events.js +0 -121
- package/dist/native/collections/events.js.map +0 -1
- package/dist/native/collections/rollups.js +0 -151
- package/dist/native/collections/rollups.js.map +0 -1
- package/dist/native/collections/seen.js +0 -47
- package/dist/native/collections/seen.js.map +0 -1
- package/dist/native/ingest/flushBatch.js +0 -60
- package/dist/native/ingest/flushBatch.js.map +0 -1
- package/dist/native/ingest/salt.js +0 -14
- package/dist/native/ingest/salt.js.map +0 -1
- package/dist/native/ingest/writeBuffer.js +0 -55
- package/dist/native/ingest/writeBuffer.js.map +0 -1
- package/dist/native/ingest/writeEvent.js +0 -14
- package/dist/native/ingest/writeEvent.js.map +0 -1
- package/dist/native/query/eventAgg.js +0 -161
- package/dist/native/query/eventAgg.js.map +0 -1
- package/dist/native/realtime/buildRealtime.js +0 -53
- package/dist/native/realtime/buildRealtime.js.map +0 -1
- package/dist/native/retention/pruneTask.js +0 -29
- package/dist/native/retention/pruneTask.js.map +0 -1
- package/dist/native/rollupAcc.js +0 -64
- package/dist/native/rollupAcc.js.map +0 -1
- package/dist/native/rollups/applyDistinctDeltas.js +0 -9
- package/dist/native/rollups/applyDistinctDeltas.js.map +0 -1
- package/dist/native/rollups/bumpRollup.js +0 -73
- package/dist/native/rollups/bumpRollup.js.map +0 -1
- package/dist/native/rollups/deltas.js +0 -90
- package/dist/native/rollups/deltas.js.map +0 -1
- package/dist/native/rollups/insertIfNew.js +0 -53
- package/dist/native/rollups/insertIfNew.js.map +0 -1
- package/dist/next/captureRewrites.d.ts +0 -41
- package/dist/next/captureRewrites.js +0 -56
- package/dist/next/captureRewrites.js.map +0 -1
- package/dist/next/posthogProxyRewrites.d.ts +0 -41
- package/dist/next/posthogProxyRewrites.js +0 -45
- package/dist/next/posthogProxyRewrites.js.map +0 -1
- package/dist/plugin/paths.js +0 -27
- package/dist/plugin/paths.js.map +0 -1
- package/dist/query/errors.js +0 -10
- package/dist/query/errors.js.map +0 -1
- package/dist/react/TrackerBoot.d.ts +0 -22
- package/dist/rsc/AnalyticsScripts.d.ts +0 -30
- package/dist/rsc/AnalyticsScripts.js +0 -41
- package/dist/rsc/AnalyticsScripts.js.map +0 -1
- package/dist/surfacing/queue.js +0 -60
- package/dist/surfacing/queue.js.map +0 -1
- package/dist/surfacing/retryPolicy.js +0 -15
- package/dist/surfacing/retryPolicy.js.map +0 -1
- package/dist/tracker/autoCapture.d.ts +0 -48
- package/dist/tracker/consent.d.ts +0 -24
- package/dist/tracker/consent.js +0 -48
- package/dist/tracker/consent.js.map +0 -1
- package/dist/tracker/loadScript.d.ts +0 -14
- package/dist/tracker/pageTracking.d.ts +0 -17
- package/dist/tracker/registry.d.ts +0 -27
- package/dist/tracker/sinks/native.d.ts +0 -22
- package/dist/tracker/sinks/plausible.d.ts +0 -14
- package/dist/tracker/sinks/posthog.d.ts +0 -14
- package/dist/tracker/sinks/umami.d.ts +0 -13
- package/dist/tracker/sinks/vendor.d.ts +0 -14
- package/dist/view/sections/styles.js +0 -74
- package/dist/view/sections/styles.js.map +0 -1
- package/dist/widgets/WidgetViewLink.js +0 -17
- package/dist/widgets/WidgetViewLink.js.map +0 -1
- package/dist/widgets/cardChrome.d.ts +0 -8
- package/dist/widgets/cardChrome.js +0 -46
- package/dist/widgets/cardChrome.js.map +0 -1
- package/dist/widgets/comparison.js +0 -43
- package/dist/widgets/comparison.js.map +0 -1
|
@@ -0,0 +1,1627 @@
|
|
|
1
|
+
import { InvalidQueryError, UnsupportedFilterError } from "../../core/sourceErrors.js";
|
|
2
|
+
import { currentDate } from "../../core/clock.js";
|
|
3
|
+
import { MAINTAIN_INTERVAL_MS } from "../../core/jobs.js";
|
|
4
|
+
import { unsupportedFilter } from "../../core/capabilities.js";
|
|
5
|
+
import { monotonicMs } from "../../core/monotonic.js";
|
|
6
|
+
import { addCalendarDays, calendarDayOf, calendarDayStart, calendarDaysBetween } from "../../timeframe/calendar.js";
|
|
7
|
+
import { DAY_LEASE_MS, dayEnd, dayFinalAfter, dayKey, heartbeatStale } from "../store/state.js";
|
|
8
|
+
import { partsToMetrics, sumParts } from "../store/parts.js";
|
|
9
|
+
import { checkMatchesPattern } from "../store/pattern.js";
|
|
10
|
+
import { ACQUISITION_ATTRIBUTES, ReadTimeoutError, VISITOR_ATTRIBUTES, compareCodePoints, countedParts, filterHolds, isRawDimension, partsFrom } from "../store/rawRead.js";
|
|
11
|
+
import { AnalyticsTrackError } from "../../core/serverEvent.js";
|
|
12
|
+
import { DEFAULT_CAPS } from "../store/caps.js";
|
|
13
|
+
import { orderTwinOf, ulid } from "../store/ids.js";
|
|
14
|
+
import { dayWindow, seamOf, startingAt } from "../store/aggregate.js";
|
|
15
|
+
import { TWIN_WINDOW_MS, twinsWithin } from "../store/hits.js";
|
|
16
|
+
import { createZoneBook, datesOf, daySpan, fileDayWithin, hourStarts, isClosed, isFixed, isSealed, localDay, localDaysOf, markerEnd, markerStart, rawFloor, rawFloorDay, todayIn, windowOf } from "./days.js";
|
|
17
|
+
import { axisOf, closedDaySource, countsVisits, foldTargets, orderOf, readFilters, readShape, runsOf, seriesOf, snapshotState, wholeDayHits } from "./planner.js";
|
|
18
|
+
import { rebuildRange } from "./rebuild.js";
|
|
19
|
+
import { MAINTAIN_TASK_SLUG } from "../tasks/maintainTask.js";
|
|
20
|
+
import { bucketInstant, foldDays } from "./buckets.js";
|
|
21
|
+
import { SNAPSHOT_LONGEST_AGE_MS, createCostModel, snapshotAboveHitsOf, snapshotMaxAgeMs } from "./cost.js";
|
|
22
|
+
import { createMaintenance } from "./maintenance.js";
|
|
23
|
+
import { addInto, sumByValue, topAcross } from "./merge.js";
|
|
24
|
+
import { NUDGE_BUDGET_MS, NUDGE_EVERY_MS, createNudger } from "./nudge.js";
|
|
25
|
+
//#region src/native/engine/engine.ts
|
|
26
|
+
/**
|
|
27
|
+
* How far ahead of the server's clock a server event's own time may be: a caller's clock a few
|
|
28
|
+
* minutes fast is tolerated, a date in the future is not.
|
|
29
|
+
*/
|
|
30
|
+
const SERVER_CLOCK_SKEW_MS = 5 * 6e4;
|
|
31
|
+
const PROVIDER = "native";
|
|
32
|
+
/** Scopes, and sides of one answer, read at once. */
|
|
33
|
+
const CONCURRENCY = 4;
|
|
34
|
+
/** Busy days remembered at most, all forgotten at once past it: a few per scope at a time. */
|
|
35
|
+
const MAX_BUSY_DAYS = 1e4;
|
|
36
|
+
/** Markers a read over many scopes holds at once; past it each scope reads its own as it plans. */
|
|
37
|
+
const MAX_KNOWN_MARKERS = 5e4;
|
|
38
|
+
/** Local days a scope's read plans day by day before it first asks where its data starts. */
|
|
39
|
+
const LONG_SPAN_DAYS = 400;
|
|
40
|
+
/** How often a run counting a day renews its lease: three times within each lease. */
|
|
41
|
+
const DAY_LEASE_RENEW_MS = Math.floor(DAY_LEASE_MS / 3);
|
|
42
|
+
/** An option that is a whole number of at least `min`, its default when absent. */
|
|
43
|
+
const wholeOption = (name, value, spec) => {
|
|
44
|
+
const resolved = value ?? spec.fallback;
|
|
45
|
+
if (!Number.isInteger(resolved) || resolved < spec.min) throw new Error(`analytics: the native engine's ${name} must be a whole number of at least ${spec.min}, got ${resolved}`);
|
|
46
|
+
return resolved;
|
|
47
|
+
};
|
|
48
|
+
const settingsOf = (options, store) => ({
|
|
49
|
+
scoped: options.scoped ?? false,
|
|
50
|
+
caps: options.caps ?? DEFAULT_CAPS,
|
|
51
|
+
itemPages: options.itemPages ?? true,
|
|
52
|
+
rawDays: options.rawDays === null ? null : wholeOption("rawDays", options.rawDays, {
|
|
53
|
+
fallback: 90,
|
|
54
|
+
min: 1
|
|
55
|
+
}),
|
|
56
|
+
aggregateDays: options.aggregateDays === void 0 || options.aggregateDays === null ? null : wholeOption("aggregateDays", options.aggregateDays, {
|
|
57
|
+
fallback: 1,
|
|
58
|
+
min: 1
|
|
59
|
+
}),
|
|
60
|
+
runner: options.maintenance?.runner ?? true,
|
|
61
|
+
maintainIntervalMs: wholeOption("maintenance.intervalMs", options.maintenance?.intervalMs, {
|
|
62
|
+
fallback: MAINTAIN_INTERVAL_MS,
|
|
63
|
+
min: 1
|
|
64
|
+
}),
|
|
65
|
+
lazyBudgetMs: wholeOption("lazy.budgetMs", options.lazy?.budgetMs, {
|
|
66
|
+
fallback: 3e3,
|
|
67
|
+
min: 0
|
|
68
|
+
}),
|
|
69
|
+
lazyRawDays: wholeOption("lazy.rawDays", options.lazy?.rawDays, {
|
|
70
|
+
fallback: 7,
|
|
71
|
+
min: 0
|
|
72
|
+
}),
|
|
73
|
+
snapshotAboveHits: wholeOption("today.snapshotAboveHits", options.today?.snapshotAboveHits, {
|
|
74
|
+
fallback: snapshotAboveHitsOf(store),
|
|
75
|
+
min: 0
|
|
76
|
+
}),
|
|
77
|
+
snapshotMaxAgeMs: options.today?.maxAgeMs === void 0 ? null : wholeOption("today.maxAgeMs", options.today.maxAgeMs, {
|
|
78
|
+
fallback: 0,
|
|
79
|
+
min: 0
|
|
80
|
+
}),
|
|
81
|
+
timeoutMs: wholeOption("timeoutMs", options.timeoutMs, {
|
|
82
|
+
fallback: 8e3,
|
|
83
|
+
min: 1
|
|
84
|
+
}),
|
|
85
|
+
splitBudgetMs: wholeOption("splitBudgetMs", options.splitBudgetMs, {
|
|
86
|
+
fallback: 4e3,
|
|
87
|
+
min: 0
|
|
88
|
+
}),
|
|
89
|
+
emptyMarkers: wholeOption("emptyMarkers", options.emptyMarkers, {
|
|
90
|
+
fallback: 31,
|
|
91
|
+
min: 0
|
|
92
|
+
}),
|
|
93
|
+
now: options.now ?? currentDate,
|
|
94
|
+
clock: options.clock ?? monotonicMs,
|
|
95
|
+
twinWindowMs: options.twinWindowMs === void 0 ? TWIN_WINDOW_MS : options.twinWindowMs
|
|
96
|
+
});
|
|
97
|
+
const attributesOf = (hit, fields) => {
|
|
98
|
+
const kept = {};
|
|
99
|
+
for (const field of fields) {
|
|
100
|
+
const value = hit[field];
|
|
101
|
+
if (value !== void 0) kept[field] = value;
|
|
102
|
+
}
|
|
103
|
+
return kept;
|
|
104
|
+
};
|
|
105
|
+
/** How many scopes a window reads: a day it leaves unread is missing for each of them. */
|
|
106
|
+
const widthOf = (window) => window.scopes?.length ?? 1;
|
|
107
|
+
/** The scope fields a store read takes for a window or a span: its one scope, or all it merged. */
|
|
108
|
+
const scopeFields = (part) => part.scopes !== void 0 && part.scopes.length > 1 ? { scopes: part.scopes } : { scope: part.scope };
|
|
109
|
+
const later = (a, b) => a === void 0 ? b : b === void 0 || a >= b ? a : b;
|
|
110
|
+
const earlier = (a, b) => a === void 0 ? b : b === void 0 || a <= b ? a : b;
|
|
111
|
+
const minDate = (a, b) => a <= b ? a : b;
|
|
112
|
+
const maxDate = (a, b) => a >= b ? a : b;
|
|
113
|
+
/** A read's row limit: none unless a whole number above zero. */
|
|
114
|
+
const limitOf = (query) => query.limit !== void 0 && Number.isInteger(query.limit) && query.limit > 0 ? query.limit : void 0;
|
|
115
|
+
/** `work`'s answer, or `refused`'s when the store refused it as too big or slow; else it throws. */
|
|
116
|
+
const unlessRefused = async (work, refused) => {
|
|
117
|
+
try {
|
|
118
|
+
return await work();
|
|
119
|
+
} catch (err) {
|
|
120
|
+
if (!(err instanceof ReadTimeoutError)) throw err;
|
|
121
|
+
return refused();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
/** One day of a raw window, cut to the window's own instants. */
|
|
125
|
+
const dayOfWindow = (window, day) => ({
|
|
126
|
+
scope: window.scope,
|
|
127
|
+
...window.scopes === void 0 ? {} : { scopes: window.scopes },
|
|
128
|
+
start: maxDate(window.start, day.start),
|
|
129
|
+
end: minDate(window.end, day.end),
|
|
130
|
+
from: day.start,
|
|
131
|
+
days: [day]
|
|
132
|
+
});
|
|
133
|
+
/** Runs `work` over `items` with at most `limit` running at once, answering in order. */
|
|
134
|
+
const mapLimited = async (items, limit, work) => {
|
|
135
|
+
const results = /* @__PURE__ */ new Map();
|
|
136
|
+
let next = 0;
|
|
137
|
+
const worker = async () => {
|
|
138
|
+
while (next < items.length) {
|
|
139
|
+
const index = next++;
|
|
140
|
+
const item = items[index];
|
|
141
|
+
if (item !== void 0) results.set(index, await work(item));
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
145
|
+
return items.flatMap((_, index) => {
|
|
146
|
+
const result = results.get(index);
|
|
147
|
+
return result === void 0 ? [] : [result];
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Ascending ranges for an aggregate read: runs of the days to read, bridged over days holding no
|
|
152
|
+
* rows (no hits, so no generation a read would count), never over any other day.
|
|
153
|
+
*/
|
|
154
|
+
const aggregateRanges = (sorted) => {
|
|
155
|
+
const reading = new Set(sorted.aggregated);
|
|
156
|
+
const runs = runsOf([...new Set([...sorted.aggregated, ...sorted.empty])].sort((a, b) => a - b));
|
|
157
|
+
const ranges = [];
|
|
158
|
+
for (const [first, last] of runs) {
|
|
159
|
+
const days = datesOf(first, last).filter((day) => reading.has(day));
|
|
160
|
+
const from = days[0];
|
|
161
|
+
const to = days.at(-1);
|
|
162
|
+
if (from !== void 0 && to !== void 0) ranges.push([from, to]);
|
|
163
|
+
}
|
|
164
|
+
return ranges;
|
|
165
|
+
};
|
|
166
|
+
const valueRowsOf = (rows) => rows.flatMap((row) => row.value === null || row.value === "" ? [] : [{
|
|
167
|
+
value: row.value,
|
|
168
|
+
parts: row.parts
|
|
169
|
+
}]);
|
|
170
|
+
/** The window a day target is counted over: its day in its zone, from its own `start` if set. */
|
|
171
|
+
const countedWindow = (target) => startingAt(dayWindow(target.scope, target.day, target.tz), target.start);
|
|
172
|
+
/** The instants a day target's hits lie between, as the store counts or probes them. */
|
|
173
|
+
const hitsWindow = (target) => ({
|
|
174
|
+
scope: target.scope,
|
|
175
|
+
start: target.start ?? calendarDayStart(target.day, target.tz),
|
|
176
|
+
end: dayEnd(target.day, target.tz)
|
|
177
|
+
});
|
|
178
|
+
const emptyMarker = (target, at) => ({
|
|
179
|
+
scope: target.scope,
|
|
180
|
+
day: target.day,
|
|
181
|
+
tz: target.tz,
|
|
182
|
+
start: seamOf(countedWindow(target)),
|
|
183
|
+
status: "empty",
|
|
184
|
+
version: 4,
|
|
185
|
+
gen: null,
|
|
186
|
+
hits: 0,
|
|
187
|
+
leaseOwner: null,
|
|
188
|
+
leaseUntil: null,
|
|
189
|
+
finalAfter: dayFinalAfter(target.day, target.tz),
|
|
190
|
+
aggregatedAt: at
|
|
191
|
+
});
|
|
192
|
+
/**
|
|
193
|
+
* Reads planned per local day over aggregates, raw hits and today's snapshot, unaggregated closed
|
|
194
|
+
* days aggregated lazily, and the leased day runs.
|
|
195
|
+
*/
|
|
196
|
+
const createEngine = (input) => {
|
|
197
|
+
const { payload, store, state } = input;
|
|
198
|
+
const options = input.options ?? {};
|
|
199
|
+
const settings = settingsOf(options, store);
|
|
200
|
+
const warn = options.warn ?? ((message) => payload.logger.warn(message));
|
|
201
|
+
const zones = createZoneBook(options.timezone, warn, (scope) => state.lastZone(scope));
|
|
202
|
+
const filterMap = options.filters ?? store.features.filters;
|
|
203
|
+
const breakdowns = options.dimensions;
|
|
204
|
+
const instance = `engine:${ulid(settings.now())}`;
|
|
205
|
+
/** A fresh lease owner for each lease this engine takes. */
|
|
206
|
+
const newOwner = () => `${instance}:${ulid(settings.now())}`;
|
|
207
|
+
const running = /* @__PURE__ */ new Set();
|
|
208
|
+
const refreshing = /* @__PURE__ */ new Map();
|
|
209
|
+
/** Days still running found too busy to read live, which they stay as their hits only grow. */
|
|
210
|
+
const busyDays = /* @__PURE__ */ new Set();
|
|
211
|
+
const cost = createCostModel(store);
|
|
212
|
+
let closed = false;
|
|
213
|
+
const zeroParts = (read) => partsFrom(countedParts(read.totalAxis, read.visits), () => 0);
|
|
214
|
+
/** Counts `task` as running until it settles, so `idle` and `close` wait for it. */
|
|
215
|
+
const track = (task) => {
|
|
216
|
+
const settled = task.then(() => void 0, () => void 0);
|
|
217
|
+
running.add(settled);
|
|
218
|
+
settled.then(() => running.delete(settled));
|
|
219
|
+
return task;
|
|
220
|
+
};
|
|
221
|
+
/** Work nobody awaits, its failure logged; none starts once the engine is closed. */
|
|
222
|
+
const background = (what, work) => closed ? Promise.resolve() : track(work().catch((err) => {
|
|
223
|
+
warn(`analytics: ${what} failed: ${String(err)}`);
|
|
224
|
+
}));
|
|
225
|
+
/**
|
|
226
|
+
* Notes one more attempt at counting a day the run holds, or gives up on it once counting it
|
|
227
|
+
* has started `MAX_COUNT_ATTEMPTS` times without completing: a crash counts as well as a throw.
|
|
228
|
+
*/
|
|
229
|
+
const attemptDay = async (target, owner) => {
|
|
230
|
+
const [held] = await state.markers(target.scope, target.day, target.day);
|
|
231
|
+
if (held?.leaseOwner !== owner) return "lost";
|
|
232
|
+
const failures = held.failures ?? 0;
|
|
233
|
+
if (failures >= 3) return await state.attempt({
|
|
234
|
+
...held,
|
|
235
|
+
status: "failed"
|
|
236
|
+
}, owner) ? "failed" : "lost";
|
|
237
|
+
return await state.attempt({
|
|
238
|
+
...held,
|
|
239
|
+
failures: failures + 1
|
|
240
|
+
}, owner) ? "counting" : "lost";
|
|
241
|
+
};
|
|
242
|
+
/** A leased count of one day; `timeoutMs` bounds a count a read started (see `AggregateRun`). */
|
|
243
|
+
const runDay = async (target, status, options = {}) => {
|
|
244
|
+
const key = dayKey(target.scope, target.day);
|
|
245
|
+
const runId = newOwner();
|
|
246
|
+
if (!await state.claim(key, runId, 6e5)) return { outcome: "busy" };
|
|
247
|
+
let completed = false;
|
|
248
|
+
const renewal = setInterval(() => {
|
|
249
|
+
state.renew(key, runId, DAY_LEASE_MS).catch(() => false);
|
|
250
|
+
}, DAY_LEASE_RENEW_MS);
|
|
251
|
+
renewal.unref?.();
|
|
252
|
+
try {
|
|
253
|
+
if (options.attempt === true) {
|
|
254
|
+
const attempt = await attemptDay(target, runId);
|
|
255
|
+
if (attempt !== "counting") return { outcome: attempt };
|
|
256
|
+
}
|
|
257
|
+
const started = settings.clock();
|
|
258
|
+
const result = await store.aggregateDay(countedWindow(target), {
|
|
259
|
+
runId,
|
|
260
|
+
caps: settings.caps,
|
|
261
|
+
status,
|
|
262
|
+
itemPages: settings.itemPages,
|
|
263
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
264
|
+
});
|
|
265
|
+
if (result.completed) cost.observe(result.hits, settings.clock() - started);
|
|
266
|
+
completed = result.completed;
|
|
267
|
+
return result.completed ? {
|
|
268
|
+
outcome: "completed",
|
|
269
|
+
hits: result.hits
|
|
270
|
+
} : { outcome: "lost" };
|
|
271
|
+
} finally {
|
|
272
|
+
clearInterval(renewal);
|
|
273
|
+
if (!completed) await state.release(key, runId).catch(() => false);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
const closedStatus = (target) => isSealed(target.day, target.tz, settings.now()) ? "final" : "provisional";
|
|
277
|
+
const snapshotDay = async (target, timeoutMs) => {
|
|
278
|
+
await state.ensureMarkers([target]);
|
|
279
|
+
return runDay(target, "partial", timeoutMs === void 0 ? {} : { timeoutMs });
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* A window's hits when reading or counting them is predicted to fit in `ms`, by a count off the
|
|
283
|
+
* index that stops just past what fits; null when they do not.
|
|
284
|
+
*/
|
|
285
|
+
const hitsWithin = async (window, ms) => {
|
|
286
|
+
const fit = cost.hitsReadableIn(ms);
|
|
287
|
+
if (fit === 0) return null;
|
|
288
|
+
const hits = await store.countHits(window, fit);
|
|
289
|
+
return hits <= fit ? hits : null;
|
|
290
|
+
};
|
|
291
|
+
/** Whether counting a day's hits is predicted to hold up the thread no longer than `stallMs`. */
|
|
292
|
+
const countFits = async (target, stallMs) => await hitsWithin(hitsWindow(target), stallMs) !== null;
|
|
293
|
+
/** Retakes a day's snapshot in the background, unless its count would outlast `stall`. */
|
|
294
|
+
const refresh = (target, stall) => {
|
|
295
|
+
const key = JSON.stringify([target.scope, target.day]);
|
|
296
|
+
if (refreshing.has(key)) return;
|
|
297
|
+
const task = background(`refreshing the snapshot of ${target.day}`, async () => {
|
|
298
|
+
if (stall === null || await countFits(target, stall)) await snapshotDay(target, settings.timeoutMs);
|
|
299
|
+
});
|
|
300
|
+
refreshing.set(key, task);
|
|
301
|
+
task.then(() => refreshing.delete(key));
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Marks a day empty under its lease, probing again once it is held: a backdated server hit stored
|
|
305
|
+
* before the claim is found here, and one stored after revokes the lease so completion fails.
|
|
306
|
+
*/
|
|
307
|
+
const emptyDay = async (target) => {
|
|
308
|
+
const key = dayKey(target.scope, target.day);
|
|
309
|
+
const runId = newOwner();
|
|
310
|
+
if (!await state.claim(key, runId, 6e5)) return false;
|
|
311
|
+
let completed = false;
|
|
312
|
+
try {
|
|
313
|
+
completed = !await store.hasHits(hitsWindow(target)) && await state.complete(emptyMarker(target, settings.now()), runId, { clean: true });
|
|
314
|
+
return completed;
|
|
315
|
+
} finally {
|
|
316
|
+
if (!completed) await state.release(key, runId).catch(() => false);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Marks days without hits empty, each under its lease, until `stop`; answers how many it
|
|
321
|
+
* marked. The target's `startOf` gives a day's window start where it is not the day's own.
|
|
322
|
+
*/
|
|
323
|
+
const emptyDays = async (target, days, stop) => {
|
|
324
|
+
const { scope, tz, startOf } = target;
|
|
325
|
+
let marked = 0;
|
|
326
|
+
for (const day of days) {
|
|
327
|
+
if (stop()) break;
|
|
328
|
+
await state.ensureMarkers([{
|
|
329
|
+
scope,
|
|
330
|
+
day,
|
|
331
|
+
tz
|
|
332
|
+
}]);
|
|
333
|
+
const start = startOf?.(day);
|
|
334
|
+
if (await emptyDay({
|
|
335
|
+
scope,
|
|
336
|
+
day,
|
|
337
|
+
tz,
|
|
338
|
+
...start ? { start } : {}
|
|
339
|
+
})) marked += 1;
|
|
340
|
+
}
|
|
341
|
+
return marked;
|
|
342
|
+
};
|
|
343
|
+
const markEmpty = (at, days, startOf) => {
|
|
344
|
+
if (days.length === 0 || at.standIn) return;
|
|
345
|
+
background("marking days without hits", async () => {
|
|
346
|
+
await emptyDays({
|
|
347
|
+
...at,
|
|
348
|
+
startOf
|
|
349
|
+
}, days, () => closed);
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* Whether each date of a run has hits: one probe for a run without, halved while it has some.
|
|
354
|
+
* A run starts where the target's `startOf` says its first day's window does.
|
|
355
|
+
*/
|
|
356
|
+
const probe = async (at, [first, last], found) => {
|
|
357
|
+
if (!await store.hasHits({
|
|
358
|
+
scope: at.scope,
|
|
359
|
+
start: at.startOf?.(first) ?? calendarDayStart(first, at.tz),
|
|
360
|
+
end: dayEnd(last, at.tz)
|
|
361
|
+
})) {
|
|
362
|
+
for (const day of datesOf(first, last)) found.none.push(day);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (first === last) {
|
|
366
|
+
found.hits.push(first);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const middle = addCalendarDays(first, Math.floor(calendarDaysBetween(first, last) / 2));
|
|
370
|
+
await probe(at, [first, middle], found);
|
|
371
|
+
await probe(at, [addCalendarDays(middle, 1), last], found);
|
|
372
|
+
};
|
|
373
|
+
const probeRun = async (target, run) => {
|
|
374
|
+
const found = {
|
|
375
|
+
hits: [],
|
|
376
|
+
none: []
|
|
377
|
+
};
|
|
378
|
+
await probe(target, run, found);
|
|
379
|
+
return found;
|
|
380
|
+
};
|
|
381
|
+
/** Raw hits are complete and within retention from `start` on. */
|
|
382
|
+
const rawCovers = (at, start) => at.rawFrom === void 0 || start >= at.rawFrom;
|
|
383
|
+
const rawBase = (read, window) => ({
|
|
384
|
+
...scopeFields(window),
|
|
385
|
+
start: window.start,
|
|
386
|
+
end: window.end,
|
|
387
|
+
from: window.from,
|
|
388
|
+
...read.query.hostname === void 0 ? {} : { hostname: read.query.hostname },
|
|
389
|
+
filters: read.filters,
|
|
390
|
+
sessions: read.visits,
|
|
391
|
+
timeoutMs: settings.timeoutMs,
|
|
392
|
+
...read.signal ? { signal: read.signal } : {}
|
|
393
|
+
});
|
|
394
|
+
const rawTotals = async (read, window) => {
|
|
395
|
+
const [row] = await store.readRaw(rawBase(read, window));
|
|
396
|
+
return row?.parts ?? zeroParts(read);
|
|
397
|
+
};
|
|
398
|
+
const aggregateRead = (read, span, target) => ({
|
|
399
|
+
...target,
|
|
400
|
+
...scopeFields(span),
|
|
401
|
+
days: span.days,
|
|
402
|
+
...read.query.hostname === void 0 ? {} : { hostname: read.query.hostname },
|
|
403
|
+
...read.signal ? { signal: read.signal } : {}
|
|
404
|
+
});
|
|
405
|
+
/**
|
|
406
|
+
* A read only raw hits can answer: its range from where they cover it on, as one window, never
|
|
407
|
+
* from before `dataFrom`, the start of the day of the scope's oldest hit.
|
|
408
|
+
*/
|
|
409
|
+
const planRaw = (at, dataFrom) => {
|
|
410
|
+
const { read, scope, tz, plan, rawFrom } = at;
|
|
411
|
+
const today = localDay(todayIn(read.now, tz), tz);
|
|
412
|
+
const clamped = rawFrom !== void 0 && read.start < rawFrom;
|
|
413
|
+
const start = maxDate(clamped ? rawFrom : read.start, dataFrom ?? read.start);
|
|
414
|
+
const end = minDate(read.end, today.end);
|
|
415
|
+
const days = localDaysOf(start, end, tz);
|
|
416
|
+
const [first] = days;
|
|
417
|
+
return {
|
|
418
|
+
...plan,
|
|
419
|
+
...clamped ? { clampedTo: rawFrom } : {},
|
|
420
|
+
raw: first ? [{
|
|
421
|
+
scope,
|
|
422
|
+
start,
|
|
423
|
+
end,
|
|
424
|
+
from: first.start,
|
|
425
|
+
days
|
|
426
|
+
}] : []
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
/** What is left of a read's budget for uncounted days, the raw reads planned for them spent. */
|
|
430
|
+
const roomOf = (read) => read.signal?.aborted ? 0 : read.lazyUntil - settings.clock() - read.planned.ms;
|
|
431
|
+
/** Whether a runner's heartbeat is fresh, so its next run counts what a read finds uncounted. */
|
|
432
|
+
const runnerFresh = (read) => {
|
|
433
|
+
read.runner.fresh ??= settings.runner ? state.lastBeat(MAINTAIN_TASK_SLUG).then((beat) => !heartbeatStale(beat, settings.maintainIntervalMs, settings.now()), () => false) : Promise.resolve(false);
|
|
434
|
+
return read.runner.fresh;
|
|
435
|
+
};
|
|
436
|
+
/** A day left uncounted: missing from the answer, and a reason to start maintenance. */
|
|
437
|
+
const skip = (read, plan) => {
|
|
438
|
+
plan.missing += 1;
|
|
439
|
+
read.uncounted.count += 1;
|
|
440
|
+
};
|
|
441
|
+
const maxAgeOf = (hits) => settings.snapshotMaxAgeMs ?? snapshotMaxAgeMs(hits, cost.readMs(hits));
|
|
442
|
+
const busyKey = (target) => JSON.stringify([
|
|
443
|
+
target.scope,
|
|
444
|
+
target.day,
|
|
445
|
+
target.start?.getTime() ?? null
|
|
446
|
+
]);
|
|
447
|
+
const markBusy = (target) => {
|
|
448
|
+
if (busyDays.size >= MAX_BUSY_DAYS) busyDays.clear();
|
|
449
|
+
busyDays.add(busyKey(target));
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Whether a day still running holds more hits than are read live, by a count that stops just
|
|
453
|
+
* past the threshold; a day found so stays so.
|
|
454
|
+
*/
|
|
455
|
+
const isBusy = async (target, local, counted) => {
|
|
456
|
+
if (busyDays.has(busyKey(target))) return true;
|
|
457
|
+
if ((counted ?? await store.countHits({
|
|
458
|
+
scope: target.scope,
|
|
459
|
+
start: local.start,
|
|
460
|
+
end: local.end
|
|
461
|
+
}, settings.snapshotAboveHits)) <= settings.snapshotAboveHits) return false;
|
|
462
|
+
markBusy(target);
|
|
463
|
+
return true;
|
|
464
|
+
};
|
|
465
|
+
/** Today's live read was refused: it is read from a snapshot from now on, the first taken now. */
|
|
466
|
+
const refuseLive = (target, stall) => {
|
|
467
|
+
markBusy(target);
|
|
468
|
+
refresh(target, stall);
|
|
469
|
+
};
|
|
470
|
+
/** What is left of a read's budget for one statement: its room, at most its stall bound. */
|
|
471
|
+
const statementRoom = (read) => read.stall === null ? roomOf(read) : Math.min(roomOf(read), read.stall);
|
|
472
|
+
/**
|
|
473
|
+
* Today: live while it holds few hits, else from its snapshot. Without one, a snapshot is taken
|
|
474
|
+
* after the read answers, and meanwhile the day is read raw if its cost fits, else left out.
|
|
475
|
+
*/
|
|
476
|
+
const planLive = async (at, local, sorted) => {
|
|
477
|
+
const { read, scope, tz, plan } = at;
|
|
478
|
+
const target = {
|
|
479
|
+
scope,
|
|
480
|
+
day: local.day,
|
|
481
|
+
tz,
|
|
482
|
+
start: local.start
|
|
483
|
+
};
|
|
484
|
+
const window = {
|
|
485
|
+
scope,
|
|
486
|
+
start: local.start,
|
|
487
|
+
end: minDate(read.end, local.end),
|
|
488
|
+
from: local.start,
|
|
489
|
+
days: [local]
|
|
490
|
+
};
|
|
491
|
+
if (at.standIn) {
|
|
492
|
+
plan.raw.push(window);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const known = read.known?.today?.get(scope);
|
|
496
|
+
if (!await isBusy(target, local, known?.start === local.start.getTime() && known.end === local.end.getTime() ? known.hits : void 0)) {
|
|
497
|
+
plan.raw.push({
|
|
498
|
+
...window,
|
|
499
|
+
today: [target]
|
|
500
|
+
});
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const marker = sorted.markers.get(local.day);
|
|
504
|
+
const snapshot = snapshotState(marker, {
|
|
505
|
+
tz,
|
|
506
|
+
window: local,
|
|
507
|
+
now: read.now,
|
|
508
|
+
maxAgeMs: maxAgeOf
|
|
509
|
+
});
|
|
510
|
+
if (snapshot !== "none" && marker?.aggregatedAt) {
|
|
511
|
+
sorted.aggregated.push(local.day);
|
|
512
|
+
plan.asOf = earlier(plan.asOf, marker.aggregatedAt);
|
|
513
|
+
if (snapshot === "stale") read.refresh.push(target);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
read.refresh.push(target);
|
|
517
|
+
const hits = await hitsWithin({
|
|
518
|
+
scope,
|
|
519
|
+
start: local.start,
|
|
520
|
+
end: local.end
|
|
521
|
+
}, statementRoom(read));
|
|
522
|
+
if (hits !== null) {
|
|
523
|
+
read.planned.ms += cost.readMs(hits);
|
|
524
|
+
plan.raw.push(window);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
plan.missing += 1;
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Closed days without rows, newest first, while their cost fits: counted with no fresh runner,
|
|
531
|
+
* else read raw (at most `lazy.rawDays`), the rest left out. A stand-in zone counts none.
|
|
532
|
+
*/
|
|
533
|
+
const planUnread = async (at, unaggregated, sorted) => {
|
|
534
|
+
if (unaggregated.length === 0) return;
|
|
535
|
+
const { read, scope, tz, plan } = at;
|
|
536
|
+
const { windowFor, markers } = sorted;
|
|
537
|
+
const counting = !at.standIn && !await runnerFresh(read);
|
|
538
|
+
const raw = [];
|
|
539
|
+
for (const day of [...unaggregated].sort((a, b) => b - a)) {
|
|
540
|
+
const window = windowFor(day);
|
|
541
|
+
const room = statementRoom(read);
|
|
542
|
+
const reading = raw.length < settings.lazyRawDays;
|
|
543
|
+
const fit = counting || reading ? cost.hitsReadableIn(room) : 0;
|
|
544
|
+
const hits = fit === 0 ? null : wholeDayHits(markers.get(day), window) ?? await store.countHits({
|
|
545
|
+
scope,
|
|
546
|
+
start: window.start,
|
|
547
|
+
end: window.end
|
|
548
|
+
}, fit);
|
|
549
|
+
const canCount = hits !== null && counting && cost.readMs(hits) <= room;
|
|
550
|
+
const canRead = hits !== null && reading && cost.readMs(hits) <= room;
|
|
551
|
+
if (hits === null || !(canCount || canRead)) {
|
|
552
|
+
skip(read, plan);
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
if (canCount) {
|
|
556
|
+
const target = {
|
|
557
|
+
scope,
|
|
558
|
+
day,
|
|
559
|
+
tz,
|
|
560
|
+
start: window.start
|
|
561
|
+
};
|
|
562
|
+
await state.ensureMarkers([{
|
|
563
|
+
scope,
|
|
564
|
+
day,
|
|
565
|
+
tz
|
|
566
|
+
}]);
|
|
567
|
+
if ((await runDay(target, closedStatus(target), { timeoutMs: settings.timeoutMs }).catch((err) => {
|
|
568
|
+
warn(`analytics: aggregating ${day} of scope "${scope}" failed: ${String(err)}`);
|
|
569
|
+
return { outcome: "lost" };
|
|
570
|
+
})).outcome === "completed") {
|
|
571
|
+
sorted.aggregated.push(day);
|
|
572
|
+
read.known?.markers?.delete(scope);
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (canRead) {
|
|
577
|
+
raw.push(day);
|
|
578
|
+
read.planned.ms += cost.readMs(hits);
|
|
579
|
+
read.uncounted.count += 1;
|
|
580
|
+
} else skip(read, plan);
|
|
581
|
+
}
|
|
582
|
+
pushRawRuns(at, raw, windowFor);
|
|
583
|
+
};
|
|
584
|
+
/** Days read from their raw hits instead, as one window per run of consecutive days. */
|
|
585
|
+
const pushRawRuns = (at, days, windowFor) => {
|
|
586
|
+
for (const [first, last] of runsOf([...days].sort((a, b) => a - b))) {
|
|
587
|
+
const windows = datesOf(first, last).map(windowFor);
|
|
588
|
+
const [head] = windows;
|
|
589
|
+
const tail = windows.at(-1);
|
|
590
|
+
if (head && tail) at.plan.raw.push({
|
|
591
|
+
scope: at.scope,
|
|
592
|
+
start: head.start,
|
|
593
|
+
end: minDate(at.read.end, tail.end),
|
|
594
|
+
from: head.start,
|
|
595
|
+
days: windows
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
/**
|
|
600
|
+
* The days read from rows on which a value the read asks about was folded into `(other)`: read
|
|
601
|
+
* from their raw hits while those are kept, else read as they are and counted as capped.
|
|
602
|
+
*/
|
|
603
|
+
const planFolded = async (at, sorted) => {
|
|
604
|
+
const { read, scope, plan } = at;
|
|
605
|
+
const { windowFor } = sorted;
|
|
606
|
+
const targets = foldTargets(read.shape);
|
|
607
|
+
if (targets.length === 0 || sorted.aggregated.length === 0) return;
|
|
608
|
+
const days = runsOf([...new Set(sorted.aggregated)].sort((a, b) => a - b));
|
|
609
|
+
const folded = /* @__PURE__ */ new Set();
|
|
610
|
+
for (const target of targets) {
|
|
611
|
+
const found = await store.foldedDays({
|
|
612
|
+
scope,
|
|
613
|
+
days,
|
|
614
|
+
...read.query.hostname === void 0 ? {} : { hostname: read.query.hostname },
|
|
615
|
+
...target
|
|
616
|
+
});
|
|
617
|
+
for (const day of found) folded.add(day);
|
|
618
|
+
}
|
|
619
|
+
if (folded.size === 0) return;
|
|
620
|
+
const kept = [];
|
|
621
|
+
const raw = [];
|
|
622
|
+
for (const day of sorted.aggregated) if (!folded.has(day)) kept.push(day);
|
|
623
|
+
else if (!isFixed(sorted.markers.get(day), at.prunedBefore) && rawCovers(at, windowFor(day).start)) raw.push(day);
|
|
624
|
+
else {
|
|
625
|
+
kept.push(day);
|
|
626
|
+
plan.capped += 1;
|
|
627
|
+
}
|
|
628
|
+
sorted.aggregated.splice(0, sorted.aggregated.length, ...kept);
|
|
629
|
+
pushRawRuns(at, raw, windowFor);
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* A day the range cuts past raw retention, which no later count can cut: nothing when it held no
|
|
633
|
+
* hits, else the read starts after it or ends before it, and says so (`clamped`).
|
|
634
|
+
*/
|
|
635
|
+
const planPastRaw = async (at, local, marker) => {
|
|
636
|
+
const { read, scope, plan } = at;
|
|
637
|
+
if (!(marker === void 0 ? await store.hasHits({
|
|
638
|
+
scope,
|
|
639
|
+
start: maxDate(read.start, local.start),
|
|
640
|
+
end: minDate(read.end, local.end)
|
|
641
|
+
}) : marker.status !== "empty" && marker.hits !== 0)) return;
|
|
642
|
+
if (local.start < read.start) plan.clampedTo = later(plan.clampedTo, local.end);
|
|
643
|
+
else plan.endsAt = earlier(plan.endsAt, local.start);
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* A read aggregates can answer: each local day from its rows, its raw hits, or a snapshot. The
|
|
647
|
+
* scope's markers from the day before `first` are read unless `span.markers` holds them.
|
|
648
|
+
*/
|
|
649
|
+
const planDays = async (at, span) => {
|
|
650
|
+
const { read, scope, tz, plan } = at;
|
|
651
|
+
const { first, last } = span;
|
|
652
|
+
const before = addCalendarDays(first, -1);
|
|
653
|
+
const markers = /* @__PURE__ */ new Map();
|
|
654
|
+
const known = span.markers ?? read.known?.markers?.get(scope);
|
|
655
|
+
for (const marker of known ?? await state.markers(scope, before, last)) if (marker.day >= before && marker.day <= last) markers.set(marker.day, marker);
|
|
656
|
+
const windowFor = (day) => windowOf(day, {
|
|
657
|
+
tz,
|
|
658
|
+
markers,
|
|
659
|
+
prunedBefore: at.prunedBefore
|
|
660
|
+
});
|
|
661
|
+
const startOf = (day) => windowFor(day).start;
|
|
662
|
+
const today = todayIn(read.now, tz);
|
|
663
|
+
const yesterday = addCalendarDays(today, -1);
|
|
664
|
+
const todayLocal = windowFor(today);
|
|
665
|
+
const yesterdayLocal = windowFor(yesterday);
|
|
666
|
+
const yesterdayLive = !isClosed(yesterdayLocal, read.now);
|
|
667
|
+
const startsLate = read.start > calendarDayStart(first, tz);
|
|
668
|
+
const reachesNow = read.end.getTime() >= read.now.getTime() - (settings.snapshotMaxAgeMs ?? SNAPSHOT_LONGEST_AGE_MS);
|
|
669
|
+
const edges = [];
|
|
670
|
+
const live = [];
|
|
671
|
+
const closed = [];
|
|
672
|
+
for (const day of datesOf(first, last)) {
|
|
673
|
+
const cutAtStart = day === first && startsLate;
|
|
674
|
+
if (day === today || day === yesterday && yesterdayLive) {
|
|
675
|
+
const local = day === today ? todayLocal : yesterdayLocal;
|
|
676
|
+
if (cutAtStart || !(read.end >= local.end || reachesNow)) edges.push(local);
|
|
677
|
+
else live.push(local);
|
|
678
|
+
} else if (cutAtStart || day === last && read.end < dayEnd(day, tz)) edges.push(windowFor(day));
|
|
679
|
+
else closed.push(day);
|
|
680
|
+
}
|
|
681
|
+
const sorted = {
|
|
682
|
+
markers,
|
|
683
|
+
windowFor,
|
|
684
|
+
aggregated: [],
|
|
685
|
+
empty: []
|
|
686
|
+
};
|
|
687
|
+
const probing = [];
|
|
688
|
+
const unaggregated = [];
|
|
689
|
+
const failed = [];
|
|
690
|
+
const bySource = {
|
|
691
|
+
aggregates: sorted.aggregated,
|
|
692
|
+
empty: sorted.empty,
|
|
693
|
+
probe: probing,
|
|
694
|
+
aggregate: unaggregated,
|
|
695
|
+
failed
|
|
696
|
+
};
|
|
697
|
+
for (const day of closed) {
|
|
698
|
+
const marker = markers.get(day);
|
|
699
|
+
bySource[closedDaySource({
|
|
700
|
+
marker,
|
|
701
|
+
tz,
|
|
702
|
+
window: windowFor(day),
|
|
703
|
+
fixed: isFixed(marker, at.prunedBefore)
|
|
704
|
+
})].push(day);
|
|
705
|
+
}
|
|
706
|
+
for (const day of failed) {
|
|
707
|
+
plan.failed += 1;
|
|
708
|
+
if ((markers.get(day)?.gen ?? null) !== null) sorted.aggregated.push(day);
|
|
709
|
+
}
|
|
710
|
+
const found = {
|
|
711
|
+
hits: [],
|
|
712
|
+
none: []
|
|
713
|
+
};
|
|
714
|
+
for (const run of runsOf(probing)) await probe({
|
|
715
|
+
...at,
|
|
716
|
+
startOf
|
|
717
|
+
}, run, found);
|
|
718
|
+
for (const day of found.none) sorted.empty.push(day);
|
|
719
|
+
const horizon = rawFloorDay(today, settings.rawDays ?? 90);
|
|
720
|
+
const toMark = found.none.filter((day) => day >= horizon && isSealed(day, tz, read.now)).sort((a, b) => b - a).slice(0, read.emptyLeft.count);
|
|
721
|
+
read.emptyLeft.count -= toMark.length;
|
|
722
|
+
markEmpty(at, toMark, startOf);
|
|
723
|
+
await planUnread(at, [...unaggregated, ...found.hits], sorted);
|
|
724
|
+
for (const local of live) await planLive(at, local, sorted);
|
|
725
|
+
await planFolded(at, sorted);
|
|
726
|
+
for (const local of edges) {
|
|
727
|
+
const start = maxDate(read.start, local.start);
|
|
728
|
+
if (!rawCovers(at, start)) {
|
|
729
|
+
await planPastRaw(at, local, markers.get(local.day));
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
plan.raw.push({
|
|
733
|
+
scope,
|
|
734
|
+
start,
|
|
735
|
+
end: minDate(read.end, local.end),
|
|
736
|
+
from: local.start,
|
|
737
|
+
days: [local]
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
const ranges = aggregateRanges(sorted);
|
|
741
|
+
return {
|
|
742
|
+
...plan,
|
|
743
|
+
aggregates: ranges.length > 0 ? {
|
|
744
|
+
scope,
|
|
745
|
+
days: ranges
|
|
746
|
+
} : null
|
|
747
|
+
};
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* The local days of a scope's part of a read, up to today, and where they start instead of the
|
|
751
|
+
* range's first date when `aggregateDays` deleted the days before; null when it reads none.
|
|
752
|
+
*/
|
|
753
|
+
const daysOf = (read, tz) => {
|
|
754
|
+
const span = daySpan(read.start, read.end, tz);
|
|
755
|
+
const today = todayIn(read.now, tz);
|
|
756
|
+
if (!span || span.first > today) return null;
|
|
757
|
+
const last = Math.min(span.last, today);
|
|
758
|
+
const kept = settings.aggregateDays === null ? null : rawFloorDay(today, settings.aggregateDays);
|
|
759
|
+
return kept !== null && span.first < kept ? {
|
|
760
|
+
first: kept,
|
|
761
|
+
last,
|
|
762
|
+
clampedTo: calendarDayStart(kept, tz)
|
|
763
|
+
} : {
|
|
764
|
+
first: span.first,
|
|
765
|
+
last
|
|
766
|
+
};
|
|
767
|
+
};
|
|
768
|
+
/**
|
|
769
|
+
* Every scope's prune cut, and the markers of the days their parts of the read cover, read in
|
|
770
|
+
* one statement each for a read of several scopes.
|
|
771
|
+
*/
|
|
772
|
+
const knownStateOf = async (read, zoned) => {
|
|
773
|
+
const scopes = zoned.map((each) => each.scope);
|
|
774
|
+
const pruned = await state.prunedBeforeIn(scopes);
|
|
775
|
+
if (read.shape.source === "raw" && read.shape.total === void 0) return { pruned };
|
|
776
|
+
let from;
|
|
777
|
+
let to;
|
|
778
|
+
for (const { tz } of zoned) {
|
|
779
|
+
const days = daysOf(read, tz);
|
|
780
|
+
if (days !== null && days.first <= days.last) {
|
|
781
|
+
const before = addCalendarDays(days.first, -1);
|
|
782
|
+
from = from === void 0 ? before : Math.min(from, before);
|
|
783
|
+
to = to === void 0 ? days.last : Math.max(to, days.last);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
const today = await todayCounts(read, zoned);
|
|
787
|
+
if (from === void 0 || to === void 0 || scopes.length * (calendarDaysBetween(from, to) + 1) > MAX_KNOWN_MARKERS) return {
|
|
788
|
+
pruned,
|
|
789
|
+
today
|
|
790
|
+
};
|
|
791
|
+
const found = new Map(scopes.map((scope) => [scope, []]));
|
|
792
|
+
for (const marker of await state.markersIn(scopes, from, to)) found.get(marker.scope)?.push(marker);
|
|
793
|
+
return {
|
|
794
|
+
pruned,
|
|
795
|
+
markers: found,
|
|
796
|
+
today
|
|
797
|
+
};
|
|
798
|
+
};
|
|
799
|
+
/**
|
|
800
|
+
* Today's hits of every scope the read reaches today in, by zone: one statement per zone and
|
|
801
|
+
* share of scopes rather than one count per scope, each bounded as `isBusy` bounds it.
|
|
802
|
+
*/
|
|
803
|
+
const todayCounts = async (read, zoned) => {
|
|
804
|
+
const byZone = /* @__PURE__ */ new Map();
|
|
805
|
+
for (const { scope, tz } of zoned) if (daysOf(read, tz)?.last === todayIn(read.now, tz)) byZone.set(tz, [...byZone.get(tz) ?? [], scope]);
|
|
806
|
+
const counts = /* @__PURE__ */ new Map();
|
|
807
|
+
for (const [tz, scopes] of byZone) {
|
|
808
|
+
const local = localDay(todayIn(read.now, tz), tz);
|
|
809
|
+
const unknown = scopes.filter((scope) => !busyDays.has(busyKey({
|
|
810
|
+
scope,
|
|
811
|
+
day: local.day,
|
|
812
|
+
tz,
|
|
813
|
+
start: local.start
|
|
814
|
+
})));
|
|
815
|
+
const window = {
|
|
816
|
+
start: local.start,
|
|
817
|
+
end: local.end
|
|
818
|
+
};
|
|
819
|
+
for (const [scope, hits] of await store.countEach(unknown, window, settings.snapshotAboveHits)) counts.set(scope, {
|
|
820
|
+
start: local.start.getTime(),
|
|
821
|
+
end: local.end.getTime(),
|
|
822
|
+
hits
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
return counts;
|
|
826
|
+
};
|
|
827
|
+
const planScope = async (read, zoned) => {
|
|
828
|
+
const { scope, tz, standIn } = zoned;
|
|
829
|
+
const plan = {
|
|
830
|
+
aggregates: null,
|
|
831
|
+
raw: [],
|
|
832
|
+
missing: 0,
|
|
833
|
+
capped: 0,
|
|
834
|
+
failed: 0,
|
|
835
|
+
standIn,
|
|
836
|
+
dayCount: 0
|
|
837
|
+
};
|
|
838
|
+
const days = daysOf(read, tz);
|
|
839
|
+
if (days === null) return plan;
|
|
840
|
+
const { first, last, clampedTo } = days;
|
|
841
|
+
if (clampedTo) plan.clampedTo = clampedTo;
|
|
842
|
+
if (first > last) return plan;
|
|
843
|
+
plan.dayCount = calendarDaysBetween(first, last) + 1;
|
|
844
|
+
const prunedBefore = read.known ? read.known.pruned.get(scope) ?? null : await state.prunedBefore(scope);
|
|
845
|
+
const at = {
|
|
846
|
+
read,
|
|
847
|
+
scope,
|
|
848
|
+
tz,
|
|
849
|
+
plan,
|
|
850
|
+
standIn,
|
|
851
|
+
prunedBefore,
|
|
852
|
+
rawFrom: later(prunedBefore ?? void 0, rawFloor(read.now, tz, settings.rawDays) ?? void 0)
|
|
853
|
+
};
|
|
854
|
+
if (calendarDaysBetween(first, last) < LONG_SPAN_DAYS) return read.shape.source === "raw" ? planRaw(at) : planDays(at, {
|
|
855
|
+
first,
|
|
856
|
+
last
|
|
857
|
+
});
|
|
858
|
+
const oldest = await store.oldestHit(scope);
|
|
859
|
+
const oldestDay = oldest === null ? null : calendarDayOf(oldest, tz);
|
|
860
|
+
if (read.shape.source === "raw") return oldestDay === null ? plan : planRaw(at, oldestDay > first ? calendarDayStart(oldestDay, tz) : void 0);
|
|
861
|
+
const markers = read.known?.markers?.get(scope) ?? await state.markers(scope, addCalendarDays(first, -1), last);
|
|
862
|
+
const firstMarked = markers.find((marker) => marker.day >= first)?.day;
|
|
863
|
+
const dataFrom = Math.min(oldestDay ?? Number.POSITIVE_INFINITY, firstMarked ?? Number.POSITIVE_INFINITY);
|
|
864
|
+
if (dataFrom > last) return plan;
|
|
865
|
+
return dataFrom > first ? planDays(at, {
|
|
866
|
+
first: dataFrom,
|
|
867
|
+
last,
|
|
868
|
+
markers: markers.filter((marker) => marker.day >= addCalendarDays(dataFrom, -1))
|
|
869
|
+
}) : planDays(at, {
|
|
870
|
+
first,
|
|
871
|
+
last,
|
|
872
|
+
markers
|
|
873
|
+
});
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* A refused raw window's days one by one, newest first, while the split budget lasts: each day
|
|
877
|
+
* refused or past the budget adds the window's width to `missing`.
|
|
878
|
+
*/
|
|
879
|
+
const splitDays = async (read, window, readDay) => {
|
|
880
|
+
const until = settings.clock() + settings.splitBudgetMs;
|
|
881
|
+
const width = widthOf(window);
|
|
882
|
+
const pieces = [];
|
|
883
|
+
let missing = 0;
|
|
884
|
+
for (const day of [...window.days].reverse()) {
|
|
885
|
+
if (settings.clock() >= until || read.signal?.aborted) {
|
|
886
|
+
missing += width;
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
await unlessRefused(async () => {
|
|
890
|
+
pieces.push(await readDay(dayOfWindow(window, day)));
|
|
891
|
+
}, () => {
|
|
892
|
+
missing += width;
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
return {
|
|
896
|
+
pieces,
|
|
897
|
+
missing
|
|
898
|
+
};
|
|
899
|
+
};
|
|
900
|
+
/**
|
|
901
|
+
* A raw window's totals, or once refused (too big, out of time) its days' one by one within the
|
|
902
|
+
* split budget ({@link splitDays}). With aggregate totals it reads none.
|
|
903
|
+
*/
|
|
904
|
+
const settleRaw = async (read, window, totalsRaw) => {
|
|
905
|
+
if (!totalsRaw) return {
|
|
906
|
+
windows: [window],
|
|
907
|
+
missing: 0
|
|
908
|
+
};
|
|
909
|
+
const totals = await unlessRefused(async () => window.totals ?? await rawTotals(read, window), () => null);
|
|
910
|
+
if (totals !== null) return {
|
|
911
|
+
windows: [{
|
|
912
|
+
...window,
|
|
913
|
+
totals
|
|
914
|
+
}],
|
|
915
|
+
missing: 0
|
|
916
|
+
};
|
|
917
|
+
for (const target of window.today ?? []) refuseLive(target, read.stall);
|
|
918
|
+
if (window.days.length <= 1) return {
|
|
919
|
+
windows: [],
|
|
920
|
+
missing: window.days.length * widthOf(window)
|
|
921
|
+
};
|
|
922
|
+
const { pieces, missing } = await splitDays(read, window, async (piece) => ({
|
|
923
|
+
...piece,
|
|
924
|
+
totals: await rawTotals(read, piece)
|
|
925
|
+
}));
|
|
926
|
+
return {
|
|
927
|
+
windows: pieces.reverse(),
|
|
928
|
+
missing
|
|
929
|
+
};
|
|
930
|
+
};
|
|
931
|
+
/** A raw side's part of the answer, or nothing and its days missing when it is refused. */
|
|
932
|
+
const orMissing = (side, work, refused) => unlessRefused(work, () => {
|
|
933
|
+
side.missing.count += side.window.days.length * widthOf(side.window);
|
|
934
|
+
return refused;
|
|
935
|
+
});
|
|
936
|
+
const sideTotals = async (read, side) => {
|
|
937
|
+
if (side.kind === "raw") return side.window.totals ?? rawTotals(read, side.window);
|
|
938
|
+
if (read.shape.source !== "aggregates") return zeroParts(read);
|
|
939
|
+
const [row] = await store.readAggregates(aggregateRead(read, side.span, {
|
|
940
|
+
...read.shape.total,
|
|
941
|
+
groupBy: "total"
|
|
942
|
+
}));
|
|
943
|
+
return row?.parts ?? zeroParts(read);
|
|
944
|
+
};
|
|
945
|
+
const sideDays = async (read, side, missing) => {
|
|
946
|
+
if (side.kind === "aggregates") {
|
|
947
|
+
if (read.shape.source !== "aggregates") return [];
|
|
948
|
+
return (await store.readAggregates(aggregateRead(read, side.span, {
|
|
949
|
+
...read.shape.total,
|
|
950
|
+
groupBy: "day"
|
|
951
|
+
}))).flatMap((row) => row.day === void 0 ? [] : [[row.day, row.parts]]);
|
|
952
|
+
}
|
|
953
|
+
const { window } = side;
|
|
954
|
+
return (await orMissing({
|
|
955
|
+
window,
|
|
956
|
+
missing
|
|
957
|
+
}, () => store.readRaw({
|
|
958
|
+
...rawBase(read, window),
|
|
959
|
+
buckets: window.days.map((d) => d.start)
|
|
960
|
+
}), [])).flatMap((row) => {
|
|
961
|
+
const day = row.bucket === void 0 ? void 0 : window.days[row.bucket];
|
|
962
|
+
return day ? [[day.day, row.parts]] : [];
|
|
963
|
+
});
|
|
964
|
+
};
|
|
965
|
+
const sideHours = async (read, window, at) => {
|
|
966
|
+
const buckets = hourStarts(window.start, window.end, at.tz);
|
|
967
|
+
if (buckets.length === 0) return [];
|
|
968
|
+
return (await orMissing({
|
|
969
|
+
window,
|
|
970
|
+
missing: at.missing
|
|
971
|
+
}, () => store.readRaw({
|
|
972
|
+
...rawBase(read, window),
|
|
973
|
+
buckets
|
|
974
|
+
}), [])).flatMap((row) => {
|
|
975
|
+
const start = row.bucket === void 0 ? void 0 : buckets[row.bucket];
|
|
976
|
+
return start ? [[start.getTime(), row.parts]] : [];
|
|
977
|
+
});
|
|
978
|
+
};
|
|
979
|
+
const ranking = (rows, limit) => ({
|
|
980
|
+
rows: valueRowsOf(rows),
|
|
981
|
+
complete: limit === void 0 || rows.length < limit
|
|
982
|
+
});
|
|
983
|
+
/** A side whose every row is in hand, ranked: offered and filled without reading again. */
|
|
984
|
+
const sideOf = (rows) => ({
|
|
985
|
+
top: async (limit) => ({
|
|
986
|
+
rows: limit === void 0 ? [...rows] : rows.slice(0, limit),
|
|
987
|
+
complete: limit === void 0 || rows.length <= limit
|
|
988
|
+
}),
|
|
989
|
+
fill: async (values) => {
|
|
990
|
+
const wanted = new Set(values);
|
|
991
|
+
return rows.filter((row) => wanted.has(row.value));
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
const rawRanked = (read, window) => ({
|
|
995
|
+
...rawBase(read, window),
|
|
996
|
+
groupBy: read.breakdown,
|
|
997
|
+
order: read.order
|
|
998
|
+
});
|
|
999
|
+
/** A refused raw window's ranking day by day ({@link splitDays}), each day read whole. */
|
|
1000
|
+
const dayPieces = async (read, window, missing) => {
|
|
1001
|
+
const split = await splitDays(read, window, async (piece) => sideOf(valueRowsOf(await store.readRaw(rawRanked(read, piece)))));
|
|
1002
|
+
missing.count += split.missing;
|
|
1003
|
+
return split.pieces;
|
|
1004
|
+
};
|
|
1005
|
+
/**
|
|
1006
|
+
* A raw window's ranking; one day beside other sides is read once, whole, and fills from that.
|
|
1007
|
+
* Refused, its days are missing, or with `split` it is read day by day ({@link dayPieces}).
|
|
1008
|
+
*/
|
|
1009
|
+
const rawSide = (read, window, at) => {
|
|
1010
|
+
const base = rawRanked(read, window);
|
|
1011
|
+
const whole = window.days.length === 1 && !at.alone;
|
|
1012
|
+
let everyRow;
|
|
1013
|
+
let pieces;
|
|
1014
|
+
let refused = false;
|
|
1015
|
+
const readWhole = () => {
|
|
1016
|
+
everyRow ??= store.readRaw(base).then(valueRowsOf);
|
|
1017
|
+
return everyRow;
|
|
1018
|
+
};
|
|
1019
|
+
const refuse = (answer) => {
|
|
1020
|
+
if (!refused) {
|
|
1021
|
+
refused = true;
|
|
1022
|
+
at.missing.count += window.days.length * widthOf(window);
|
|
1023
|
+
}
|
|
1024
|
+
return answer;
|
|
1025
|
+
};
|
|
1026
|
+
return {
|
|
1027
|
+
top: (limit) => unlessRefused(async () => whole ? sideOf(await readWhole()).top(limit) : ranking(await store.readRaw({
|
|
1028
|
+
...base,
|
|
1029
|
+
...limit === void 0 ? {} : { limit }
|
|
1030
|
+
}), limit), async () => {
|
|
1031
|
+
if (!at.split || window.days.length <= 1) return refuse({
|
|
1032
|
+
rows: [],
|
|
1033
|
+
complete: true
|
|
1034
|
+
});
|
|
1035
|
+
pieces = await dayPieces(read, window, at.missing);
|
|
1036
|
+
const rows = await topAcross(pieces, read.order, limit);
|
|
1037
|
+
return {
|
|
1038
|
+
rows,
|
|
1039
|
+
complete: limit === void 0 || rows.length < limit
|
|
1040
|
+
};
|
|
1041
|
+
}),
|
|
1042
|
+
async fill(values) {
|
|
1043
|
+
if (pieces) return sumByValue((await Promise.all(pieces.map((piece) => piece.fill(values)))).flat());
|
|
1044
|
+
if (refused) return [];
|
|
1045
|
+
return unlessRefused(async () => whole ? sideOf(await readWhole()).fill(values) : valueRowsOf(await store.readRaw({
|
|
1046
|
+
...base,
|
|
1047
|
+
values
|
|
1048
|
+
})), () => refuse([]));
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
};
|
|
1052
|
+
const rankedSide = (read, side, at) => {
|
|
1053
|
+
if (side.kind === "raw") return rawSide(read, side.window, at);
|
|
1054
|
+
const target = read.shape.source === "aggregates" ? read.shape.breakdown : void 0;
|
|
1055
|
+
if (!target) return {
|
|
1056
|
+
top: async () => ({
|
|
1057
|
+
rows: [],
|
|
1058
|
+
complete: true
|
|
1059
|
+
}),
|
|
1060
|
+
fill: async () => []
|
|
1061
|
+
};
|
|
1062
|
+
const base = aggregateRead(read, side.span, {
|
|
1063
|
+
...target,
|
|
1064
|
+
order: read.order
|
|
1065
|
+
});
|
|
1066
|
+
return {
|
|
1067
|
+
async top(limit) {
|
|
1068
|
+
return ranking(await store.readAggregates({
|
|
1069
|
+
...base,
|
|
1070
|
+
...limit === void 0 ? {} : { limit }
|
|
1071
|
+
}), limit);
|
|
1072
|
+
},
|
|
1073
|
+
async fill(values) {
|
|
1074
|
+
return valueRowsOf(await store.readAggregates({
|
|
1075
|
+
...base,
|
|
1076
|
+
values
|
|
1077
|
+
}));
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
const rowsOf = async (read, sides, at) => {
|
|
1082
|
+
const { metrics } = read.query;
|
|
1083
|
+
const { missing, labelZone } = at;
|
|
1084
|
+
const breakdown = read.breakdown;
|
|
1085
|
+
if (breakdown !== void 0) {
|
|
1086
|
+
const alone = sides.length === 1;
|
|
1087
|
+
return (await topAcross(sides.map((side) => rankedSide(read, side, {
|
|
1088
|
+
missing,
|
|
1089
|
+
alone,
|
|
1090
|
+
split: at.split
|
|
1091
|
+
})), read.order, limitOf(read.query))).map((row) => {
|
|
1092
|
+
const dimensions = {};
|
|
1093
|
+
dimensions[breakdown] = row.value;
|
|
1094
|
+
return {
|
|
1095
|
+
dimensions,
|
|
1096
|
+
metrics: partsToMetrics(row.parts, metrics)
|
|
1097
|
+
};
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
if (read.series === "hour") {
|
|
1101
|
+
const byHour = /* @__PURE__ */ new Map();
|
|
1102
|
+
const perWindow = await mapLimited(sides.flatMap((side) => side.kind === "raw" ? [side.window] : []), CONCURRENCY, (window) => sideHours(read, window, {
|
|
1103
|
+
tz: labelZone,
|
|
1104
|
+
missing
|
|
1105
|
+
}));
|
|
1106
|
+
for (const [hour, parts] of perWindow.flat()) addInto(byHour, hour, parts);
|
|
1107
|
+
return [...byHour].sort(([a], [b]) => a - b).map(([hour, parts]) => ({
|
|
1108
|
+
timestamp: new Date(hour).toISOString(),
|
|
1109
|
+
metrics: partsToMetrics(parts, metrics)
|
|
1110
|
+
}));
|
|
1111
|
+
}
|
|
1112
|
+
if (read.series === void 0) return [{ metrics: partsToMetrics(at.totals, metrics) }];
|
|
1113
|
+
const unit = read.series;
|
|
1114
|
+
const byDay = /* @__PURE__ */ new Map();
|
|
1115
|
+
const fileDay = fileDayWithin(read, labelZone);
|
|
1116
|
+
const perSide = await mapLimited(sides, CONCURRENCY, (side) => sideDays(read, side, missing));
|
|
1117
|
+
for (const [scopeDay, parts] of perSide.flat()) addInto(byDay, fileDay(scopeDay), parts);
|
|
1118
|
+
const days = [...byDay].sort(([a], [b]) => a - b).map(([day, parts]) => ({
|
|
1119
|
+
day,
|
|
1120
|
+
parts
|
|
1121
|
+
}));
|
|
1122
|
+
if (unit === "day") return days.map(({ day, parts }) => ({
|
|
1123
|
+
timestamp: calendarDayStart(day, labelZone).toISOString(),
|
|
1124
|
+
metrics: partsToMetrics(parts, metrics)
|
|
1125
|
+
}));
|
|
1126
|
+
return foldDays(days, unit).buckets.map((bucket) => ({
|
|
1127
|
+
timestamp: bucketInstant(bucket.start, labelZone).toISOString(),
|
|
1128
|
+
metrics: partsToMetrics(bucket.parts, metrics)
|
|
1129
|
+
}));
|
|
1130
|
+
};
|
|
1131
|
+
/** The first scope a side reads; every scope merged into it reports in the same currency. */
|
|
1132
|
+
const scopeOfSide = (side) => side.kind === "aggregates" ? side.span.scope : side.window.scope;
|
|
1133
|
+
/** A scope's reporting currency, asked once per read. */
|
|
1134
|
+
const reportingOf = (read, scope) => {
|
|
1135
|
+
const known = read.currencies.get(scope);
|
|
1136
|
+
if (known) return known;
|
|
1137
|
+
const asked = options.currency ? options.currency(scope).catch(() => void 0) : Promise.resolve(void 0);
|
|
1138
|
+
read.currencies.set(scope, asked);
|
|
1139
|
+
return asked;
|
|
1140
|
+
};
|
|
1141
|
+
/**
|
|
1142
|
+
* What scopes read together must share: the reporting currency when the read names the
|
|
1143
|
+
* currencies its revenue adds by it (see `mixedCurrencies`), nothing otherwise.
|
|
1144
|
+
*/
|
|
1145
|
+
const mergeKeyOf = async (read, scope) => read.query.metrics.includes("revenue") && !read.filters.some((filter) => filter.dimension === "currency") ? JSON.stringify(await reportingOf(read, scope) ?? null) : "";
|
|
1146
|
+
const scopesIn = (part) => part.scopes ?? [part.scope];
|
|
1147
|
+
/**
|
|
1148
|
+
* Aggregate spans over the same dates, one read for all their scopes: each scope's rows are of
|
|
1149
|
+
* its own local days, so the sum is the sum of reading each alone.
|
|
1150
|
+
*/
|
|
1151
|
+
const mergeSpans = (spans, keyOf) => {
|
|
1152
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1153
|
+
for (const span of spans) {
|
|
1154
|
+
const key = JSON.stringify([keyOf(span.scope), span.days]);
|
|
1155
|
+
const held = merged.get(key);
|
|
1156
|
+
merged.set(key, held ? {
|
|
1157
|
+
...held,
|
|
1158
|
+
scopes: [...scopesIn(held), ...scopesIn(span)]
|
|
1159
|
+
} : { ...span });
|
|
1160
|
+
}
|
|
1161
|
+
return [...merged.values()];
|
|
1162
|
+
};
|
|
1163
|
+
/**
|
|
1164
|
+
* Raw windows over the same instants, cut into the same days (scopes of one zone), one read for
|
|
1165
|
+
* all their scopes: visits are cut per scope, so the answer is the sum of reading each alone.
|
|
1166
|
+
*/
|
|
1167
|
+
const mergeWindows = (windows, keyOf) => {
|
|
1168
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1169
|
+
for (const window of windows) {
|
|
1170
|
+
const key = JSON.stringify([
|
|
1171
|
+
keyOf(window.scope),
|
|
1172
|
+
window.start.getTime(),
|
|
1173
|
+
window.end.getTime(),
|
|
1174
|
+
window.from.getTime(),
|
|
1175
|
+
window.days.map((day) => [
|
|
1176
|
+
day.day,
|
|
1177
|
+
day.start.getTime(),
|
|
1178
|
+
day.end.getTime()
|
|
1179
|
+
]),
|
|
1180
|
+
window.totals === void 0
|
|
1181
|
+
]);
|
|
1182
|
+
const held = merged.get(key);
|
|
1183
|
+
merged.set(key, held && held.totals === void 0 ? {
|
|
1184
|
+
...held,
|
|
1185
|
+
scopes: [...scopesIn(held), ...scopesIn(window)],
|
|
1186
|
+
today: [...held.today ?? [], ...window.today ?? []]
|
|
1187
|
+
} : { ...window });
|
|
1188
|
+
}
|
|
1189
|
+
return [...merged.values()];
|
|
1190
|
+
};
|
|
1191
|
+
/**
|
|
1192
|
+
* The currencies a side's amounts were sent in, those with revenue alone, under the read's
|
|
1193
|
+
* currency filters only: what the period took, not what its other filters keep.
|
|
1194
|
+
*/
|
|
1195
|
+
const sideCurrencies = async (read, side, named) => {
|
|
1196
|
+
return (side.kind === "aggregates" ? await store.readAggregates(aggregateRead(read, side.span, {
|
|
1197
|
+
dim: "currency",
|
|
1198
|
+
groupBy: "value"
|
|
1199
|
+
})) : await unlessRefused(() => store.readRaw({
|
|
1200
|
+
...rawBase(read, side.window),
|
|
1201
|
+
filters: named,
|
|
1202
|
+
sessions: false,
|
|
1203
|
+
groupBy: "currency"
|
|
1204
|
+
}), () => [])).flatMap((row) => row.value !== null && (row.parts.revenue ?? 0) !== 0 && named.every((filter) => filterHolds(row.value ?? "", filter)) ? [row.value] : []);
|
|
1205
|
+
};
|
|
1206
|
+
/**
|
|
1207
|
+
* The currencies a read's revenue adds, when more than one: a scope's reporting currency alone,
|
|
1208
|
+
* else (or under a currency filter) each as sent. An `eq` currency filter never mixes.
|
|
1209
|
+
*/
|
|
1210
|
+
const mixedCurrencies = async (read, sided) => {
|
|
1211
|
+
const named = read.filters.filter((filter) => filter.dimension === "currency");
|
|
1212
|
+
if (!read.query.metrics.includes("revenue") || named.some((filter) => filter.operator === "eq")) return [];
|
|
1213
|
+
const codes = /* @__PURE__ */ new Set();
|
|
1214
|
+
const unconverted = [];
|
|
1215
|
+
const revenueIn = /* @__PURE__ */ new Map();
|
|
1216
|
+
for (const { side, parts } of sided) {
|
|
1217
|
+
const reporting = named.length === 0 ? await reportingOf(read, scopeOfSide(side)) : void 0;
|
|
1218
|
+
if (reporting === void 0) unconverted.push(side);
|
|
1219
|
+
else revenueIn.set(reporting, (revenueIn.get(reporting) ?? 0) + (parts.revenue ?? 0));
|
|
1220
|
+
}
|
|
1221
|
+
for (const [code, revenue] of revenueIn) if (revenue !== 0) codes.add(code);
|
|
1222
|
+
const found = await mapLimited(unconverted, CONCURRENCY, (side) => sideCurrencies(read, side, named));
|
|
1223
|
+
for (const code of found.flat()) codes.add(code);
|
|
1224
|
+
return [...codes].sort(compareCodePoints);
|
|
1225
|
+
};
|
|
1226
|
+
/** One part of an answer: its sides, its raw windows settled, and the days it is missing. */
|
|
1227
|
+
const sidesOf = async (read, plans, totalsRaw) => {
|
|
1228
|
+
const missing = { count: plans.reduce((sum, plan) => sum + plan.missing, 0) };
|
|
1229
|
+
const spans = plans.flatMap((plan) => plan.aggregates ? [plan.aggregates] : []);
|
|
1230
|
+
const windows = plans.flatMap((plan) => plan.raw);
|
|
1231
|
+
const keys = /* @__PURE__ */ new Map();
|
|
1232
|
+
for (const scope of new Set([...spans, ...windows].map((part) => part.scope))) keys.set(scope, await mergeKeyOf(read, scope));
|
|
1233
|
+
const keyOf = (scope) => keys.get(scope) ?? "";
|
|
1234
|
+
const settled = await mapLimited(mergeWindows(windows, keyOf), CONCURRENCY, (window) => settleRaw(read, window, totalsRaw));
|
|
1235
|
+
missing.count += settled.reduce((sum, outcome) => sum + outcome.missing, 0);
|
|
1236
|
+
return {
|
|
1237
|
+
sides: [...mergeSpans(spans, keyOf).map((span) => ({
|
|
1238
|
+
kind: "aggregates",
|
|
1239
|
+
span
|
|
1240
|
+
})), ...settled.flatMap(({ windows }) => windows.map((window) => ({
|
|
1241
|
+
kind: "raw",
|
|
1242
|
+
window
|
|
1243
|
+
})))],
|
|
1244
|
+
missing
|
|
1245
|
+
};
|
|
1246
|
+
};
|
|
1247
|
+
/**
|
|
1248
|
+
* The answer of a read's plans; with `totalsBy`, its totals come from those plans instead (its
|
|
1249
|
+
* filter's own rows) and its rows from its raw hits alone.
|
|
1250
|
+
*/
|
|
1251
|
+
const answer = async (read, plans, { labelZone, totalsBy }) => {
|
|
1252
|
+
const { query } = read;
|
|
1253
|
+
const ofRows = await sidesOf(read, plans, totalsBy === void 0);
|
|
1254
|
+
const totalsRead = totalsBy?.read ?? read;
|
|
1255
|
+
const ofTotals = totalsBy ? await sidesOf(totalsBy.read, totalsBy.plans, true) : ofRows;
|
|
1256
|
+
const sided = await mapLimited(ofTotals.sides, CONCURRENCY, async (side) => ({
|
|
1257
|
+
side,
|
|
1258
|
+
parts: await sideTotals(totalsRead, side)
|
|
1259
|
+
}));
|
|
1260
|
+
const totals = sumParts([zeroParts(totalsRead), ...sided.map(({ parts }) => parts)]);
|
|
1261
|
+
const rows = await rowsOf(read, ofRows.sides, {
|
|
1262
|
+
totals,
|
|
1263
|
+
labelZone,
|
|
1264
|
+
missing: ofRows.missing,
|
|
1265
|
+
split: totalsBy !== void 0
|
|
1266
|
+
});
|
|
1267
|
+
const mixed = await mixedCurrencies(totalsRead, sided);
|
|
1268
|
+
const every = [...plans, ...totalsBy?.plans ?? []];
|
|
1269
|
+
const clampedTo = every.reduce((at, plan) => later(at, plan.clampedTo), void 0);
|
|
1270
|
+
const endsAt = every.reduce((at, plan) => earlier(at, plan.endsAt), void 0);
|
|
1271
|
+
const asOf = every.reduce((at, plan) => earlier(at, plan.asOf), void 0);
|
|
1272
|
+
const dayCount = every.reduce((most, plan) => Math.max(most, plan.dayCount), 0);
|
|
1273
|
+
const capped = every.reduce((sum, plan) => sum + plan.capped, 0);
|
|
1274
|
+
const failedIn = (list) => list.reduce((sum, plan) => sum + plan.failed, 0);
|
|
1275
|
+
const failed = Math.max(failedIn(plans), failedIn(totalsBy?.plans ?? []));
|
|
1276
|
+
const missing = Math.max(ofRows.missing.count, ofTotals.missing.count);
|
|
1277
|
+
const visitorsAre = dayCount <= 1 ? "distinct" : "sumOfDaily";
|
|
1278
|
+
const withoutVisitor = totals.pageviewsWithoutVisitor ?? 0;
|
|
1279
|
+
const withoutConsent = totals.pageviewsWithoutConsent ?? 0;
|
|
1280
|
+
return {
|
|
1281
|
+
rows,
|
|
1282
|
+
totals: partsToMetrics(totals, query.metrics),
|
|
1283
|
+
meta: {
|
|
1284
|
+
provider: PROVIDER,
|
|
1285
|
+
fetchedAt: settings.now().toISOString(),
|
|
1286
|
+
...clampedTo || endsAt ? { clamped: true } : {},
|
|
1287
|
+
...clampedTo ? { dataFrom: clampedTo.toISOString() } : {},
|
|
1288
|
+
...endsAt ? { dataTo: endsAt.toISOString() } : {},
|
|
1289
|
+
...query.metrics.includes("visitors") ? { visitorsAre } : {},
|
|
1290
|
+
...missing > 0 ? { partial: { missingDays: missing } } : {},
|
|
1291
|
+
...capped > 0 ? { capped: { days: capped } } : {},
|
|
1292
|
+
...failed > 0 ? { failed: { days: failed } } : {},
|
|
1293
|
+
...asOf ? { asOf: asOf.toISOString() } : {},
|
|
1294
|
+
...every.some((plan) => plan.standIn) ? { timezoneUnresolved: true } : {},
|
|
1295
|
+
...mixed.length > 1 ? { mixedCurrencies: mixed } : {},
|
|
1296
|
+
...withoutVisitor > 0 ? { withoutVisitor: { pageviews: withoutVisitor } } : {},
|
|
1297
|
+
...withoutConsent > 0 ? { withoutConsent: { pageviews: withoutConsent } } : {}
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
};
|
|
1301
|
+
/**
|
|
1302
|
+
* The plans of a raw read's totals from its single filter's own rows, over the days its rows
|
|
1303
|
+
* cover (raw retention may start them late); none for a read whose rows aggregates answer.
|
|
1304
|
+
*/
|
|
1305
|
+
const planTotals = async (read, zoned, plans) => {
|
|
1306
|
+
if (read.shape.source !== "raw" || !read.shape.total || read.breakdown === void 0) return;
|
|
1307
|
+
const totalsRead = {
|
|
1308
|
+
...read,
|
|
1309
|
+
breakdown: void 0,
|
|
1310
|
+
series: void 0,
|
|
1311
|
+
shape: {
|
|
1312
|
+
source: "aggregates",
|
|
1313
|
+
total: read.shape.total
|
|
1314
|
+
},
|
|
1315
|
+
axis: read.totalAxis
|
|
1316
|
+
};
|
|
1317
|
+
return {
|
|
1318
|
+
read: totalsRead,
|
|
1319
|
+
plans: await mapLimited(zoned.map((each, index) => ({
|
|
1320
|
+
each,
|
|
1321
|
+
from: plans[index]?.clampedTo
|
|
1322
|
+
})), CONCURRENCY, ({ each, from }) => planScope(from === void 0 ? totalsRead : {
|
|
1323
|
+
...totalsRead,
|
|
1324
|
+
start: maxDate(read.start, from)
|
|
1325
|
+
}, each))
|
|
1326
|
+
};
|
|
1327
|
+
};
|
|
1328
|
+
/** Every scope with raw hits or day markers: a scope whose hits are all pruned keeps its days. */
|
|
1329
|
+
const everyScope = async () => {
|
|
1330
|
+
if (!settings.scoped) return [""];
|
|
1331
|
+
const [withHits, withDays] = await Promise.all([store.scopes(), state.scopes()]);
|
|
1332
|
+
return [...new Set([...withHits, ...withDays])].sort(compareCodePoints);
|
|
1333
|
+
};
|
|
1334
|
+
const scopesOf = async (query) => settings.scoped && query.scope !== void 0 ? [query.scope] : everyScope();
|
|
1335
|
+
const breakdownOf = (query) => query.dimensions?.find((dimension) => isRawDimension(dimension) && (breakdowns === void 0 || breakdowns.has(dimension)));
|
|
1336
|
+
const aggregateClosed = async (target, options = {}) => {
|
|
1337
|
+
if (!isClosed(localDay(target.day, target.tz), settings.now())) throw new Error(`analytics: ${target.day} in ${target.tz} has not closed yet, so it can only be snapshotted`);
|
|
1338
|
+
await state.ensureMarkers([target]);
|
|
1339
|
+
return runDay(target, closedStatus(target), options);
|
|
1340
|
+
};
|
|
1341
|
+
const rebuild = (rebuildInput, req) => rebuildRange({
|
|
1342
|
+
store,
|
|
1343
|
+
state,
|
|
1344
|
+
scopes: everyScope,
|
|
1345
|
+
scoped: settings.scoped,
|
|
1346
|
+
zoneOf: (scope, asking) => zones.strict(scope, asking),
|
|
1347
|
+
probe: probeRun,
|
|
1348
|
+
now: settings.now
|
|
1349
|
+
}, rebuildInput, req);
|
|
1350
|
+
/**
|
|
1351
|
+
* The day a hit at `at` is counted on: the completed day whose recorded window holds it (an older
|
|
1352
|
+
* zone's count keeps its own), else the day whose window in `tz` does (see `windowOf`).
|
|
1353
|
+
*/
|
|
1354
|
+
const countedDayOf = async (scope, at, tz) => {
|
|
1355
|
+
const guess = calendarDayOf(at, tz);
|
|
1356
|
+
const markers = await state.markers(scope, addCalendarDays(guess, -2), addCalendarDays(guess, 2));
|
|
1357
|
+
const prunedBefore = await state.prunedBefore(scope);
|
|
1358
|
+
const counted = markers.find((marker) => marker.aggregatedAt !== null && markerStart(marker) <= at && at < markerEnd(marker));
|
|
1359
|
+
if (counted) return {
|
|
1360
|
+
day: counted.day,
|
|
1361
|
+
window: {
|
|
1362
|
+
day: counted.day,
|
|
1363
|
+
start: markerStart(counted),
|
|
1364
|
+
end: markerEnd(counted)
|
|
1365
|
+
},
|
|
1366
|
+
marker: counted,
|
|
1367
|
+
prunedBefore
|
|
1368
|
+
};
|
|
1369
|
+
const byDay = new Map(markers.map((marker) => [marker.day, marker]));
|
|
1370
|
+
const scopeDays = {
|
|
1371
|
+
tz,
|
|
1372
|
+
markers: byDay,
|
|
1373
|
+
prunedBefore
|
|
1374
|
+
};
|
|
1375
|
+
const own = windowOf(guess, scopeDays);
|
|
1376
|
+
const day = at < own.start ? addCalendarDays(guess, -1) : guess;
|
|
1377
|
+
return {
|
|
1378
|
+
day,
|
|
1379
|
+
window: day === guess ? own : windowOf(day, scopeDays),
|
|
1380
|
+
marker: byDay.get(day),
|
|
1381
|
+
prunedBefore
|
|
1382
|
+
};
|
|
1383
|
+
};
|
|
1384
|
+
const orderStored = async (scope, id) => {
|
|
1385
|
+
const twin = orderTwinOf(id);
|
|
1386
|
+
const found = twin === void 0 ? null : await store.hitById(twin);
|
|
1387
|
+
const tz = found === null ? null : await zones.strict(scope);
|
|
1388
|
+
if (found === null || tz === null) return;
|
|
1389
|
+
const placed = await countedDayOf(scope, found.ts, tz);
|
|
1390
|
+
if (!isFixed(placed.marker, placed.prunedBefore) && (placed.prunedBefore === null || placed.window.start >= placed.prunedBefore) && isClosed(placed.window, settings.now())) await state.markDirty(scope, [placed.day]);
|
|
1391
|
+
};
|
|
1392
|
+
const maintenance = createMaintenance({
|
|
1393
|
+
store,
|
|
1394
|
+
state,
|
|
1395
|
+
scopes: everyScope,
|
|
1396
|
+
orderStored,
|
|
1397
|
+
zoneOf: (scope, req) => zones.strict(scope, req),
|
|
1398
|
+
aggregate: (target) => aggregateClosed(target, { attempt: true }),
|
|
1399
|
+
snapshot: snapshotDay,
|
|
1400
|
+
fits: countFits,
|
|
1401
|
+
markEmpty: emptyDays,
|
|
1402
|
+
probe: probeRun,
|
|
1403
|
+
rebuild,
|
|
1404
|
+
rawDays: settings.rawDays,
|
|
1405
|
+
aggregateDays: settings.aggregateDays,
|
|
1406
|
+
today: {
|
|
1407
|
+
busy: isBusy,
|
|
1408
|
+
maxAgeMs: maxAgeOf
|
|
1409
|
+
},
|
|
1410
|
+
now: settings.now,
|
|
1411
|
+
clock: settings.clock,
|
|
1412
|
+
open: () => !closed,
|
|
1413
|
+
owner: newOwner,
|
|
1414
|
+
warn
|
|
1415
|
+
});
|
|
1416
|
+
let warnedDeferred = false;
|
|
1417
|
+
const nudger = createNudger({
|
|
1418
|
+
now: () => settings.now().getTime(),
|
|
1419
|
+
everyMs: NUDGE_EVERY_MS,
|
|
1420
|
+
start: () => background("maintenance started by ingest", async () => {
|
|
1421
|
+
const beat = settings.runner ? await state.lastBeat(MAINTAIN_TASK_SLUG) : null;
|
|
1422
|
+
if (settings.runner && !heartbeatStale(beat, settings.maintainIntervalMs, settings.now())) {
|
|
1423
|
+
await state.sweep(settings.now());
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
const stallMs = await store.blockingBudgetMs?.() ?? null;
|
|
1427
|
+
const report = await maintenance.run({
|
|
1428
|
+
budgetMs: NUDGE_BUDGET_MS,
|
|
1429
|
+
...stallMs === null ? {} : { stallMs }
|
|
1430
|
+
});
|
|
1431
|
+
if (report.deferred > 0 && !warnedDeferred) {
|
|
1432
|
+
warnedDeferred = true;
|
|
1433
|
+
warn(`analytics: maintenance started by ingest left ${report.deferred} count(s) to the analytics-maintain job: each would hold up this process's requests longer than ${stallMs} ms. Run that job in a second process only once the SQLite adapter has wal: true and a busyTimeout of at least 5000, which also moves these counts to worker threads.`);
|
|
1434
|
+
}
|
|
1435
|
+
})
|
|
1436
|
+
});
|
|
1437
|
+
/** A realtime read of every scope named: one scope's alone, several by name, none read at all. */
|
|
1438
|
+
const liveOf = (scopes, read) => {
|
|
1439
|
+
const [only] = scopes;
|
|
1440
|
+
if (only === void 0) return Promise.resolve({
|
|
1441
|
+
visitors: 0,
|
|
1442
|
+
pageviews: 0,
|
|
1443
|
+
minutes: [],
|
|
1444
|
+
pages: [],
|
|
1445
|
+
sources: []
|
|
1446
|
+
});
|
|
1447
|
+
return store.realtime(scopes.length === 1 ? {
|
|
1448
|
+
...read,
|
|
1449
|
+
scope: only
|
|
1450
|
+
} : {
|
|
1451
|
+
...read,
|
|
1452
|
+
scopes
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
const idle = async () => {
|
|
1456
|
+
while (running.size > 0) await Promise.allSettled([...running]);
|
|
1457
|
+
};
|
|
1458
|
+
return {
|
|
1459
|
+
async read(query, ctx = {}) {
|
|
1460
|
+
const filters = readFilters(query);
|
|
1461
|
+
const refused = unsupportedFilter({ filters: filterMap }, filters);
|
|
1462
|
+
if (refused) throw new UnsupportedFilterError(PROVIDER, refused);
|
|
1463
|
+
for (const filter of filters) if (filter.operator === "matches") checkMatchesPattern(filter.value);
|
|
1464
|
+
const breakdown = breakdownOf(query);
|
|
1465
|
+
const counted = [...filters.map((filter) => filter.dimension), breakdown];
|
|
1466
|
+
if (counted.includes("goal") && counted.includes("item")) throw new InvalidQueryError("analytics: a native read counts goal completions or content items, never both: drop the goal or the item from its filters and breakdown", "dimensions");
|
|
1467
|
+
const series = seriesOf(query, breakdown);
|
|
1468
|
+
const axis = axisOf(filters, breakdown);
|
|
1469
|
+
const stall = await store.blockingBudgetMs?.() ?? null;
|
|
1470
|
+
const read = {
|
|
1471
|
+
query,
|
|
1472
|
+
now: settings.now(),
|
|
1473
|
+
start: query.dateRange.start,
|
|
1474
|
+
end: new Date(query.dateRange.end.getTime() + 1),
|
|
1475
|
+
filters,
|
|
1476
|
+
breakdown,
|
|
1477
|
+
series,
|
|
1478
|
+
shape: readShape({
|
|
1479
|
+
filters,
|
|
1480
|
+
breakdown,
|
|
1481
|
+
hours: series === "hour"
|
|
1482
|
+
}),
|
|
1483
|
+
axis,
|
|
1484
|
+
totalAxis: axisOf(filters, void 0),
|
|
1485
|
+
order: orderOf(query, axis),
|
|
1486
|
+
visits: countsVisits(query),
|
|
1487
|
+
...ctx.signal ? { signal: ctx.signal } : {},
|
|
1488
|
+
lazyUntil: settings.clock() + settings.lazyBudgetMs,
|
|
1489
|
+
stall,
|
|
1490
|
+
planned: { ms: 0 },
|
|
1491
|
+
runner: {},
|
|
1492
|
+
uncounted: { count: 0 },
|
|
1493
|
+
emptyLeft: { count: settings.emptyMarkers },
|
|
1494
|
+
refresh: [],
|
|
1495
|
+
currencies: /* @__PURE__ */ new Map()
|
|
1496
|
+
};
|
|
1497
|
+
const readZones = zones.forRead(query.timezone);
|
|
1498
|
+
const scopes = await scopesOf(query);
|
|
1499
|
+
const zoned = await Promise.all(scopes.map(async (scope) => ({
|
|
1500
|
+
scope,
|
|
1501
|
+
...await readZones.of(scope)
|
|
1502
|
+
})));
|
|
1503
|
+
try {
|
|
1504
|
+
if (zoned.length > 1) read.known = await knownStateOf(read, zoned);
|
|
1505
|
+
const plans = await mapLimited(zoned, CONCURRENCY, (each) => planScope(read, each));
|
|
1506
|
+
const totalsBy = await planTotals(read, zoned, plans);
|
|
1507
|
+
const [single] = zoned;
|
|
1508
|
+
return await answer(read, plans, {
|
|
1509
|
+
labelZone: query.timezone === void 0 && zoned.length === 1 && single ? single.tz : readZones.named,
|
|
1510
|
+
...totalsBy ? { totalsBy } : {}
|
|
1511
|
+
});
|
|
1512
|
+
} finally {
|
|
1513
|
+
if (read.uncounted.count > 0 && !closed) nudger.nudge();
|
|
1514
|
+
for (const target of read.refresh) refresh(target, read.stall);
|
|
1515
|
+
}
|
|
1516
|
+
},
|
|
1517
|
+
async realtime(query, ctx = {}) {
|
|
1518
|
+
const scope = settings.scoped ? query.scope : "";
|
|
1519
|
+
const readZones = zones.forRead(query.timezone);
|
|
1520
|
+
const tz = scope === void 0 ? readZones.named : (await readZones.of(scope)).tz;
|
|
1521
|
+
const scopes = scope === void 0 ? await everyScope() : [scope];
|
|
1522
|
+
const start = query.dateRange.start;
|
|
1523
|
+
const ranked = query.dimensions?.find((dimension) => dimension === "page" || dimension === "source");
|
|
1524
|
+
const byMinute = ranked === void 0 && query.granularity === "minute";
|
|
1525
|
+
const part = ranked === "page" ? "pages" : ranked === "source" ? "sources" : byMinute ? "minutes" : null;
|
|
1526
|
+
const live = await liveOf(scopes, {
|
|
1527
|
+
start,
|
|
1528
|
+
end: new Date(query.dateRange.end.getTime() + 1),
|
|
1529
|
+
from: calendarDayStart(calendarDayOf(start, tz), tz),
|
|
1530
|
+
...query.hostname === void 0 ? {} : { hostname: query.hostname },
|
|
1531
|
+
...query.path === void 0 ? {} : { path: query.path },
|
|
1532
|
+
top: limitOf(query) ?? 10,
|
|
1533
|
+
parts: part === null ? [] : [part],
|
|
1534
|
+
timeoutMs: settings.timeoutMs,
|
|
1535
|
+
...ctx.signal ? { signal: ctx.signal } : {}
|
|
1536
|
+
});
|
|
1537
|
+
const counts = (count) => {
|
|
1538
|
+
const metrics = {};
|
|
1539
|
+
for (const metric of query.metrics) if (metric === "pageviews" || metric === "visitors") metrics[metric] = count[metric];
|
|
1540
|
+
return metrics;
|
|
1541
|
+
};
|
|
1542
|
+
const rows = [];
|
|
1543
|
+
if (ranked) for (const top of ranked === "page" ? live.pages : live.sources) {
|
|
1544
|
+
const dimensions = {};
|
|
1545
|
+
dimensions[ranked] = top.value;
|
|
1546
|
+
rows.push({
|
|
1547
|
+
dimensions,
|
|
1548
|
+
metrics: counts(top)
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
else if (byMinute) {
|
|
1552
|
+
const minutes = new Map(live.minutes.map((minute) => [minute.minute.getTime(), minute]));
|
|
1553
|
+
const first = start.getTime() - start.getTime() % 6e4;
|
|
1554
|
+
const last = query.dateRange.end.getTime() - query.dateRange.end.getTime() % 6e4;
|
|
1555
|
+
for (let minute = first; minute <= last; minute += 6e4) rows.push({
|
|
1556
|
+
timestamp: new Date(minute).toISOString(),
|
|
1557
|
+
metrics: counts(minutes.get(minute) ?? {
|
|
1558
|
+
visitors: 0,
|
|
1559
|
+
pageviews: 0
|
|
1560
|
+
})
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
return {
|
|
1564
|
+
rows,
|
|
1565
|
+
totals: counts(live),
|
|
1566
|
+
meta: {
|
|
1567
|
+
provider: PROVIDER,
|
|
1568
|
+
fetchedAt: settings.now().toISOString()
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
},
|
|
1572
|
+
aggregate: (target) => aggregateClosed(target),
|
|
1573
|
+
snapshot: snapshotDay,
|
|
1574
|
+
maintain: (maintainInput) => track(maintenance.run(maintainInput)),
|
|
1575
|
+
rebuild: (rebuildInput) => track(rebuild(rebuildInput)),
|
|
1576
|
+
async serverHitDay(scope, at) {
|
|
1577
|
+
const tz = await zones.strict(scope);
|
|
1578
|
+
if (tz === null) return null;
|
|
1579
|
+
const now = settings.now();
|
|
1580
|
+
const placed = await countedDayOf(scope, at, tz);
|
|
1581
|
+
if (settings.rawDays !== null) {
|
|
1582
|
+
const floor = rawFloorDay(todayIn(now, tz), settings.rawDays);
|
|
1583
|
+
if (placed.day <= floor) throw new AnalyticsTrackError(`analytics: a server event at ${at.toISOString()} falls on ${placed.day} in ${tz}, at or before ${floor}, the oldest day whose raw hits are surely kept (retention.rawDays), so it would never be counted`);
|
|
1584
|
+
}
|
|
1585
|
+
return {
|
|
1586
|
+
scope,
|
|
1587
|
+
day: placed.day,
|
|
1588
|
+
tz,
|
|
1589
|
+
closed: isClosed(placed.window, now)
|
|
1590
|
+
};
|
|
1591
|
+
},
|
|
1592
|
+
async reopen(target) {
|
|
1593
|
+
await state.markDirty(target.scope, [target.day]);
|
|
1594
|
+
},
|
|
1595
|
+
orderStored: (scope, id) => track(orderStored(scope, id)),
|
|
1596
|
+
async saleAttribution(scope, sale) {
|
|
1597
|
+
const [wire, server] = await Promise.all([store.hitById(sale.wire), store.hitById(sale.server)]);
|
|
1598
|
+
const counted = wire !== null && (server === null || twinsWithin(wire.ts, server.ts, settings.twinWindowMs)) ? wire : server;
|
|
1599
|
+
if (counted === null) return {};
|
|
1600
|
+
const tz = counted.v === "" ? null : await zones.strict(scope);
|
|
1601
|
+
const acquired = (tz === null ? null : await store.latestLanding({
|
|
1602
|
+
scope,
|
|
1603
|
+
hostname: counted.hostname,
|
|
1604
|
+
v: counted.v,
|
|
1605
|
+
start: calendarDayStart(calendarDayOf(counted.ts, tz), tz),
|
|
1606
|
+
end: counted.ts
|
|
1607
|
+
})) ?? counted;
|
|
1608
|
+
return {
|
|
1609
|
+
...attributesOf(acquired, ACQUISITION_ATTRIBUTES),
|
|
1610
|
+
...acquired.channelVersion === void 0 ? {} : { channelVersion: acquired.channelVersion },
|
|
1611
|
+
...attributesOf(counted, VISITOR_ATTRIBUTES)
|
|
1612
|
+
};
|
|
1613
|
+
},
|
|
1614
|
+
nudge() {
|
|
1615
|
+
if (!closed) nudger.nudge();
|
|
1616
|
+
},
|
|
1617
|
+
idle,
|
|
1618
|
+
async close() {
|
|
1619
|
+
closed = true;
|
|
1620
|
+
await idle();
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
};
|
|
1624
|
+
//#endregion
|
|
1625
|
+
export { SERVER_CLOCK_SKEW_MS, createEngine };
|
|
1626
|
+
|
|
1627
|
+
//# sourceMappingURL=engine.js.map
|