rudder-sdk-js 2.16.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,207 @@
1
+ export {
2
+ Analytics
3
+ };
4
+
5
+ /**
6
+ * Represents a generic object in the APIs
7
+ * Use for parameters like context, traits etc.
8
+ */
9
+ export interface apiObject {
10
+ [index: string]:
11
+ | string
12
+ | number
13
+ | boolean
14
+ | undefined
15
+ | apiObject
16
+ | unknown
17
+ | (string | number | boolean | apiObject)[];
18
+ }
19
+
20
+ /**
21
+ * Represents the integration options object
22
+ * Example usages:
23
+ * integrationOptions { All: false, "Google Analytics": true, "Braze": true}
24
+ * integrationOptions { All: true, "Chartbeat": false, "Customer.io": false}
25
+ */
26
+ export interface integrationOptions {
27
+ // Defaults to true
28
+ // If set to false, specific integration should be set to true to send the event
29
+ All?: boolean;
30
+ // Destination name: true/false/integration specific information
31
+ [index: string]: boolean | apiObject | undefined;
32
+ }
33
+
34
+ /**
35
+ * Represents the constructor options object
36
+ * Example usages:
37
+ * constructorOptions { flushAt: 20, "flushInterval": 20000, "enable": true, "maxInternalQueueSize":20000, "logLevel": "info"/"debug"/"error"/"silly"/"off"}
38
+ */
39
+ export interface constructorOptions {
40
+ flushAt?: number;
41
+ flushInterval?: number;
42
+ enable?: boolean;
43
+ maxInternalQueueSize?: number;
44
+ logLevel?: 'silly' | 'debug' | 'info' | 'error' | 'off';
45
+ }
46
+
47
+ /**
48
+ * Represents the callback in the APIs
49
+ */
50
+ export type apiCallback = () => void;
51
+ declare class Analytics {
52
+ /**
53
+ * Initialize a new `Analytics` with your Segment project's `writeKey` and an
54
+ * optional dictionary of `options`.
55
+ *
56
+ * @param {String} writeKey
57
+ * @param {String} dataPlaneURL
58
+ * @param {Object=} options (optional)
59
+ * @param {Number=20} options.flushAt (default: 20)
60
+ * @param {Number=20000} options.flushInterval (default: 20000)
61
+ * @param {Boolean=true} options.enable (default: true)
62
+ * @param {Number=20000} options.maxInternalQueueSize
63
+ */
64
+ constructor(
65
+ writeKey: string,
66
+ dataPlaneURL: string,
67
+ options?: constructorOptions
68
+ );
69
+
70
+ /**
71
+ * Send an identify `message`.
72
+ *
73
+ * @param {Object} message
74
+ * @param {String=} message.userId (optional)
75
+ * @param {String=} message.anonymousId (optional)
76
+ * @param {Object=} message.context (optional)
77
+ * @param {Object=} message.traits (optional)
78
+ * @param {Object=} message.integrations (optional)
79
+ * @param {Date=} message.timestamp (optional)
80
+ * @param {Function=} callback (optional)
81
+ * @return {Analytics}
82
+ */
83
+ identify(
84
+ message: {
85
+ userId?: string;
86
+ anonymousId?: string;
87
+ context?: apiObject;
88
+ traits?: apiObject;
89
+ integrations?: integrationOptions;
90
+ timestamp?: Date;
91
+ },
92
+ callback?: apiCallback
93
+ ): Analytics;
94
+ /**
95
+ * Send a group `message`.
96
+ *
97
+ * @param {Object} message
98
+ * @param {String} message.groupId
99
+ * @param {String=} message.userId (optional)
100
+ * @param {String=} message.anonymousId (optional)
101
+ * @param {Object=} message.context (optional)
102
+ * @param {Object=} message.traits (optional)
103
+ * @param {Object=} message.integrations (optional)
104
+ * @param {Date=} message.timestamp (optional)
105
+ * @param {Function=} callback (optional)
106
+ * @return {Analytics}
107
+ */
108
+ group(
109
+ message: {
110
+ groupId: string;
111
+ userId?: string;
112
+ anonymousId?: string;
113
+ context?: apiObject;
114
+ traits?: apiObject;
115
+ integrations?: integrationOptions;
116
+ timestamp?: Date;
117
+ },
118
+ callback?: apiCallback
119
+ ): Analytics;
120
+ /**
121
+ * Send a track `message`.
122
+ *
123
+ * @param {Object} message
124
+ * @param {String} message.event
125
+ * @param {String=} message.userId (optional)
126
+ * @param {String=} message.anonymousId (optional)
127
+ * @param {Object=} message.context (optional)
128
+ * @param {Object=} message.properties (optional)
129
+ * @param {Object=} message.integrations (optional)
130
+ * @param {Date=} message.timestamp (optional)
131
+ * @param {Function=} callback (optional)
132
+ * @return {Analytics}
133
+ */
134
+ track(
135
+ message: {
136
+ event: string;
137
+ userId?: string;
138
+ anonymousId?: string;
139
+ context?: apiObject;
140
+ properties?: apiObject;
141
+ integrations?: integrationOptions;
142
+ timestamp?: Date;
143
+ },
144
+ callback?: apiCallback
145
+ ): Analytics;
146
+ /**
147
+ * Send a page `message`.
148
+ *
149
+ * @param {Object} message
150
+ * @param {String} message.name
151
+ * @param {String=} message.userId (optional)
152
+ * @param {String=} message.anonymousId (optional)
153
+ * @param {Object=} message.context (optional)
154
+ * @param {Object=} message.properties (optional)
155
+ * @param {Object=} message.integrations (optional)
156
+ * @param {Date=} message.timestamp (optional)
157
+ * @param {Function=} callback (optional)
158
+ * @return {Analytics}
159
+ */
160
+ page(
161
+ message: {
162
+ name: string;
163
+ userId?: string;
164
+ anonymousId?: string;
165
+ context?: apiObject;
166
+ properties?: apiObject;
167
+ integrations?: integrationOptions;
168
+ timestamp?: Date;
169
+ },
170
+ callback?: apiCallback
171
+ ): Analytics;
172
+
173
+ /**
174
+ * Send an alias `message`.
175
+ *
176
+ * @param {Object} message
177
+ * @param {String} message.previousId
178
+ * @param {String=} message.userId (optional)
179
+ * @param {String=} message.anonymousId (optional)
180
+ * @param {Object=} message.context (optional)
181
+ * @param {Object=} message.properties (optional)
182
+ * @param {Object=} message.integrations (optional)
183
+ * @param {Date=} message.timestamp (optional)
184
+ * @param {Function=} callback (optional)
185
+ * @return {Analytics}
186
+ */
187
+ alias(
188
+ message: {
189
+ previousId: string;
190
+ userId?: string;
191
+ anonymousId?: string;
192
+ context?: apiObject;
193
+ properties?: apiObject;
194
+ integrations?: integrationOptions;
195
+ timestamp?: Date;
196
+ },
197
+ callback?: apiCallback
198
+ ): Analytics;
199
+
200
+ /**
201
+ * Flush the current queue
202
+ *
203
+ * @param {Function} [callback] (optional)
204
+ * @return {Analytics}
205
+ */
206
+ flush(callback?: Function): Analytics;
207
+ }