rudder-sdk-js 2.21.1 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +3365 -0
- package/README.md +29 -29
- package/index.d.ts +29 -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 +4918 -10765
- package/service-worker/index.js +4918 -10765
- 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:
|
@@ -69,16 +69,13 @@ declare module "rudder-sdk-js" {
|
|
69
69
|
queueOptions?: queueOptions;
|
70
70
|
// Defaults to true
|
71
71
|
loadIntegration?: boolean;
|
72
|
+
lockIntegrationsVersion?: boolean;
|
72
73
|
// Defaults to false
|
73
74
|
secureCookie?: boolean;
|
74
75
|
// Defaults to "Lax" (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite)
|
75
76
|
sameSiteCookie?: string;
|
76
77
|
logLevel?: string;
|
77
|
-
getSourceConfig?: () =>
|
78
|
-
| string
|
79
|
-
| apiObject
|
80
|
-
| Promise<apiObject>
|
81
|
-
| Promise<string>;
|
78
|
+
getSourceConfig?: () => string | apiObject | Promise<apiObject> | Promise<string>;
|
82
79
|
setCookieDomain?: string;
|
83
80
|
sendAdblockPage?: boolean;
|
84
81
|
sendAdblockPageOptions?: apiOptions;
|
@@ -92,7 +89,7 @@ declare module "rudder-sdk-js" {
|
|
92
89
|
sessions?: {
|
93
90
|
autoTrack?: boolean; // Defaults to true
|
94
91
|
timeout?: number; // Defaults to 30 mins
|
95
|
-
}
|
92
|
+
};
|
96
93
|
}
|
97
94
|
|
98
95
|
/**
|
@@ -139,11 +136,7 @@ declare module "rudder-sdk-js" {
|
|
139
136
|
* @param dataPlaneUrl
|
140
137
|
* @param options
|
141
138
|
*/
|
142
|
-
function load(
|
143
|
-
writeKey: string,
|
144
|
-
dataPlaneUrl: string,
|
145
|
-
options?: loadOptions
|
146
|
-
): void;
|
139
|
+
function load(writeKey: string, dataPlaneUrl: string, options?: loadOptions): void;
|
147
140
|
|
148
141
|
/**
|
149
142
|
* To register a callback for SDK ready state
|
@@ -164,7 +157,7 @@ declare module "rudder-sdk-js" {
|
|
164
157
|
name?: string,
|
165
158
|
properties?: apiObject,
|
166
159
|
options?: apiOptions,
|
167
|
-
callback?: apiCallback
|
160
|
+
callback?: apiCallback,
|
168
161
|
): void;
|
169
162
|
|
170
163
|
/**
|
@@ -174,12 +167,7 @@ declare module "rudder-sdk-js" {
|
|
174
167
|
* @param properties
|
175
168
|
* @param callback
|
176
169
|
*/
|
177
|
-
function page(
|
178
|
-
category: string,
|
179
|
-
name: string,
|
180
|
-
properties: apiObject,
|
181
|
-
callback: apiCallback
|
182
|
-
): void;
|
170
|
+
function page(category: string, name: string, properties: apiObject, callback: apiCallback): void;
|
183
171
|
|
184
172
|
/**
|
185
173
|
* To record a page view event
|
@@ -200,7 +188,7 @@ declare module "rudder-sdk-js" {
|
|
200
188
|
name: string,
|
201
189
|
properties?: apiObject,
|
202
190
|
options?: apiOptions,
|
203
|
-
callback?: apiCallback
|
191
|
+
callback?: apiCallback,
|
204
192
|
): void;
|
205
193
|
|
206
194
|
/**
|
@@ -209,11 +197,7 @@ declare module "rudder-sdk-js" {
|
|
209
197
|
* @param properties
|
210
198
|
* @param callback
|
211
199
|
*/
|
212
|
-
function page(
|
213
|
-
name: string,
|
214
|
-
properties: apiObject,
|
215
|
-
callback: apiCallback
|
216
|
-
): void;
|
200
|
+
function page(name: string, properties: apiObject, callback: apiCallback): void;
|
217
201
|
|
218
202
|
/**
|
219
203
|
*
|
@@ -228,11 +212,7 @@ declare module "rudder-sdk-js" {
|
|
228
212
|
* @param options
|
229
213
|
* @param callback
|
230
214
|
*/
|
231
|
-
function page(
|
232
|
-
properties: apiObject,
|
233
|
-
options: apiOptions,
|
234
|
-
callback?: apiCallback
|
235
|
-
): void;
|
215
|
+
function page(properties: apiObject, options: apiOptions, callback?: apiCallback): void;
|
236
216
|
|
237
217
|
/**
|
238
218
|
* To record a page view event
|
@@ -252,7 +232,7 @@ declare module "rudder-sdk-js" {
|
|
252
232
|
event: string,
|
253
233
|
properties?: apiObject,
|
254
234
|
options?: apiOptions,
|
255
|
-
callback?: apiCallback
|
235
|
+
callback?: apiCallback,
|
256
236
|
): void;
|
257
237
|
|
258
238
|
/**
|
@@ -261,11 +241,7 @@ declare module "rudder-sdk-js" {
|
|
261
241
|
* @param properties
|
262
242
|
* @param callback
|
263
243
|
*/
|
264
|
-
function track(
|
265
|
-
event: string,
|
266
|
-
properties: apiObject,
|
267
|
-
callback: apiCallback
|
268
|
-
): void;
|
244
|
+
function track(event: string, properties: apiObject, callback: apiCallback): void;
|
269
245
|
|
270
246
|
/**
|
271
247
|
* To record a user track event
|
@@ -285,7 +261,7 @@ declare module "rudder-sdk-js" {
|
|
285
261
|
userId?: string,
|
286
262
|
traits?: apiObject,
|
287
263
|
options?: apiOptions,
|
288
|
-
callback?: apiCallback
|
264
|
+
callback?: apiCallback,
|
289
265
|
): void;
|
290
266
|
|
291
267
|
/**
|
@@ -294,11 +270,7 @@ declare module "rudder-sdk-js" {
|
|
294
270
|
* @param traits
|
295
271
|
* @param callback
|
296
272
|
*/
|
297
|
-
function identify(
|
298
|
-
userId: string,
|
299
|
-
traits: apiObject,
|
300
|
-
callback: apiCallback
|
301
|
-
): void;
|
273
|
+
function identify(userId: string, traits: apiObject, callback: apiCallback): void;
|
302
274
|
|
303
275
|
/**
|
304
276
|
* To record a user identification event
|
@@ -313,11 +285,7 @@ declare module "rudder-sdk-js" {
|
|
313
285
|
* @param options
|
314
286
|
* @param callback
|
315
287
|
*/
|
316
|
-
function identify(
|
317
|
-
traits: apiObject,
|
318
|
-
options: apiOptions,
|
319
|
-
callback?: apiCallback
|
320
|
-
): void;
|
288
|
+
function identify(traits: apiObject, options: apiOptions, callback?: apiCallback): void;
|
321
289
|
|
322
290
|
/**
|
323
291
|
*
|
@@ -333,12 +301,7 @@ declare module "rudder-sdk-js" {
|
|
333
301
|
* @param options
|
334
302
|
* @param callback
|
335
303
|
*/
|
336
|
-
function alias(
|
337
|
-
to: string,
|
338
|
-
from?: string,
|
339
|
-
options?: apiOptions,
|
340
|
-
callback?: apiCallback
|
341
|
-
): void;
|
304
|
+
function alias(to: string, from?: string, options?: apiOptions, callback?: apiCallback): void;
|
342
305
|
|
343
306
|
/**
|
344
307
|
* To record a user alias event
|
@@ -374,7 +337,7 @@ declare module "rudder-sdk-js" {
|
|
374
337
|
groupId: string,
|
375
338
|
traits?: apiObject,
|
376
339
|
options?: apiOptions,
|
377
|
-
callback?: apiCallback
|
340
|
+
callback?: apiCallback,
|
378
341
|
): void;
|
379
342
|
|
380
343
|
/**
|
@@ -383,11 +346,7 @@ declare module "rudder-sdk-js" {
|
|
383
346
|
* @param traits
|
384
347
|
* @param callback
|
385
348
|
*/
|
386
|
-
function group(
|
387
|
-
groupId: string,
|
388
|
-
traits: apiObject,
|
389
|
-
callback: apiCallback
|
390
|
-
): void;
|
349
|
+
function group(groupId: string, traits: apiObject, callback: apiCallback): void;
|
391
350
|
|
392
351
|
/**
|
393
352
|
* To record a user group event
|
@@ -402,11 +361,7 @@ declare module "rudder-sdk-js" {
|
|
402
361
|
* @param options
|
403
362
|
* @param callback
|
404
363
|
*/
|
405
|
-
function group(
|
406
|
-
traits: apiObject,
|
407
|
-
options: apiOptions,
|
408
|
-
callback?: apiCallback
|
409
|
-
): void;
|
364
|
+
function group(traits: apiObject, options: apiOptions, callback?: apiCallback): void;
|
410
365
|
|
411
366
|
/**
|
412
367
|
* To record a user group event
|
@@ -425,10 +380,7 @@ declare module "rudder-sdk-js" {
|
|
425
380
|
* @param anonymousId
|
426
381
|
* @param rudderAmpLinkerParm AMP Linker ID string
|
427
382
|
*/
|
428
|
-
function setAnonymousId(
|
429
|
-
anonymousId?: string,
|
430
|
-
rudderAmpLinkerParm?: string
|
431
|
-
): void;
|
383
|
+
function setAnonymousId(anonymousId?: string, rudderAmpLinkerParm?: string): void;
|
432
384
|
|
433
385
|
/**
|
434
386
|
* Clear user information
|
@@ -459,12 +411,17 @@ declare module "rudder-sdk-js" {
|
|
459
411
|
/**
|
460
412
|
* To manually start user session in the SDK
|
461
413
|
*/
|
462
|
-
|
414
|
+
function startSession(sessionId?: number): void;
|
463
415
|
|
464
|
-
|
416
|
+
/**
|
465
417
|
* To manually end user session in the SDK
|
466
418
|
*/
|
467
|
-
|
419
|
+
function endSession(): void;
|
420
|
+
|
421
|
+
/**
|
422
|
+
* To fetch the current sessionId
|
423
|
+
*/
|
424
|
+
function getSessionId(): number | null;
|
468
425
|
|
469
426
|
export {
|
470
427
|
integrationOptions,
|
@@ -490,5 +447,6 @@ declare module "rudder-sdk-js" {
|
|
490
447
|
getGroupTraits,
|
491
448
|
startSession,
|
492
449
|
endSession,
|
450
|
+
getSessionId,
|
493
451
|
};
|
494
452
|
}
|