@liiift-studio/sanity-visitor-insights 0.2.0 → 0.2.2

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.
@@ -1,80 +0,0 @@
1
- /** What this module needs from a Sanity client — kept minimal so it is trivial to stub in tests. */
2
- interface SanityQueryClient {
3
- fetch<T>(query: string, params?: Record<string, unknown>): Promise<T>;
4
- }
5
-
6
- /**
7
- * GA4 Data API client.
8
- *
9
- * Only `runReport` and `batchRunReports` are used. `runFunnelReport` is deliberately not called:
10
- * it is an alpha surface with its own stricter quota, and it returns step-conversion marginals
11
- * rather than observed paths — drawing a flow diagram from it would imply co-occurrence that was
12
- * never measured. The journey report approximates instead, and says so.
13
- */
14
-
15
- /** A GA4 report request, narrowed to the fields this package sets. */
16
- interface Ga4ReportRequest {
17
- dimensions?: Array<{
18
- name: string;
19
- }>;
20
- metrics?: Array<{
21
- name: string;
22
- }>;
23
- dateRanges: Array<{
24
- startDate: string;
25
- endDate: string;
26
- }>;
27
- dimensionFilter?: unknown;
28
- orderBys?: unknown;
29
- limit?: number;
30
- keepEmptyRows?: boolean;
31
- }
32
- /** A parsed report row: dimension values and metric values, positionally aligned to the request. */
33
- interface Ga4Row {
34
- dimensions: string[];
35
- metrics: number[];
36
- }
37
- /** A parsed GA4 report. */
38
- interface Ga4Report {
39
- rows: Ga4Row[];
40
- /** True when GA4 withheld rows for privacy thresholding — totals are then incomplete. */
41
- thresholded: boolean;
42
- /** True when GA4 answered from a sample rather than the full data set. */
43
- sampled: boolean;
44
- /** Total row count GA4 reports, which may exceed rows returned when a limit applied. */
45
- rowCount: number;
46
- /**
47
- * The property's configured timezone, as GA4 reports it. Worth capturing because every range
48
- * is anchored to the timezone in site config, and a mismatch silently shifts day boundaries.
49
- */
50
- timeZone?: string;
51
- }
52
- /** A GA4 client bound to one property. */
53
- interface Ga4Client {
54
- runReport(request: Ga4ReportRequest): Promise<Ga4Report>;
55
- batchRunReports(requests: Ga4ReportRequest[]): Promise<Ga4Report[]>;
56
- }
57
-
58
- /**
59
- * Vercel Web Analytics client.
60
- *
61
- * Vercel's Web Analytics read API is not a stable, versioned public surface the way the GA4 Data
62
- * API is, and access depends on plan tier. This client is therefore written to degrade rather than
63
- * throw: a missing token, an unavailable plan, or a changed endpoint all surface as an unconfigured
64
- * or errored source in the report envelope, so the Measurement Health panel can say "Vercel did not
65
- * answer" instead of implying the site had no traffic.
66
- *
67
- * Vercel is counted here purely as a second, cookieless pageview measurement. It is never treated
68
- * as ground truth, and never subtracted from a GA4 session count — those are different units.
69
- */
70
- /** Daily pageview counts, keyed by ISO date. */
71
- interface VercelPageviews {
72
- byDate: Record<string, number>;
73
- total: number;
74
- }
75
- /** A Vercel client bound to one project. */
76
- interface VercelClient {
77
- pageviews(start: string, end: string): Promise<VercelPageviews>;
78
- }
79
-
80
- export type { Ga4Client as G, SanityQueryClient as S, VercelClient as V, Ga4ReportRequest as a, Ga4Report as b, VercelPageviews as c };