countly-sdk-web 26.1.1 → 26.1.2

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
@@ -1,3 +1,7 @@
1
+ ## 26.1.2
2
+
3
+ - Delayed remote config refresh after merged device ID changes to reduce request ordering races.
4
+
1
5
  ## 26.1.1
2
6
 
3
7
  - Improved device metric detection capabilities.
@@ -15,7 +15,7 @@ function initMain(name, version) {
15
15
  }
16
16
 
17
17
  const SDK_NAME = "javascript_native_web";
18
- const SDK_VERSION = "26.1.1";
18
+ const SDK_VERSION = "26.1.2";
19
19
 
20
20
  // tests
21
21
  describe("Bridged SDK Utilities Tests", () => {
@@ -275,3 +275,48 @@ describe("Set ID change tests ", () => {
275
275
  });
276
276
 
277
277
  });
278
+
279
+ describe("Device ID remote config sequencing", () => {
280
+ it("delays remote config refetch by 1 second after merge device ID changes", () => {
281
+ hp.haltAndClearStorage(() => {
282
+ var fakeServer = hp.createFakeRequestHandler({
283
+ onRequest: function (req) {
284
+ if (req.functionName === "fetch_remote_config_explicit") {
285
+ return { status: 200, responseText: "{}" };
286
+ }
287
+
288
+ return { status: 200, responseText: '{"result":"Success"}' };
289
+ }
290
+ });
291
+
292
+ var inst = Countly.init({
293
+ app_key: hp.appKey,
294
+ url: "https://test.count.ly",
295
+ device_id: "old ID",
296
+ debug: true,
297
+ use_explicit_rc_api: true,
298
+ disable_sdk_behavior_settings_updates: true,
299
+ fake_request_handler: fakeServer.handler
300
+ });
301
+
302
+ cy.wait(hp.sWait).then(() => {
303
+ inst.remote_config = function () { };
304
+ fakeServer.clear();
305
+ Countly.change_id("new ID", true);
306
+ });
307
+
308
+ cy.wait(300).then(() => {
309
+ var earlyRemoteConfigRequest = fakeServer.getRequests().find((req) => req.functionName === "fetch_remote_config_explicit");
310
+ expect(earlyRemoteConfigRequest).to.not.exist;
311
+ });
312
+
313
+ cy.wait(1100).then(() => {
314
+ var requests = fakeServer.getRequests();
315
+ var remoteConfigRequest = requests.find((req) => req.functionName === "fetch_remote_config_explicit");
316
+
317
+ expect(remoteConfigRequest).to.exist;
318
+ expect(remoteConfigRequest.params.device_id).to.equal("new ID");
319
+ });
320
+ });
321
+ });
322
+ });
@@ -3,7 +3,7 @@
3
3
  var Countly = require("../../lib/countly");
4
4
  var hp = require("../support/helper.js");
5
5
  const SDK_NAME = "javascript_native_web";
6
- const SDK_VERSION = "26.1.1";
6
+ const SDK_VERSION = "26.1.2";
7
7
 
8
8
  function initMain(name, version) {
9
9
  Countly.init({
package/lib/countly.js CHANGED
@@ -350,7 +350,7 @@
350
350
  backoffCount: "cly_hc_backoff_count",
351
351
  consecutiveBackoffCount: "cly_hc_consecutive_backoff_count"
352
352
  });
353
- var SDK_VERSION = "26.1.1";
353
+ var SDK_VERSION = "26.1.2";
354
354
  var SDK_NAME = "javascript_native_web";
355
355
 
356
356
  // Using this on document.referrer would return an array with 17 elements in it. The 12th element (array[11]) would be the path we are looking for. Others would be things like password and such (use https://regex101.com/ to check more)
@@ -1200,6 +1200,7 @@
1200
1200
  var _clientHintsPromise = /*#__PURE__*/new WeakMap();
1201
1201
  var _pendingRequestBuffer = /*#__PURE__*/new WeakMap();
1202
1202
  var _clientHintsBufferTimeoutId = /*#__PURE__*/new WeakMap();
1203
+ var _changeIdRemoteConfigTimeoutId = /*#__PURE__*/new WeakMap();
1203
1204
  var _initializeClientHints = /*#__PURE__*/new WeakMap();
1204
1205
  var _flushPendingRequestBuffer = /*#__PURE__*/new WeakMap();
1205
1206
  var _getAndSetServerConfig = /*#__PURE__*/new WeakMap();
@@ -1396,6 +1397,7 @@
1396
1397
  _classPrivateFieldInitSpec(this, _clientHintsPromise, void 0);
1397
1398
  _classPrivateFieldInitSpec(this, _pendingRequestBuffer, void 0);
1398
1399
  _classPrivateFieldInitSpec(this, _clientHintsBufferTimeoutId, void 0);
1400
+ _classPrivateFieldInitSpec(this, _changeIdRemoteConfigTimeoutId, void 0);
1399
1401
  /**
1400
1402
  * Fetch User-Agent Client Hints and cache values for metrics enrichment.
1401
1403
  * @private
@@ -2201,6 +2203,10 @@
2201
2203
  clearTimeout(_classPrivateFieldGet2(_clientHintsBufferTimeoutId, _this));
2202
2204
  _classPrivateFieldSet2(_clientHintsBufferTimeoutId, _this, null);
2203
2205
  }
2206
+ if (_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this)) {
2207
+ clearTimeout(_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this));
2208
+ _classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, _this, null);
2209
+ }
2204
2210
  _classPrivateFieldSet2(_pendingRequestBuffer, _this, null);
2205
2211
  _classPrivateFieldSet2(_clientHintsPromise, _this, null);
2206
2212
  _classPrivateFieldSet2(_uaClientHints, _this, null);
@@ -2635,7 +2641,17 @@
2635
2641
  if (_this.remote_config) {
2636
2642
  _classPrivateFieldSet2(_remoteConfigs, _this, {});
2637
2643
  _classPrivateFieldGet2(_setValueInStorage, _this).call(_this, "cly_remote_configs", _classPrivateFieldGet2(_remoteConfigs, _this));
2638
- _this.fetch_remote_config(_this.remote_config);
2644
+ if (merge) {
2645
+ if (_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this)) {
2646
+ clearTimeout(_classPrivateFieldGet2(_changeIdRemoteConfigTimeoutId, _this));
2647
+ }
2648
+ _classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, _this, setTimeout(function () {
2649
+ _classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, _this, null);
2650
+ _this.fetch_remote_config(_this.remote_config);
2651
+ }, 1000));
2652
+ } else {
2653
+ _this.fetch_remote_config(_this.remote_config);
2654
+ }
2639
2655
  }
2640
2656
  });
2641
2657
  /**
@@ -7642,6 +7658,7 @@
7642
7658
  _classPrivateFieldSet2(_clientHintsPromise, this, null);
7643
7659
  _classPrivateFieldSet2(_pendingRequestBuffer, this, null);
7644
7660
  _classPrivateFieldSet2(_clientHintsBufferTimeoutId, this, null);
7661
+ _classPrivateFieldSet2(_changeIdRemoteConfigTimeoutId, this, null);
7645
7662
  this.app_key = getConfig("app_key", _ob, null);
7646
7663
  this.url = stripTrailingSlash(getConfig("url", _ob, ""));
7647
7664
  this.serialize = getConfig("serialize", _ob, Countly.serialize);