rudder-sdk-js 2.5.0 → 2.6.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.
Files changed (2) hide show
  1. package/index.js +43 -13
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4793,6 +4793,7 @@
4793
4793
  CHARTBEAT: "Chartbeat",
4794
4794
  COMSCORE: "Comscore",
4795
4795
  CUSTOMERIO: "Customer IO",
4796
+ DCM_Floodlight: "DCM Floodlight",
4796
4797
  FACEBOOK_PIXEL: "Facebook Pixel",
4797
4798
  GTM: "Google Tag Manager",
4798
4799
  HOTJAR: "Hotjar",
@@ -4835,7 +4836,7 @@
4835
4836
 
4836
4837
  // Reserved Keywords for properties/traits
4837
4838
  var ReservedPropertyKeywords = ["anonymous_id", "id", "sent_at", "received_at", "timestamp", "original_timestamp", "event_text", "event"]; // ECommerce Parameter Names Enumeration
4838
- var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=2.5.0";
4839
+ var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=2.6.0";
4839
4840
  var CDN_INT_DIR = "js-integrations";
4840
4841
  var DEST_SDK_BASE_URL = "https://cdn.rudderlabs.com/v1.1/".concat(CDN_INT_DIR);
4841
4842
  var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
@@ -11541,7 +11542,7 @@
11541
11542
  this.build = "1.0.0";
11542
11543
  this.name = "RudderLabs JavaScript SDK";
11543
11544
  this.namespace = "com.rudderlabs.javascript";
11544
- this.version = "2.5.0";
11545
+ this.version = "2.6.0";
11545
11546
  });
11546
11547
 
11547
11548
  /* eslint-disable max-classes-per-file */
@@ -11550,7 +11551,7 @@
11550
11551
  _classCallCheck(this, RudderLibraryInfo);
11551
11552
 
11552
11553
  this.name = "RudderLabs JavaScript SDK";
11553
- this.version = "2.5.0";
11554
+ this.version = "2.6.0";
11554
11555
  }); // Operating System information class
11555
11556
 
11556
11557
 
@@ -13809,10 +13810,9 @@
13809
13810
  this.eventRepository = eventRepository;
13810
13811
  this.sendAdblockPage = false;
13811
13812
  this.sendAdblockPageOptions = {};
13812
- this.clientSuppliedCallbacks = {};
13813
-
13814
- this.readyCallback = function () {};
13813
+ this.clientSuppliedCallbacks = {}; // Array to store the callback functions registered in the ready API
13815
13814
 
13815
+ this.readyCallbacks = [];
13816
13816
  this.methodToCallbackMapping = {
13817
13817
  syncPixel: "syncPixelCallback"
13818
13818
  };
@@ -13821,7 +13821,9 @@
13821
13821
  this.dynamicallyLoadedIntegrations = {};
13822
13822
  this.destSDKBaseURL = DEST_SDK_BASE_URL;
13823
13823
  this.cookieConsentOptions = {};
13824
- this.logLevel = undefined;
13824
+ this.logLevel = undefined; // flag to indicate client integrations` ready status
13825
+
13826
+ this.clientIntegrationsReady = false;
13825
13827
  }
13826
13828
  /**
13827
13829
  * initialize the user after load config
@@ -13880,6 +13882,18 @@
13880
13882
  });
13881
13883
  });
13882
13884
  }
13885
+ /**
13886
+ * Function to execute the ready method callbacks
13887
+ * @param {Analytics} self
13888
+ */
13889
+
13890
+ }, {
13891
+ key: "executeReadyCallback",
13892
+ value: function executeReadyCallback() {
13893
+ this.readyCallbacks.forEach(function (callback) {
13894
+ return callback();
13895
+ });
13896
+ }
13883
13897
  /**
13884
13898
  * Process the response from control plane and
13885
13899
  * call initialize for integrations
@@ -13987,11 +14001,13 @@
13987
14001
  var self = this;
13988
14002
  this.allModulesInitialized().then(function () {
13989
14003
  if (!self.clientIntegrations || self.clientIntegrations.length == 0) {
13990
- if (self.readyCallback) {
13991
- self.readyCallback();
13992
- }
14004
+ // If no integrations are there to be loaded
14005
+ // set clientIntegrationsReady to be true
14006
+ _this2.clientIntegrationsReady = true; // Execute the callbacks if any
13993
14007
 
13994
- self.toBeProcessedByIntegrationArray = [];
14008
+ _this2.executeReadyCallback();
14009
+
14010
+ _this2.toBeProcessedByIntegrationArray = [];
13995
14011
  return;
13996
14012
  }
13997
14013
 
@@ -14024,7 +14040,11 @@
14024
14040
  if (object.clientIntegrationObjects.every(function (intg) {
14025
14041
  return !intg.isReady || intg.isReady();
14026
14042
  })) {
14027
- object.readyCallback();
14043
+ // Integrations are ready
14044
+ // set clientIntegrationsReady to be true
14045
+ object.clientIntegrationsReady = true; // Execute the callbacks if any
14046
+
14047
+ object.executeReadyCallback();
14028
14048
  } // send the queued events to the fetched integration
14029
14049
 
14030
14050
 
@@ -14753,7 +14773,17 @@
14753
14773
  if (!this.loaded) return;
14754
14774
 
14755
14775
  if (typeof callback === "function") {
14756
- this.readyCallback = callback;
14776
+ /**
14777
+ * If integrations are loaded or no integration is available for loading
14778
+ * execute the callback immediately
14779
+ * else push the callbacks to a queue that will be executed after loading completes
14780
+ */
14781
+ if (this.clientIntegrationsReady) {
14782
+ callback();
14783
+ } else {
14784
+ this.readyCallbacks.push(callback);
14785
+ }
14786
+
14757
14787
  return;
14758
14788
  }
14759
14789
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rudder-sdk-js",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "RudderStack Javascript SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",