@rudderstack/analytics-js 3.6.0 → 3.7.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 CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [3.7.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.6.1...@rudderstack/analytics-js@3.7.0) (2024-07-19)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `@rudderstack/analytics-js-cookies` updated to version `3.6.1`
10
+ * `@rudderstack/analytics-js-common` updated to version `3.6.1`
11
+ * `@rudderstack/analytics-js-plugins` updated to version `3.6.1`
12
+
13
+ ### Features
14
+
15
+ * error reporting plugin ([#1601](https://github.com/rudderlabs/rudder-sdk-js/issues/1601)) ([1f2629e](https://github.com/rudderlabs/rudder-sdk-js/commit/1f2629e594740763ce9bd54a21213b92d80ae085))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * event API overloads ([#1782](https://github.com/rudderlabs/rudder-sdk-js/issues/1782)) ([02c5b47](https://github.com/rudderlabs/rudder-sdk-js/commit/02c5b47d0a83250fb5180e9ed467a92361663dab))
21
+
22
+ ## [3.6.1](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.6.0...@rudderstack/analytics-js@3.6.1) (2024-07-05)
23
+
24
+ ### Dependency Updates
25
+
26
+ * `@rudderstack/analytics-js-cookies` updated to version `3.6.0`
27
+ * `@rudderstack/analytics-js-common` updated to version `3.6.0`
28
+ * `@rudderstack/analytics-js-plugins` updated to version `3.6.0`
29
+
30
+ ### Bug Fixes
31
+
32
+ * package lint issues ([#1773](https://github.com/rudderlabs/rudder-sdk-js/issues/1773)) ([8e45d05](https://github.com/rudderlabs/rudder-sdk-js/commit/8e45d052bd6366d647d06226aa89b1fa2e512f9d))
33
+
5
34
  ## [3.6.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.5.2...@rudderstack/analytics-js@3.6.0) (2024-07-04)
6
35
 
7
36
  ### Dependency Updates
package/LICENSE.md ADDED
@@ -0,0 +1,53 @@
1
+ ### Elastic License 2.0 (ELv2)
2
+
3
+ ## Acceptance
4
+
5
+ By using the software, you agree to all of the terms and conditions below.
6
+
7
+ ## Copyright License
8
+
9
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
10
+
11
+ ## Limitations
12
+
13
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
14
+
15
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
16
+
17
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor's trademarks is subject to applicable law.
18
+
19
+ ## Patents
20
+
21
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
22
+
23
+ ## Notices
24
+
25
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
26
+
27
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
28
+
29
+ ## No Other Rights
30
+
31
+ These terms do not imply any licenses other than those expressly granted in these terms.
32
+
33
+ ## Termination
34
+
35
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
36
+
37
+ ## No Liability
38
+
39
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
40
+
41
+ ## Definitions
42
+
43
+ The *licensor* is the entity offering these terms, and the *software* is the software the licensor makes available under these terms, including any portion of it.
44
+
45
+ *you* refers to the individual or entity agreeing to these terms.
46
+
47
+ *your company* is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. *control* means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
48
+
49
+ *your licenses* are all the licenses granted to you for the software under these terms.
50
+
51
+ *use* means anything you do with the software requiring one of your licenses.
52
+
53
+ *trademark* means trademarks, service marks, and similar rights.
package/README.md CHANGED
@@ -92,3 +92,47 @@ For more details, see:
92
92
 
93
93
  - [Vercel Edge Usage](https://github.com/rudderlabs/rudder-sdk-js/blob/main/examples/serverless/USAGE.md)
94
94
  - [Cloudflare Worker Usage](https://github.com/rudderlabs/rudder-sdk-js/blob/main/examples/serverless/USAGE.md)
95
+
96
+ ## License
97
+
98
+ This project is licensed under the Elastic License 2.0. See the [LICENSE.md](LICENSE.md) file for details. Review the license terms to understand your permissions and restrictions.
99
+
100
+ If you have any questions about licensing, please [contact us](#contact-us) or refer to the [official Elastic licensing](https://www.elastic.co/licensing/elastic-license) page.
101
+
102
+ ## Contribute
103
+
104
+ We invite you to contribute to this project. For more information on how to contribute, please see [**here**](../../CONTRIBUTING.md).
105
+
106
+ ## Contact us
107
+
108
+ For more information on any of the sections covered in this readme, you can [**contact us**](mailto:%20docs@rudderstack.com) or start a conversation on our [**Slack**](https://resources.rudderstack.com/join-rudderstack-slack) channel.
109
+
110
+ ## Follow Us
111
+
112
+ - [RudderStack Blog][rudderstack-blog]
113
+ - [Slack][slack]
114
+ - [Twitter][twitter]
115
+ - [LinkedIn][linkedin]
116
+ - [dev.to][devto]
117
+ - [Medium][medium]
118
+ - [YouTube][youtube]
119
+ - [HackerNews][hackernews]
120
+ - [Product Hunt][producthunt]
121
+
122
+ ## :clap: Our Supporters
123
+
124
+ [![Stargazers repo roster for @rudderlabs/rudder-sdk-js](https://reporoster.com/stars/rudderlabs/rudder-sdk-js)](https://github.com/rudderlabs/rudder-sdk-js/stargazers)
125
+
126
+ [![Forkers repo roster for @rudderlabs/rudder-sdk-js](https://reporoster.com/forks/rudderlabs/rudder-sdk-js)](https://github.com/rudderlabs/rudder-sdk-js/network/members)
127
+
128
+ <!----variables---->
129
+
130
+ [rudderstack-blog]: https://rudderstack.com/blog/
131
+ [slack]: https://resources.rudderstack.com/join-rudderstack-slack
132
+ [twitter]: https://twitter.com/rudderstack
133
+ [linkedin]: https://www.linkedin.com/company/rudderlabs/
134
+ [devto]: https://dev.to/rudderstack
135
+ [medium]: https://rudderstack.medium.com/
136
+ [youtube]: https://www.youtube.com/channel/UCgV-B77bV_-LOmKYHw8jvBw
137
+ [hackernews]: https://news.ycombinator.com/item?id=21081756
138
+ [producthunt]: https://www.producthunt.com/posts/rudderstack
@@ -44,7 +44,7 @@ type Nullable<T> = T | null;
44
44
  * Use for parameters like properties, traits etc.
45
45
  */
46
46
  type ApiObject = {
47
- [index: string]: string | number | boolean | ApiObject | null | Date | (string | number | boolean | null | ApiObject)[] | undefined;
47
+ [index: string]: string | number | boolean | ApiObject | null | Date | (string | number | boolean | null | Date | ApiObject)[] | undefined;
48
48
  };
49
49
 
50
50
  type DestinationIntgConfig = boolean | undefined | ApiObject;
@@ -79,7 +79,7 @@ type APIEvent = {
79
79
  callback?: () => void;
80
80
  userId?: Nullable<string>;
81
81
  traits?: Nullable<ApiObject>;
82
- to?: Nullable<string>;
82
+ to?: string;
83
83
  from?: string;
84
84
  groupId?: Nullable<string>;
85
85
  };
@@ -338,7 +338,6 @@ type IdentifyTraits = {
338
338
  prospect?: string | boolean;
339
339
  doubleOptin?: string | boolean;
340
340
  event_id?: string;
341
- constructor?: Record<string, string>;
342
341
  organization?: string;
343
342
  region?: string;
344
343
  anonymous?: string | boolean;
@@ -354,45 +353,44 @@ type IdentifyTraits = {
354
353
  anonymousId?: string | number;
355
354
  ip_address?: string;
356
355
  number?: string | number;
357
- [index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | null | ApiObject)[] | undefined;
356
+ [index: string]: string | number | boolean | ApiObject | null | Date | (string | number | boolean | null | Date | ApiObject)[] | undefined;
358
357
  };
359
358
 
360
359
  type AnalyticsIdentifyMethod = {
361
- (userId?: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
362
- (userId: string, traits: Nullable<IdentifyTraits>, callback: ApiCallback): void;
363
- (userId: string, callback: ApiCallback): void;
364
- (traits: Nullable<IdentifyTraits>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
360
+ (userId: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
361
+ (userId: string, traits?: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
362
+ (userId: string, callback?: ApiCallback): void;
363
+ (traits: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
365
364
  (traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
366
365
  };
367
366
  type AnalyticsPageMethod = {
368
- (category?: string, name?: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
369
- (category: string, name: string, properties: Nullable<ApiObject>, callback: ApiCallback): void;
367
+ (category: string, name: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
368
+ (category: string, name: string, properties?: Nullable<ApiObject>, callback?: ApiCallback): void;
369
+ (category: string, name: string, callback?: ApiCallback): void;
370
370
  (name: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
371
- (category: string, name: string, callback: ApiCallback): void;
372
- (name: string, properties: Nullable<ApiObject>, callback: ApiCallback): void;
373
- (name: string, callback: ApiCallback): void;
374
- (properties: Nullable<ApiObject>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
371
+ (name: string, properties?: Nullable<ApiObject>, callback?: ApiCallback): void;
372
+ (name: string, callback?: ApiCallback): void;
373
+ (properties: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
375
374
  (properties: Nullable<ApiObject>, callback?: ApiCallback): void;
375
+ (callback?: ApiCallback): void;
376
376
  };
377
377
  type AnalyticsTrackMethod = {
378
378
  (event: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
379
- (event: string, properties: Nullable<ApiObject>, callback: ApiCallback): void;
380
- (event: string, callback: ApiCallback): void;
379
+ (event: string, properties?: Nullable<ApiObject>, callback?: ApiCallback): void;
380
+ (event: string, callback?: ApiCallback): void;
381
381
  };
382
382
  type AnalyticsGroupMethod = {
383
- (groupId: string | number, traits?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
384
- (groupId: string | number, traits: Nullable<ApiObject>, callback: ApiCallback): void;
385
- (groupId: string | number, callback: ApiCallback): void;
386
- (traits: Nullable<ApiObject>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
387
- (traits: Nullable<ApiObject>, callback?: ApiCallback): void;
383
+ (groupId: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
384
+ (groupId: string, traits?: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
385
+ (groupId: string, callback?: ApiCallback): void;
386
+ (traits: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
387
+ (traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
388
388
  };
389
389
  type AnalyticsAliasMethod = {
390
- (to: Nullable<string>, from?: string, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
391
- (to: Nullable<string>, from: string, callback: ApiCallback): void;
392
- (to: Nullable<string>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
393
- (to: Nullable<string>, callback: ApiCallback): void;
394
- (to: ApiCallback): void;
395
- (): void;
390
+ (to: string, from?: string, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
391
+ (to: string, from?: string, callback?: ApiCallback): void;
392
+ (to: string, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
393
+ (to: string, callback?: ApiCallback): void;
396
394
  };
397
395
  interface IRudderAnalytics<T = any> {
398
396
  analyticsInstances: Record<string, T>;
@@ -497,6 +495,20 @@ interface IRudderAnalytics<T = any> {
497
495
  consent(options?: ConsentOptions): void;
498
496
  }
499
497
 
498
+ /**
499
+ * A buffer queue to serve as a store for any type of data
500
+ */
501
+ declare class BufferQueue<T = any> {
502
+ items: T[];
503
+ constructor();
504
+ enqueue(item: T): void;
505
+ dequeue(): Nullable<T> | undefined;
506
+ isEmpty(): boolean;
507
+ size(): number;
508
+ clear(): void;
509
+ }
510
+ //# sourceMappingURL=BufferQueue.d.ts.map
511
+
500
512
  interface IExternalSourceLoadConfig {
501
513
  url: string;
502
514
  id: string;
@@ -509,36 +521,22 @@ interface IExternalSrcLoader {
509
521
  errorHandler?: {
510
522
  onError(error: unknown, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean): void;
511
523
  leaveBreadcrumb(breadcrumb: string): void;
512
- notifyError(error: Error): void;
524
+ notifyError(error: Error, errorState: ErrorState): void;
513
525
  };
514
526
  logger?: ILogger;
515
527
  timeout: number;
516
528
  loadJSFile(config: IExternalSourceLoadConfig): void;
517
529
  }
518
530
 
519
- /**
520
- * A buffer queue to serve as a store for any type of data
521
- */
522
- declare class BufferQueue<T = any> {
523
- items: T[];
524
- constructor();
525
- enqueue(item: T): void;
526
- dequeue(): Nullable<T> | undefined;
527
- isEmpty(): boolean;
528
- size(): number;
529
- clear(): void;
530
- }
531
- //# sourceMappingURL=BufferQueue.d.ts.map
532
-
533
531
  type SDKError = unknown | Error | ErrorEvent | Event | PromiseRejectionEvent;
534
532
  interface IErrorHandler {
535
533
  logger?: ILogger;
536
534
  pluginEngine?: IPluginEngine;
537
535
  errorBuffer: BufferQueue<PreLoadErrorData>;
538
- init(externalSrcLoader: IExternalSrcLoader): void;
536
+ init(httpClient: IHttpClient, externalSrcLoader: IExternalSrcLoader): void;
539
537
  onError(error: SDKError, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean, errorType?: string): void;
540
538
  leaveBreadcrumb(breadcrumb: string): void;
541
- notifyError(error: Error): void;
539
+ notifyError(error: Error, errorState: ErrorState): void;
542
540
  attachErrorListeners(): void;
543
541
  }
544
542
  type ErrorState = {
@@ -670,14 +668,14 @@ type TrackCallOptions = {
670
668
  callback?: ApiCallback;
671
669
  };
672
670
  type IdentifyCallOptions = {
673
- userId?: string | null;
671
+ userId?: Nullable<string>;
674
672
  traits?: Nullable<IdentifyTraits>;
675
673
  options?: Nullable<ApiOptions>;
676
674
  callback?: ApiCallback;
677
675
  };
678
676
  type AliasCallOptions = {
679
- to?: Nullable<string>;
680
- from?: Nullable<string>;
677
+ to: string;
678
+ from?: string;
681
679
  options?: Nullable<ApiOptions>;
682
680
  callback?: ApiCallback;
683
681
  };
@@ -982,23 +980,44 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
982
980
  /**
983
981
  * Process page arguments and forward to page call
984
982
  */
985
- page(category?: string | Nullable<ApiObject> | ApiCallback, name?: string | Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, properties?: Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
983
+ page(category: string, name: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
984
+ page(category: string, name: string, properties?: Nullable<ApiObject>, callback?: ApiCallback): void;
985
+ page(category: string, name: string, callback?: ApiCallback): void;
986
+ page(name: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
987
+ page(name: string, properties?: Nullable<ApiObject>, callback?: ApiCallback): void;
988
+ page(name: string, callback?: ApiCallback): void;
989
+ page(properties: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
990
+ page(properties: Nullable<ApiObject>, callback?: ApiCallback): void;
991
+ page(callback?: ApiCallback): void;
986
992
  /**
987
993
  * Process track arguments and forward to page call
988
994
  */
989
- track(event: string, properties?: Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
995
+ track(event: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
996
+ track(event: string, properties?: Nullable<ApiObject>, callback?: ApiCallback): void;
997
+ track(event: string, callback?: ApiCallback): void;
990
998
  /**
991
999
  * Process identify arguments and forward to page call
992
1000
  */
993
- identify(userId?: string | number | Nullable<IdentifyTraits>, traits?: Nullable<IdentifyTraits> | Nullable<ApiOptions> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
1001
+ identify(userId: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
1002
+ identify(userId: string, traits?: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
1003
+ identify(userId: string, callback?: ApiCallback): void;
1004
+ identify(traits: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
1005
+ identify(traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
994
1006
  /**
995
1007
  * Process alias arguments and forward to page call
996
1008
  */
997
- alias(to?: Nullable<string> | ApiCallback, from?: string | Nullable<ApiOptions> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
1009
+ alias(to: string, from?: string, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
1010
+ alias(to: string, from?: string, callback?: ApiCallback): void;
1011
+ alias(to: string, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
1012
+ alias(to: string, callback?: ApiCallback): void;
998
1013
  /**
999
1014
  * Process group arguments and forward to page call
1000
1015
  */
1001
- group(groupId: string | number | Nullable<ApiObject> | ApiCallback, traits?: Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
1016
+ group(groupId: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
1017
+ group(groupId: string, traits?: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
1018
+ group(groupId: string, callback?: ApiCallback): void;
1019
+ group(traits: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
1020
+ group(traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
1002
1021
  reset(resetAnonymousId?: boolean): void;
1003
1022
  getAnonymousId(options?: AnonymousIdOptions): string | undefined;
1004
1023
  setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;