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