-
Notifications
You must be signed in to change notification settings - Fork 30.2k
/
index.d.ts
133 lines (120 loc) · 4.13 KB
/
index.d.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
export = AnalyticsNode.Analytics;
declare namespace AnalyticsNode {
type Identity =
| {
userId: string | number;
}
| {
anonymousId: string | number;
};
type Message = Identity & {
type: string;
context: {
library: {
name: string;
version: string;
};
[key: string]: any;
};
_metadata: {
nodeVersion: string;
[key: string]: any;
};
timestamp?: Date | undefined;
messageId?: string | undefined;
};
interface Data {
batch: Message[];
timestamp: Date;
sentAt: Date;
}
interface Integrations {
[integration_name: string]: IntegrationValue;
}
type IntegrationValue = boolean | { [integration_key: string]: any };
class Analytics {
constructor(
writeKey: string,
opts?: {
flushAt?: number | undefined;
flushInterval?: number | undefined;
host?: string | undefined;
enable?: boolean | undefined;
timeout?: number | string | undefined;
flushed?: boolean | undefined;
errorHandler?: (err: Error) => void;
},
);
/* The identify method lets you tie a user to their actions and record
traits about them. */
identify(
message: Identity & {
traits?: any;
timestamp?: Date | undefined;
context?: any;
integrations?: Integrations | undefined;
},
callback?: (err: Error) => void,
): Analytics;
/* The track method lets you record the actions your users perform. */
track(
message: Identity & {
event: string;
properties?: any;
timestamp?: Date | undefined;
context?: any;
integrations?: Integrations | undefined;
},
callback?: (err: Error) => void,
): Analytics;
/* The page method lets you record page views on your website, along with
optional extra information about the page being viewed. */
page(
message: Identity & {
category?: string | undefined;
name?: string | undefined;
properties?: any;
timestamp?: Date | undefined;
context?: any;
integrations?: Integrations | undefined;
messageId?: string | undefined;
},
callback?: (err: Error) => void,
): Analytics;
/* The screen method lets you record whenever a user sees a screen,
the mobile equivalent of page, in your mobile app, along with
any properties about the screen. */
screen(
message: Identity & {
name?: string | undefined;
properties?: any;
timestamp?: Date | undefined;
context?: any;
integrations?: Integrations | undefined;
},
callback?: (err: Error) => void,
): Analytics;
/* alias is how you associate one identity with another. */
alias(
message: Identity & {
previousId: string | number;
integrations?: Integrations | undefined;
},
callback?: (err: Error) => void,
): Analytics;
/* Group calls can be used to associate individual users with shared
accounts or companies. */
group(
message: Identity & {
groupId: string | number;
traits?: any;
context?: any;
timestamp?: Date | undefined;
integrations?: Integrations | undefined;
},
callback?: (err: Error) => void,
): Analytics;
/* Flush batched calls to make sure nothing is left in the queue */
flush(callback?: (err: Error, data: Data) => void): Promise<{ batch: any; timestamp: string; sentAt: string }>;
}
}