rudder-sdk-js 2.21.0 → 2.21.1
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/README.md +29 -29
- package/index.d.ts +71 -22
- package/index.es.js +15037 -1
- package/index.html +8 -0
- package/index.js +15063 -1
- package/package.json +2 -2
- package/service-worker/index.d.ts +13 -7
- package/service-worker/index.es.js +10738 -4863
- package/service-worker/index.js +10738 -4863
- package/CHANGELOG.md +0 -3328
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,6 +68,7 @@ The APIs exported by the module are:
|
|
68
68
|
- `getAnonymousId`
|
69
69
|
- `setAnonymousId`
|
70
70
|
|
71
|
+
|
71
72
|
### Sample implementations
|
72
73
|
|
73
74
|
Refer to the following projects for a detailed walk-through of the above steps:
|
@@ -77,15 +78,15 @@ Refer to the following projects for a detailed walk-through of the above steps:
|
|
77
78
|
|
78
79
|
### Supported browser versions
|
79
80
|
|
80
|
-
| **Browser**
|
81
|
-
|
|
82
|
-
| Safari
|
83
|
-
| IE
|
84
|
-
| Edge
|
85
|
-
| Mozilla Firefox
|
86
|
-
| Chrome
|
87
|
-
| Opera
|
88
|
-
| Yandex
|
81
|
+
| **Browser** | **Supported Versions** |
|
82
|
+
| :------------------ | :--------------------- |
|
83
|
+
| Safari | v7 or later |
|
84
|
+
| IE | v10 or later |
|
85
|
+
| Edge | v15 or later |
|
86
|
+
| Mozilla Firefox | v40 or later |
|
87
|
+
| Chrome | v37 or later |
|
88
|
+
| Opera | v23 or later |
|
89
|
+
| Yandex | v14.12 or later |
|
89
90
|
|
90
91
|
> 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.
|
91
92
|
|
@@ -97,27 +98,26 @@ A sample `identify()` call is shown below:
|
|
97
98
|
|
98
99
|
```javascript
|
99
100
|
rudderanalytics.identify(
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
},
|
104
|
-
{
|
101
|
+
"12345", {
|
102
|
+
email: "name@domain.com"
|
103
|
+
}, {
|
105
104
|
page: {
|
106
|
-
path:
|
107
|
-
referrer:
|
108
|
-
search:
|
109
|
-
title:
|
110
|
-
url:
|
105
|
+
path: "",
|
106
|
+
referrer: "",
|
107
|
+
search: "",
|
108
|
+
title: "",
|
109
|
+
url: "",
|
111
110
|
},
|
112
111
|
},
|
113
112
|
() => {
|
114
|
-
console.log(
|
115
|
-
}
|
113
|
+
console.log("in identify call");
|
114
|
+
}
|
116
115
|
);
|
117
116
|
```
|
118
117
|
|
119
118
|
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.
|
120
119
|
|
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,15 +130,14 @@ A sample `track` call is shown below:
|
|
130
130
|
|
131
131
|
```javascript
|
132
132
|
rudderanalytics.track(
|
133
|
-
|
134
|
-
{
|
133
|
+
"test track event GA3", {
|
135
134
|
revenue: 30,
|
136
|
-
currency:
|
135
|
+
currency: "USD",
|
137
136
|
user_actual_id: 12345,
|
138
137
|
},
|
139
138
|
() => {
|
140
|
-
console.log(
|
141
|
-
}
|
139
|
+
console.log("in track call");
|
140
|
+
}
|
142
141
|
);
|
143
142
|
```
|
144
143
|
|
@@ -154,12 +153,13 @@ An example is shown in the following snippet:
|
|
154
153
|
|
155
154
|
```javascript
|
156
155
|
rudderanalytics.ready(() => {
|
157
|
-
console.log(
|
156
|
+
console.log("we are all set!!!");
|
158
157
|
});
|
159
158
|
```
|
160
159
|
|
161
160
|
> 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).
|
162
161
|
|
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,7 +74,11 @@ 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?: () =>
|
77
|
+
getSourceConfig?: () =>
|
78
|
+
| string
|
79
|
+
| apiObject
|
80
|
+
| Promise<apiObject>
|
81
|
+
| Promise<string>;
|
78
82
|
setCookieDomain?: string;
|
79
83
|
sendAdblockPage?: boolean;
|
80
84
|
sendAdblockPageOptions?: apiOptions;
|
@@ -88,7 +92,7 @@ declare module 'rudder-sdk-js' {
|
|
88
92
|
sessions?: {
|
89
93
|
autoTrack?: boolean; // Defaults to true
|
90
94
|
timeout?: number; // Defaults to 30 mins
|
91
|
-
}
|
95
|
+
}
|
92
96
|
}
|
93
97
|
|
94
98
|
/**
|
@@ -135,7 +139,11 @@ declare module 'rudder-sdk-js' {
|
|
135
139
|
* @param dataPlaneUrl
|
136
140
|
* @param options
|
137
141
|
*/
|
138
|
-
function load(
|
142
|
+
function load(
|
143
|
+
writeKey: string,
|
144
|
+
dataPlaneUrl: string,
|
145
|
+
options?: loadOptions
|
146
|
+
): void;
|
139
147
|
|
140
148
|
/**
|
141
149
|
* To register a callback for SDK ready state
|
@@ -156,7 +164,7 @@ declare module 'rudder-sdk-js' {
|
|
156
164
|
name?: string,
|
157
165
|
properties?: apiObject,
|
158
166
|
options?: apiOptions,
|
159
|
-
callback?: apiCallback
|
167
|
+
callback?: apiCallback
|
160
168
|
): void;
|
161
169
|
|
162
170
|
/**
|
@@ -166,7 +174,12 @@ declare module 'rudder-sdk-js' {
|
|
166
174
|
* @param properties
|
167
175
|
* @param callback
|
168
176
|
*/
|
169
|
-
function page(
|
177
|
+
function page(
|
178
|
+
category: string,
|
179
|
+
name: string,
|
180
|
+
properties: apiObject,
|
181
|
+
callback: apiCallback
|
182
|
+
): void;
|
170
183
|
|
171
184
|
/**
|
172
185
|
* To record a page view event
|
@@ -187,7 +200,7 @@ declare module 'rudder-sdk-js' {
|
|
187
200
|
name: string,
|
188
201
|
properties?: apiObject,
|
189
202
|
options?: apiOptions,
|
190
|
-
callback?: apiCallback
|
203
|
+
callback?: apiCallback
|
191
204
|
): void;
|
192
205
|
|
193
206
|
/**
|
@@ -196,7 +209,11 @@ declare module 'rudder-sdk-js' {
|
|
196
209
|
* @param properties
|
197
210
|
* @param callback
|
198
211
|
*/
|
199
|
-
function page(
|
212
|
+
function page(
|
213
|
+
name: string,
|
214
|
+
properties: apiObject,
|
215
|
+
callback: apiCallback
|
216
|
+
): void;
|
200
217
|
|
201
218
|
/**
|
202
219
|
*
|
@@ -211,7 +228,11 @@ declare module 'rudder-sdk-js' {
|
|
211
228
|
* @param options
|
212
229
|
* @param callback
|
213
230
|
*/
|
214
|
-
function page(
|
231
|
+
function page(
|
232
|
+
properties: apiObject,
|
233
|
+
options: apiOptions,
|
234
|
+
callback?: apiCallback
|
235
|
+
): void;
|
215
236
|
|
216
237
|
/**
|
217
238
|
* To record a page view event
|
@@ -231,7 +252,7 @@ declare module 'rudder-sdk-js' {
|
|
231
252
|
event: string,
|
232
253
|
properties?: apiObject,
|
233
254
|
options?: apiOptions,
|
234
|
-
callback?: apiCallback
|
255
|
+
callback?: apiCallback
|
235
256
|
): void;
|
236
257
|
|
237
258
|
/**
|
@@ -240,7 +261,11 @@ declare module 'rudder-sdk-js' {
|
|
240
261
|
* @param properties
|
241
262
|
* @param callback
|
242
263
|
*/
|
243
|
-
function track(
|
264
|
+
function track(
|
265
|
+
event: string,
|
266
|
+
properties: apiObject,
|
267
|
+
callback: apiCallback
|
268
|
+
): void;
|
244
269
|
|
245
270
|
/**
|
246
271
|
* To record a user track event
|
@@ -260,7 +285,7 @@ declare module 'rudder-sdk-js' {
|
|
260
285
|
userId?: string,
|
261
286
|
traits?: apiObject,
|
262
287
|
options?: apiOptions,
|
263
|
-
callback?: apiCallback
|
288
|
+
callback?: apiCallback
|
264
289
|
): void;
|
265
290
|
|
266
291
|
/**
|
@@ -269,7 +294,11 @@ declare module 'rudder-sdk-js' {
|
|
269
294
|
* @param traits
|
270
295
|
* @param callback
|
271
296
|
*/
|
272
|
-
function identify(
|
297
|
+
function identify(
|
298
|
+
userId: string,
|
299
|
+
traits: apiObject,
|
300
|
+
callback: apiCallback
|
301
|
+
): void;
|
273
302
|
|
274
303
|
/**
|
275
304
|
* To record a user identification event
|
@@ -284,7 +313,11 @@ declare module 'rudder-sdk-js' {
|
|
284
313
|
* @param options
|
285
314
|
* @param callback
|
286
315
|
*/
|
287
|
-
function identify(
|
316
|
+
function identify(
|
317
|
+
traits: apiObject,
|
318
|
+
options: apiOptions,
|
319
|
+
callback?: apiCallback
|
320
|
+
): void;
|
288
321
|
|
289
322
|
/**
|
290
323
|
*
|
@@ -300,7 +333,12 @@ declare module 'rudder-sdk-js' {
|
|
300
333
|
* @param options
|
301
334
|
* @param callback
|
302
335
|
*/
|
303
|
-
function alias(
|
336
|
+
function alias(
|
337
|
+
to: string,
|
338
|
+
from?: string,
|
339
|
+
options?: apiOptions,
|
340
|
+
callback?: apiCallback
|
341
|
+
): void;
|
304
342
|
|
305
343
|
/**
|
306
344
|
* To record a user alias event
|
@@ -336,7 +374,7 @@ declare module 'rudder-sdk-js' {
|
|
336
374
|
groupId: string,
|
337
375
|
traits?: apiObject,
|
338
376
|
options?: apiOptions,
|
339
|
-
callback?: apiCallback
|
377
|
+
callback?: apiCallback
|
340
378
|
): void;
|
341
379
|
|
342
380
|
/**
|
@@ -345,7 +383,11 @@ declare module 'rudder-sdk-js' {
|
|
345
383
|
* @param traits
|
346
384
|
* @param callback
|
347
385
|
*/
|
348
|
-
function group(
|
386
|
+
function group(
|
387
|
+
groupId: string,
|
388
|
+
traits: apiObject,
|
389
|
+
callback: apiCallback
|
390
|
+
): void;
|
349
391
|
|
350
392
|
/**
|
351
393
|
* To record a user group event
|
@@ -360,7 +402,11 @@ declare module 'rudder-sdk-js' {
|
|
360
402
|
* @param options
|
361
403
|
* @param callback
|
362
404
|
*/
|
363
|
-
function group(
|
405
|
+
function group(
|
406
|
+
traits: apiObject,
|
407
|
+
options: apiOptions,
|
408
|
+
callback?: apiCallback
|
409
|
+
): void;
|
364
410
|
|
365
411
|
/**
|
366
412
|
* To record a user group event
|
@@ -379,7 +425,10 @@ declare module 'rudder-sdk-js' {
|
|
379
425
|
* @param anonymousId
|
380
426
|
* @param rudderAmpLinkerParm AMP Linker ID string
|
381
427
|
*/
|
382
|
-
function setAnonymousId(
|
428
|
+
function setAnonymousId(
|
429
|
+
anonymousId?: string,
|
430
|
+
rudderAmpLinkerParm?: string
|
431
|
+
): void;
|
383
432
|
|
384
433
|
/**
|
385
434
|
* Clear user information
|
@@ -410,12 +459,12 @@ declare module 'rudder-sdk-js' {
|
|
410
459
|
/**
|
411
460
|
* To manually start user session in the SDK
|
412
461
|
*/
|
413
|
-
|
462
|
+
function startSession(sessionId?: number): void;
|
414
463
|
|
415
|
-
|
464
|
+
/**
|
416
465
|
* To manually end user session in the SDK
|
417
466
|
*/
|
418
|
-
|
467
|
+
function endSession(): void;
|
419
468
|
|
420
469
|
export {
|
421
470
|
integrationOptions,
|