-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.ts
53 lines (47 loc) · 1.08 KB
/
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
48
49
50
51
52
53
export type Period = "12mo" | "6mo" | "month" | "30d" | "7d" | "day";
export type Interval = "date" | "month";
export type Properties =
| "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"
| `event:props:${string}`;
export type Metrics =
| "visitors"
| "pageviews"
| "bounce_rate"
| "visit_duration"
| "events"
| "visits";
export type Aggregated<Compare extends boolean> = Compare extends true ? {
value: number;
change: number;
}
: { value: number };
export type Datapoints<Metric extends string> = Array<
& {
[key in Metric]: string;
}
& {
date: string;
}
>;
type Breakdown<T extends string, Metric extends Metrics> =
& {
[key in T]: string;
}
& {
[key in Metric]: number;
};
export type Breakdowns<T extends Properties, Metric extends Metrics> = Array<
T extends `${string}:${infer Key}` ? Breakdown<Key, Metric> : never
>;