@10x-media/analytics 1.0.0-beta.6 → 1.0.0-beta.8
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 +73 -0
- package/README.md +13 -3
- package/dist/adapters/ga4/ga4.js +3 -2
- package/dist/adapters/ga4/ga4.js.map +1 -1
- package/dist/adapters/http/fetchJson.js +1 -1
- package/dist/adapters/plausible/plausible.d.ts +10 -0
- package/dist/adapters/plausible/plausible.js +42 -1
- package/dist/adapters/plausible/plausible.js.map +1 -1
- package/dist/adapters/posthog/posthog.d.ts +10 -1
- package/dist/adapters/posthog/posthog.js +47 -0
- package/dist/adapters/posthog/posthog.js.map +1 -1
- package/dist/adapters/umami/umami.d.ts +5 -1
- package/dist/adapters/umami/umami.js +26 -0
- package/dist/adapters/umami/umami.js.map +1 -1
- package/dist/capture/getTrackerConfig.d.ts +20 -0
- package/dist/capture/getTrackerConfig.js +31 -0
- package/dist/capture/getTrackerConfig.js.map +1 -0
- package/dist/capture/mountPath.js +14 -0
- package/dist/capture/mountPath.js.map +1 -0
- package/dist/capture/proxyEndpoint.js +123 -0
- package/dist/capture/proxyEndpoint.js.map +1 -0
- package/dist/capture/proxyRoutes.js +108 -0
- package/dist/capture/proxyRoutes.js.map +1 -0
- package/dist/capture/requestBody.js +68 -0
- package/dist/capture/requestBody.js.map +1 -0
- package/dist/capture/slots.d.ts +8 -0
- package/dist/capture/slots.js +54 -0
- package/dist/capture/slots.js.map +1 -0
- package/dist/capture/trackerConfig.d.ts +33 -0
- package/dist/capture/trackerConfig.js +95 -0
- package/dist/capture/trackerConfig.js.map +1 -0
- package/dist/capture/trackerEndpoint.js +35 -0
- package/dist/capture/trackerEndpoint.js.map +1 -0
- package/dist/charts/BarList.d.ts +15 -1
- package/dist/charts/BarList.js +34 -18
- package/dist/charts/BarList.js.map +1 -1
- package/dist/charts/TrendChart.d.ts +16 -3
- package/dist/charts/TrendChart.js +172 -106
- package/dist/charts/TrendChart.js.map +1 -1
- package/dist/charts/bars.d.ts +2 -0
- package/dist/charts/bars.js +2 -1
- package/dist/charts/bars.js.map +1 -1
- package/dist/charts/bucket.js +10 -1
- package/dist/charts/bucket.js.map +1 -1
- package/dist/charts/spline.js +2 -2
- package/dist/charts/spline.js.map +1 -1
- package/dist/charts/styles.js +18 -1
- package/dist/charts/styles.js.map +1 -1
- package/dist/core/cacheKey.js +13 -1
- package/dist/core/cacheKey.js.map +1 -1
- package/dist/core/capture.d.ts +49 -0
- package/dist/core/contract.d.ts +35 -4
- package/dist/core/contract.js +29 -1
- package/dist/core/contract.js.map +1 -1
- package/dist/core/granularity.js +1 -1
- package/dist/core/options.d.ts +148 -4
- package/dist/core/options.js +121 -3
- package/dist/core/options.js.map +1 -1
- package/dist/core/registry.d.ts +1 -0
- package/dist/core/scopeList.js +32 -0
- package/dist/core/scopeList.js.map +1 -0
- package/dist/core/scopedRead.js +45 -28
- package/dist/core/scopedRead.js.map +1 -1
- package/dist/core/serverEvent.d.ts +42 -0
- package/dist/core/serverEvent.js +12 -0
- package/dist/core/serverEvent.js.map +1 -0
- package/dist/exports/client.d.ts +8 -2
- package/dist/exports/client.js +6 -1
- package/dist/exports/next.d.ts +2 -1
- package/dist/exports/next.js +2 -1
- package/dist/exports/react.d.ts +4 -0
- package/dist/exports/react.js +5 -0
- package/dist/exports/rsc.d.ts +8 -1
- package/dist/exports/rsc.js +7 -2
- package/dist/exports/tracker.d.ts +18 -0
- package/dist/exports/tracker.js +12 -0
- package/dist/exports/types.d.ts +14 -3
- package/dist/exports/types.js +2 -2
- package/dist/fields/AnalyticsPanelClient.js +2 -2
- package/dist/fields/AnalyticsPanelField.js +1 -1
- package/dist/fields/AnalyticsStatField.js +2 -2
- package/dist/fields/config/MetricSelectField.js +2 -2
- package/dist/fields/config/MetricSelectField.js.map +1 -1
- package/dist/fields/config/SourceSelectField.js +2 -2
- package/dist/fields/config/SourceSelectField.js.map +1 -1
- package/dist/fields/config/fetchSources.d.ts +5 -1
- package/dist/fields/config/narrow.js +2 -0
- package/dist/fields/config/narrow.js.map +1 -1
- package/dist/fields/readForDocument.d.ts +5 -0
- package/dist/fields/readForDocument.js +6 -6
- package/dist/fields/readForDocument.js.map +1 -1
- package/dist/goals/GoalSelectField.d.ts +7 -0
- package/dist/goals/GoalSelectField.js +77 -0
- package/dist/goals/GoalSelectField.js.map +1 -0
- package/dist/goals/collection.js +250 -0
- package/dist/goals/collection.js.map +1 -0
- package/dist/goals/currency.js +14 -0
- package/dist/goals/currency.js.map +1 -0
- package/dist/goals/fetchGoals.d.ts +18 -0
- package/dist/goals/fetchGoals.js +29 -0
- package/dist/goals/fetchGoals.js.map +1 -0
- package/dist/goals/goalField.d.ts +31 -0
- package/dist/goals/goalField.js +56 -0
- package/dist/goals/goalField.js.map +1 -0
- package/dist/goals/goalsEndpoint.d.ts +1 -0
- package/dist/goals/goalsEndpoint.js +55 -0
- package/dist/goals/goalsEndpoint.js.map +1 -0
- package/dist/goals/match.js +64 -0
- package/dist/goals/match.js.map +1 -0
- package/dist/goals/resolver.d.ts +8 -0
- package/dist/goals/resolver.js +147 -0
- package/dist/goals/resolver.js.map +1 -0
- package/dist/goals/trackGoalAction.d.ts +74 -0
- package/dist/goals/trackGoalAction.js +139 -0
- package/dist/goals/trackGoalAction.js.map +1 -0
- package/dist/goals/types.d.ts +33 -0
- package/dist/goals/types.js +7 -0
- package/dist/goals/types.js.map +1 -0
- package/dist/goals/useAnalyticsGoals.d.ts +20 -0
- package/dist/goals/useAnalyticsGoals.js +67 -0
- package/dist/goals/useAnalyticsGoals.js.map +1 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +104 -17
- package/dist/index.js.map +1 -1
- package/dist/native/collections/events.js +21 -1
- package/dist/native/collections/events.js.map +1 -1
- package/dist/native/collections/rollups.js +24 -0
- package/dist/native/collections/rollups.js.map +1 -1
- package/dist/native/geo/maxmindResolver.js +2 -4
- package/dist/native/geo/maxmindResolver.js.map +1 -1
- package/dist/native/ingest/clientIp.js +15 -0
- package/dist/native/ingest/clientIp.js.map +1 -0
- package/dist/native/ingest/device.js +11 -3
- package/dist/native/ingest/device.js.map +1 -1
- package/dist/native/ingest/endpoint.d.ts +1 -0
- package/dist/native/ingest/endpoint.js +25 -4
- package/dist/native/ingest/endpoint.js.map +1 -1
- package/dist/native/ingest/flushBatch.js +4 -13
- package/dist/native/ingest/flushBatch.js.map +1 -1
- package/dist/native/ingest/normalizeEvent.d.ts +20 -0
- package/dist/native/ingest/normalizeEvent.js +78 -10
- package/dist/native/ingest/normalizeEvent.js.map +1 -1
- package/dist/native/ingest/serverTrack.d.ts +20 -0
- package/dist/native/ingest/serverTrack.js +99 -0
- package/dist/native/ingest/serverTrack.js.map +1 -0
- package/dist/native/ingest/validate.js +27 -0
- package/dist/native/ingest/validate.js.map +1 -0
- package/dist/native/nativeAdapter.d.ts +1 -1
- package/dist/native/nativeAdapter.js +38 -11
- package/dist/native/nativeAdapter.js.map +1 -1
- package/dist/native/query/eventAgg.js +39 -13
- package/dist/native/query/eventAgg.js.map +1 -1
- package/dist/native/retention/pruneTask.js +1 -1
- package/dist/native/rollupAcc.js +12 -1
- package/dist/native/rollupAcc.js.map +1 -1
- package/dist/native/rollups/bumpRollup.js +5 -1
- package/dist/native/rollups/bumpRollup.js.map +1 -1
- package/dist/native/rollups/deltas.js +28 -6
- package/dist/native/rollups/deltas.js.map +1 -1
- package/dist/native/rollups/insertIfNew.js +36 -2
- package/dist/native/rollups/insertIfNew.js.map +1 -1
- package/dist/next/captureRewrites.d.ts +41 -0
- package/dist/next/captureRewrites.js +56 -0
- package/dist/next/captureRewrites.js.map +1 -0
- package/dist/next/posthogProxyRewrites.d.ts +5 -0
- package/dist/next/posthogProxyRewrites.js +16 -21
- package/dist/next/posthogProxyRewrites.js.map +1 -1
- package/dist/plugin/documentEndpoint.js +28 -10
- package/dist/plugin/documentEndpoint.js.map +1 -1
- package/dist/plugin/paths.js +15 -1
- package/dist/plugin/paths.js.map +1 -1
- package/dist/plugin/queryEndpoint.js +113 -0
- package/dist/plugin/queryEndpoint.js.map +1 -0
- package/dist/plugin/readContextForRequest.js +71 -0
- package/dist/plugin/readContextForRequest.js.map +1 -0
- package/dist/plugin/realtimeEndpoint.js +6 -3
- package/dist/plugin/realtimeEndpoint.js.map +1 -1
- package/dist/plugin/runtime.d.ts +1 -0
- package/dist/plugin/runtime.js +31 -1
- package/dist/plugin/runtime.js.map +1 -1
- package/dist/plugin/scopeFieldBoot.js +22 -0
- package/dist/plugin/scopeFieldBoot.js.map +1 -0
- package/dist/plugin/sourcesEndpoint.js +13 -39
- package/dist/plugin/sourcesEndpoint.js.map +1 -1
- package/dist/plugin/warmTask.js +0 -0
- package/dist/plugin/warmTask.js.map +1 -1
- package/dist/providers/collection.js +71 -25
- package/dist/providers/collection.js.map +1 -1
- package/dist/providers/factory.js +8 -2
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/resolver.js.map +1 -1
- package/dist/query/dates.js +64 -0
- package/dist/query/dates.js.map +1 -0
- package/dist/query/errors.d.ts +17 -0
- package/dist/query/errors.js +10 -0
- package/dist/query/errors.js.map +1 -0
- package/dist/query/fetchQuery.d.ts +59 -0
- package/dist/query/fetchQuery.js +110 -0
- package/dist/query/fetchQuery.js.map +1 -0
- package/dist/query/parse.d.ts +22 -0
- package/dist/query/parse.js +168 -0
- package/dist/query/parse.js.map +1 -0
- package/dist/query/response.d.ts +36 -0
- package/dist/react/AnalyticsProvider.d.ts +43 -0
- package/dist/react/AnalyticsProvider.js +66 -0
- package/dist/react/AnalyticsProvider.js.map +1 -0
- package/dist/react/TrackerBoot.d.ts +22 -0
- package/dist/react/TrackerBoot.js +30 -0
- package/dist/react/TrackerBoot.js.map +1 -0
- package/dist/react/useAnalytics.d.ts +17 -0
- package/dist/react/useAnalytics.js +36 -0
- package/dist/react/useAnalytics.js.map +1 -0
- package/dist/rsc/AnalyticsScripts.d.ts +30 -0
- package/dist/rsc/AnalyticsScripts.js +41 -0
- package/dist/rsc/AnalyticsScripts.js.map +1 -0
- package/dist/surfacing/cacheStore.d.ts +1 -0
- package/dist/surfacing/cacheStore.js +18 -2
- package/dist/surfacing/cacheStore.js.map +1 -1
- package/dist/surfacing/engine.d.ts +1 -0
- package/dist/surfacing/engine.js +44 -4
- package/dist/surfacing/engine.js.map +1 -1
- package/dist/surfacing/queue.js +22 -6
- package/dist/surfacing/queue.js.map +1 -1
- package/dist/surfacing/rateLimiter.js +130 -0
- package/dist/surfacing/rateLimiter.js.map +1 -0
- package/dist/surfacing/retryPolicy.js +15 -0
- package/dist/surfacing/retryPolicy.js.map +1 -0
- package/dist/sync/syncTask.js +60 -33
- package/dist/sync/syncTask.js.map +1 -1
- package/dist/testing/memoryAdapter.d.ts +2 -0
- package/dist/testing/memoryAdapter.js +10 -0
- package/dist/testing/memoryAdapter.js.map +1 -1
- package/dist/timeframe/tz.js +17 -6
- package/dist/timeframe/tz.js.map +1 -1
- package/dist/tracker/autoCapture.d.ts +48 -0
- package/dist/tracker/autoCapture.js +129 -0
- package/dist/tracker/autoCapture.js.map +1 -0
- package/dist/tracker/consent.d.ts +24 -0
- package/dist/tracker/consent.js +48 -0
- package/dist/tracker/consent.js.map +1 -0
- package/dist/tracker/createTracker.d.ts +18 -0
- package/dist/tracker/createTracker.js +163 -0
- package/dist/tracker/createTracker.js.map +1 -0
- package/dist/tracker/initTracker.d.ts +22 -0
- package/dist/tracker/initTracker.js +33 -0
- package/dist/tracker/initTracker.js.map +1 -0
- package/dist/tracker/loadScript.d.ts +14 -0
- package/dist/tracker/loadScript.js +41 -0
- package/dist/tracker/loadScript.js.map +1 -0
- package/dist/tracker/pageTracking.d.ts +17 -0
- package/dist/tracker/pageTracking.js +38 -0
- package/dist/tracker/pageTracking.js.map +1 -0
- package/dist/tracker/registry.d.ts +27 -0
- package/dist/tracker/registry.js +73 -0
- package/dist/tracker/registry.js.map +1 -0
- package/dist/tracker/sinks/native.d.ts +22 -0
- package/dist/tracker/sinks/native.js +56 -0
- package/dist/tracker/sinks/native.js.map +1 -0
- package/dist/tracker/sinks/plausible.d.ts +14 -0
- package/dist/tracker/sinks/plausible.js +25 -0
- package/dist/tracker/sinks/plausible.js.map +1 -0
- package/dist/tracker/sinks/posthog.d.ts +14 -0
- package/dist/tracker/sinks/posthog.js +18 -0
- package/dist/tracker/sinks/posthog.js.map +1 -0
- package/dist/tracker/sinks/umami.d.ts +13 -0
- package/dist/tracker/sinks/umami.js +17 -0
- package/dist/tracker/sinks/umami.js.map +1 -0
- package/dist/tracker/sinks/vendor.d.ts +14 -0
- package/dist/tracker/sinks/vendor.js +66 -0
- package/dist/tracker/sinks/vendor.js.map +1 -0
- package/dist/tracker/transport.js +28 -0
- package/dist/tracker/transport.js.map +1 -0
- package/dist/tracker/types.d.ts +66 -0
- package/dist/translations/ar.js +104 -1
- package/dist/translations/ar.js.map +1 -1
- package/dist/translations/de.js +104 -1
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +104 -1
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +104 -1
- package/dist/translations/es.js.map +1 -1
- package/dist/translations/fr.js +104 -1
- package/dist/translations/fr.js.map +1 -1
- package/dist/translations/id.js +104 -1
- package/dist/translations/id.js.map +1 -1
- package/dist/translations/keys.d.ts +103 -0
- package/dist/translations/keys.js +104 -1
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +104 -1
- package/dist/translations/ko.js.map +1 -1
- package/dist/translations/metricKeys.js +1 -1
- package/dist/translations/metricKeys.js.map +1 -1
- package/dist/translations/pt.js +104 -1
- package/dist/translations/pt.js.map +1 -1
- package/dist/translations/ru.js +104 -1
- package/dist/translations/ru.js.map +1 -1
- package/dist/translations/uk.js +104 -1
- package/dist/translations/uk.js.map +1 -1
- package/dist/translations/zh.js +104 -1
- package/dist/translations/zh.js.map +1 -1
- package/dist/view/AnalyticsNavLink.d.ts +19 -0
- package/dist/view/AnalyticsNavLink.js +40 -0
- package/dist/view/AnalyticsNavLink.js.map +1 -0
- package/dist/view/AnalyticsView.d.ts +23 -0
- package/dist/view/AnalyticsView.js +45 -0
- package/dist/view/AnalyticsView.js.map +1 -0
- package/dist/view/AnalyticsViewClient.d.ts +15 -0
- package/dist/view/AnalyticsViewClient.js +189 -0
- package/dist/view/AnalyticsViewClient.js.map +1 -0
- package/dist/view/authRedirect.js +32 -0
- package/dist/view/authRedirect.js.map +1 -0
- package/dist/view/conversionRate.js +18 -0
- package/dist/view/conversionRate.js.map +1 -0
- package/dist/view/dayRange.js +68 -0
- package/dist/view/dayRange.js.map +1 -0
- package/dist/view/gating.d.ts +1 -0
- package/dist/view/gating.js +105 -0
- package/dist/view/gating.js.map +1 -0
- package/dist/view/labels.js +44 -0
- package/dist/view/labels.js.map +1 -0
- package/dist/view/registerView.js +48 -0
- package/dist/view/registerView.js.map +1 -0
- package/dist/view/sections/Breakdowns.js +157 -0
- package/dist/view/sections/Breakdowns.js.map +1 -0
- package/dist/view/sections/EmptyStates.js +92 -0
- package/dist/view/sections/EmptyStates.js.map +1 -0
- package/dist/view/sections/FilterChips.js +41 -0
- package/dist/view/sections/FilterChips.js.map +1 -0
- package/dist/view/sections/GoalsPanel.js +81 -0
- package/dist/view/sections/GoalsPanel.js.map +1 -0
- package/dist/view/sections/OverviewCards.js +65 -0
- package/dist/view/sections/OverviewCards.js.map +1 -0
- package/dist/view/sections/RealtimeStrip.js +77 -0
- package/dist/view/sections/RealtimeStrip.js.map +1 -0
- package/dist/view/sections/Toolbar.js +179 -0
- package/dist/view/sections/Toolbar.js.map +1 -0
- package/dist/view/sections/Trend.js +119 -0
- package/dist/view/sections/Trend.js.map +1 -0
- package/dist/view/sections/styles.js +74 -0
- package/dist/view/sections/styles.js.map +1 -0
- package/dist/view/state.js +206 -0
- package/dist/view/state.js.map +1 -0
- package/dist/view/useViewQueries.js +150 -0
- package/dist/view/useViewQueries.js.map +1 -0
- package/dist/view/viewProps.d.ts +40 -0
- package/dist/view/viewProps.js +90 -0
- package/dist/view/viewProps.js.map +1 -0
- package/dist/widgets/AnalyticsBreakdownWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsBreakdownWidget.js +22 -4
- package/dist/widgets/AnalyticsBreakdownWidget.js.map +1 -1
- package/dist/widgets/AnalyticsGoalsWidget.d.ts +14 -0
- package/dist/widgets/AnalyticsGoalsWidget.js +188 -0
- package/dist/widgets/AnalyticsGoalsWidget.js.map +1 -0
- package/dist/widgets/AnalyticsMetricWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsMetricWidget.js +35 -12
- package/dist/widgets/AnalyticsMetricWidget.js.map +1 -1
- package/dist/widgets/AnalyticsRealtimeWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsRealtimeWidget.js +42 -22
- package/dist/widgets/AnalyticsRealtimeWidget.js.map +1 -1
- package/dist/widgets/AnalyticsTrendWidget.d.ts +2 -1
- package/dist/widgets/AnalyticsTrendWidget.js +51 -15
- package/dist/widgets/AnalyticsTrendWidget.js.map +1 -1
- package/dist/widgets/WidgetViewLink.js +17 -0
- package/dist/widgets/WidgetViewLink.js.map +1 -0
- package/dist/widgets/breakdownTypes.js +32 -0
- package/dist/widgets/breakdownTypes.js.map +1 -1
- package/dist/widgets/cardChrome.js +31 -7
- package/dist/widgets/cardChrome.js.map +1 -1
- package/dist/widgets/range.js +43 -12
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/readForWidget.d.ts +12 -0
- package/dist/widgets/readForWidget.js +30 -19
- package/dist/widgets/readForWidget.js.map +1 -1
- package/dist/widgets/readForWidgetBreakdown.d.ts +15 -0
- package/dist/widgets/readForWidgetBreakdown.js +32 -20
- package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
- package/dist/widgets/readForWidgetGoals.d.ts +57 -0
- package/dist/widgets/readForWidgetGoals.js +126 -0
- package/dist/widgets/readForWidgetGoals.js.map +1 -0
- package/dist/widgets/readForWidgetRealtime.js +1 -1
- package/dist/widgets/readForWidgetSeries.d.ts +13 -0
- package/dist/widgets/readForWidgetSeries.js +56 -28
- package/dist/widgets/readForWidgetSeries.js.map +1 -1
- package/dist/widgets/registerWidgets.js +58 -9
- package/dist/widgets/registerWidgets.js.map +1 -1
- package/dist/widgets/types.js +16 -2
- package/dist/widgets/types.js.map +1 -1
- package/dist/widgets/viewLink.d.ts +22 -0
- package/dist/widgets/viewLink.js +83 -0
- package/dist/widgets/viewLink.js.map +1 -0
- package/package.json +25 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { satisfiesCapabilities } from "../core/capabilities.js";
|
|
2
1
|
import { getRuntime, resolveTimezoneFor } from "../plugin/runtime.js";
|
|
3
|
-
import { resolveReadContext } from "../core/scopedRead.js";
|
|
4
2
|
import { resolveTimeframe } from "../timeframe/presets.js";
|
|
3
|
+
import { satisfiesCapabilities } from "../core/capabilities.js";
|
|
4
|
+
import { resolveReadContext } from "../core/scopedRead.js";
|
|
5
5
|
//#region src/widgets/readForWidgetBreakdown.ts
|
|
6
6
|
/**
|
|
7
7
|
* Site-wide ranked breakdown of one metric by one dimension, read through the engine.
|
|
@@ -15,7 +15,7 @@ const readForWidgetBreakdown = async (args) => {
|
|
|
15
15
|
if (!runtime) return {
|
|
16
16
|
status: "unavailable",
|
|
17
17
|
adapterId: adapterId ?? "",
|
|
18
|
-
dateRange: range ?? resolveTimeframe(timeframe, now),
|
|
18
|
+
dateRange: range ?? resolveTimeframe(timeframe, now, args.timezone),
|
|
19
19
|
rows: emptyRows
|
|
20
20
|
};
|
|
21
21
|
const ctx = await resolveReadContext({
|
|
@@ -27,10 +27,10 @@ const readForWidgetBreakdown = async (args) => {
|
|
|
27
27
|
if (!ctx.ok) return {
|
|
28
28
|
status: "unavailable",
|
|
29
29
|
adapterId: adapterId ?? "",
|
|
30
|
-
dateRange: range ?? resolveTimeframe(timeframe, now),
|
|
30
|
+
dateRange: range ?? resolveTimeframe(timeframe, now, args.timezone),
|
|
31
31
|
rows: emptyRows
|
|
32
32
|
};
|
|
33
|
-
const tz = await resolveTimezoneFor(runtime, req, ctx.scope);
|
|
33
|
+
const tz = args.timezone ?? await resolveTimezoneFor(runtime, req, ctx.scope);
|
|
34
34
|
const dateRange = range ?? resolveTimeframe(timeframe, now, tz);
|
|
35
35
|
const base = {
|
|
36
36
|
dateRange,
|
|
@@ -54,29 +54,41 @@ const readForWidgetBreakdown = async (args) => {
|
|
|
54
54
|
adapterId: adapter.id,
|
|
55
55
|
...base
|
|
56
56
|
};
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
const metrics = [metric, ...(args.extraMetrics ?? []).filter((m) => m !== metric && adapter.capabilities.metrics.has(m))];
|
|
58
|
+
let result;
|
|
59
|
+
try {
|
|
60
|
+
result = await runtime.engine.read(adapter, {
|
|
61
|
+
metrics,
|
|
62
|
+
dimensions: [dimension],
|
|
63
|
+
dateRange,
|
|
64
|
+
limit,
|
|
65
|
+
order: {
|
|
66
|
+
metric,
|
|
67
|
+
direction: "desc"
|
|
68
|
+
},
|
|
69
|
+
filters,
|
|
70
|
+
timezone: tz,
|
|
71
|
+
scope: ctx.queryScope
|
|
72
|
+
});
|
|
73
|
+
} catch {
|
|
74
|
+
return {
|
|
75
|
+
status: "unavailable",
|
|
76
|
+
adapterId: adapter.id,
|
|
77
|
+
...base
|
|
78
|
+
};
|
|
79
|
+
}
|
|
70
80
|
const rows = result.rows.map((row) => ({
|
|
71
81
|
label: row.dimensions?.[dimension] ?? "(none)",
|
|
72
|
-
value: row.metrics[metric] ?? 0
|
|
82
|
+
value: row.metrics[metric] ?? 0,
|
|
83
|
+
...metrics.length > 1 ? { metrics: row.metrics } : {}
|
|
73
84
|
}));
|
|
74
85
|
return {
|
|
75
86
|
status: "ok",
|
|
76
87
|
adapterId: adapter.id,
|
|
77
88
|
dateRange,
|
|
78
89
|
rows,
|
|
79
|
-
clamped: result.meta.clamped ?? false
|
|
90
|
+
clamped: result.meta.clamped ?? false,
|
|
91
|
+
stale: result.meta.stale ?? false
|
|
80
92
|
};
|
|
81
93
|
};
|
|
82
94
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readForWidgetBreakdown.js","names":[],"sources":["../../src/widgets/readForWidgetBreakdown.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { satisfiesCapabilities } from '../core/capabilities'\nimport type {\n\tAnalyticsAdapter,\n\tAnalyticsFilter,\n\tDateRange,\n\tDimensionKey,\n\tMetricKey,\n} from '../core/contract'\nimport { resolveReadContext } from '../core/scopedRead'\nimport { getRuntime, resolveTimezoneFor } from '../plugin/runtime'\nimport { resolveTimeframe, type TimeframePreset } from '../timeframe/presets'\nimport type { WidgetReadStatus } from './readForWidget'\n\nexport interface BreakdownRow {\n\tlabel: string\n\tvalue: number\n}\n\nexport interface WidgetBreakdownResult {\n\tstatus: WidgetReadStatus\n\tadapterId: string\n\tdateRange: DateRange\n\trows: BreakdownRow[]\n\tclamped?: boolean\n}\n\nexport interface ReadForWidgetBreakdownArgs {\n\treq: PayloadRequest\n\tmetric: MetricKey\n\tdimension: DimensionKey\n\ttimeframe: TimeframePreset\n\tlimit: number\n\tadapterId?: string\n\tnow: Date\n\trange?: DateRange\n\t/** Explicit scope override; omitted resolves via the plugin's scopeResolver. */\n\tscope?: string | null\n\tfilters?: AnalyticsFilter[]\n}\n\n/**\n * Site-wide ranked breakdown of one metric by one dimension, read through the engine.\n * Mirrors `readForWidget` but gates on the dimension too and maps each result row to a\n * `{ label, value }` pair the bar list renders. The adapter owns sorting and limiting.\n */\nexport const readForWidgetBreakdown = async (\n\targs: ReadForWidgetBreakdownArgs\n): Promise<WidgetBreakdownResult> => {\n\tconst { req, metric, dimension, timeframe, limit, adapterId, now, range, filters } = args\n\tconst emptyRows = [] as BreakdownRow[]\n\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn {\n\t\t\tstatus: 'unavailable',\n\t\t\tadapterId: adapterId ?? '',\n\t\t\tdateRange: range ?? resolveTimeframe(timeframe, now),\n\t\t\trows: emptyRows,\n\t\t}\n\t}\n\tconst ctx = await resolveReadContext({ runtime, req, adapterId, scope: args.scope })\n\tif (!ctx.ok) {\n\t\treturn {\n\t\t\tstatus: 'unavailable',\n\t\t\tadapterId: adapterId ?? '',\n\t\t\tdateRange: range ?? resolveTimeframe(timeframe, now),\n\t\t\trows: emptyRows,\n\t\t}\n\t}\n\tconst tz = await resolveTimezoneFor(runtime, req, ctx.scope)\n\tconst dateRange = range ?? resolveTimeframe(timeframe, now, tz)\n\tconst base = { dateRange, rows: emptyRows }\n\tconst adapter: AnalyticsAdapter = ctx.adapter\n\tif (!adapter.isConfigured()) {\n\t\treturn { status: 'not-configured', adapterId: adapter.id, ...base }\n\t}\n\tif (\n\t\t!satisfiesCapabilities(adapter.capabilities, {\n\t\t\tmetrics: [metric],\n\t\t\tdimensions: [dimension],\n\t\t\t...(filters && filters.length > 0\n\t\t\t\t? {\n\t\t\t\t\t\tfilters: filters.map((f) => f.dimension),\n\t\t\t\t\t\tfilterOperators: filters.map((f) => f.operator),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t})\n\t) {\n\t\treturn { status: 'unavailable', adapterId: adapter.id, ...base }\n\t}\n\tconst result = await runtime.engine.read(adapter, {\n\t\tmetrics
|
|
1
|
+
{"version":3,"file":"readForWidgetBreakdown.js","names":[],"sources":["../../src/widgets/readForWidgetBreakdown.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { satisfiesCapabilities } from '../core/capabilities'\nimport type {\n\tAnalyticsAdapter,\n\tAnalyticsFilter,\n\tAnalyticsResult,\n\tDateRange,\n\tDimensionKey,\n\tMetricKey,\n} from '../core/contract'\nimport { resolveReadContext } from '../core/scopedRead'\nimport { getRuntime, resolveTimezoneFor } from '../plugin/runtime'\nimport { resolveTimeframe, type TimeframePreset } from '../timeframe/presets'\nimport type { WidgetReadStatus } from './readForWidget'\n\nexport interface BreakdownRow {\n\tlabel: string\n\tvalue: number\n\t/** Every metric the read asked for, present only when `extraMetrics` asked for more. */\n\tmetrics?: Partial<Record<MetricKey, number>>\n}\n\nexport interface WidgetBreakdownResult {\n\tstatus: WidgetReadStatus\n\tadapterId: string\n\tdateRange: DateRange\n\trows: BreakdownRow[]\n\tclamped?: boolean\n\t/** True when the engine served a stale cache entry after a failed provider read. */\n\tstale?: boolean\n}\n\nexport interface ReadForWidgetBreakdownArgs {\n\treq: PayloadRequest\n\tmetric: MetricKey\n\tdimension: DimensionKey\n\ttimeframe: TimeframePreset\n\tlimit: number\n\tadapterId?: string\n\tnow: Date\n\trange?: DateRange\n\t/** Explicit scope override; omitted resolves via the plugin's scopeResolver. */\n\tscope?: string | null\n\t/**\n\t * Reporting timezone the caller already resolved, reused rather than resolved again so\n\t * a caller-supplied `range` is read in the very timezone it was interpreted in.\n\t */\n\ttimezone?: string\n\tfilters?: AnalyticsFilter[]\n\t/**\n\t * Further metrics to read alongside the ranked one, narrowed to what the source serves\n\t * so an unsupported one never turns the whole read unavailable. They reach each row's\n\t * `metrics`; ranking and status still follow `metric` alone.\n\t */\n\textraMetrics?: MetricKey[]\n}\n\n/**\n * Site-wide ranked breakdown of one metric by one dimension, read through the engine.\n * Mirrors `readForWidget` but gates on the dimension too and maps each result row to a\n * `{ label, value }` pair the bar list renders. The adapter owns sorting and limiting.\n */\nexport const readForWidgetBreakdown = async (\n\targs: ReadForWidgetBreakdownArgs\n): Promise<WidgetBreakdownResult> => {\n\tconst { req, metric, dimension, timeframe, limit, adapterId, now, range, filters } = args\n\tconst emptyRows = [] as BreakdownRow[]\n\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn {\n\t\t\tstatus: 'unavailable',\n\t\t\tadapterId: adapterId ?? '',\n\t\t\tdateRange: range ?? resolveTimeframe(timeframe, now, args.timezone),\n\t\t\trows: emptyRows,\n\t\t}\n\t}\n\tconst ctx = await resolveReadContext({ runtime, req, adapterId, scope: args.scope })\n\tif (!ctx.ok) {\n\t\treturn {\n\t\t\tstatus: 'unavailable',\n\t\t\tadapterId: adapterId ?? '',\n\t\t\tdateRange: range ?? resolveTimeframe(timeframe, now, args.timezone),\n\t\t\trows: emptyRows,\n\t\t}\n\t}\n\tconst tz = args.timezone ?? (await resolveTimezoneFor(runtime, req, ctx.scope))\n\tconst dateRange = range ?? resolveTimeframe(timeframe, now, tz)\n\tconst base = { dateRange, rows: emptyRows }\n\tconst adapter: AnalyticsAdapter = ctx.adapter\n\tif (!adapter.isConfigured()) {\n\t\treturn { status: 'not-configured', adapterId: adapter.id, ...base }\n\t}\n\tif (\n\t\t!satisfiesCapabilities(adapter.capabilities, {\n\t\t\tmetrics: [metric],\n\t\t\tdimensions: [dimension],\n\t\t\t...(filters && filters.length > 0\n\t\t\t\t? {\n\t\t\t\t\t\tfilters: filters.map((f) => f.dimension),\n\t\t\t\t\t\tfilterOperators: filters.map((f) => f.operator),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t})\n\t) {\n\t\treturn { status: 'unavailable', adapterId: adapter.id, ...base }\n\t}\n\tconst metrics = [\n\t\tmetric,\n\t\t...(args.extraMetrics ?? []).filter((m) => m !== metric && adapter.capabilities.metrics.has(m)),\n\t]\n\tlet result: AnalyticsResult\n\ttry {\n\t\tresult = await runtime.engine.read(adapter, {\n\t\t\tmetrics,\n\t\t\tdimensions: [dimension],\n\t\t\tdateRange,\n\t\t\tlimit,\n\t\t\torder: { metric, direction: 'desc' },\n\t\t\tfilters,\n\t\t\ttimezone: tz,\n\t\t\tscope: ctx.queryScope,\n\t\t})\n\t} catch {\n\t\t// No cache entry (fresh or stale) survived the failed read; degrade like an\n\t\t// unsupported capability instead of throwing through the widget render tree.\n\t\treturn { status: 'unavailable', adapterId: adapter.id, ...base }\n\t}\n\tconst rows = result.rows.map((row) => ({\n\t\tlabel: row.dimensions?.[dimension] ?? '(none)',\n\t\tvalue: row.metrics[metric] ?? 0,\n\t\t...(metrics.length > 1 ? { metrics: row.metrics } : {}),\n\t}))\n\treturn {\n\t\tstatus: 'ok',\n\t\tadapterId: adapter.id,\n\t\tdateRange,\n\t\trows,\n\t\tclamped: result.meta.clamped ?? false,\n\t\tstale: result.meta.stale ?? false,\n\t}\n}\n"],"mappings":";;;;;;;;;;AA8DA,MAAa,yBAAyB,OACrC,SACoC;CACpC,MAAM,EAAE,KAAK,QAAQ,WAAW,WAAW,OAAO,WAAW,KAAK,OAAO,YAAY;CACrF,MAAM,YAAY,CAAC;CAEnB,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAO;EACN,QAAQ;EACR,WAAW,aAAa;EACxB,WAAW,SAAS,iBAAiB,WAAW,KAAK,KAAK,QAAQ;EAClE,MAAM;CACP;CAED,MAAM,MAAM,MAAM,mBAAmB;EAAE;EAAS;EAAK;EAAW,OAAO,KAAK;CAAM,CAAC;CACnF,IAAI,CAAC,IAAI,IACR,OAAO;EACN,QAAQ;EACR,WAAW,aAAa;EACxB,WAAW,SAAS,iBAAiB,WAAW,KAAK,KAAK,QAAQ;EAClE,MAAM;CACP;CAED,MAAM,KAAK,KAAK,YAAa,MAAM,mBAAmB,SAAS,KAAK,IAAI,KAAK;CAC7E,MAAM,YAAY,SAAS,iBAAiB,WAAW,KAAK,EAAE;CAC9D,MAAM,OAAO;EAAE;EAAW,MAAM;CAAU;CAC1C,MAAM,UAA4B,IAAI;CACtC,IAAI,CAAC,QAAQ,aAAa,GACzB,OAAO;EAAE,QAAQ;EAAkB,WAAW,QAAQ;EAAI,GAAG;CAAK;CAEnE,IACC,CAAC,sBAAsB,QAAQ,cAAc;EAC5C,SAAS,CAAC,MAAM;EAChB,YAAY,CAAC,SAAS;EACtB,GAAI,WAAW,QAAQ,SAAS,IAC7B;GACA,SAAS,QAAQ,KAAK,MAAM,EAAE,SAAS;GACvC,iBAAiB,QAAQ,KAAK,MAAM,EAAE,QAAQ;EAC/C,IACC,CAAC;CACL,CAAC,GAED,OAAO;EAAE,QAAQ;EAAe,WAAW,QAAQ;EAAI,GAAG;CAAK;CAEhE,MAAM,UAAU,CACf,QACA,IAAI,KAAK,gBAAgB,CAAC,GAAG,QAAQ,MAAM,MAAM,UAAU,QAAQ,aAAa,QAAQ,IAAI,CAAC,CAAC,CAC/F;CACA,IAAI;CACJ,IAAI;EACH,SAAS,MAAM,QAAQ,OAAO,KAAK,SAAS;GAC3C;GACA,YAAY,CAAC,SAAS;GACtB;GACA;GACA,OAAO;IAAE;IAAQ,WAAW;GAAO;GACnC;GACA,UAAU;GACV,OAAO,IAAI;EACZ,CAAC;CACF,QAAQ;EAGP,OAAO;GAAE,QAAQ;GAAe,WAAW,QAAQ;GAAI,GAAG;EAAK;CAChE;CACA,MAAM,OAAO,OAAO,KAAK,KAAK,SAAS;EACtC,OAAO,IAAI,aAAa,cAAc;EACtC,OAAO,IAAI,QAAQ,WAAW;EAC9B,GAAI,QAAQ,SAAS,IAAI,EAAE,SAAS,IAAI,QAAQ,IAAI,CAAC;CACtD,EAAE;CACF,OAAO;EACN,QAAQ;EACR,WAAW,QAAQ;EACnB;EACA;EACA,SAAS,OAAO,KAAK,WAAW;EAChC,OAAO,OAAO,KAAK,SAAS;CAC7B;AACD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DateRange } from "../core/contract.js";
|
|
2
|
+
import { TimeframePreset } from "../timeframe/presets.js";
|
|
3
|
+
import { WidgetReadStatus } from "./readForWidget.js";
|
|
4
|
+
import { PayloadRequest } from "payload";
|
|
5
|
+
|
|
6
|
+
//#region src/widgets/readForWidgetGoals.d.ts
|
|
7
|
+
interface GoalRow {
|
|
8
|
+
slug: string;
|
|
9
|
+
/** The goal's admin-facing name, or its slug when no configured goal claims it. */
|
|
10
|
+
name: string;
|
|
11
|
+
conversions: number;
|
|
12
|
+
revenue?: number;
|
|
13
|
+
/** 0..1 share of the site's visitors, absent when either side of the ratio is missing. */
|
|
14
|
+
rate?: number;
|
|
15
|
+
previousConversions?: number;
|
|
16
|
+
}
|
|
17
|
+
interface WidgetGoalsResult {
|
|
18
|
+
status: WidgetReadStatus;
|
|
19
|
+
adapterId: string;
|
|
20
|
+
dateRange: DateRange;
|
|
21
|
+
timezone: string;
|
|
22
|
+
rows: GoalRow[];
|
|
23
|
+
/** Range total the rate divides by; absent when the source does not serve visitors. */
|
|
24
|
+
siteVisitors?: number;
|
|
25
|
+
clamped?: boolean;
|
|
26
|
+
stale?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface ReadForWidgetGoalsArgs {
|
|
29
|
+
req: PayloadRequest;
|
|
30
|
+
timeframe: TimeframePreset;
|
|
31
|
+
limit: number;
|
|
32
|
+
/** Read the previous window too, when the source can compare. */
|
|
33
|
+
compare: boolean;
|
|
34
|
+
adapterId?: string;
|
|
35
|
+
now: Date;
|
|
36
|
+
range?: DateRange;
|
|
37
|
+
/** Explicit scope override; omitted resolves via the plugin's scopeResolver. */
|
|
38
|
+
scope?: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Reporting timezone the caller already resolved, reused rather than resolved again so
|
|
41
|
+
* a caller-supplied `range` is read in the very timezone it was interpreted in.
|
|
42
|
+
*/
|
|
43
|
+
timezone?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The goals table behind the goals widget: conversions per goal over the window, each with
|
|
47
|
+
* its revenue, its share of the site's visitors, and (when comparing) the same goal's
|
|
48
|
+
* conversions in the previous window. Rows come from one `goal` breakdown read and the site
|
|
49
|
+
* total from one totals read, both through the existing widget helpers so capability
|
|
50
|
+
* gating, scoping and caching stay in one place. Revenue and visitors ride along only where
|
|
51
|
+
* the source serves them; the status is the breakdown's, since a table without its rows has
|
|
52
|
+
* nothing to show.
|
|
53
|
+
*/
|
|
54
|
+
declare const readForWidgetGoals: (args: ReadForWidgetGoalsArgs) => Promise<WidgetGoalsResult>;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { GoalRow, ReadForWidgetGoalsArgs, WidgetGoalsResult, readForWidgetGoals };
|
|
57
|
+
//# sourceMappingURL=readForWidgetGoals.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { getRuntime, resolveGoalsDetailedFor, resolveTimezoneFor } from "../plugin/runtime.js";
|
|
2
|
+
import { resolveTimeframe } from "../timeframe/presets.js";
|
|
3
|
+
import { resolveReadContext } from "../core/scopedRead.js";
|
|
4
|
+
import { previousWindow } from "./comparison.js";
|
|
5
|
+
import { readForWidget } from "./readForWidget.js";
|
|
6
|
+
import { readForWidgetBreakdown } from "./readForWidgetBreakdown.js";
|
|
7
|
+
import { conversionRate } from "../view/conversionRate.js";
|
|
8
|
+
//#region src/widgets/readForWidgetGoals.ts
|
|
9
|
+
/**
|
|
10
|
+
* How much wider than the table the previous window is read. Both windows rank by their own
|
|
11
|
+
* conversions, so a goal in today's top rows may sit well below them in the previous window;
|
|
12
|
+
* reading only as many rows as the table shows would drop exactly those deltas. Capped at
|
|
13
|
+
* the bound every analytics query is held to.
|
|
14
|
+
*/
|
|
15
|
+
const PREVIOUS_LIMIT_FACTOR = 4;
|
|
16
|
+
const previousLimit = (limit) => Math.min(limit * PREVIOUS_LIMIT_FACTOR, 500);
|
|
17
|
+
/**
|
|
18
|
+
* Goal names for the read's own scope. A resolver that throws must not cost the widget its
|
|
19
|
+
* table, so the rows fall back to their slugs.
|
|
20
|
+
*/
|
|
21
|
+
const goalNames = async (runtime, req, scope) => {
|
|
22
|
+
try {
|
|
23
|
+
const resolved = await resolveGoalsDetailedFor(runtime, req, scope);
|
|
24
|
+
return new Map(resolved.map(({ goal }) => [goal.slug, goal.name]));
|
|
25
|
+
} catch (err) {
|
|
26
|
+
req.payload.logger?.warn(`analytics: widget goal names failed to resolve: ${String(err)}`);
|
|
27
|
+
return /* @__PURE__ */ new Map();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The goals table behind the goals widget: conversions per goal over the window, each with
|
|
32
|
+
* its revenue, its share of the site's visitors, and (when comparing) the same goal's
|
|
33
|
+
* conversions in the previous window. Rows come from one `goal` breakdown read and the site
|
|
34
|
+
* total from one totals read, both through the existing widget helpers so capability
|
|
35
|
+
* gating, scoping and caching stay in one place. Revenue and visitors ride along only where
|
|
36
|
+
* the source serves them; the status is the breakdown's, since a table without its rows has
|
|
37
|
+
* nothing to show.
|
|
38
|
+
*/
|
|
39
|
+
const readForWidgetGoals = async (args) => {
|
|
40
|
+
const { req, timeframe, limit, compare, adapterId, now } = args;
|
|
41
|
+
const fallback = (status, id) => ({
|
|
42
|
+
status,
|
|
43
|
+
adapterId: id,
|
|
44
|
+
dateRange: args.range ?? resolveTimeframe(timeframe, now, args.timezone),
|
|
45
|
+
timezone: args.timezone ?? "UTC",
|
|
46
|
+
rows: []
|
|
47
|
+
});
|
|
48
|
+
const runtime = getRuntime(req.payload);
|
|
49
|
+
if (!runtime) return fallback("unavailable", adapterId ?? "");
|
|
50
|
+
const ctx = await resolveReadContext({
|
|
51
|
+
runtime,
|
|
52
|
+
req,
|
|
53
|
+
adapterId,
|
|
54
|
+
scope: args.scope
|
|
55
|
+
});
|
|
56
|
+
if (!ctx.ok) return fallback("unavailable", adapterId ?? "");
|
|
57
|
+
const adapter = ctx.adapter;
|
|
58
|
+
const tz = args.timezone ?? await resolveTimezoneFor(runtime, req, ctx.scope);
|
|
59
|
+
const dateRange = args.range ?? resolveTimeframe(timeframe, now, tz);
|
|
60
|
+
const shared = {
|
|
61
|
+
req,
|
|
62
|
+
timeframe,
|
|
63
|
+
adapterId: adapter.id,
|
|
64
|
+
scope: ctx.scope,
|
|
65
|
+
timezone: tz,
|
|
66
|
+
now
|
|
67
|
+
};
|
|
68
|
+
const comparisonRange = compare && runtime.comparison && adapter.capabilities.comparison ? previousWindow(dateRange, tz) ?? void 0 : void 0;
|
|
69
|
+
const [breakdown, totals, previous, names] = await Promise.all([
|
|
70
|
+
readForWidgetBreakdown({
|
|
71
|
+
...shared,
|
|
72
|
+
range: dateRange,
|
|
73
|
+
metric: "conversions",
|
|
74
|
+
dimension: "goal",
|
|
75
|
+
limit,
|
|
76
|
+
extraMetrics: ["revenue", "visitors"]
|
|
77
|
+
}),
|
|
78
|
+
adapter.capabilities.metrics.has("visitors") ? readForWidget({
|
|
79
|
+
...shared,
|
|
80
|
+
range: dateRange,
|
|
81
|
+
metrics: ["visitors"],
|
|
82
|
+
comparison: false
|
|
83
|
+
}) : void 0,
|
|
84
|
+
comparisonRange ? readForWidgetBreakdown({
|
|
85
|
+
...shared,
|
|
86
|
+
range: comparisonRange,
|
|
87
|
+
metric: "conversions",
|
|
88
|
+
dimension: "goal",
|
|
89
|
+
limit: previousLimit(limit)
|
|
90
|
+
}) : void 0,
|
|
91
|
+
goalNames(runtime, req, ctx.scope)
|
|
92
|
+
]);
|
|
93
|
+
if (breakdown.status !== "ok") return {
|
|
94
|
+
...fallback(breakdown.status, breakdown.adapterId),
|
|
95
|
+
dateRange,
|
|
96
|
+
timezone: tz
|
|
97
|
+
};
|
|
98
|
+
const previousBySlug = new Map((previous?.status === "ok" ? previous.rows : []).map((row) => [row.label, row.value]));
|
|
99
|
+
const siteVisitors = totals?.status === "ok" ? totals.metrics.visitors : void 0;
|
|
100
|
+
const rows = breakdown.rows.map((row) => {
|
|
101
|
+
const rate = conversionRate(row.metrics?.visitors, siteVisitors);
|
|
102
|
+
const previousConversions = previousBySlug.get(row.label);
|
|
103
|
+
return {
|
|
104
|
+
slug: row.label,
|
|
105
|
+
name: names.get(row.label) ?? row.label,
|
|
106
|
+
conversions: row.value,
|
|
107
|
+
...row.metrics?.revenue !== void 0 ? { revenue: row.metrics.revenue } : {},
|
|
108
|
+
...rate !== null ? { rate } : {},
|
|
109
|
+
...previousConversions !== void 0 ? { previousConversions } : {}
|
|
110
|
+
};
|
|
111
|
+
}).sort((a, b) => b.conversions - a.conversions).slice(0, limit);
|
|
112
|
+
return {
|
|
113
|
+
status: "ok",
|
|
114
|
+
adapterId: adapter.id,
|
|
115
|
+
dateRange,
|
|
116
|
+
timezone: tz,
|
|
117
|
+
rows,
|
|
118
|
+
...siteVisitors !== void 0 ? { siteVisitors } : {},
|
|
119
|
+
clamped: Boolean(breakdown.clamped || totals?.clamped || previous?.clamped),
|
|
120
|
+
stale: Boolean(breakdown.stale || totals?.stale || previous?.stale)
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
export { readForWidgetGoals };
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=readForWidgetGoals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readForWidgetGoals.js","names":[],"sources":["../../src/widgets/readForWidgetGoals.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport type { DateRange } from '../core/contract'\nimport { resolveReadContext } from '../core/scopedRead'\nimport {\n\ttype AnalyticsRuntime,\n\tgetRuntime,\n\tresolveGoalsDetailedFor,\n\tresolveTimezoneFor,\n} from '../plugin/runtime'\nimport { MAX_QUERY_LIMIT } from '../query/limits'\nimport { resolveTimeframe, type TimeframePreset } from '../timeframe/presets'\nimport { DEFAULT_TIMEZONE } from '../timeframe/tz'\nimport { conversionRate } from '../view/conversionRate'\nimport { previousWindow } from './comparison'\nimport { readForWidget, type WidgetReadStatus } from './readForWidget'\nimport { readForWidgetBreakdown } from './readForWidgetBreakdown'\n\nexport interface GoalRow {\n\tslug: string\n\t/** The goal's admin-facing name, or its slug when no configured goal claims it. */\n\tname: string\n\tconversions: number\n\trevenue?: number\n\t/** 0..1 share of the site's visitors, absent when either side of the ratio is missing. */\n\trate?: number\n\tpreviousConversions?: number\n}\n\nexport interface WidgetGoalsResult {\n\tstatus: WidgetReadStatus\n\tadapterId: string\n\tdateRange: DateRange\n\ttimezone: string\n\trows: GoalRow[]\n\t/** Range total the rate divides by; absent when the source does not serve visitors. */\n\tsiteVisitors?: number\n\tclamped?: boolean\n\tstale?: boolean\n}\n\nexport interface ReadForWidgetGoalsArgs {\n\treq: PayloadRequest\n\ttimeframe: TimeframePreset\n\tlimit: number\n\t/** Read the previous window too, when the source can compare. */\n\tcompare: boolean\n\tadapterId?: string\n\tnow: Date\n\trange?: DateRange\n\t/** Explicit scope override; omitted resolves via the plugin's scopeResolver. */\n\tscope?: string | null\n\t/**\n\t * Reporting timezone the caller already resolved, reused rather than resolved again so\n\t * a caller-supplied `range` is read in the very timezone it was interpreted in.\n\t */\n\ttimezone?: string\n}\n\n/**\n * How much wider than the table the previous window is read. Both windows rank by their own\n * conversions, so a goal in today's top rows may sit well below them in the previous window;\n * reading only as many rows as the table shows would drop exactly those deltas. Capped at\n * the bound every analytics query is held to.\n */\nconst PREVIOUS_LIMIT_FACTOR = 4\n\nconst previousLimit = (limit: number): number =>\n\tMath.min(limit * PREVIOUS_LIMIT_FACTOR, MAX_QUERY_LIMIT)\n\n/**\n * Goal names for the read's own scope. A resolver that throws must not cost the widget its\n * table, so the rows fall back to their slugs.\n */\nconst goalNames = async (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest,\n\tscope: string | null\n): Promise<Map<string, string>> => {\n\ttry {\n\t\tconst resolved = await resolveGoalsDetailedFor(runtime, req, scope)\n\t\treturn new Map(resolved.map(({ goal }) => [goal.slug, goal.name]))\n\t} catch (err) {\n\t\treq.payload.logger?.warn(`analytics: widget goal names failed to resolve: ${String(err)}`)\n\t\treturn new Map()\n\t}\n}\n\n/**\n * The goals table behind the goals widget: conversions per goal over the window, each with\n * its revenue, its share of the site's visitors, and (when comparing) the same goal's\n * conversions in the previous window. Rows come from one `goal` breakdown read and the site\n * total from one totals read, both through the existing widget helpers so capability\n * gating, scoping and caching stay in one place. Revenue and visitors ride along only where\n * the source serves them; the status is the breakdown's, since a table without its rows has\n * nothing to show.\n */\nexport const readForWidgetGoals = async (\n\targs: ReadForWidgetGoalsArgs\n): Promise<WidgetGoalsResult> => {\n\tconst { req, timeframe, limit, compare, adapterId, now } = args\n\tconst fallback = (status: WidgetReadStatus, id: string): WidgetGoalsResult => ({\n\t\tstatus,\n\t\tadapterId: id,\n\t\tdateRange: args.range ?? resolveTimeframe(timeframe, now, args.timezone),\n\t\ttimezone: args.timezone ?? DEFAULT_TIMEZONE,\n\t\trows: [],\n\t})\n\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn fallback('unavailable', adapterId ?? '')\n\t}\n\tconst ctx = await resolveReadContext({ runtime, req, adapterId, scope: args.scope })\n\tif (!ctx.ok) {\n\t\treturn fallback('unavailable', adapterId ?? '')\n\t}\n\tconst adapter = ctx.adapter\n\tconst tz = args.timezone ?? (await resolveTimezoneFor(runtime, req, ctx.scope))\n\tconst dateRange = args.range ?? resolveTimeframe(timeframe, now, tz)\n\t// The sub-reads resolve their own context; pinning the adapter, scope, timezone and\n\t// window keeps all three answering about exactly the same read.\n\tconst shared = { req, timeframe, adapterId: adapter.id, scope: ctx.scope, timezone: tz, now }\n\tconst comparisonRange =\n\t\tcompare && runtime.comparison && adapter.capabilities.comparison\n\t\t\t? (previousWindow(dateRange, tz) ?? undefined)\n\t\t\t: undefined\n\n\tconst [breakdown, totals, previous, names] = await Promise.all([\n\t\treadForWidgetBreakdown({\n\t\t\t...shared,\n\t\t\trange: dateRange,\n\t\t\tmetric: 'conversions',\n\t\t\tdimension: 'goal',\n\t\t\tlimit,\n\t\t\textraMetrics: ['revenue', 'visitors'],\n\t\t}),\n\t\tadapter.capabilities.metrics.has('visitors')\n\t\t\t? // The site total is a denominator, never a delta: its own previous window would\n\t\t\t\t// be a second read nothing renders.\n\t\t\t\treadForWidget({ ...shared, range: dateRange, metrics: ['visitors'], comparison: false })\n\t\t\t: undefined,\n\t\tcomparisonRange\n\t\t\t? readForWidgetBreakdown({\n\t\t\t\t\t...shared,\n\t\t\t\t\trange: comparisonRange,\n\t\t\t\t\tmetric: 'conversions',\n\t\t\t\t\tdimension: 'goal',\n\t\t\t\t\tlimit: previousLimit(limit),\n\t\t\t\t})\n\t\t\t: undefined,\n\t\tgoalNames(runtime, req, ctx.scope),\n\t])\n\tif (breakdown.status !== 'ok') {\n\t\treturn { ...fallback(breakdown.status, breakdown.adapterId), dateRange, timezone: tz }\n\t}\n\n\tconst previousBySlug = new Map(\n\t\t(previous?.status === 'ok' ? previous.rows : []).map((row) => [row.label, row.value])\n\t)\n\tconst siteVisitors = totals?.status === 'ok' ? totals.metrics.visitors : undefined\n\tconst rows: GoalRow[] = breakdown.rows\n\t\t.map((row) => {\n\t\t\tconst rate = conversionRate(row.metrics?.visitors, siteVisitors)\n\t\t\tconst previousConversions = previousBySlug.get(row.label)\n\t\t\treturn {\n\t\t\t\tslug: row.label,\n\t\t\t\tname: names.get(row.label) ?? row.label,\n\t\t\t\tconversions: row.value,\n\t\t\t\t...(row.metrics?.revenue !== undefined ? { revenue: row.metrics.revenue } : {}),\n\t\t\t\t...(rate !== null ? { rate } : {}),\n\t\t\t\t...(previousConversions !== undefined ? { previousConversions } : {}),\n\t\t\t}\n\t\t})\n\t\t// The adapter ranks and caps already; re-applying both keeps one that does not from\n\t\t// spilling a long, unranked table into a dashboard card.\n\t\t.sort((a, b) => b.conversions - a.conversions)\n\t\t.slice(0, limit)\n\n\treturn {\n\t\tstatus: 'ok',\n\t\tadapterId: adapter.id,\n\t\tdateRange,\n\t\ttimezone: tz,\n\t\trows,\n\t\t...(siteVisitors !== undefined ? { siteVisitors } : {}),\n\t\tclamped: Boolean(breakdown.clamped || totals?.clamped || previous?.clamped),\n\t\tstale: Boolean(breakdown.stale || totals?.stale || previous?.stale),\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAgEA,MAAM,wBAAwB;AAE9B,MAAM,iBAAiB,UACtB,KAAK,IAAI,QAAQ,uBAAA,GAAsC;;;;;AAMxD,MAAM,YAAY,OACjB,SACA,KACA,UACkC;CAClC,IAAI;EACH,MAAM,WAAW,MAAM,wBAAwB,SAAS,KAAK,KAAK;EAClE,OAAO,IAAI,IAAI,SAAS,KAAK,EAAE,WAAW,CAAC,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC;CACl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
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { satisfiesCapabilities } from "../core/capabilities.js";
|
|
2
1
|
import { getRuntime } from "../plugin/runtime.js";
|
|
2
|
+
import { satisfiesCapabilities } from "../core/capabilities.js";
|
|
3
3
|
import { resolveReadContext } from "../core/scopedRead.js";
|
|
4
4
|
import { kvCacheStore } from "../surfacing/cacheStore.js";
|
|
5
5
|
//#region src/widgets/readForWidgetRealtime.ts
|
|
@@ -21,6 +21,12 @@ interface WidgetSeriesResult {
|
|
|
21
21
|
previousTotal?: number;
|
|
22
22
|
/** The previous comparable window, present only when comparison ran. */
|
|
23
23
|
comparisonRange?: DateRange;
|
|
24
|
+
/**
|
|
25
|
+
* The previous window's daily series, present only when `compare` was asked for and the
|
|
26
|
+
* adapter supports comparison. Zero-filled to the same length as `points`, so the
|
|
27
|
+
* previous window's day i overlays `points[i]`.
|
|
28
|
+
*/
|
|
29
|
+
comparisonPoints?: SeriesPoint[];
|
|
24
30
|
}
|
|
25
31
|
interface ReadForWidgetSeriesArgs {
|
|
26
32
|
req: PayloadRequest;
|
|
@@ -31,7 +37,14 @@ interface ReadForWidgetSeriesArgs {
|
|
|
31
37
|
range?: DateRange;
|
|
32
38
|
/** Explicit scope override; omitted resolves via the plugin's scopeResolver. */
|
|
33
39
|
scope?: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Reporting timezone the caller already resolved, reused rather than resolved again so
|
|
42
|
+
* a caller-supplied `range` is read in the very timezone it was interpreted in.
|
|
43
|
+
*/
|
|
44
|
+
timezone?: string;
|
|
34
45
|
filters?: AnalyticsFilter[];
|
|
46
|
+
/** Also return the previous window's series, for the chart's comparison overlay. */
|
|
47
|
+
compare?: boolean;
|
|
35
48
|
}
|
|
36
49
|
/**
|
|
37
50
|
* Site-wide time-series read for a trend widget: resolve the timeframe, pick the
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { satisfiesCapabilities } from "../core/capabilities.js";
|
|
2
|
-
import { supportsGranularity } from "../core/granularity.js";
|
|
3
1
|
import { addDaysInTz, startOfDayInTz, zonedDayIso } from "../timeframe/tz.js";
|
|
4
2
|
import { getRuntime, resolveTimezoneFor } from "../plugin/runtime.js";
|
|
5
|
-
import { resolveReadContext } from "../core/scopedRead.js";
|
|
6
3
|
import { resolveTimeframe } from "../timeframe/presets.js";
|
|
4
|
+
import { satisfiesCapabilities } from "../core/capabilities.js";
|
|
5
|
+
import { supportsGranularity } from "../core/granularity.js";
|
|
6
|
+
import { resolveReadContext } from "../core/scopedRead.js";
|
|
7
7
|
import { previousWindow } from "./comparison.js";
|
|
8
8
|
//#region src/widgets/readForWidgetSeries.ts
|
|
9
9
|
const MAX_SERIES_DAYS = 366;
|
|
@@ -37,18 +37,28 @@ const fillDailySeries = (args) => {
|
|
|
37
37
|
}));
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
+
* Project a comparison series onto the primary axis: day i of the previous window overlays
|
|
41
|
+
* day i of the current one. Both windows span the same day count by construction, so this
|
|
42
|
+
* only guards a DST-shifted or clamped edge, silently truncating or zero-filling; a filled
|
|
43
|
+
* bucket borrows the axis day so every point still carries a real date.
|
|
44
|
+
*/
|
|
45
|
+
const alignSeries = (points, axis) => points.length === axis.length ? points : axis.map((day, i) => points[i] ?? {
|
|
46
|
+
date: day.date,
|
|
47
|
+
value: 0
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
40
50
|
* Site-wide time-series read for a trend widget: resolve the timeframe, pick the
|
|
41
51
|
* adapter, gate on the metric and day-granularity support, read through the engine,
|
|
42
52
|
* then return a zero-filled daily series plus the headline total. Mirrors
|
|
43
53
|
* `readForWidget` but yields points instead of a single value.
|
|
44
54
|
*/
|
|
45
55
|
const readForWidgetSeries = async (args) => {
|
|
46
|
-
const { req, metric, timeframe, adapterId, now, range, filters } = args;
|
|
56
|
+
const { req, metric, timeframe, adapterId, now, range, filters, compare } = args;
|
|
47
57
|
const fallback = (status, id) => ({
|
|
48
58
|
status,
|
|
49
59
|
adapterId: id,
|
|
50
|
-
dateRange: range ?? resolveTimeframe(timeframe, now),
|
|
51
|
-
timezone: "UTC",
|
|
60
|
+
dateRange: range ?? resolveTimeframe(timeframe, now, args.timezone),
|
|
61
|
+
timezone: args.timezone ?? "UTC",
|
|
52
62
|
points: [],
|
|
53
63
|
total: 0
|
|
54
64
|
});
|
|
@@ -61,7 +71,7 @@ const readForWidgetSeries = async (args) => {
|
|
|
61
71
|
scope: args.scope
|
|
62
72
|
});
|
|
63
73
|
if (!ctx.ok) return fallback("unavailable", adapterId ?? "");
|
|
64
|
-
const tz = await resolveTimezoneFor(runtime, req, ctx.scope);
|
|
74
|
+
const tz = args.timezone ?? await resolveTimezoneFor(runtime, req, ctx.scope);
|
|
65
75
|
const dateRange = range ?? resolveTimeframe(timeframe, now, tz);
|
|
66
76
|
const base = {
|
|
67
77
|
dateRange,
|
|
@@ -87,36 +97,54 @@ const readForWidgetSeries = async (args) => {
|
|
|
87
97
|
...base
|
|
88
98
|
};
|
|
89
99
|
const comparisonRange = runtime.comparison && adapter.capabilities.comparison ? previousWindow(dateRange, tz) ?? void 0 : void 0;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
let result;
|
|
101
|
+
let previous;
|
|
102
|
+
try {
|
|
103
|
+
[result, previous] = await Promise.all([runtime.engine.read(adapter, {
|
|
104
|
+
metrics: [metric],
|
|
105
|
+
dateRange,
|
|
106
|
+
granularity: "day",
|
|
107
|
+
filters,
|
|
108
|
+
timezone: tz,
|
|
109
|
+
scope: ctx.queryScope
|
|
110
|
+
}), comparisonRange ? runtime.engine.read(adapter, {
|
|
111
|
+
metrics: [metric],
|
|
112
|
+
dateRange: comparisonRange,
|
|
113
|
+
...compare ? { granularity: "day" } : {},
|
|
114
|
+
filters,
|
|
115
|
+
timezone: tz,
|
|
116
|
+
scope: ctx.queryScope
|
|
117
|
+
}) : void 0]);
|
|
118
|
+
} catch {
|
|
119
|
+
return {
|
|
120
|
+
status: "unavailable",
|
|
121
|
+
adapterId: adapter.id,
|
|
122
|
+
...base
|
|
123
|
+
};
|
|
124
|
+
}
|
|
104
125
|
const previousTotal = previous ? previous.totals?.[metric] : void 0;
|
|
126
|
+
const points = fillDailySeries({
|
|
127
|
+
rows: result.rows,
|
|
128
|
+
dateRange,
|
|
129
|
+
metric,
|
|
130
|
+
tz
|
|
131
|
+
});
|
|
105
132
|
return {
|
|
106
133
|
status: "ok",
|
|
107
134
|
adapterId: adapter.id,
|
|
108
135
|
dateRange,
|
|
109
136
|
timezone: tz,
|
|
110
|
-
points
|
|
111
|
-
rows: result.rows,
|
|
112
|
-
dateRange,
|
|
113
|
-
metric,
|
|
114
|
-
tz
|
|
115
|
-
}),
|
|
137
|
+
points,
|
|
116
138
|
total: result.totals?.[metric] ?? 0,
|
|
117
139
|
clamped: result.meta.clamped ?? false,
|
|
118
140
|
previousTotal,
|
|
119
|
-
comparisonRange
|
|
141
|
+
comparisonRange,
|
|
142
|
+
...compare && previous && comparisonRange ? { comparisonPoints: alignSeries(fillDailySeries({
|
|
143
|
+
rows: previous.rows,
|
|
144
|
+
dateRange: comparisonRange,
|
|
145
|
+
metric,
|
|
146
|
+
tz
|
|
147
|
+
}), points) } : {}
|
|
120
148
|
};
|
|
121
149
|
};
|
|
122
150
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readForWidgetSeries.js","names":[],"sources":["../../src/widgets/readForWidgetSeries.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { satisfiesCapabilities } from '../core/capabilities'\nimport type {\n\tAnalyticsAdapter,\n\tAnalyticsFilter,\n\tAnalyticsRow,\n\tDateRange,\n\tMetricKey,\n} from '../core/contract'\nimport { supportsGranularity } from '../core/granularity'\nimport { resolveReadContext } from '../core/scopedRead'\nimport { getRuntime, resolveTimezoneFor } from '../plugin/runtime'\nimport { resolveTimeframe, type TimeframePreset } from '../timeframe/presets'\nimport { addDaysInTz, DEFAULT_TIMEZONE, startOfDayInTz, zonedDayIso } from '../timeframe/tz'\nimport { previousWindow } from './comparison'\nimport type { WidgetReadStatus } from './readForWidget'\n\nexport interface SeriesPoint {\n\tdate: string\n\tvalue: number\n}\n\nexport interface WidgetSeriesResult {\n\tstatus: WidgetReadStatus\n\tadapterId: string\n\tdateRange: DateRange\n\t/** Reporting timezone the read resolved in; the trend axis buckets in it. */\n\ttimezone: string\n\tpoints: SeriesPoint[]\n\ttotal: number\n\tclamped?: boolean\n\t/** Previous-window headline total, present only when the adapter supports comparison. */\n\tpreviousTotal?: number\n\t/** The previous comparable window, present only when comparison ran. */\n\tcomparisonRange?: DateRange\n}\n\nexport interface ReadForWidgetSeriesArgs {\n\treq: PayloadRequest\n\tmetric: MetricKey\n\ttimeframe: TimeframePreset\n\tadapterId?: string\n\tnow: Date\n\trange?: DateRange\n\t/** Explicit scope override; omitted resolves via the plugin's scopeResolver. */\n\tscope?: string | null\n\tfilters?: AnalyticsFilter[]\n}\n\nconst MAX_SERIES_DAYS = 366\n\n/**\n * Project time-series rows onto a contiguous daily axis, zero-filling gaps. Days are\n * counted in `tz` (defaulting to UTC), so a reporting-timezone read aligns each bucket\n * to that zone's midnight. The axis is capped at the most recent `MAX_SERIES_DAYS` so\n * an unbounded range (all time) stays a bounded, drawable sparkline; the headline total\n * still reflects the full range.\n */\nexport const fillDailySeries = (args: {\n\trows: AnalyticsRow[]\n\tdateRange: DateRange\n\tmetric: MetricKey\n\ttz?: string\n}): SeriesPoint[] => {\n\tconst { rows, dateRange, metric } = args\n\tconst tz = args.tz ?? DEFAULT_TIMEZONE\n\tconst lastDay = startOfDayInTz(dateRange.end, tz)\n\tconst requestedStart = startOfDayInTz(dateRange.start, tz)\n\tconst byDay = new Map<string, number>()\n\tfor (const row of rows) {\n\t\tif (!row.timestamp) {\n\t\t\tcontinue\n\t\t}\n\t\tconst day = zonedDayIso(new Date(row.timestamp), tz)\n\t\tbyDay.set(day, (byDay.get(day) ?? 0) + (row.metrics[metric] ?? 0))\n\t}\n\t// Walk calendar days back from the last day so DST-length days never mis-step, capping\n\t// the axis at MAX_SERIES_DAYS or the requested start, whichever is more recent.\n\tconst isoDays: string[] = []\n\tlet cursor = lastDay\n\tfor (let i = 0; i < MAX_SERIES_DAYS && cursor.getTime() >= requestedStart.getTime(); i += 1) {\n\t\tisoDays.push(cursor.toISOString())\n\t\tcursor = addDaysInTz(cursor, -1, tz)\n\t}\n\treturn isoDays.reverse().map((date) => ({ date, value: byDay.get(date) ?? 0 }))\n}\n\n/**\n * Site-wide time-series read for a trend widget: resolve the timeframe, pick the\n * adapter, gate on the metric and day-granularity support, read through the engine,\n * then return a zero-filled daily series plus the headline total. Mirrors\n * `readForWidget` but yields points instead of a single value.\n */\nexport const readForWidgetSeries = async (\n\targs: ReadForWidgetSeriesArgs\n): Promise<WidgetSeriesResult> => {\n\tconst { req, metric, timeframe, adapterId, now, range, filters } = args\n\tconst fallback = (status: WidgetReadStatus, id: string): WidgetSeriesResult => ({\n\t\tstatus,\n\t\tadapterId: id,\n\t\tdateRange: range ?? resolveTimeframe(timeframe, now),\n\t\ttimezone: DEFAULT_TIMEZONE,\n\t\tpoints: [],\n\t\ttotal: 0,\n\t})\n\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn fallback('unavailable', adapterId ?? '')\n\t}\n\tconst ctx = await resolveReadContext({ runtime, req, adapterId, scope: args.scope })\n\tif (!ctx.ok) {\n\t\treturn fallback('unavailable', adapterId ?? '')\n\t}\n\tconst tz = await resolveTimezoneFor(runtime, req, ctx.scope)\n\tconst dateRange = range ?? resolveTimeframe(timeframe, now, tz)\n\tconst base = { dateRange, timezone: tz, points: [] as SeriesPoint[], total: 0 }\n\tconst adapter: AnalyticsAdapter = ctx.adapter\n\tif (!adapter.isConfigured()) {\n\t\treturn { status: 'not-configured', adapterId: adapter.id, ...base }\n\t}\n\tif (\n\t\t!satisfiesCapabilities(adapter.capabilities, {\n\t\t\tmetrics: [metric],\n\t\t\t...(filters && filters.length > 0\n\t\t\t\t? {\n\t\t\t\t\t\tfilters: filters.map((f) => f.dimension),\n\t\t\t\t\t\tfilterOperators: filters.map((f) => f.operator),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t}) ||\n\t\t!supportsGranularity(adapter.capabilities, 'day')\n\t) {\n\t\treturn { status: 'unavailable', adapterId: adapter.id, ...base }\n\t}\n\tconst comparisonRange =\n\t\truntime.comparison && adapter.capabilities.comparison\n\t\t\t? (previousWindow(dateRange, tz) ?? undefined)\n\t\t\t: undefined\n\tconst [result, previous] = await Promise.all([\n\t\truntime.engine.read(adapter, {\n\t\t\tmetrics: [metric],\n\t\t\tdateRange,\n\t\t\tgranularity: 'day',\n\t\t\tfilters,\n\t\t\ttimezone: tz,\n\t\t\tscope: ctx.queryScope,\n\t\t}),\n\t\tcomparisonRange\n\t\t\t? runtime.engine.read(adapter, {\n\t\t\t\t\tmetrics: [metric],\n\t\t\t\t\tdateRange: comparisonRange,\n\t\t\t\t\tfilters,\n\t\t\t\t\ttimezone: tz,\n\t\t\t\t\tscope: ctx.queryScope,\n\t\t\t\t})\n\t\t\t: undefined,\n\t])\n\tconst previousTotal = previous ? previous.totals?.[metric] : undefined\n\treturn {\n\t\tstatus: 'ok',\n\t\tadapterId: adapter.id,\n\t\tdateRange,\n\t\ttimezone: tz,\n\t\tpoints: fillDailySeries({ rows: result.rows, dateRange, metric, tz }),\n\t\ttotal: result.totals?.[metric] ?? 0,\n\t\tclamped: result.meta.clamped ?? false,\n\t\tpreviousTotal,\n\t\tcomparisonRange,\n\t}\n}\n"],"mappings":";;;;;;;;AAiDA,MAAM,kBAAkB;;;;;;;;AASxB,MAAa,mBAAmB,SAKX;CACpB,MAAM,EAAE,MAAM,WAAW,WAAW;CACpC,MAAM,KAAK,KAAK,MAAA;CAChB,MAAM,UA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eries.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { satisfiesCapabilities } from '../core/capabilities'\nimport type {\n\tAnalyticsAdapter,\n\tAnalyticsFilter,\n\tAnalyticsResult,\n\tAnalyticsRow,\n\tDateRange,\n\tMetricKey,\n} from '../core/contract'\nimport { supportsGranularity } from '../core/granularity'\nimport { resolveReadContext } from '../core/scopedRead'\nimport { getRuntime, resolveTimezoneFor } from '../plugin/runtime'\nimport { resolveTimeframe, type TimeframePreset } from '../timeframe/presets'\nimport { addDaysInTz, DEFAULT_TIMEZONE, startOfDayInTz, zonedDayIso } from '../timeframe/tz'\nimport { previousWindow } from './comparison'\nimport type { WidgetReadStatus } from './readForWidget'\n\nexport interface SeriesPoint {\n\tdate: string\n\tvalue: number\n}\n\nexport interface WidgetSeriesResult {\n\tstatus: WidgetReadStatus\n\tadapterId: string\n\tdateRange: DateRange\n\t/** Reporting timezone the read resolved in; the trend axis buckets in it. */\n\ttimezone: string\n\tpoints: SeriesPoint[]\n\ttotal: number\n\tclamped?: boolean\n\t/** Previous-window headline total, present only when the adapter supports comparison. */\n\tpreviousTotal?: number\n\t/** The previous comparable window, present only when comparison ran. */\n\tcomparisonRange?: DateRange\n\t/**\n\t * The previous window's daily series, present only when `compare` was asked for and the\n\t * adapter supports comparison. Zero-filled to the same length as `points`, so the\n\t * previous window's day i overlays `points[i]`.\n\t */\n\tcomparisonPoints?: SeriesPoint[]\n}\n\nexport interface ReadForWidgetSeriesArgs {\n\treq: PayloadRequest\n\tmetric: MetricKey\n\ttimeframe: TimeframePreset\n\tadapterId?: string\n\tnow: Date\n\trange?: DateRange\n\t/** Explicit scope override; omitted resolves via the plugin's scopeResolver. */\n\tscope?: string | null\n\t/**\n\t * Reporting timezone the caller already resolved, reused rather than resolved again so\n\t * a caller-supplied `range` is read in the very timezone it was interpreted in.\n\t */\n\ttimezone?: string\n\tfilters?: AnalyticsFilter[]\n\t/** Also return the previous window's series, for the chart's comparison overlay. */\n\tcompare?: boolean\n}\n\nconst MAX_SERIES_DAYS = 366\n\n/**\n * Project time-series rows onto a contiguous daily axis, zero-filling gaps. Days are\n * counted in `tz` (defaulting to UTC), so a reporting-timezone read aligns each bucket\n * to that zone's midnight. The axis is capped at the most recent `MAX_SERIES_DAYS` so\n * an unbounded range (all time) stays a bounded, drawable sparkline; the headline total\n * still reflects the full range.\n */\nexport const fillDailySeries = (args: {\n\trows: AnalyticsRow[]\n\tdateRange: DateRange\n\tmetric: MetricKey\n\ttz?: string\n}): SeriesPoint[] => {\n\tconst { rows, dateRange, metric } = args\n\tconst tz = args.tz ?? DEFAULT_TIMEZONE\n\tconst lastDay = startOfDayInTz(dateRange.end, tz)\n\tconst requestedStart = startOfDayInTz(dateRange.start, tz)\n\tconst byDay = new Map<string, number>()\n\tfor (const row of rows) {\n\t\tif (!row.timestamp) {\n\t\t\tcontinue\n\t\t}\n\t\tconst day = zonedDayIso(new Date(row.timestamp), tz)\n\t\tbyDay.set(day, (byDay.get(day) ?? 0) + (row.metrics[metric] ?? 0))\n\t}\n\t// Walk calendar days back from the last day so DST-length days never mis-step, capping\n\t// the axis at MAX_SERIES_DAYS or the requested start, whichever is more recent.\n\tconst isoDays: string[] = []\n\tlet cursor = lastDay\n\tfor (let i = 0; i < MAX_SERIES_DAYS && cursor.getTime() >= requestedStart.getTime(); i += 1) {\n\t\tisoDays.push(cursor.toISOString())\n\t\tcursor = addDaysInTz(cursor, -1, tz)\n\t}\n\treturn isoDays.reverse().map((date) => ({ date, value: byDay.get(date) ?? 0 }))\n}\n\n/**\n * Project a comparison series onto the primary axis: day i of the previous window overlays\n * day i of the current one. Both windows span the same day count by construction, so this\n * only guards a DST-shifted or clamped edge, silently truncating or zero-filling; a filled\n * bucket borrows the axis day so every point still carries a real date.\n */\nconst alignSeries = (points: SeriesPoint[], axis: SeriesPoint[]): SeriesPoint[] =>\n\tpoints.length === axis.length\n\t\t? points\n\t\t: axis.map((day, i) => points[i] ?? { date: day.date, value: 0 })\n\n/**\n * Site-wide time-series read for a trend widget: resolve the timeframe, pick the\n * adapter, gate on the metric and day-granularity support, read through the engine,\n * then return a zero-filled daily series plus the headline total. Mirrors\n * `readForWidget` but yields points instead of a single value.\n */\nexport const readForWidgetSeries = async (\n\targs: ReadForWidgetSeriesArgs\n): Promise<WidgetSeriesResult> => {\n\tconst { req, metric, timeframe, adapterId, now, range, filters, compare } = args\n\tconst fallback = (status: WidgetReadStatus, id: string): WidgetSeriesResult => ({\n\t\tstatus,\n\t\tadapterId: id,\n\t\tdateRange: range ?? resolveTimeframe(timeframe, now, args.timezone),\n\t\ttimezone: args.timezone ?? DEFAULT_TIMEZONE,\n\t\tpoints: [],\n\t\ttotal: 0,\n\t})\n\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn fallback('unavailable', adapterId ?? '')\n\t}\n\tconst ctx = await resolveReadContext({ runtime, req, adapterId, scope: args.scope })\n\tif (!ctx.ok) {\n\t\treturn fallback('unavailable', adapterId ?? '')\n\t}\n\tconst tz = args.timezone ?? (await resolveTimezoneFor(runtime, req, ctx.scope))\n\tconst dateRange = range ?? resolveTimeframe(timeframe, now, tz)\n\tconst base = { dateRange, timezone: tz, points: [] as SeriesPoint[], total: 0 }\n\tconst adapter: AnalyticsAdapter = ctx.adapter\n\tif (!adapter.isConfigured()) {\n\t\treturn { status: 'not-configured', adapterId: adapter.id, ...base }\n\t}\n\tif (\n\t\t!satisfiesCapabilities(adapter.capabilities, {\n\t\t\tmetrics: [metric],\n\t\t\t...(filters && filters.length > 0\n\t\t\t\t? {\n\t\t\t\t\t\tfilters: filters.map((f) => f.dimension),\n\t\t\t\t\t\tfilterOperators: filters.map((f) => f.operator),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t}) ||\n\t\t!supportsGranularity(adapter.capabilities, 'day')\n\t) {\n\t\treturn { status: 'unavailable', adapterId: adapter.id, ...base }\n\t}\n\tconst comparisonRange =\n\t\truntime.comparison && adapter.capabilities.comparison\n\t\t\t? (previousWindow(dateRange, tz) ?? undefined)\n\t\t\t: undefined\n\tlet result: AnalyticsResult\n\tlet previous: AnalyticsResult | undefined\n\ttry {\n\t\t;[result, previous] = await Promise.all([\n\t\t\truntime.engine.read(adapter, {\n\t\t\t\tmetrics: [metric],\n\t\t\t\tdateRange,\n\t\t\t\tgranularity: 'day',\n\t\t\t\tfilters,\n\t\t\t\ttimezone: tz,\n\t\t\t\tscope: ctx.queryScope,\n\t\t\t}),\n\t\t\tcomparisonRange\n\t\t\t\t? runtime.engine.read(adapter, {\n\t\t\t\t\t\tmetrics: [metric],\n\t\t\t\t\t\tdateRange: comparisonRange,\n\t\t\t\t\t\t// The overlay needs the previous window bucketed like the primary; the delta\n\t\t\t\t\t\t// alone only needs its total, so the read stays as it was without `compare`.\n\t\t\t\t\t\t...(compare ? { granularity: 'day' as const } : {}),\n\t\t\t\t\t\tfilters,\n\t\t\t\t\t\ttimezone: tz,\n\t\t\t\t\t\tscope: ctx.queryScope,\n\t\t\t\t\t})\n\t\t\t\t: undefined,\n\t\t])\n\t} catch {\n\t\t// No cache entry (fresh or stale) survived the failed read; degrade like an\n\t\t// unsupported capability instead of throwing through the widget render tree.\n\t\treturn { status: 'unavailable', adapterId: adapter.id, ...base }\n\t}\n\tconst previousTotal = previous ? previous.totals?.[metric] : undefined\n\tconst points = fillDailySeries({ rows: result.rows, dateRange, metric, tz })\n\treturn {\n\t\tstatus: 'ok',\n\t\tadapterId: adapter.id,\n\t\tdateRange,\n\t\ttimezone: tz,\n\t\tpoints,\n\t\ttotal: result.totals?.[metric] ?? 0,\n\t\tclamped: result.meta.clamped ?? false,\n\t\tpreviousTotal,\n\t\tcomparisonRange,\n\t\t...(compare && previous && comparisonRange\n\t\t\t? {\n\t\t\t\t\tcomparisonPoints: alignSeries(\n\t\t\t\t\t\tfillDailySeries({ rows: previous.rows, dateRange: comparisonRange, metric, tz }),\n\t\t\t\t\t\tpoints\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t: {}),\n\t}\n}\n"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