@microsoft/1ds-post-js 3.2.0 → 3.2.3

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 (53) hide show
  1. package/README.md +1 -1
  2. package/bundle/{ms.post-3.2.0.gbl.js → ms.post-3.2.3.gbl.js} +1022 -986
  3. package/bundle/ms.post-3.2.3.gbl.js.map +1 -0
  4. package/bundle/ms.post-3.2.3.gbl.min.js +7 -0
  5. package/bundle/ms.post-3.2.3.gbl.min.js.map +1 -0
  6. package/bundle/ms.post-3.2.3.integrity.json +46 -0
  7. package/bundle/{ms.post-3.2.0.js → ms.post-3.2.3.js} +1022 -986
  8. package/bundle/ms.post-3.2.3.js.map +1 -0
  9. package/bundle/ms.post-3.2.3.min.js +7 -0
  10. package/bundle/ms.post-3.2.3.min.js.map +1 -0
  11. package/bundle/ms.post.gbl.js +1021 -985
  12. package/bundle/ms.post.gbl.js.map +1 -1
  13. package/bundle/ms.post.gbl.min.js +2 -2
  14. package/bundle/ms.post.gbl.min.js.map +1 -1
  15. package/bundle/ms.post.integrity.json +17 -17
  16. package/bundle/ms.post.js +1021 -985
  17. package/bundle/ms.post.js.map +1 -1
  18. package/bundle/ms.post.min.js +2 -2
  19. package/bundle/ms.post.min.js.map +1 -1
  20. package/dist/ms.post.js +56 -27
  21. package/dist/ms.post.js.map +1 -1
  22. package/dist/ms.post.min.js +2 -2
  23. package/dist/ms.post.min.js.map +1 -1
  24. package/dist-esm/src/BatchNotificationActions.js +1 -1
  25. package/dist-esm/src/ClockSkewManager.js +1 -1
  26. package/dist-esm/src/Constants.js +1 -1
  27. package/dist-esm/src/DataModels.js +1 -1
  28. package/dist-esm/src/EventBatch.js +1 -1
  29. package/dist-esm/src/HttpManager.d.ts +2 -1
  30. package/dist-esm/src/HttpManager.js +67 -67
  31. package/dist-esm/src/HttpManager.js.map +1 -1
  32. package/dist-esm/src/Index.js +1 -1
  33. package/dist-esm/src/KillSwitch.js +1 -1
  34. package/dist-esm/src/PostChannel.d.ts +2 -5
  35. package/dist-esm/src/PostChannel.js +84 -66
  36. package/dist-esm/src/PostChannel.js.map +1 -1
  37. package/dist-esm/src/RetryPolicy.js +1 -1
  38. package/dist-esm/src/Serializer.js +1 -1
  39. package/dist-esm/src/TimeoutOverrideWrapper.d.ts +18 -0
  40. package/dist-esm/src/TimeoutOverrideWrapper.js +28 -0
  41. package/dist-esm/src/TimeoutOverrideWrapper.js.map +1 -0
  42. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  43. package/package.json +3 -3
  44. package/src/HttpManager.ts +5 -4
  45. package/src/PostChannel.ts +59 -27
  46. package/src/TimeoutOverrideWrapper.ts +29 -0
  47. package/bundle/ms.post-3.2.0.gbl.js.map +0 -1
  48. package/bundle/ms.post-3.2.0.gbl.min.js +0 -7
  49. package/bundle/ms.post-3.2.0.gbl.min.js.map +0 -1
  50. package/bundle/ms.post-3.2.0.integrity.json +0 -46
  51. package/bundle/ms.post-3.2.0.js.map +0 -1
  52. package/bundle/ms.post-3.2.0.min.js +0 -7
  53. package/bundle/ms.post-3.2.0.min.js.map +0 -1
