forked from Schotsl/Plausible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
47 lines (40 loc) · 1007 Bytes
/
types.ts
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
export type Period = "12mo" | "6mo" | "month" | "30d" | "7d" | "day";
export type Interval = "date" | "month";
export type Property =
| "event:name"
| "event:page"
| "visit:source"
| "visit:referrer"
| "visit:utm_medium"
| "visit:utm_source"
| "visit:utm_campaign"
| "visit:device"
| "visit:browser"
| "visit:browser_version"
| "visit:os"
| "visit:os_version"
| "visit:country";
export type Metrics =
| "visitors"
| "pageviews"
| "bounce_rate"
| "visit_duration";
// I have no clue how the Breakdown / BreakdownReturns works so shoutout to @iDavidB
export type Datapoints = {
date: string;
visitors: number;
}[];
export type Aggregated = {
value: number;
change?: number;
};
type Breakdown<T extends string, Metric extends Metrics> =
& {
[key in T]: string;
}
& {
[key in Metric]: number;
};
export type Breakdowns<T extends Property, Metric extends Metrics> = Array<
T extends `${infer _}:${infer Key}` ? Breakdown<Key, Metric> : never
>;