@10x-media/analytics 0.1.0-beta.0
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 +41 -0
- package/LICENSE +21 -0
- package/README.md +387 -0
- package/dist/RealtimeCounter-BJrjMPSa.js +473 -0
- package/dist/RealtimeCounter-BJrjMPSa.js.map +1 -0
- package/dist/contract-CWZPKWuR.d.ts +83 -0
- package/dist/dist-B6HruP5v.js +4731 -0
- package/dist/dist-B6HruP5v.js.map +1 -0
- package/dist/exports/adapters/ga4.d.ts +20 -0
- package/dist/exports/adapters/ga4.js +177 -0
- package/dist/exports/adapters/ga4.js.map +1 -0
- package/dist/exports/adapters/native.d.ts +22 -0
- package/dist/exports/adapters/native.js +849 -0
- package/dist/exports/adapters/native.js.map +1 -0
- package/dist/exports/adapters/plausible.d.ts +15 -0
- package/dist/exports/adapters/plausible.js +143 -0
- package/dist/exports/adapters/plausible.js.map +1 -0
- package/dist/exports/adapters/posthog.d.ts +17 -0
- package/dist/exports/adapters/posthog.js +119 -0
- package/dist/exports/adapters/posthog.js.map +1 -0
- package/dist/exports/adapters/umami.d.ts +18 -0
- package/dist/exports/adapters/umami.js +139 -0
- package/dist/exports/adapters/umami.js.map +1 -0
- package/dist/exports/client.d.ts +77 -0
- package/dist/exports/client.js +388 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/geo.d.ts +19 -0
- package/dist/exports/geo.js +2 -0
- package/dist/exports/i18n.d.ts +63 -0
- package/dist/exports/i18n.js +3 -0
- package/dist/exports/rsc.d.ts +120 -0
- package/dist/exports/rsc.js +598 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/exports/types.d.ts +4 -0
- package/dist/exports/types.js +1 -0
- package/dist/fetchJson-DZb2_Puj.js +36 -0
- package/dist/fetchJson-DZb2_Puj.js.map +1 -0
- package/dist/geoResolver-CasIa4T9.d.ts +12 -0
- package/dist/index-CZdCT0WJ.d.ts +98 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1081 -0
- package/dist/index.js.map +1 -0
- package/dist/keys-DEqL4LOT.js +57 -0
- package/dist/keys-DEqL4LOT.js.map +1 -0
- package/dist/lib-CE5x1zLQ.js +1058 -0
- package/dist/lib-CE5x1zLQ.js.map +1 -0
- package/dist/maxmindResolver-CXYXXdul.js +99 -0
- package/dist/maxmindResolver-CXYXXdul.js.map +1 -0
- package/dist/presets-CBfq_uJX.d.ts +38 -0
- package/dist/readForWidgetRealtime-D1BD37ST.d.ts +32 -0
- package/dist/series-zytbzPoc.js +17 -0
- package/dist/series-zytbzPoc.js.map +1 -0
- package/dist/server-Cuvhgz-S.js +492 -0
- package/dist/server-Cuvhgz-S.js.map +1 -0
- package/dist/testing/memoryAdapter.d.ts +16 -0
- package/dist/testing/memoryAdapter.js +98 -0
- package/dist/testing/memoryAdapter.js.map +1 -0
- package/dist/translations-keiKtSjF.js +77 -0
- package/dist/translations-keiKtSjF.js.map +1 -0
- package/package.json +156 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import { _ as readForWidgetRealtime, a as readForWidgetSeries, c as readForWidget, f as breakdownSpecBySlug, h as REALTIME_PATH, i as TIMEFRAME_KEYS, l as formatRangeCaption, m as resolveTimeframe, r as METRIC_KEYS, s as readForWidgetBreakdown, t as asTranslate, u as resolveCustomRange, x as satisfiesCapabilities, y as getRuntime } from "../server-Cuvhgz-S.js";
|
|
2
|
+
import { t as keys } from "../keys-DEqL4LOT.js";
|
|
3
|
+
import { n as TrendChart, r as BarList, t as RealtimeCounter } from "../RealtimeCounter-BJrjMPSa.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/fields/format.ts
|
|
6
|
+
const formatDuration = (ms) => {
|
|
7
|
+
const totalSeconds = Math.round(ms / 1e3);
|
|
8
|
+
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
9
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
10
|
+
const seconds = totalSeconds % 60;
|
|
11
|
+
if (minutes < 60) return seconds === 0 ? `${minutes}m` : `${minutes}m ${seconds}s`;
|
|
12
|
+
const hours = Math.floor(minutes / 60);
|
|
13
|
+
const remMinutes = minutes % 60;
|
|
14
|
+
return remMinutes === 0 ? `${hours}h` : `${hours}h ${remMinutes}m`;
|
|
15
|
+
};
|
|
16
|
+
const formatCount = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
17
|
+
const PERCENT_METRICS = new Set(["bounceRate", "scrollDepth"]);
|
|
18
|
+
const formatMetricValue = (metric, value, locale) => {
|
|
19
|
+
if (metric === "avgDuration") return formatDuration(value);
|
|
20
|
+
if (PERCENT_METRICS.has(metric)) return `${Math.round(value)}%`;
|
|
21
|
+
return formatCount(value, locale);
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/binding/resolvePath.ts
|
|
25
|
+
const getByPath = (doc, dotPath) => dotPath.split(".").reduce((value, key) => {
|
|
26
|
+
if (value && typeof value === "object") return value[key];
|
|
27
|
+
}, doc);
|
|
28
|
+
const nonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a document's analytics path. The `path` resolver wins; the `pathField`
|
|
31
|
+
* value is the fallback. Returns null when neither yields a non-empty string (for
|
|
32
|
+
* example an unsaved document with no slug yet).
|
|
33
|
+
*/
|
|
34
|
+
const resolvePath = async (binding, doc, ctx) => {
|
|
35
|
+
if (binding.path) {
|
|
36
|
+
const resolved = await binding.path(doc, ctx);
|
|
37
|
+
if (nonEmptyString(resolved)) return resolved;
|
|
38
|
+
}
|
|
39
|
+
if (binding.pathField) {
|
|
40
|
+
const value = getByPath(doc, binding.pathField);
|
|
41
|
+
if (nonEmptyString(value)) return value;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
const CACHE_KEY = "__analyticsPathCache";
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the path once per (doc, request): the same `doc` reference is handed to
|
|
48
|
+
* every analytics field on a document, so caching the in-flight Promise on
|
|
49
|
+
* `req.context` collapses an async (possibly ancestor-walking) resolver from once per
|
|
50
|
+
* field to once per document, and shares it across concurrent field renders. When the
|
|
51
|
+
* request carries no context bag (incomplete reqs in tests or unusual call sites), it
|
|
52
|
+
* degrades to a direct, un-memoized resolve so the result stays correct.
|
|
53
|
+
*/
|
|
54
|
+
const resolvePathCached = (binding, doc, ctx) => {
|
|
55
|
+
const context = ctx.req.context;
|
|
56
|
+
if (!context) return resolvePath(binding, doc, ctx);
|
|
57
|
+
let cache = context[CACHE_KEY];
|
|
58
|
+
if (!cache) {
|
|
59
|
+
cache = /* @__PURE__ */ new WeakMap();
|
|
60
|
+
context[CACHE_KEY] = cache;
|
|
61
|
+
}
|
|
62
|
+
let cached = cache.get(doc);
|
|
63
|
+
if (!cached) {
|
|
64
|
+
cached = resolvePath(binding, doc, ctx);
|
|
65
|
+
cache.set(doc, cached);
|
|
66
|
+
}
|
|
67
|
+
return cached;
|
|
68
|
+
};
|
|
69
|
+
const resolveHostname = (binding, doc) => {
|
|
70
|
+
if (typeof binding.hostname === "function") return binding.hostname(doc);
|
|
71
|
+
return binding.hostname;
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/fields/readForDocument.ts
|
|
75
|
+
/**
|
|
76
|
+
* Resolve a document's analytics for one display field: look up the runtime, resolve
|
|
77
|
+
* the bound path, capability-gate the requested metrics against the active adapter,
|
|
78
|
+
* then read through the surfacing engine. Returns a discriminated status so the
|
|
79
|
+
* rendering component can show the right empty state without throwing.
|
|
80
|
+
*/
|
|
81
|
+
const readForField = async (args) => {
|
|
82
|
+
const { req, collectionSlug, data, metrics, timeframe, adapterId, now } = args;
|
|
83
|
+
const dateRange = resolveTimeframe(timeframe, now);
|
|
84
|
+
const runtime = getRuntime(req.payload);
|
|
85
|
+
if (!runtime) return {
|
|
86
|
+
status: "not-bound",
|
|
87
|
+
adapterId: adapterId ?? "",
|
|
88
|
+
dateRange,
|
|
89
|
+
metrics: {}
|
|
90
|
+
};
|
|
91
|
+
const binding = runtime.bindings[collectionSlug];
|
|
92
|
+
if (!binding) return {
|
|
93
|
+
status: "not-bound",
|
|
94
|
+
adapterId: adapterId ?? "",
|
|
95
|
+
dateRange,
|
|
96
|
+
metrics: {}
|
|
97
|
+
};
|
|
98
|
+
let adapter;
|
|
99
|
+
try {
|
|
100
|
+
adapter = adapterId ? runtime.registry.get(adapterId) : runtime.registry.default();
|
|
101
|
+
} catch {
|
|
102
|
+
return {
|
|
103
|
+
status: "unavailable",
|
|
104
|
+
adapterId: adapterId ?? "",
|
|
105
|
+
dateRange,
|
|
106
|
+
metrics: {}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
let path;
|
|
110
|
+
try {
|
|
111
|
+
path = await resolvePathCached(binding, data, {
|
|
112
|
+
req,
|
|
113
|
+
locale: req.locale ?? void 0
|
|
114
|
+
});
|
|
115
|
+
} catch {
|
|
116
|
+
path = null;
|
|
117
|
+
}
|
|
118
|
+
if (!path) return {
|
|
119
|
+
status: "no-path",
|
|
120
|
+
adapterId: adapter.id,
|
|
121
|
+
dateRange,
|
|
122
|
+
metrics: {}
|
|
123
|
+
};
|
|
124
|
+
if (!adapter.isConfigured()) return {
|
|
125
|
+
status: "not-configured",
|
|
126
|
+
adapterId: adapter.id,
|
|
127
|
+
dateRange,
|
|
128
|
+
metrics: {}
|
|
129
|
+
};
|
|
130
|
+
if (!satisfiesCapabilities(adapter.capabilities, {
|
|
131
|
+
metrics,
|
|
132
|
+
perPageQuery: true
|
|
133
|
+
})) return {
|
|
134
|
+
status: "unavailable",
|
|
135
|
+
adapterId: adapter.id,
|
|
136
|
+
dateRange,
|
|
137
|
+
metrics: {}
|
|
138
|
+
};
|
|
139
|
+
const result = await runtime.engine.read(adapter, {
|
|
140
|
+
path,
|
|
141
|
+
hostname: resolveHostname(binding, data),
|
|
142
|
+
metrics,
|
|
143
|
+
dateRange
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
status: "ok",
|
|
147
|
+
adapterId: adapter.id,
|
|
148
|
+
dateRange,
|
|
149
|
+
metrics: result.totals ?? {}
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/fields/AnalyticsStatField.tsx
|
|
154
|
+
const STATE_KEYS = {
|
|
155
|
+
"no-path": keys.stateNoData,
|
|
156
|
+
"not-bound": keys.stateNotBound,
|
|
157
|
+
"not-configured": keys.stateNotConfigured,
|
|
158
|
+
unavailable: keys.stateUnavailable
|
|
159
|
+
};
|
|
160
|
+
const wrapStyle = {
|
|
161
|
+
display: "flex",
|
|
162
|
+
flexWrap: "wrap",
|
|
163
|
+
gap: "var(--base, 1rem)",
|
|
164
|
+
alignItems: "flex-end"
|
|
165
|
+
};
|
|
166
|
+
const cardStyle$1 = {
|
|
167
|
+
display: "flex",
|
|
168
|
+
flexDirection: "column",
|
|
169
|
+
gap: "0.25rem"
|
|
170
|
+
};
|
|
171
|
+
const labelStyle$1 = {
|
|
172
|
+
fontSize: "0.75rem",
|
|
173
|
+
opacity: .6,
|
|
174
|
+
textTransform: "uppercase"
|
|
175
|
+
};
|
|
176
|
+
const valueStyle = {
|
|
177
|
+
fontSize: "1.5rem",
|
|
178
|
+
fontWeight: 600,
|
|
179
|
+
lineHeight: 1.1
|
|
180
|
+
};
|
|
181
|
+
const captionStyle = {
|
|
182
|
+
fontSize: "0.75rem",
|
|
183
|
+
opacity: .5,
|
|
184
|
+
width: "100%"
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Read-only server component for a per-document analytics stat (or row of stats).
|
|
188
|
+
* Resolves the document's bound path, reads through the surfacing engine, and renders
|
|
189
|
+
* static markup. Interactivity (timeframe picker, refresh) is intentionally deferred.
|
|
190
|
+
*/
|
|
191
|
+
const AnalyticsStatField = async (props) => {
|
|
192
|
+
const { req, data, collectionSlug, i18n, metrics, timeframe, adapterId } = props;
|
|
193
|
+
const t = asTranslate(i18n.t);
|
|
194
|
+
const locale = i18n.language ?? "en-US";
|
|
195
|
+
const result = await readForField({
|
|
196
|
+
req,
|
|
197
|
+
collectionSlug,
|
|
198
|
+
data,
|
|
199
|
+
metrics,
|
|
200
|
+
timeframe,
|
|
201
|
+
adapterId,
|
|
202
|
+
now: /* @__PURE__ */ new Date()
|
|
203
|
+
});
|
|
204
|
+
if (result.status !== "ok") return /* @__PURE__ */ jsx("div", {
|
|
205
|
+
className: "field-type",
|
|
206
|
+
style: { opacity: .6 },
|
|
207
|
+
children: t(STATE_KEYS[result.status])
|
|
208
|
+
});
|
|
209
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
210
|
+
className: "field-type",
|
|
211
|
+
style: wrapStyle,
|
|
212
|
+
children: [metrics.map((metric) => /* @__PURE__ */ jsxs("div", {
|
|
213
|
+
style: cardStyle$1,
|
|
214
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
215
|
+
style: labelStyle$1,
|
|
216
|
+
children: t(METRIC_KEYS[metric])
|
|
217
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
218
|
+
style: valueStyle,
|
|
219
|
+
children: formatMetricValue(metric, result.metrics[metric] ?? 0, locale)
|
|
220
|
+
})]
|
|
221
|
+
}, metric)), /* @__PURE__ */ jsx("span", {
|
|
222
|
+
style: captionStyle,
|
|
223
|
+
children: t(TIMEFRAME_KEYS[timeframe])
|
|
224
|
+
})]
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/widgets/cardChrome.ts
|
|
229
|
+
const cardStyle = {
|
|
230
|
+
display: "flex",
|
|
231
|
+
flexDirection: "column",
|
|
232
|
+
gap: "0.375rem",
|
|
233
|
+
padding: "var(--base, 1rem)",
|
|
234
|
+
background: "var(--theme-elevation-50)",
|
|
235
|
+
border: "1px solid var(--theme-elevation-150)",
|
|
236
|
+
borderRadius: "var(--style-radius-m, 6px)",
|
|
237
|
+
boxSizing: "border-box"
|
|
238
|
+
};
|
|
239
|
+
const labelStyle = {
|
|
240
|
+
fontSize: "0.6875rem",
|
|
241
|
+
fontWeight: 600,
|
|
242
|
+
letterSpacing: "0.04em",
|
|
243
|
+
textTransform: "uppercase",
|
|
244
|
+
color: "var(--theme-elevation-500)"
|
|
245
|
+
};
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/widgets/AnalyticsBreakdownWidget.tsx
|
|
248
|
+
const STATE_KEY$3 = {
|
|
249
|
+
"not-configured": keys.stateNotConfigured,
|
|
250
|
+
unavailable: keys.stateUnavailable
|
|
251
|
+
};
|
|
252
|
+
async function AnalyticsBreakdownWidget(props) {
|
|
253
|
+
const spec = breakdownSpecBySlug(props.widgetSlug);
|
|
254
|
+
const t = asTranslate(props.req.i18n.t);
|
|
255
|
+
const data = props.widgetData ?? {};
|
|
256
|
+
const metric = data.metric ?? "pageviews";
|
|
257
|
+
const rawTimeframe = data.timeframe ?? "last30days";
|
|
258
|
+
const customRange = resolveCustomRange(rawTimeframe, data.range);
|
|
259
|
+
const timeframe = rawTimeframe === "custom" ? "last30days" : rawTimeframe;
|
|
260
|
+
const limit = data.limit ?? 5;
|
|
261
|
+
const title = data.title?.trim() || (spec ? t(spec.label) : "");
|
|
262
|
+
if (!spec) return /* @__PURE__ */ jsx("div", {
|
|
263
|
+
className: "analytics-breakdown-widget",
|
|
264
|
+
style: cardStyle,
|
|
265
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
266
|
+
style: { color: "var(--theme-elevation-400)" },
|
|
267
|
+
children: t(keys.stateUnavailable)
|
|
268
|
+
})
|
|
269
|
+
});
|
|
270
|
+
const result = await readForWidgetBreakdown({
|
|
271
|
+
req: props.req,
|
|
272
|
+
metric,
|
|
273
|
+
dimension: spec.dimension,
|
|
274
|
+
timeframe,
|
|
275
|
+
limit,
|
|
276
|
+
adapterId: data.dataSource,
|
|
277
|
+
now: /* @__PURE__ */ new Date(),
|
|
278
|
+
range: customRange
|
|
279
|
+
});
|
|
280
|
+
const locale = props.req.i18n.language ?? "en-US";
|
|
281
|
+
const caption = customRange ? formatRangeCaption(customRange, locale) : t(TIMEFRAME_KEYS[timeframe]);
|
|
282
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
283
|
+
className: "analytics-breakdown-widget",
|
|
284
|
+
style: cardStyle,
|
|
285
|
+
children: [
|
|
286
|
+
/* @__PURE__ */ jsx("span", {
|
|
287
|
+
style: labelStyle,
|
|
288
|
+
children: title
|
|
289
|
+
}),
|
|
290
|
+
result.status !== "ok" ? /* @__PURE__ */ jsx("span", {
|
|
291
|
+
style: { color: "var(--theme-elevation-400)" },
|
|
292
|
+
children: t(STATE_KEY$3[result.status])
|
|
293
|
+
}) : /* @__PURE__ */ jsx(BarList, {
|
|
294
|
+
data: result.rows.map((row) => ({
|
|
295
|
+
label: row.label,
|
|
296
|
+
value: row.value,
|
|
297
|
+
display: formatMetricValue(metric, row.value, locale)
|
|
298
|
+
})),
|
|
299
|
+
emptyLabel: t(keys.stateNoBreakdown)
|
|
300
|
+
}),
|
|
301
|
+
/* @__PURE__ */ jsx("span", {
|
|
302
|
+
style: {
|
|
303
|
+
fontSize: "0.75rem",
|
|
304
|
+
color: "var(--theme-elevation-400)"
|
|
305
|
+
},
|
|
306
|
+
children: caption
|
|
307
|
+
}),
|
|
308
|
+
result.status === "ok" && result.clamped ? /* @__PURE__ */ jsx("span", {
|
|
309
|
+
style: {
|
|
310
|
+
fontSize: "0.6875rem",
|
|
311
|
+
color: "var(--theme-elevation-400)"
|
|
312
|
+
},
|
|
313
|
+
children: t(keys.stateClamped)
|
|
314
|
+
}) : null
|
|
315
|
+
]
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/widgets/AnalyticsMetricWidget.tsx
|
|
320
|
+
const STATE_KEY$2 = {
|
|
321
|
+
"not-configured": keys.stateNotConfigured,
|
|
322
|
+
unavailable: keys.stateUnavailable
|
|
323
|
+
};
|
|
324
|
+
async function AnalyticsMetricWidget(props) {
|
|
325
|
+
const data = props.widgetData ?? {};
|
|
326
|
+
const metric = data.metric ?? "pageviews";
|
|
327
|
+
const rawTimeframe = data.timeframe ?? "last30days";
|
|
328
|
+
const customRange = resolveCustomRange(rawTimeframe, data.range);
|
|
329
|
+
const timeframe = rawTimeframe === "custom" ? "last30days" : rawTimeframe;
|
|
330
|
+
const t = asTranslate(props.req.i18n.t);
|
|
331
|
+
const locale = props.req.i18n.language ?? "en-US";
|
|
332
|
+
const title = data.title?.trim() || t(METRIC_KEYS[metric]);
|
|
333
|
+
const caption = customRange ? formatRangeCaption(customRange, locale) : t(TIMEFRAME_KEYS[timeframe]);
|
|
334
|
+
const result = await readForWidget({
|
|
335
|
+
req: props.req,
|
|
336
|
+
metrics: [metric],
|
|
337
|
+
timeframe,
|
|
338
|
+
adapterId: data.dataSource,
|
|
339
|
+
now: /* @__PURE__ */ new Date(),
|
|
340
|
+
range: customRange
|
|
341
|
+
});
|
|
342
|
+
if (result.status !== "ok") return /* @__PURE__ */ jsxs("div", {
|
|
343
|
+
className: "analytics-metric-widget",
|
|
344
|
+
style: cardStyle,
|
|
345
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
346
|
+
style: labelStyle,
|
|
347
|
+
children: title
|
|
348
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
349
|
+
style: { color: "var(--theme-elevation-400)" },
|
|
350
|
+
children: t(STATE_KEY$2[result.status])
|
|
351
|
+
})]
|
|
352
|
+
});
|
|
353
|
+
const value = result.metrics[metric];
|
|
354
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
355
|
+
className: "analytics-metric-widget",
|
|
356
|
+
style: cardStyle,
|
|
357
|
+
children: [
|
|
358
|
+
/* @__PURE__ */ jsx("span", {
|
|
359
|
+
style: labelStyle,
|
|
360
|
+
children: title
|
|
361
|
+
}),
|
|
362
|
+
/* @__PURE__ */ jsx("span", {
|
|
363
|
+
style: {
|
|
364
|
+
fontSize: "2rem",
|
|
365
|
+
fontWeight: 700,
|
|
366
|
+
lineHeight: 1.1,
|
|
367
|
+
color: "var(--theme-elevation-800)"
|
|
368
|
+
},
|
|
369
|
+
children: value === void 0 ? "–" : formatMetricValue(metric, value, locale)
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ jsx("span", {
|
|
372
|
+
style: {
|
|
373
|
+
fontSize: "0.75rem",
|
|
374
|
+
color: "var(--theme-elevation-400)"
|
|
375
|
+
},
|
|
376
|
+
children: caption
|
|
377
|
+
}),
|
|
378
|
+
result.clamped ? /* @__PURE__ */ jsx("span", {
|
|
379
|
+
style: {
|
|
380
|
+
fontSize: "0.6875rem",
|
|
381
|
+
color: "var(--theme-elevation-400)"
|
|
382
|
+
},
|
|
383
|
+
children: t(keys.stateClamped)
|
|
384
|
+
}) : null
|
|
385
|
+
]
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/widgets/AnalyticsRealtimeWidget.tsx
|
|
390
|
+
const STATE_KEY$1 = {
|
|
391
|
+
"not-configured": keys.stateNotConfigured,
|
|
392
|
+
unavailable: keys.stateUnavailable
|
|
393
|
+
};
|
|
394
|
+
const POLL_INTERVAL_MS = 15e3;
|
|
395
|
+
async function AnalyticsRealtimeWidget(props) {
|
|
396
|
+
const data = props.widgetData ?? {};
|
|
397
|
+
const metric = data.metric ?? "visitors";
|
|
398
|
+
const windowMinutes = Number(data.windowMinutes) || 30;
|
|
399
|
+
const t = asTranslate(props.req.i18n.t);
|
|
400
|
+
const locale = props.req.i18n.language ?? "en-US";
|
|
401
|
+
const title = data.title?.trim() || t(keys.widgetRealtimeLabel);
|
|
402
|
+
const result = await readForWidgetRealtime({
|
|
403
|
+
req: props.req,
|
|
404
|
+
metric,
|
|
405
|
+
windowMinutes,
|
|
406
|
+
adapterId: data.dataSource,
|
|
407
|
+
now: /* @__PURE__ */ new Date()
|
|
408
|
+
});
|
|
409
|
+
if (result.status !== "ok") return /* @__PURE__ */ jsxs("div", {
|
|
410
|
+
className: "analytics-realtime-widget",
|
|
411
|
+
style: cardStyle,
|
|
412
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
413
|
+
style: labelStyle,
|
|
414
|
+
children: title
|
|
415
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
416
|
+
style: { color: "var(--theme-elevation-400)" },
|
|
417
|
+
children: t(STATE_KEY$1[result.status])
|
|
418
|
+
})]
|
|
419
|
+
});
|
|
420
|
+
const caption = `${t(METRIC_KEYS[metric])} ${t(keys.widgetRealtimeCaption)}`;
|
|
421
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
422
|
+
className: "analytics-realtime-widget",
|
|
423
|
+
style: cardStyle,
|
|
424
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
425
|
+
style: labelStyle,
|
|
426
|
+
children: title
|
|
427
|
+
}), /* @__PURE__ */ jsx(RealtimeCounter, {
|
|
428
|
+
endpoint: `/api${REALTIME_PATH}`,
|
|
429
|
+
intervalMs: POLL_INTERVAL_MS,
|
|
430
|
+
metric,
|
|
431
|
+
windowMinutes,
|
|
432
|
+
dataSource: data.dataSource,
|
|
433
|
+
initialActiveNow: result.activeNow,
|
|
434
|
+
initialSeries: result.series,
|
|
435
|
+
locale,
|
|
436
|
+
caption,
|
|
437
|
+
pausedLabel: t(keys.widgetRealtimePaused)
|
|
438
|
+
})]
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/charts/bucket.ts
|
|
443
|
+
const UNIT_BY_TIMEFRAME = {
|
|
444
|
+
today: "day",
|
|
445
|
+
last7days: "day",
|
|
446
|
+
last30days: "day",
|
|
447
|
+
thisMonth: "day",
|
|
448
|
+
last90days: "week",
|
|
449
|
+
thisYear: "month",
|
|
450
|
+
lastYear: "month",
|
|
451
|
+
allTime: "month"
|
|
452
|
+
};
|
|
453
|
+
const startOfUtcDay = (d) => new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
|
|
454
|
+
const bucketStart = (d, unit) => {
|
|
455
|
+
if (unit === "month") return new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1));
|
|
456
|
+
if (unit === "week") {
|
|
457
|
+
const day = startOfUtcDay(d);
|
|
458
|
+
const dow = (day.getUTCDay() + 6) % 7;
|
|
459
|
+
day.setUTCDate(day.getUTCDate() - dow);
|
|
460
|
+
return day;
|
|
461
|
+
}
|
|
462
|
+
return startOfUtcDay(d);
|
|
463
|
+
};
|
|
464
|
+
const bucketByUnit = (points, unit, weekday) => {
|
|
465
|
+
const groups = /* @__PURE__ */ new Map();
|
|
466
|
+
for (const p of points) {
|
|
467
|
+
const d = bucketStart(new Date(p.date), unit);
|
|
468
|
+
const key = d.toISOString();
|
|
469
|
+
const g = groups.get(key);
|
|
470
|
+
if (g) g.value += p.value;
|
|
471
|
+
else groups.set(key, {
|
|
472
|
+
date: d,
|
|
473
|
+
value: p.value
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
const sorted = [...groups.values()].sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
477
|
+
const first = sorted[0];
|
|
478
|
+
const last = sorted.at(-1);
|
|
479
|
+
const multiYear = first !== void 0 && last !== void 0 && first.date.getUTCFullYear() !== last.date.getUTCFullYear();
|
|
480
|
+
const format = (d) => {
|
|
481
|
+
if (weekday) return new Intl.DateTimeFormat("en-US", {
|
|
482
|
+
weekday: "short",
|
|
483
|
+
timeZone: "UTC"
|
|
484
|
+
}).format(d);
|
|
485
|
+
if (unit === "month") return new Intl.DateTimeFormat("en-US", {
|
|
486
|
+
month: "short",
|
|
487
|
+
year: multiYear ? "numeric" : void 0,
|
|
488
|
+
timeZone: "UTC"
|
|
489
|
+
}).format(d);
|
|
490
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
491
|
+
month: "short",
|
|
492
|
+
day: "numeric",
|
|
493
|
+
timeZone: "UTC"
|
|
494
|
+
}).format(d);
|
|
495
|
+
};
|
|
496
|
+
return sorted.map((g) => ({
|
|
497
|
+
label: format(g.date),
|
|
498
|
+
value: g.value
|
|
499
|
+
}));
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* Aggregate a daily series into display buckets sized to the timeframe (day for short
|
|
503
|
+
* ranges, week for ~quarter, month for year+), each with a formatted label. Distinct
|
|
504
|
+
* metrics are summed per bucket (a documented daily-uniques approximation).
|
|
505
|
+
*/
|
|
506
|
+
const bucketSeries = (points, timeframe, _now) => bucketByUnit(points, UNIT_BY_TIMEFRAME[timeframe], timeframe === "last7days" || timeframe === "today");
|
|
507
|
+
const DAY = 864e5;
|
|
508
|
+
const unitForSpan = (spanDays) => spanDays <= 31 ? "day" : spanDays <= 120 ? "week" : "month";
|
|
509
|
+
/**
|
|
510
|
+
* Bucket a daily series for a custom (arbitrary) range, choosing the bucket unit from
|
|
511
|
+
* the span the way the presets do: short ranges by day, a quarter by week, longer by
|
|
512
|
+
* month. Weekday labels are only used for the fixed 7-day preset, never here.
|
|
513
|
+
*/
|
|
514
|
+
const bucketByRange = (points, range) => {
|
|
515
|
+
return bucketByUnit(points, unitForSpan(Math.round((range.end.getTime() - range.start.getTime()) / DAY)), false);
|
|
516
|
+
};
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/widgets/AnalyticsTrendWidget.tsx
|
|
519
|
+
const STATE_KEY = {
|
|
520
|
+
"not-configured": keys.stateNotConfigured,
|
|
521
|
+
unavailable: keys.stateUnavailable
|
|
522
|
+
};
|
|
523
|
+
async function AnalyticsTrendWidget(props) {
|
|
524
|
+
const data = props.widgetData ?? {};
|
|
525
|
+
const metric = data.metric ?? "pageviews";
|
|
526
|
+
const rawTimeframe = data.timeframe ?? "last30days";
|
|
527
|
+
const customRange = resolveCustomRange(rawTimeframe, data.range);
|
|
528
|
+
const timeframe = rawTimeframe === "custom" ? "last30days" : rawTimeframe;
|
|
529
|
+
const t = asTranslate(props.req.i18n.t);
|
|
530
|
+
const locale = props.req.i18n.language ?? "en-US";
|
|
531
|
+
const title = data.title?.trim() || t(METRIC_KEYS[metric]);
|
|
532
|
+
const result = await readForWidgetSeries({
|
|
533
|
+
req: props.req,
|
|
534
|
+
metric,
|
|
535
|
+
timeframe,
|
|
536
|
+
adapterId: data.dataSource,
|
|
537
|
+
now: /* @__PURE__ */ new Date(),
|
|
538
|
+
range: customRange
|
|
539
|
+
});
|
|
540
|
+
if (result.status !== "ok") return /* @__PURE__ */ jsxs("div", {
|
|
541
|
+
className: "analytics-trend-widget",
|
|
542
|
+
style: cardStyle,
|
|
543
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
544
|
+
style: labelStyle,
|
|
545
|
+
children: title
|
|
546
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
547
|
+
style: { color: "var(--theme-elevation-400)" },
|
|
548
|
+
children: t(STATE_KEY[result.status])
|
|
549
|
+
})]
|
|
550
|
+
});
|
|
551
|
+
const caption = customRange ? formatRangeCaption(customRange, locale) : t(TIMEFRAME_KEYS[timeframe]);
|
|
552
|
+
const trendPoints = (customRange ? bucketByRange(result.points, customRange) : bucketSeries(result.points, timeframe, /* @__PURE__ */ new Date())).map((b) => ({
|
|
553
|
+
...b,
|
|
554
|
+
display: formatMetricValue(metric, b.value, locale)
|
|
555
|
+
}));
|
|
556
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
557
|
+
className: "analytics-trend-widget",
|
|
558
|
+
style: cardStyle,
|
|
559
|
+
children: [
|
|
560
|
+
/* @__PURE__ */ jsx("span", {
|
|
561
|
+
style: labelStyle,
|
|
562
|
+
children: title
|
|
563
|
+
}),
|
|
564
|
+
/* @__PURE__ */ jsx("span", {
|
|
565
|
+
style: {
|
|
566
|
+
fontSize: "1.75rem",
|
|
567
|
+
fontWeight: 700,
|
|
568
|
+
lineHeight: 1.1,
|
|
569
|
+
color: "var(--theme-elevation-800)"
|
|
570
|
+
},
|
|
571
|
+
children: formatMetricValue(metric, result.total, locale)
|
|
572
|
+
}),
|
|
573
|
+
/* @__PURE__ */ jsx(TrendChart, {
|
|
574
|
+
buckets: trendPoints,
|
|
575
|
+
ariaLabel: `${title} ${caption}`,
|
|
576
|
+
minHeight: 180
|
|
577
|
+
}),
|
|
578
|
+
/* @__PURE__ */ jsx("span", {
|
|
579
|
+
style: {
|
|
580
|
+
fontSize: "0.75rem",
|
|
581
|
+
color: "var(--theme-elevation-400)"
|
|
582
|
+
},
|
|
583
|
+
children: caption
|
|
584
|
+
}),
|
|
585
|
+
result.clamped ? /* @__PURE__ */ jsx("span", {
|
|
586
|
+
style: {
|
|
587
|
+
fontSize: "0.6875rem",
|
|
588
|
+
color: "var(--theme-elevation-400)"
|
|
589
|
+
},
|
|
590
|
+
children: t(keys.stateClamped)
|
|
591
|
+
}) : null
|
|
592
|
+
]
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
//#endregion
|
|
596
|
+
export { AnalyticsBreakdownWidget, AnalyticsMetricWidget, AnalyticsRealtimeWidget, AnalyticsStatField, AnalyticsTrendWidget, formatMetricValue, readForWidget, readForWidgetBreakdown, readForWidgetRealtime, readForWidgetSeries };
|
|
597
|
+
|
|
598
|
+
//# sourceMappingURL=rsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc.js","names":["cardStyle","labelStyle","STATE_KEY","STATE_KEY","STATE_KEY"],"sources":["../../src/fields/format.ts","../../src/binding/resolvePath.ts","../../src/fields/readForDocument.ts","../../src/fields/AnalyticsStatField.tsx","../../src/widgets/cardChrome.ts","../../src/widgets/AnalyticsBreakdownWidget.tsx","../../src/widgets/AnalyticsMetricWidget.tsx","../../src/widgets/AnalyticsRealtimeWidget.tsx","../../src/charts/bucket.ts","../../src/widgets/AnalyticsTrendWidget.tsx"],"sourcesContent":["import type { MetricKey } from '../core/contract'\n\nexport const formatDuration = (ms: number): string => {\n\tconst totalSeconds = Math.round(ms / 1000)\n\tif (totalSeconds < 60) return `${totalSeconds}s`\n\tconst minutes = Math.floor(totalSeconds / 60)\n\tconst seconds = totalSeconds % 60\n\tif (minutes < 60) return seconds === 0 ? `${minutes}m` : `${minutes}m ${seconds}s`\n\tconst hours = Math.floor(minutes / 60)\n\tconst remMinutes = minutes % 60\n\treturn remMinutes === 0 ? `${hours}h` : `${hours}h ${remMinutes}m`\n}\n\nexport const formatCount = (value: number, locale: string): string =>\n\tnew Intl.NumberFormat(locale).format(value)\n\nconst PERCENT_METRICS: ReadonlySet<MetricKey> = new Set(['bounceRate', 'scrollDepth'])\n\nexport const formatMetricValue = (metric: MetricKey, value: number, locale: string): string => {\n\tif (metric === 'avgDuration') return formatDuration(value)\n\tif (PERCENT_METRICS.has(metric)) return `${Math.round(value)}%`\n\treturn formatCount(value, locale)\n}\n","import type { AnalyticsBinding, BindingContext, BindingDoc } from './types'\n\nconst getByPath = (doc: BindingDoc, dotPath: string): unknown =>\n\tdotPath.split('.').reduce<unknown>((value, key) => {\n\t\tif (value && typeof value === 'object') {\n\t\t\treturn (value as Record<string, unknown>)[key]\n\t\t}\n\t\treturn undefined\n\t}, doc)\n\nconst nonEmptyString = (value: unknown): value is string =>\n\ttypeof value === 'string' && value.length > 0\n\n/**\n * Resolve a document's analytics path. The `path` resolver wins; the `pathField`\n * value is the fallback. Returns null when neither yields a non-empty string (for\n * example an unsaved document with no slug yet).\n */\nexport const resolvePath = async (\n\tbinding: AnalyticsBinding,\n\tdoc: BindingDoc,\n\tctx: BindingContext\n): Promise<string | null> => {\n\tif (binding.path) {\n\t\tconst resolved = await binding.path(doc, ctx)\n\t\tif (nonEmptyString(resolved)) return resolved\n\t}\n\tif (binding.pathField) {\n\t\tconst value = getByPath(doc, binding.pathField)\n\t\tif (nonEmptyString(value)) return value\n\t}\n\treturn null\n}\n\nconst CACHE_KEY = '__analyticsPathCache'\n\n/**\n * Resolve the path once per (doc, request): the same `doc` reference is handed to\n * every analytics field on a document, so caching the in-flight Promise on\n * `req.context` collapses an async (possibly ancestor-walking) resolver from once per\n * field to once per document, and shares it across concurrent field renders. When the\n * request carries no context bag (incomplete reqs in tests or unusual call sites), it\n * degrades to a direct, un-memoized resolve so the result stays correct.\n */\nexport const resolvePathCached = (\n\tbinding: AnalyticsBinding,\n\tdoc: BindingDoc,\n\tctx: BindingContext\n): Promise<string | null> => {\n\tconst context = ctx.req.context as Record<string, unknown> | undefined\n\tif (!context) {\n\t\treturn resolvePath(binding, doc, ctx)\n\t}\n\tlet cache = context[CACHE_KEY] as WeakMap<BindingDoc, Promise<string | null>> | undefined\n\tif (!cache) {\n\t\tcache = new WeakMap()\n\t\tcontext[CACHE_KEY] = cache\n\t}\n\tlet cached = cache.get(doc)\n\tif (!cached) {\n\t\tcached = resolvePath(binding, doc, ctx)\n\t\tcache.set(doc, cached)\n\t}\n\treturn cached\n}\n\nexport const resolveHostname = (binding: AnalyticsBinding, doc: BindingDoc): string | undefined => {\n\tif (typeof binding.hostname === 'function') return binding.hostname(doc)\n\treturn binding.hostname\n}\n","import type { PayloadRequest } from 'payload'\nimport { resolveHostname, resolvePathCached } from '../binding/resolvePath'\nimport type { BindingDoc } from '../binding/types'\nimport { satisfiesCapabilities } from '../core/capabilities'\nimport type { AnalyticsAdapter, DateRange, MetricKey } from '../core/contract'\nimport { getRuntime } from '../plugin/runtime'\nimport { resolveTimeframe, type TimeframePreset } from '../timeframe/presets'\n\nexport type FieldReadStatus = 'ok' | 'no-path' | 'not-bound' | 'not-configured' | 'unavailable'\n\nexport interface FieldReadResult {\n\tstatus: FieldReadStatus\n\tadapterId: string\n\tdateRange: DateRange\n\tmetrics: Partial<Record<MetricKey, number>>\n}\n\nexport interface ReadForFieldArgs {\n\treq: PayloadRequest\n\tcollectionSlug: string\n\tdata: BindingDoc\n\tmetrics: MetricKey[]\n\ttimeframe: TimeframePreset\n\tadapterId?: string\n\tnow: Date\n}\n\n/**\n * Resolve a document's analytics for one display field: look up the runtime, resolve\n * the bound path, capability-gate the requested metrics against the active adapter,\n * then read through the surfacing engine. Returns a discriminated status so the\n * rendering component can show the right empty state without throwing.\n */\nexport const readForField = async (args: ReadForFieldArgs): Promise<FieldReadResult> => {\n\tconst { req, collectionSlug, data, metrics, timeframe, adapterId, now } = args\n\tconst dateRange = resolveTimeframe(timeframe, now)\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn { status: 'not-bound', adapterId: adapterId ?? '', dateRange, metrics: {} }\n\t}\n\tconst binding = runtime.bindings[collectionSlug]\n\tif (!binding) {\n\t\treturn { status: 'not-bound', adapterId: adapterId ?? '', dateRange, metrics: {} }\n\t}\n\tlet adapter: AnalyticsAdapter\n\ttry {\n\t\tadapter = adapterId ? runtime.registry.get(adapterId) : runtime.registry.default()\n\t} catch {\n\t\treturn { status: 'unavailable', adapterId: adapterId ?? '', dateRange, metrics: {} }\n\t}\n\tlet path: string | null\n\ttry {\n\t\tpath = await resolvePathCached(binding, data, { req, locale: req.locale ?? undefined })\n\t} catch {\n\t\tpath = null\n\t}\n\tif (!path) {\n\t\treturn { status: 'no-path', adapterId: adapter.id, dateRange, metrics: {} }\n\t}\n\tif (!adapter.isConfigured()) {\n\t\treturn { status: 'not-configured', adapterId: adapter.id, dateRange, metrics: {} }\n\t}\n\tif (!satisfiesCapabilities(adapter.capabilities, { metrics, perPageQuery: true })) {\n\t\treturn { status: 'unavailable', adapterId: adapter.id, dateRange, metrics: {} }\n\t}\n\tconst result = await runtime.engine.read(adapter, {\n\t\tpath,\n\t\thostname: resolveHostname(binding, data),\n\t\tmetrics,\n\t\tdateRange,\n\t})\n\treturn { status: 'ok', adapterId: adapter.id, dateRange, metrics: result.totals ?? {} }\n}\n","import type { PayloadRequest } from 'payload'\nimport type { CSSProperties } from 'react'\nimport type { BindingDoc } from '../binding/types'\nimport type { MetricKey } from '../core/contract'\nimport type { TimeframePreset } from '../timeframe/presets'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { METRIC_KEYS, TIMEFRAME_KEYS } from '../translations/metricKeys'\nimport { asTranslate } from '../translations/server'\nimport { formatMetricValue } from './format'\nimport { type FieldReadStatus, readForField } from './readForDocument'\n\ninterface AnalyticsStatFieldProps {\n\treq: PayloadRequest\n\tdata: BindingDoc\n\tcollectionSlug: string\n\ti18n: { t: unknown; language?: string }\n\tmetrics: MetricKey[]\n\ttimeframe: TimeframePreset\n\tvariant: 'stat' | 'row'\n\tadapterId?: string\n}\n\nconst STATE_KEYS: Record<Exclude<FieldReadStatus, 'ok'>, TranslationKey> = {\n\t'no-path': keys.stateNoData,\n\t'not-bound': keys.stateNotBound,\n\t'not-configured': keys.stateNotConfigured,\n\tunavailable: keys.stateUnavailable,\n}\n\nconst wrapStyle: CSSProperties = {\n\tdisplay: 'flex',\n\tflexWrap: 'wrap',\n\tgap: 'var(--base, 1rem)',\n\talignItems: 'flex-end',\n}\nconst cardStyle: CSSProperties = { display: 'flex', flexDirection: 'column', gap: '0.25rem' }\nconst labelStyle: CSSProperties = { fontSize: '0.75rem', opacity: 0.6, textTransform: 'uppercase' }\nconst valueStyle: CSSProperties = { fontSize: '1.5rem', fontWeight: 600, lineHeight: 1.1 }\nconst captionStyle: CSSProperties = { fontSize: '0.75rem', opacity: 0.5, width: '100%' }\n\n/**\n * Read-only server component for a per-document analytics stat (or row of stats).\n * Resolves the document's bound path, reads through the surfacing engine, and renders\n * static markup. Interactivity (timeframe picker, refresh) is intentionally deferred.\n */\nexport const AnalyticsStatField = async (props: AnalyticsStatFieldProps) => {\n\tconst { req, data, collectionSlug, i18n, metrics, timeframe, adapterId } = props\n\tconst t = asTranslate(i18n.t)\n\tconst locale = i18n.language ?? 'en-US'\n\n\tconst result = await readForField({\n\t\treq,\n\t\tcollectionSlug,\n\t\tdata,\n\t\tmetrics,\n\t\ttimeframe,\n\t\tadapterId,\n\t\tnow: new Date(),\n\t})\n\n\tif (result.status !== 'ok') {\n\t\treturn (\n\t\t\t<div className=\"field-type\" style={{ opacity: 0.6 }}>\n\t\t\t\t{t(STATE_KEYS[result.status])}\n\t\t\t</div>\n\t\t)\n\t}\n\n\treturn (\n\t\t<div className=\"field-type\" style={wrapStyle}>\n\t\t\t{metrics.map((metric) => (\n\t\t\t\t<div key={metric} style={cardStyle}>\n\t\t\t\t\t<span style={labelStyle}>{t(METRIC_KEYS[metric])}</span>\n\t\t\t\t\t<span style={valueStyle}>\n\t\t\t\t\t\t{formatMetricValue(metric, result.metrics[metric] ?? 0, locale)}\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t))}\n\t\t\t<span style={captionStyle}>{t(TIMEFRAME_KEYS[timeframe])}</span>\n\t\t</div>\n\t)\n}\n","import type { CSSProperties } from 'react'\n\nexport const cardStyle: CSSProperties = {\n\tdisplay: 'flex',\n\tflexDirection: 'column',\n\tgap: '0.375rem',\n\tpadding: 'var(--base, 1rem)',\n\tbackground: 'var(--theme-elevation-50)',\n\tborder: '1px solid var(--theme-elevation-150)',\n\tborderRadius: 'var(--style-radius-m, 6px)',\n\tboxSizing: 'border-box',\n}\n\nexport const labelStyle: CSSProperties = {\n\tfontSize: '0.6875rem',\n\tfontWeight: 600,\n\tletterSpacing: '0.04em',\n\ttextTransform: 'uppercase',\n\tcolor: 'var(--theme-elevation-500)',\n}\n","import type { WidgetServerProps } from 'payload'\nimport { BarList } from '../charts/BarList'\nimport type { MetricKey } from '../core/contract'\nimport { formatMetricValue } from '../fields/format'\nimport type { TimeframePreset } from '../timeframe/presets'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { TIMEFRAME_KEYS } from '../translations/metricKeys'\nimport { asTranslate } from '../translations/server'\nimport { type BreakdownWidgetData, breakdownSpecBySlug } from './breakdownTypes'\nimport { cardStyle, labelStyle } from './cardChrome'\nimport { formatRangeCaption, resolveCustomRange } from './range'\nimport type { WidgetReadStatus } from './readForWidget'\nimport { readForWidgetBreakdown } from './readForWidgetBreakdown'\n\nconst STATE_KEY: Record<Exclude<WidgetReadStatus, 'ok'>, TranslationKey> = {\n\t'not-configured': keys.stateNotConfigured,\n\tunavailable: keys.stateUnavailable,\n}\n\nexport default async function AnalyticsBreakdownWidget(props: WidgetServerProps) {\n\tconst spec = breakdownSpecBySlug(props.widgetSlug)\n\tconst t = asTranslate(props.req.i18n.t)\n\tconst data = (props.widgetData ?? {}) as BreakdownWidgetData\n\tconst metric: MetricKey = data.metric ?? 'pageviews'\n\tconst rawTimeframe = data.timeframe ?? 'last30days'\n\tconst customRange = resolveCustomRange(rawTimeframe, data.range)\n\tconst timeframe: TimeframePreset = rawTimeframe === 'custom' ? 'last30days' : rawTimeframe\n\tconst limit = data.limit ?? 5\n\tconst title = data.title?.trim() || (spec ? t(spec.label) : '')\n\n\tif (!spec) {\n\t\treturn (\n\t\t\t<div className=\"analytics-breakdown-widget\" style={cardStyle}>\n\t\t\t\t<span style={{ color: 'var(--theme-elevation-400)' }}>{t(keys.stateUnavailable)}</span>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tconst result = await readForWidgetBreakdown({\n\t\treq: props.req,\n\t\tmetric,\n\t\tdimension: spec.dimension,\n\t\ttimeframe,\n\t\tlimit,\n\t\tadapterId: data.dataSource,\n\t\tnow: new Date(),\n\t\trange: customRange,\n\t})\n\n\tconst locale = props.req.i18n.language ?? 'en-US'\n\tconst caption = customRange\n\t\t? formatRangeCaption(customRange, locale)\n\t\t: t(TIMEFRAME_KEYS[timeframe])\n\treturn (\n\t\t<div className=\"analytics-breakdown-widget\" style={cardStyle}>\n\t\t\t<span style={labelStyle}>{title}</span>\n\t\t\t{result.status !== 'ok' ? (\n\t\t\t\t<span style={{ color: 'var(--theme-elevation-400)' }}>{t(STATE_KEY[result.status])}</span>\n\t\t\t) : (\n\t\t\t\t<BarList\n\t\t\t\t\tdata={result.rows.map((row) => ({\n\t\t\t\t\t\tlabel: row.label,\n\t\t\t\t\t\tvalue: row.value,\n\t\t\t\t\t\tdisplay: formatMetricValue(metric, row.value, locale),\n\t\t\t\t\t}))}\n\t\t\t\t\temptyLabel={t(keys.stateNoBreakdown)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<span style={{ fontSize: '0.75rem', color: 'var(--theme-elevation-400)' }}>{caption}</span>\n\t\t\t{result.status === 'ok' && result.clamped ? (\n\t\t\t\t<span style={{ fontSize: '0.6875rem', color: 'var(--theme-elevation-400)' }}>\n\t\t\t\t\t{t(keys.stateClamped)}\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n","import type { WidgetServerProps } from 'payload'\nimport type { MetricKey } from '../core/contract'\nimport { formatMetricValue } from '../fields/format'\nimport type { TimeframePreset } from '../timeframe/presets'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { METRIC_KEYS, TIMEFRAME_KEYS } from '../translations/metricKeys'\nimport { asTranslate } from '../translations/server'\nimport { cardStyle, labelStyle } from './cardChrome'\nimport { formatRangeCaption, resolveCustomRange } from './range'\nimport { readForWidget, type WidgetReadStatus } from './readForWidget'\nimport type { MetricWidgetData } from './types'\n\nconst STATE_KEY: Record<Exclude<WidgetReadStatus, 'ok'>, TranslationKey> = {\n\t'not-configured': keys.stateNotConfigured,\n\tunavailable: keys.stateUnavailable,\n}\n\nexport default async function AnalyticsMetricWidget(props: WidgetServerProps) {\n\tconst data = (props.widgetData ?? {}) as MetricWidgetData\n\tconst metric: MetricKey = data.metric ?? 'pageviews'\n\tconst rawTimeframe = data.timeframe ?? 'last30days'\n\tconst customRange = resolveCustomRange(rawTimeframe, data.range)\n\tconst timeframe: TimeframePreset = rawTimeframe === 'custom' ? 'last30days' : rawTimeframe\n\tconst t = asTranslate(props.req.i18n.t)\n\tconst locale = props.req.i18n.language ?? 'en-US'\n\tconst title = data.title?.trim() || t(METRIC_KEYS[metric])\n\tconst caption = customRange\n\t\t? formatRangeCaption(customRange, locale)\n\t\t: t(TIMEFRAME_KEYS[timeframe])\n\n\tconst result = await readForWidget({\n\t\treq: props.req,\n\t\tmetrics: [metric],\n\t\ttimeframe,\n\t\tadapterId: data.dataSource,\n\t\tnow: new Date(),\n\t\trange: customRange,\n\t})\n\n\tif (result.status !== 'ok') {\n\t\treturn (\n\t\t\t<div className=\"analytics-metric-widget\" style={cardStyle}>\n\t\t\t\t<span style={labelStyle}>{title}</span>\n\t\t\t\t<span style={{ color: 'var(--theme-elevation-400)' }}>{t(STATE_KEY[result.status])}</span>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tconst value = result.metrics[metric]\n\treturn (\n\t\t<div className=\"analytics-metric-widget\" style={cardStyle}>\n\t\t\t<span style={labelStyle}>{title}</span>\n\t\t\t<span\n\t\t\t\tstyle={{\n\t\t\t\t\tfontSize: '2rem',\n\t\t\t\t\tfontWeight: 700,\n\t\t\t\t\tlineHeight: 1.1,\n\t\t\t\t\tcolor: 'var(--theme-elevation-800)',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{value === undefined ? '–' : formatMetricValue(metric, value, locale)}\n\t\t\t</span>\n\t\t\t<span style={{ fontSize: '0.75rem', color: 'var(--theme-elevation-400)' }}>{caption}</span>\n\t\t\t{result.clamped ? (\n\t\t\t\t<span style={{ fontSize: '0.6875rem', color: 'var(--theme-elevation-400)' }}>\n\t\t\t\t\t{t(keys.stateClamped)}\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n","import type { WidgetServerProps } from 'payload'\nimport type { MetricKey } from '../core/contract'\nimport { REALTIME_PATH } from '../plugin/realtimeEndpoint'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { METRIC_KEYS } from '../translations/metricKeys'\nimport { asTranslate } from '../translations/server'\nimport { cardStyle, labelStyle } from './cardChrome'\nimport { RealtimeCounter } from './RealtimeCounter'\nimport { readForWidgetRealtime, type WidgetRealtimeStatus } from './readForWidgetRealtime'\n\nconst STATE_KEY: Record<Exclude<WidgetRealtimeStatus, 'ok'>, TranslationKey> = {\n\t'not-configured': keys.stateNotConfigured,\n\tunavailable: keys.stateUnavailable,\n}\n\ninterface RealtimeWidgetData {\n\ttitle?: string\n\tmetric?: 'visitors' | 'pageviews'\n\twindowMinutes?: number | string\n\tdataSource?: string\n}\n\nconst POLL_INTERVAL_MS = 15_000\n\nexport default async function AnalyticsRealtimeWidget(props: WidgetServerProps) {\n\tconst data = (props.widgetData ?? {}) as RealtimeWidgetData\n\tconst metric: MetricKey = data.metric ?? 'visitors'\n\tconst windowMinutes = Number(data.windowMinutes) || 30\n\tconst t = asTranslate(props.req.i18n.t)\n\tconst locale = props.req.i18n.language ?? 'en-US'\n\tconst title = data.title?.trim() || t(keys.widgetRealtimeLabel)\n\n\tconst result = await readForWidgetRealtime({\n\t\treq: props.req,\n\t\tmetric,\n\t\twindowMinutes,\n\t\tadapterId: data.dataSource,\n\t\tnow: new Date(),\n\t})\n\n\tif (result.status !== 'ok') {\n\t\treturn (\n\t\t\t<div className=\"analytics-realtime-widget\" style={cardStyle}>\n\t\t\t\t<span style={labelStyle}>{title}</span>\n\t\t\t\t<span style={{ color: 'var(--theme-elevation-400)' }}>{t(STATE_KEY[result.status])}</span>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tconst caption = `${t(METRIC_KEYS[metric])} ${t(keys.widgetRealtimeCaption)}`\n\treturn (\n\t\t<div className=\"analytics-realtime-widget\" style={cardStyle}>\n\t\t\t<span style={labelStyle}>{title}</span>\n\t\t\t<RealtimeCounter\n\t\t\t\tendpoint={`/api${REALTIME_PATH}`}\n\t\t\t\tintervalMs={POLL_INTERVAL_MS}\n\t\t\t\tmetric={metric}\n\t\t\t\twindowMinutes={windowMinutes}\n\t\t\t\tdataSource={data.dataSource}\n\t\t\t\tinitialActiveNow={result.activeNow}\n\t\t\t\tinitialSeries={result.series}\n\t\t\t\tlocale={locale}\n\t\t\t\tcaption={caption}\n\t\t\t\tpausedLabel={t(keys.widgetRealtimePaused)}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n","import type { DateRange } from '../core/contract'\nimport type { TimeframePreset } from '../timeframe/presets'\nimport type { SeriesPoint } from '../widgets/readForWidgetSeries'\n\nexport interface ChartBucket {\n\tlabel: string\n\tvalue: number\n}\n\ntype Unit = 'day' | 'week' | 'month'\n\nconst UNIT_BY_TIMEFRAME: Record<TimeframePreset, Unit> = {\n\ttoday: 'day',\n\tlast7days: 'day',\n\tlast30days: 'day',\n\tthisMonth: 'day',\n\tlast90days: 'week',\n\tthisYear: 'month',\n\tlastYear: 'month',\n\tallTime: 'month',\n}\n\nconst startOfUtcDay = (d: Date): Date =>\n\tnew Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()))\n\nconst bucketStart = (d: Date, unit: Unit): Date => {\n\tif (unit === 'month') return new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1))\n\tif (unit === 'week') {\n\t\tconst day = startOfUtcDay(d)\n\t\tconst dow = (day.getUTCDay() + 6) % 7\n\t\tday.setUTCDate(day.getUTCDate() - dow)\n\t\treturn day\n\t}\n\treturn startOfUtcDay(d)\n}\n\nconst bucketByUnit = (points: SeriesPoint[], unit: Unit, weekday: boolean): ChartBucket[] => {\n\tconst groups = new Map<string, { date: Date; value: number }>()\n\tfor (const p of points) {\n\t\tconst d = bucketStart(new Date(p.date), unit)\n\t\tconst key = d.toISOString()\n\t\tconst g = groups.get(key)\n\t\tif (g) {\n\t\t\tg.value += p.value\n\t\t} else {\n\t\t\tgroups.set(key, { date: d, value: p.value })\n\t\t}\n\t}\n\tconst sorted = [...groups.values()].sort((a, b) => a.date.getTime() - b.date.getTime())\n\tconst first = sorted[0]\n\tconst last = sorted.at(-1)\n\tconst multiYear =\n\t\tfirst !== undefined &&\n\t\tlast !== undefined &&\n\t\tfirst.date.getUTCFullYear() !== last.date.getUTCFullYear()\n\tconst format = (d: Date): string => {\n\t\tif (weekday) {\n\t\t\treturn new Intl.DateTimeFormat('en-US', { weekday: 'short', timeZone: 'UTC' }).format(d)\n\t\t}\n\t\tif (unit === 'month') {\n\t\t\treturn new Intl.DateTimeFormat('en-US', {\n\t\t\t\tmonth: 'short',\n\t\t\t\tyear: multiYear ? 'numeric' : undefined,\n\t\t\t\ttimeZone: 'UTC',\n\t\t\t}).format(d)\n\t\t}\n\t\treturn new Intl.DateTimeFormat('en-US', {\n\t\t\tmonth: 'short',\n\t\t\tday: 'numeric',\n\t\t\ttimeZone: 'UTC',\n\t\t}).format(d)\n\t}\n\treturn sorted.map((g) => ({ label: format(g.date), value: g.value }))\n}\n\n/**\n * Aggregate a daily series into display buckets sized to the timeframe (day for short\n * ranges, week for ~quarter, month for year+), each with a formatted label. Distinct\n * metrics are summed per bucket (a documented daily-uniques approximation).\n */\nexport const bucketSeries = (\n\tpoints: SeriesPoint[],\n\ttimeframe: TimeframePreset,\n\t_now: Date\n): ChartBucket[] =>\n\tbucketByUnit(\n\t\tpoints,\n\t\tUNIT_BY_TIMEFRAME[timeframe],\n\t\ttimeframe === 'last7days' || timeframe === 'today'\n\t)\n\nconst DAY = 86_400_000\n\nconst unitForSpan = (spanDays: number): Unit =>\n\tspanDays <= 31 ? 'day' : spanDays <= 120 ? 'week' : 'month'\n\n/**\n * Bucket a daily series for a custom (arbitrary) range, choosing the bucket unit from\n * the span the way the presets do: short ranges by day, a quarter by week, longer by\n * month. Weekday labels are only used for the fixed 7-day preset, never here.\n */\nexport const bucketByRange = (points: SeriesPoint[], range: DateRange): ChartBucket[] => {\n\tconst spanDays = Math.round((range.end.getTime() - range.start.getTime()) / DAY)\n\treturn bucketByUnit(points, unitForSpan(spanDays), false)\n}\n","import type { WidgetServerProps } from 'payload'\nimport { bucketByRange, bucketSeries } from '../charts/bucket'\nimport { TrendChart } from '../charts/TrendChart'\nimport type { MetricKey } from '../core/contract'\nimport { formatMetricValue } from '../fields/format'\nimport type { TimeframePreset } from '../timeframe/presets'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { METRIC_KEYS, TIMEFRAME_KEYS } from '../translations/metricKeys'\nimport { asTranslate } from '../translations/server'\nimport { cardStyle, labelStyle } from './cardChrome'\nimport { formatRangeCaption, resolveCustomRange } from './range'\nimport type { WidgetReadStatus } from './readForWidget'\nimport { readForWidgetSeries } from './readForWidgetSeries'\nimport type { MetricWidgetData } from './types'\n\nconst STATE_KEY: Record<Exclude<WidgetReadStatus, 'ok'>, TranslationKey> = {\n\t'not-configured': keys.stateNotConfigured,\n\tunavailable: keys.stateUnavailable,\n}\n\nexport default async function AnalyticsTrendWidget(props: WidgetServerProps) {\n\tconst data = (props.widgetData ?? {}) as MetricWidgetData\n\tconst metric: MetricKey = data.metric ?? 'pageviews'\n\tconst rawTimeframe = data.timeframe ?? 'last30days'\n\tconst customRange = resolveCustomRange(rawTimeframe, data.range)\n\tconst timeframe: TimeframePreset = rawTimeframe === 'custom' ? 'last30days' : rawTimeframe\n\tconst t = asTranslate(props.req.i18n.t)\n\tconst locale = props.req.i18n.language ?? 'en-US'\n\tconst title = data.title?.trim() || t(METRIC_KEYS[metric])\n\n\tconst result = await readForWidgetSeries({\n\t\treq: props.req,\n\t\tmetric,\n\t\ttimeframe,\n\t\tadapterId: data.dataSource,\n\t\tnow: new Date(),\n\t\trange: customRange,\n\t})\n\n\tif (result.status !== 'ok') {\n\t\treturn (\n\t\t\t<div className=\"analytics-trend-widget\" style={cardStyle}>\n\t\t\t\t<span style={labelStyle}>{title}</span>\n\t\t\t\t<span style={{ color: 'var(--theme-elevation-400)' }}>{t(STATE_KEY[result.status])}</span>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tconst caption = customRange\n\t\t? formatRangeCaption(customRange, locale)\n\t\t: t(TIMEFRAME_KEYS[timeframe])\n\tconst buckets = customRange\n\t\t? bucketByRange(result.points, customRange)\n\t\t: bucketSeries(result.points, timeframe, new Date())\n\tconst trendPoints = buckets.map((b) => ({\n\t\t...b,\n\t\tdisplay: formatMetricValue(metric, b.value, locale),\n\t}))\n\treturn (\n\t\t<div className=\"analytics-trend-widget\" style={cardStyle}>\n\t\t\t<span style={labelStyle}>{title}</span>\n\t\t\t<span\n\t\t\t\tstyle={{\n\t\t\t\t\tfontSize: '1.75rem',\n\t\t\t\t\tfontWeight: 700,\n\t\t\t\t\tlineHeight: 1.1,\n\t\t\t\t\tcolor: 'var(--theme-elevation-800)',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{formatMetricValue(metric, result.total, locale)}\n\t\t\t</span>\n\t\t\t<TrendChart buckets={trendPoints} ariaLabel={`${title} ${caption}`} minHeight={180} />\n\t\t\t<span style={{ fontSize: '0.75rem', color: 'var(--theme-elevation-400)' }}>{caption}</span>\n\t\t\t{result.clamped ? (\n\t\t\t\t<span style={{ fontSize: '0.6875rem', color: 'var(--theme-elevation-400)' }}>\n\t\t\t\t\t{t(keys.stateClamped)}\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;AAEA,MAAa,kBAAkB,OAAuB;CACrD,MAAM,eAAe,KAAK,MAAM,KAAK,GAAI;CACzC,IAAI,eAAe,IAAI,OAAO,GAAG,aAAa;CAC9C,MAAM,UAAU,KAAK,MAAM,eAAe,EAAE;CAC5C,MAAM,UAAU,eAAe;CAC/B,IAAI,UAAU,IAAI,OAAO,YAAY,IAAI,GAAG,QAAQ,KAAK,GAAG,QAAQ,IAAI,QAAQ;CAChF,MAAM,QAAQ,KAAK,MAAM,UAAU,EAAE;CACrC,MAAM,aAAa,UAAU;CAC7B,OAAO,eAAe,IAAI,GAAG,MAAM,KAAK,GAAG,MAAM,IAAI,WAAW;AACjE;AAEA,MAAa,eAAe,OAAe,WAC1C,IAAI,KAAK,aAAa,MAAM,EAAE,OAAO,KAAK;AAE3C,MAAM,kBAA0C,IAAI,IAAI,CAAC,cAAc,aAAa,CAAC;AAErF,MAAa,qBAAqB,QAAmB,OAAe,WAA2B;CAC9F,IAAI,WAAW,eAAe,OAAO,eAAe,KAAK;CACzD,IAAI,gBAAgB,IAAI,MAAM,GAAG,OAAO,GAAG,KAAK,MAAM,KAAK,EAAE;CAC7D,OAAO,YAAY,OAAO,MAAM;AACjC;;;ACpBA,MAAM,aAAa,KAAiB,YACnC,QAAQ,MAAM,GAAG,EAAE,QAAiB,OAAO,QAAQ;CAClD,IAAI,SAAS,OAAO,UAAU,UAC7B,OAAQ,MAAkC;AAG5C,GAAG,GAAG;AAEP,MAAM,kBAAkB,UACvB,OAAO,U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