package/dist/ms.post.js CHANGED
@@ -1,13 +1,13 @@
1
1
  /*!
2
- * 1DS JS SDK POST plugin, 3.2.0
2
+ * 1DS JS SDK POST plugin, 3.2.3
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@microsoft/applicationinsights-shims'), require('@microsoft/1ds-core-js'), require('@microsoft/dynamicproto-js')) :
8
- typeof define === 'function' && define.amd ? define(['exports', '@microsoft/applicationinsights-shims', '@microsoft/1ds-core-js', '@microsoft/dynamicproto-js'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.oneDS = global.oneDS || {}, global.applicationinsightsShims, global._1dsCoreJs, global.dynamicProto));
10
- })(this, (function (exports, applicationinsightsShims, _1dsCoreJs, dynamicProto) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@microsoft/applicationinsights-shims'), require('@microsoft/dynamicproto-js'), require('@microsoft/1ds-core-js')) :
8
+ typeof define === 'function' && define.amd ? define(['exports', '@microsoft/applicationinsights-shims', '@microsoft/dynamicproto-js', '@microsoft/1ds-core-js'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.oneDS = global.oneDS || {}, global.applicationinsightsShims, global.dynamicProto, global._1dsCoreJs));
10
+ })(this, (function (exports, applicationinsightsShims, dynamicProto, _1dsCoreJs) { 'use strict';
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
13
13
 
@@ -517,7 +517,7 @@
517
517
  }
518
518
  }
519
519
  var HttpManager = /** @class */ (function () {
520
- function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions) {
520
+ function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions, timeoutOverride) {
521
521
  this._responseHandlers = [];
522
522
  var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
523
523
  var _killSwitch = new KillSwitch();
@@ -656,7 +656,7 @@
656
656
  xdr.send(payload.data);
657
657
  }
658
658
  else {
659
- _postManager._setTimeoutOverride(function () {
659
+ timeoutOverride.set(function () {
660
660
  xdr.send(payload.data);
661
661
  }, 0);
662
662
  }
@@ -714,7 +714,7 @@
714
714
  _doOnComplete(oncomplete, 200, {});
715
715
  }
716
716
  if (!responseHandled && payload.timeout > 0) {
717
- _postManager._setTimeoutOverride(function () {
717
+ timeoutOverride.set(function () {
718
718
  if (!responseHandled) {
719
719
  responseHandled = true;
720
720
  _doOnComplete(oncomplete, 500, {});
@@ -1253,7 +1253,7 @@
1253
1253
  cb();
1254
1254
  }
1255
1255
  else {
1256
- _postManager._setTimeoutOverride(cb, interval);
1256
+ timeoutOverride.set(cb, interval);
1257
1257
  }
1258
1258
  }
1259
1259
  function _convertAllHeadersToMap(headersString) {
@@ -1345,13 +1345,29 @@
1345
1345
  return HttpManager;
1346
1346
  }());
1347
1347
 
1348
+ function defaultSetTimeout(callback, ms) {
1349
+ var args = [];
1350
+ for (var _i = 2; _i < arguments.length; _i++) {
1351
+ args[_i - 2] = arguments[_i];
1352
+ }
1353
+ return setTimeout(callback, ms, args);
1354
+ }
1355
+ function defaultClearTimeout(timeoutId) {
1356
+ clearTimeout(timeoutId);
1357
+ }
1358
+ function createTimeoutWrapper(argSetTimeout, argClearTimeout) {
1359
+ return {
1360
+ set: argSetTimeout || defaultSetTimeout,
1361
+ clear: argClearTimeout || defaultClearTimeout
1362
+ };
1363
+ }
1364
+
1348
1365
  var FlushCheckTimer = 0.250;
1349
1366
  var MaxNumberEventPerBatch = 500;
1350
1367
  var EventsDroppedAtOneTime = 20;
1351
1368
  var MaxSendAttempts = 6;
1352
1369
  var MaxSyncUnloadSendAttempts = 2;
1353
1370
  var MaxBackoffCount = 4;
1354
- var globalContext = _1dsCoreJs.isWindowObjectAvailable ? window : undefined;
1355
1371
  var MaxConnections = 2;
1356
1372
  var MaxRequestRetriesBeforeBackoff = 1;
1357
1373
  var strEventsDiscarded = "eventsDiscarded";
@@ -1365,7 +1381,7 @@
1365
1381
  var _this = _super.call(this) || this;
1366
1382
  _this.identifier = "PostChannel";
1367
1383
  _this.priority = 1011;
1368
- _this.version = '3.2.0';
1384
+ _this.version = '3.2.3';
1369
1385
  var _config;
1370
1386
  var _isTeardownCalled = false;
1371
1387
  var _flushCallbackQueue = [];
@@ -1390,10 +1406,10 @@
1390
1406
  var _delayedBatchReason;
1391
1407
  var _optimizeObject = true;
1392
1408
  var _isPageUnloadTriggered = false;
1393
- var _disableXhrSync = false;
1394
1409
  var _maxEventSendAttempts = MaxSendAttempts;
1395
1410
  var _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
1396
1411
  var _evtNamespace;
1412
+ var _timeoutWrapper;
1397
1413
  dynamicProto__default(PostChannel, _this, function (_self, _base) {
1398
1414
  _initDefaults();
1399
1415
  _self["_getDbgPlgTargets"] = function () {
@@ -1409,8 +1425,7 @@
1409
1425
  var ctx = _self._getTelCtx();
1410
1426
  coreConfig.extensionConfig[_self.identifier] = coreConfig.extensionConfig[_self.identifier] || {};
1411
1427
  _config = ctx.getExtCfg(_self.identifier);
1412
- _self._setTimeoutOverride = _config.setTimeoutOverride ? _config.setTimeoutOverride : setTimeout.bind(globalContext);
1413
- _self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
1428
+ _timeoutWrapper = createTimeoutWrapper(_config.setTimeoutOverride, _config.clearTimeoutOverride);
1414
1429
  _optimizeObject = !_config.disableOptimizeObj && _1dsCoreJs.isChromium();
1415
1430
  _hookWParam(extendedCore);
1416
1431
  if (_config.eventsLimitInMem > 0) {
@@ -1422,7 +1437,6 @@
1422
1437
  if (_config.autoFlushEventsLimit > 0) {
1423
1438
  _autoFlushEventsLimit = _config.autoFlushEventsLimit;
1424
1439
  }
1425
- _disableXhrSync = _config.disableXhrSync;
1426
1440
  if (_1dsCoreJs.isNumber(_config[strMaxEventRetryAttempts])) {
1427
1441
  _maxEventSendAttempts = _config[strMaxEventRetryAttempts];
1428
1442
  }
@@ -1630,13 +1644,13 @@
1630
1644
  _self.flush = function (async, callback, sendReason) {
1631
1645
  if (async === void 0) { async = true; }
1632
1646
  if (!_paused) {
1633
- _clearScheduledTimer();
1634
1647
  sendReason = sendReason || 1 ;
1635
1648
  if (async) {
1636
- _queueBatches(1 , 0 , sendReason);
1637
- _resetQueueCounts();
1638
1649
  if (_flushCallbackTimerId == null) {
1650
+ _clearScheduledTimer();
1651
+ _queueBatches(1 , 0 , sendReason);
1639
1652
  _flushCallbackTimerId = _createTimer(function () {
1653
+ _flushCallbackTimerId = null;
1640
1654
  _flushImpl(callback, sendReason);
1641
1655
  }, 0);
1642
1656
  }
@@ -1645,10 +1659,14 @@
1645
1659
  }
1646
1660
  }
1647
1661
  else {
1662
+ var cleared = _clearScheduledTimer();
1648
1663
  _sendEventsForLatencyAndAbove(1 , 1 , sendReason);
1649
1664
  if (callback !== null && callback !== undefined) {
1650
1665
  callback();
1651
1666
  }
1667
+ if (cleared) {
1668
+ _scheduleTimer();
1669
+ }
1652
1670
  }
1653
1671
  }
1654
1672
  };
@@ -1739,10 +1757,10 @@
1739
1757
  _delayedBatchReason = null;
1740
1758
  _optimizeObject = true;
1741
1759
  _isPageUnloadTriggered = false;
1742
- _disableXhrSync = false;
1743
1760
  _maxEventSendAttempts = MaxSendAttempts;
1744
1761
  _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
1745
1762
  _evtNamespace = null;
1763
+ _timeoutWrapper = createTimeoutWrapper();
1746
1764
  _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
1747
1765
  requeue: _requeueEvents,
1748
1766
  send: _sendingEvent,
@@ -1750,7 +1768,7 @@
1750
1768
  drop: _eventsDropped,
1751
1769
  rspFail: _eventsResponseFail,
1752
1770
  oth: _otherEvent
1753
- });
1771
+ }, _timeoutWrapper);
1754
1772
  _initializeProfiles();
1755
1773
  _clearQueues();
1756
1774
  _setAutoLimits();
@@ -1763,19 +1781,21 @@
1763
1781
  if (_currentBackoffCount) {
1764
1782
  timerMultiplier = retryPolicyGetMillisToBackoffForRetry(_currentBackoffCount - 1);
1765
1783
  }
1766
- return _self._setTimeoutOverride(theTimerFunc, timeOut * timerMultiplier);
1784
+ return _timeoutWrapper.set(theTimerFunc, timeOut * timerMultiplier);
1767
1785
  }
1768
1786
  function _clearScheduledTimer() {
1769
1787
  if (_scheduledTimerId !== null) {
1770
- _self._clearTimeoutOverride(_scheduledTimerId);
1788
+ _timeoutWrapper.clear(_scheduledTimerId);
1771
1789
  _scheduledTimerId = null;
1772
1790
  _timerCount = 0;
1791
+ return true;
1773
1792
  }
1793
+ return false;
1774
1794
  }
1775
1795
  function _releaseAllQueues(sendType, sendReason) {
1776
1796
  _clearScheduledTimer();
1777
1797
  if (_flushCallbackTimerId) {
1778
- _self._clearTimeoutOverride(_flushCallbackTimerId);
1798
+ _timeoutWrapper.clear(_flushCallbackTimerId);
1779
1799
  _flushCallbackTimerId = null;
1780
1800
  }
1781
1801
  if (!_paused) {
@@ -1934,18 +1954,20 @@
1934
1954
  }
1935
1955
  function _flushImpl(callback, sendReason) {
1936
1956
  _sendEventsForLatencyAndAbove(1 , 0 , sendReason);
1957
+ _resetQueueCounts();
1937
1958
  _waitForIdleManager(function () {
1938
1959
  if (callback) {
1939
1960
  callback();
1940
1961
  }
1941
1962
  if (_flushCallbackQueue.length > 0) {
1942
- _flushCallbackTimerId = _createTimer(function () { return _flushImpl(_flushCallbackQueue.shift(), sendReason); }, 0);
1963
+ _flushCallbackTimerId = _createTimer(function () {
1964
+ _flushCallbackTimerId = null;
1965
+ _flushImpl(_flushCallbackQueue.shift(), sendReason);
1966
+ }, 0);
1943
1967
  }
1944
1968
  else {
1945
1969
  _flushCallbackTimerId = null;
1946
- if (_hasEvents()) {
1947
- _scheduleTimer();
1948
- }
1970
+ _scheduleTimer();
1949
1971
  }
1950
1972
  });
1951
1973
  }
@@ -1955,6 +1977,7 @@
1955
1977
  }
1956
1978
  else {
1957
1979
  _flushCallbackTimerId = _createTimer(function () {
1980
+ _flushCallbackTimerId = null;
1958
1981
  _waitForIdleManager(callback);
1959
1982
  }, FlushCheckTimer);
1960
1983
  }
@@ -2069,6 +2092,12 @@
2069
2092
  _autoFlushBatchLimit = 0;
2070
2093
  }
2071
2094
  }
2095
+ _1dsCoreJs.objDefineAccessors(_self, "_setTimeoutOverride", function () { return _timeoutWrapper.set; }, function (value) {
2096
+ _timeoutWrapper = createTimeoutWrapper(value, _timeoutWrapper.clear);
2097
+ });
2098
+ _1dsCoreJs.objDefineAccessors(_self, "_clearTimeoutOverride", function () { return _timeoutWrapper.clear; }, function (value) {
2099
+ _timeoutWrapper = createTimeoutWrapper(_timeoutWrapper.set, value);
2100
+ });
2072
2101
  });
2073
2102
  return _this;
2074
2103
  }