Repository navigation
Expand file tree
/
Copy pathapi.ts
More file actions
67 lines (59 loc) · 1.7 KB
/
Copy pathapi.ts
File metadata and controls
67 lines (59 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Wire contracts shared by the Fastify API, the demo Web Worker and the
* dashboard. Both data sources return exactly these shapes.
*/
import type { BreakdownResult, Summary, TimeseriesResult } from './query.js';
import type { Granularity } from './time.js';
import type { CheckResult } from './uptime.js';
import type { Device, Dimension } from './types.js';
export interface SummaryResponse {
interval: Granularity;
current: Summary;
previous: Summary;
}
export type BreakdownResponse = BreakdownResult;
export type TimeseriesResponse = TimeseriesResult;
export interface LiveEvent {
id: string;
ts: number;
path: string;
referrer: string;
country: string;
device: Device;
browser: string;
}
export interface RealtimeResponse {
active: number;
/** Pageviews per minute for the last 30 minutes. */
perMinute: { t: number; pageviews: number; visitors: number }[];
recent: LiveEvent[];
}
export type LiveMessage =
| { type: 'hello'; siteId: string; active: number }
| { type: 'pageview'; siteId: string; active: number; event: LiveEvent }
| { type: 'active'; siteId: string; active: number }
| { type: 'check'; check: CheckResult };
export interface StatsQueryParams {
from: number;
to: number;
}
export interface BreakdownQueryParams extends StatsQueryParams {
dimension: Dimension;
limit?: number;
search?: string;
}
/** Wire format of the tracker beacon (kept terse to keep the script tiny). */
export interface TrackerPayload {
/** site id */
s: string;
/** page URL */
u: string;
/** document.referrer */
r?: string;
/** viewport width */
w?: number;
/** page load duration, ms */
l?: number;
/** event name, defaults to "pageview" */
n?: string;
}