forked from rudderlabs/rudder-sdk-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
204 lines (197 loc) · 5.61 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
export default Analytics;
/**
* Represents a generic object in the APIs
* Use for parameters like context, traits etc.
*/
export interface apiObject {
[index: string]:
| string
| number
| boolean
| undefined
| apiObject
| (string | number | boolean | apiObject)[];
}
/**
* Represents the integration options object
* Example usages:
* integrationOptions { All: false, "Google Analytics": true, "Braze": true}
* integrationOptions { All: true, "Chartbeat": false, "Customer.io": false}
*/
export interface integrationOptions {
// Defaults to true
// If set to false, specific integration should be set to true to send the event
All?: boolean;
// Destination name: true/false/integration specific information
[index: string]: boolean | apiObject | undefined;
}
/**
* Represents the constructor options object
* Example usages:
* constructorOptions { flushAt: 20, "flushInterval": 20000, "enable": true, "maxInternalQueueSize":20000, "logLevel": "info"/"debug"/"error"/"silly"}
*/
export interface constructorOptions {
flushAt?: number;
flushInterval?: number;
enable?: boolean;
maxInternalQueueSize?: number;
logLevel?: string;
}
/**
* Represents the callback in the APIs
*/
export type apiCallback = () => void;
declare class Analytics {
/**
* Initialize a new `Analytics` with your Segment project's `writeKey` and an
* optional dictionary of `options`.
*
* @param {String} writeKey
* @param {String} dataPlaneURL
* @param {Object=} options (optional)
* @param {Number=20} options.flushAt (default: 20)
* @param {Number=20000} options.flushInterval (default: 20000)
* @param {Boolean=true} options.enable (default: true)
* @param {Number=20000} options.maxInternalQueueSize
*/
constructor(
writeKey: string,
dataPlaneURL: string,
options?: constructorOptions
);
/**
* Send an identify `message`.
*
* @param {Object} message
* @param {String=} message.userId (optional)
* @param {String=} message.anonymousId (optional)
* @param {Object=} message.context (optional)
* @param {Object=} message.traits (optional)
* @param {Object=} message.integrations (optional)
* @param {Date=} message.timestamp (optional)
* @param {Function=} callback (optional)
* @return {Analytics}
*/
identify(
message: {
userId?: string;
anonymousId?: string;
context?: apiObject;
traits?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback
): Analytics;
/**
* Send a group `message`.
*
* @param {Object} message
* @param {String} message.groupId
* @param {String=} message.userId (optional)
* @param {String=} message.anonymousId (optional)
* @param {Object=} message.context (optional)
* @param {Object=} message.traits (optional)
* @param {Object=} message.integrations (optional)
* @param {Date=} message.timestamp (optional)
* @param {Function=} callback (optional)
* @return {Analytics}
*/
group(
message: {
groupId: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
traits?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback
): Analytics;
/**
* Send a track `message`.
*
* @param {Object} message
* @param {String} message.event
* @param {String=} message.userId (optional)
* @param {String=} message.anonymousId (optional)
* @param {Object=} message.context (optional)
* @param {Object=} message.properties (optional)
* @param {Object=} message.integrations (optional)
* @param {Date=} message.timestamp (optional)
* @param {Function=} callback (optional)
* @return {Analytics}
*/
track(
message: {
event: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback
): Analytics;
/**
* Send a page `message`.
*
* @param {Object} message
* @param {String} message.name
* @param {String=} message.userId (optional)
* @param {String=} message.anonymousId (optional)
* @param {Object=} message.context (optional)
* @param {Object=} message.properties (optional)
* @param {Object=} message.integrations (optional)
* @param {Date=} message.timestamp (optional)
* @param {Function=} callback (optional)
* @return {Analytics}
*/
page(
message: {
name: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback
): Analytics;
/**
* Send an alias `message`.
*
* @param {Object} message
* @param {String} message.previousId
* @param {String=} message.userId (optional)
* @param {String=} message.anonymousId (optional)
* @param {Object=} message.context (optional)
* @param {Object=} message.properties (optional)
* @param {Object=} message.integrations (optional)
* @param {Date=} message.timestamp (optional)
* @param {Function=} callback (optional)
* @return {Analytics}
*/
alias(
message: {
previousId: string;
userId?: string;
anonymousId?: string;
context?: apiObject;
properties?: apiObject;
integrations?: integrationOptions;
timestamp?: Date;
},
callback?: apiCallback
): Analytics;
/**
* Flush the current queue
*
* @param {Function} [callback] (optional)
* @return {Analytics}
*/
flush(callback?: Function): Analytics;
}