rudder-sdk-js 2.20.0 → 2.21.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/CHANGELOG.md +3328 -0
- package/README.md +29 -29
- package/index.d.ts +22 -71
- package/index.es.js +1 -15037
- package/index.js +1 -15063
- package/package.json +2 -2
- package/service-worker/index.d.ts +7 -13
- package/service-worker/index.es.js +4899 -10774
- package/service-worker/index.js +4899 -10774
- package/index.html +0 -8
package/README.md
CHANGED
@@ -5,7 +5,7 @@ The [**RudderStack**](https://rudderstack.com/) JavaScript SDK leverages the `ru
|
|
5
5
|
> For detailed documentation on the RudderStack JavaScript SDK, click [**here**](https://docs.rudderstack.com/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk).
|
6
6
|
|
7
7
|
| **IMPORTANT**: We have deprecated the Autotrack feature for the RudderStack JavaScript SDK. If you still wish to use it for your project, refer to [**this repository**](https://github.com/rudderlabs/rudder-sdk-js-autotrack#autotrack). |
|
8
|
-
|
|
8
|
+
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
9
9
|
|
10
10
|
## Installing the JavaScript SDK
|
11
11
|
|
@@ -68,7 +68,6 @@ The APIs exported by the module are:
|
|
68
68
|
- `getAnonymousId`
|
69
69
|
- `setAnonymousId`
|
70
70
|
|
71
|
-
|
72
71
|
### Sample implementations
|
73
72
|
|
74
73
|
Refer to the following projects for a detailed walk-through of the above steps:
|
@@ -78,15 +77,15 @@ Refer to the following projects for a detailed walk-through of the above steps:
|
|
78
77
|
|
79
78
|
### Supported browser versions
|
80
79
|
|
81
|
-
| **Browser**
|
82
|
-
|
|
83
|
-
| Safari
|
84
|
-
| IE
|
85
|
-
| Edge
|
86
|
-
| Mozilla Firefox
|
87
|
-
| Chrome
|
88
|
-
| Opera
|
89
|
-
| Yandex
|
80
|
+
| **Browser** | **Supported Versions** |
|
81
|
+
| :-------------- | :--------------------- |
|
82
|
+
| Safari | v7 or later |
|
83
|
+
| IE | v10 or later |
|
84
|
+
| Edge | v15 or later |
|
85
|
+
| Mozilla Firefox | v40 or later |
|
86
|
+
| Chrome | v37 or later |
|
87
|
+
| Opera | v23 or later |
|
88
|
+
| Yandex | v14.12 or later |
|
90
89
|
|
91
90
|
> If the SDK does not work on the browser versions that you are targeting, verify if adding the browser polyfills to your application solves the issue.
|
92
91
|
|
@@ -98,26 +97,27 @@ A sample `identify()` call is shown below:
|
|
98
97
|
|
99
98
|
```javascript
|
100
99
|
rudderanalytics.identify(
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
'12345',
|
101
|
+
{
|
102
|
+
email: 'name@domain.com',
|
103
|
+
},
|
104
|
+
{
|
104
105
|
page: {
|
105
|
-
path:
|
106
|
-
referrer:
|
107
|
-
search:
|
108
|
-
title:
|
109
|
-
url:
|
106
|
+
path: '',
|
107
|
+
referrer: '',
|
108
|
+
search: '',
|
109
|
+
title: '',
|
110
|
+
url: '',
|
110
111
|
},
|
111
112
|
},
|
112
113
|
() => {
|
113
|
-
console.log(
|
114
|
-
}
|
114
|
+
console.log('in identify call');
|
115
|
+
},
|
115
116
|
);
|
116
117
|
```
|
117
118
|
|
118
119
|
In the above example, the user-related information like the `userId` and `email` along with the [**contextual information**](https://docs.rudderstack.com/rudderstack-api/api-specification/rudderstack-spec/common-fields#javascript-sdk) is captured.
|
119
120
|
|
120
|
-
|
121
121
|
> There is no need to call `identify()` for anonymous visitors to your website. Such visitors are automatically assigned an `anonymousId`.
|
122
122
|
|
123
123
|
For more information on how to use the `identify` call, refer to the [**JavaScript SDK documentation**](https://docs.rudderstack.com/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk).
|
@@ -130,14 +130,15 @@ A sample `track` call is shown below:
|
|
130
130
|
|
131
131
|
```javascript
|
132
132
|
rudderanalytics.track(
|
133
|
-
|
133
|
+
'test track event GA3',
|
134
|
+
{
|
134
135
|
revenue: 30,
|
135
|
-
currency:
|
136
|
+
currency: 'USD',
|
136
137
|
user_actual_id: 12345,
|
137
138
|
},
|
138
139
|
() => {
|
139
|
-
console.log(
|
140
|
-
}
|
140
|
+
console.log('in track call');
|
141
|
+
},
|
141
142
|
);
|
142
143
|
```
|
143
144
|
|
@@ -153,13 +154,12 @@ An example is shown in the following snippet:
|
|
153
154
|
|
154
155
|
```javascript
|
155
156
|
rudderanalytics.ready(() => {
|
156
|
-
console.log(
|
157
|
+
console.log('we are all set!!!');
|
157
158
|
});
|
158
159
|
```
|
159
160
|
|
160
161
|
> For more information on the other supported methods, refer to the [**JavaScript SDK APIs**](https://docs.rudderstack.com/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk#supported-apis).
|
161
162
|
|
162
|
-
|
163
163
|
## Self-Hosted control plane
|
164
164
|
|
165
165
|
If you are using a device mode destination like Heap, FullStory, etc., the JavaScript SDK needs to fetch the required configuration from the [**control plane**](https://docs.rudderstack.com/get-started/rudderstack-architecture#control-plane).
|
@@ -175,7 +175,7 @@ rudderanalytics.load(<WRITE_KEY>, <DATA_PLANE_URL>, {
|
|
175
175
|
> More information on how to get the `CONTROL_PLANE_URL` can be found [**here**](https://docs.rudderstack.com/get-started/control-plane-lite#what-is-the-control-plane-url).
|
176
176
|
|
177
177
|
| **For detailed technical documentation and troubleshooting guide on the RudderStack’s JavaScript SDK, check out our [docs](https://docs.rudderstack.com/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk).** |
|
178
|
-
|
|
178
|
+
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
179
179
|
|
180
180
|
## Contact us
|
181
181
|
|
package/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
declare module
|
1
|
+
declare module 'rudder-sdk-js' {
|
2
2
|
/**
|
3
3
|
* Represents the integration options object
|
4
4
|
* Example usages:
|
@@ -74,11 +74,7 @@ declare module "rudder-sdk-js" {
|
|
74
74
|
// Defaults to "Lax" (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite)
|
75
75
|
sameSiteCookie?: string;
|
76
76
|
logLevel?: string;
|
77
|
-
getSourceConfig?: () =>
|
78
|
-
| string
|
79
|
-
| apiObject
|
80
|
-
| Promise<apiObject>
|
81
|
-
| Promise<string>;
|
77
|
+
getSourceConfig?: () => string | apiObject | Promise<apiObject> | Promise<string>;
|
82
78
|
setCookieDomain?: string;
|
83
79
|
sendAdblockPage?: boolean;
|
84
80
|
sendAdblockPageOptions?: apiOptions;
|
@@ -92,7 +88,7 @@ declare module "rudder-sdk-js" {
|
|
92
88
|
sessions?: {
|
93
89
|
autoTrack?: boolean; // Defaults to true
|
94
90
|
timeout?: number; // Defaults to 30 mins
|
95
|
-
}
|
91
|
+
};
|
96
92
|
}
|
97
93
|
|
98
94
|
/**
|
@@ -139,11 +135,7 @@ declare module "rudder-sdk-js" {
|
|
139
135
|
* @param dataPlaneUrl
|
140
136
|
* @param options
|
141
137
|
*/
|
142
|
-
function load(
|
143
|
-
writeKey: string,
|
144
|
-
dataPlaneUrl: string,
|
145
|
-
options?: loadOptions
|
146
|
-
): void;
|
138
|
+
function load(writeKey: string, dataPlaneUrl: string, options?: loadOptions): void;
|
147
139
|
|
148
140
|
/**
|
149
141
|
* To register a callback for SDK ready state
|
@@ -164,7 +156,7 @@ declare module "rudder-sdk-js" {
|
|
164
156
|
name?: string,
|
165
157
|
properties?: apiObject,
|
166
158
|
options?: apiOptions,
|
167
|
-
callback?: apiCallback
|
159
|
+
callback?: apiCallback,
|
168
160
|
): void;
|
169
161
|
|
170
162
|
/**
|
@@ -174,12 +166,7 @@ declare module "rudder-sdk-js" {
|
|
174
166
|
* @param properties
|
175
167
|
* @param callback
|
176
168
|
*/
|
177
|
-
function page(
|
178
|
-
category: string,
|
179
|
-
name: string,
|
180
|
-
properties: apiObject,
|
181
|
-
callback: apiCallback
|
182
|
-
): void;
|
169
|
+
function page(category: string, name: string, properties: apiObject, callback: apiCallback): void;
|
183
170
|
|
184
171
|
/**
|
185
172
|
* To record a page view event
|
@@ -200,7 +187,7 @@ declare module "rudder-sdk-js" {
|
|
200
187
|
name: string,
|
201
188
|
properties?: apiObject,
|
202
189
|
options?: apiOptions,
|
203
|
-
callback?: apiCallback
|
190
|
+
callback?: apiCallback,
|
204
191
|
): void;
|
205
192
|
|
206
193
|
/**
|
@@ -209,11 +196,7 @@ declare module "rudder-sdk-js" {
|
|
209
196
|
* @param properties
|
210
197
|
* @param callback
|
211
198
|
*/
|
212
|
-
function page(
|
213
|
-
name: string,
|
214
|
-
properties: apiObject,
|
215
|
-
callback: apiCallback
|
216
|
-
): void;
|
199
|
+
function page(name: string, properties: apiObject, callback: apiCallback): void;
|
217
200
|
|
218
201
|
/**
|
219
202
|
*
|
@@ -228,11 +211,7 @@ declare module "rudder-sdk-js" {
|
|
228
211
|
* @param options
|
229
212
|
* @param callback
|
230
213
|
*/
|
231
|
-
function page(
|
232
|
-
properties: apiObject,
|
233
|
-
options: apiOptions,
|
234
|
-
callback?: apiCallback
|
235
|
-
): void;
|
214
|
+
function page(properties: apiObject, options: apiOptions, callback?: apiCallback): void;
|
236
215
|
|
237
216
|
/**
|
238
217
|
* To record a page view event
|
@@ -252,7 +231,7 @@ declare module "rudder-sdk-js" {
|
|
252
231
|
event: string,
|
253
232
|
properties?: apiObject,
|
254
233
|
options?: apiOptions,
|
255
|
-
callback?: apiCallback
|
234
|
+
callback?: apiCallback,
|
256
235
|
): void;
|
257
236
|
|
258
237
|
/**
|
@@ -261,11 +240,7 @@ declare module "rudder-sdk-js" {
|
|
261
240
|
* @param properties
|
262
241
|
* @param callback
|
263
242
|
*/
|
264
|
-
function track(
|
265
|
-
event: string,
|
266
|
-
properties: apiObject,
|
267
|
-
callback: apiCallback
|
268
|
-
): void;
|
243
|
+
function track(event: string, properties: apiObject, callback: apiCallback): void;
|
269
244
|
|
270
245
|
/**
|
271
246
|
* To record a user track event
|
@@ -285,7 +260,7 @@ declare module "rudder-sdk-js" {
|
|
285
260
|
userId?: string,
|
286
261
|
traits?: apiObject,
|
287
262
|
options?: apiOptions,
|
288
|
-
callback?: apiCallback
|
263
|
+
callback?: apiCallback,
|
289
264
|
): void;
|
290
265
|
|
291
266
|
/**
|
@@ -294,11 +269,7 @@ declare module "rudder-sdk-js" {
|
|
294
269
|
* @param traits
|
295
270
|
* @param callback
|
296
271
|
*/
|
297
|
-
function identify(
|
298
|
-
userId: string,
|
299
|
-
traits: apiObject,
|
300
|
-
callback: apiCallback
|
301
|
-
): void;
|
272
|
+
function identify(userId: string, traits: apiObject, callback: apiCallback): void;
|
302
273
|
|
303
274
|
/**
|
304
275
|
* To record a user identification event
|
@@ -313,11 +284,7 @@ declare module "rudder-sdk-js" {
|
|
313
284
|
* @param options
|
314
285
|
* @param callback
|
315
286
|
*/
|
316
|
-
function identify(
|
317
|
-
traits: apiObject,
|
318
|
-
options: apiOptions,
|
319
|
-
callback?: apiCallback
|
320
|
-
): void;
|
287
|
+
function identify(traits: apiObject, options: apiOptions, callback?: apiCallback): void;
|
321
288
|
|
322
289
|
/**
|
323
290
|
*
|
@@ -333,12 +300,7 @@ declare module "rudder-sdk-js" {
|
|
333
300
|
* @param options
|
334
301
|
* @param callback
|
335
302
|
*/
|
336
|
-
function alias(
|
337
|
-
to: string,
|
338
|
-
from?: string,
|
339
|
-
options?: apiOptions,
|
340
|
-
callback?: apiCallback
|
341
|
-
): void;
|
303
|
+
function alias(to: string, from?: string, options?: apiOptions, callback?: apiCallback): void;
|
342
304
|
|
343
305
|
/**
|
344
306
|
* To record a user alias event
|
@@ -374,7 +336,7 @@ declare module "rudder-sdk-js" {
|
|
374
336
|
groupId: string,
|
375
337
|
traits?: apiObject,
|
376
338
|
options?: apiOptions,
|
377
|
-
callback?: apiCallback
|
339
|
+
callback?: apiCallback,
|
378
340
|
): void;
|
379
341
|
|
380
342
|
/**
|
@@ -383,11 +345,7 @@ declare module "rudder-sdk-js" {
|
|
383
345
|
* @param traits
|
384
346
|
* @param callback
|
385
347
|
*/
|
386
|
-
function group(
|
387
|
-
groupId: string,
|
388
|
-
traits: apiObject,
|
389
|
-
callback: apiCallback
|
390
|
-
): void;
|
348
|
+
function group(groupId: string, traits: apiObject, callback: apiCallback): void;
|
391
349
|
|
392
350
|
/**
|
393
351
|
* To record a user group event
|
@@ -402,11 +360,7 @@ declare module "rudder-sdk-js" {
|
|
402
360
|
* @param options
|
403
361
|
* @param callback
|
404
362
|
*/
|
405
|
-
function group(
|
406
|
-
traits: apiObject,
|
407
|
-
options: apiOptions,
|
408
|
-
callback?: apiCallback
|
409
|
-
): void;
|
363
|
+
function group(traits: apiObject, options: apiOptions, callback?: apiCallback): void;
|
410
364
|
|
411
365
|
/**
|
412
366
|
* To record a user group event
|
@@ -425,10 +379,7 @@ declare module "rudder-sdk-js" {
|
|
425
379
|
* @param anonymousId
|
426
380
|
* @param rudderAmpLinkerParm AMP Linker ID string
|
427
381
|
*/
|
428
|
-
function setAnonymousId(
|
429
|
-
anonymousId?: string,
|
430
|
-
rudderAmpLinkerParm?: string
|
431
|
-
): void;
|
382
|
+
function setAnonymousId(anonymousId?: string, rudderAmpLinkerParm?: string): void;
|
432
383
|
|
433
384
|
/**
|
434
385
|
* Clear user information
|
@@ -459,12 +410,12 @@ declare module "rudder-sdk-js" {
|
|
459
410
|
/**
|
460
411
|
* To manually start user session in the SDK
|
461
412
|
*/
|
462
|
-
|
413
|
+
function startSession(sessionId?: number): void;
|
463
414
|
|
464
|
-
|
415
|
+
/**
|
465
416
|
* To manually end user session in the SDK
|
466
417
|
*/
|
467
|
-
|
418
|
+
function endSession(): void;
|
468
419
|
|
469
420
|
export {
|
470
421
|
integrationOptions,
|