forked from stacks-archive/stats
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.ts
70 lines (57 loc) · 1.13 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
export enum Providers {
Segment = 'segment',
}
export interface SegmentConfig {
name: typeof Providers.Segment;
writeKey: string;
}
export type Provider = SegmentConfig;
export interface ActionData {
id: string;
provider: Provider;
}
export interface Context {
page: {
path: string;
hash?: string;
origin: string;
url: string;
};
}
export interface EventData {
name: string;
[key: string]: any;
}
export interface EventAction extends ActionData {
context: Context;
eventData: EventData;
}
export interface PageData {
name: string;
title?: string;
href?: string;
url?: string;
[key: string]: any;
}
export interface PageAction extends ActionData {
context: Context;
pageData: PageData;
}
export enum Actions {
EVENT = 'event',
PAGE = 'page',
}
interface BaseRunOptions {
id: string;
context: Context;
providers: Provider[];
}
export interface PageRun extends BaseRunOptions {
action: typeof Actions.PAGE;
pageData: PageData;
}
export interface EventRun extends BaseRunOptions {
action: typeof Actions.EVENT;
eventData: EventData;
}
export type RunOptions = EventRun | PageRun;