@microsoft/1ds-post-js 3.1.10 → 3.1.11

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 +123 -5
  2. package/bundle/{ms.post-3.1.10.gbl.js → ms.post-3.1.11.gbl.js} +163 -86
  3. package/bundle/ms.post-3.1.11.gbl.js.map +1 -0
  4. package/bundle/ms.post-3.1.11.gbl.min.js +7 -0
  5. package/bundle/ms.post-3.1.11.gbl.min.js.map +1 -0
  6. package/bundle/ms.post-3.1.11.integrity.json +46 -0
  7. package/bundle/{ms.post-3.1.10.js → ms.post-3.1.11.js} +163 -86
  8. package/bundle/ms.post-3.1.11.js.map +1 -0
  9. package/bundle/ms.post-3.1.11.min.js +7 -0
  10. package/bundle/ms.post-3.1.11.min.js.map +1 -0
  11. package/bundle/ms.post.gbl.js +162 -85
  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 +162 -85
  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 +101 -47
  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.d.ts +1 -0
  27. package/dist-esm/src/Constants.js +2 -1
  28. package/dist-esm/src/Constants.js.map +1 -1
  29. package/dist-esm/src/DataModels.d.ts +49 -0
  30. package/dist-esm/src/DataModels.js +1 -1
  31. package/dist-esm/src/EventBatch.js +1 -1
  32. package/dist-esm/src/HttpManager.d.ts +1 -1
  33. package/dist-esm/src/HttpManager.js +63 -24
  34. package/dist-esm/src/HttpManager.js.map +1 -1
  35. package/dist-esm/src/Index.js +1 -1
  36. package/dist-esm/src/KillSwitch.js +1 -1
  37. package/dist-esm/src/PostChannel.js +51 -28
  38. package/dist-esm/src/PostChannel.js.map +1 -1
  39. package/dist-esm/src/RetryPolicy.js +1 -1
  40. package/dist-esm/src/Serializer.js +1 -1
  41. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  42. package/package.json +2 -2
  43. package/src/Constants.ts +1 -0
  44. package/src/DataModels.ts +62 -1
  45. package/src/HttpManager.ts +67 -22
  46. package/src/PostChannel.ts +56 -28
  47. package/bundle/ms.post-3.1.10.gbl.js.map +0 -1
  48. package/bundle/ms.post-3.1.10.gbl.min.js +0 -7
  49. package/bundle/ms.post-3.1.10.gbl.min.js.map +0 -1
  50. package/bundle/ms.post-3.1.10.integrity.json +0 -46
  51. package/bundle/ms.post-3.1.10.js.map +0 -1
  52. package/bundle/ms.post-3.1.10.min.js +0 -7
  53. package/bundle/ms.post-3.1.10.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * 1DS JS SDK POST plugin, 3.1.10
2
+ * 1DS JS SDK POST plugin, 3.1.11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -435,10 +435,19 @@
435
435
  var strOnPrefix = "on";
436
436
  var strAttachEvent = "attachEvent";
437
437
  var strAddEventHelper = "addEventListener";
438
+ var cStrStartsWith = "startsWith";
439
+ var strIndexOf = "indexOf";
440
+ var cStrTrim = "trim";
441
+ var strToString = "toString";
438
442
  var _objDefineProperty = ObjDefineProperty;
439
- function objToString(obj) {
440
- return ObjProto.toString.call(obj);
441
- }
443
+ var _objKeys = ObjClass.keys;
444
+ var StringProto = String[strShimPrototype];
445
+ var _strTrim = StringProto[cStrTrim];
446
+ var _strStartsWith = StringProto[cStrStartsWith];
447
+ var _isArray = Array.isArray;
448
+ var _objToString = ObjProto[strToString];
449
+ var _fnToString = ObjHasOwnProperty[strToString];
450
+ _fnToString.call(ObjClass);
442
451
  function isUndefined(value) {
443
452
  return value === undefined || typeof value === strShimUndefined;
444
453
  }
@@ -446,13 +455,13 @@
446
455
  return (value === null || isUndefined(value));
447
456
  }
448
457
  function hasOwnProperty(obj, prop) {
449
- return obj && ObjHasOwnProperty.call(obj, prop);
458
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
450
459
  }
451
460
  function isObject(value) {
452
- return typeof value === strShimObject;
461
+ return !!(value && typeof value === strShimObject);
453
462
  }
454
463
  function isFunction(value) {
455
- return typeof value === strShimFunction;
464
+ return !!(value && typeof value === strShimFunction);
456
465
  }
457
466
  function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
458
467
  if (useCapture === void 0) { useCapture = false; }
@@ -484,24 +493,27 @@
484
493
  }
485
494
  function strStartsWith(value, checkValue) {
486
495
  var result = false;
487
- if (value && checkValue) {
488
- var chkLen = checkValue.length;
489
- if (value === checkValue) {
490
- return true;
491
- }
492
- else if (value.length >= chkLen) {
493
- for (var lp = 0; lp < chkLen; lp++) {
494
- if (value[lp] !== checkValue[lp]) {
495
- return false;
496
- }
496
+ if (value && checkValue && !(result = value === checkValue)) {
497
+ result = _strStartsWith ? value[cStrStartsWith](checkValue) : _strStartsWithPoly(value, checkValue);
498
+ }
499
+ return result;
500
+ }
501
+ function _strStartsWithPoly(value, checkValue) {
502
+ var result = false;
503
+ var chkLen = checkValue ? checkValue.length : 0;
504
+ if (value && chkLen && value.length >= chkLen && !(result = value === checkValue)) {
505
+ for (var lp = 0; lp < chkLen; lp++) {
506
+ if (value[lp] !== checkValue[lp]) {
507
+ return false;
497
508
  }
498
- result = true;
499
509
  }
510
+ result = true;
500
511
  }
501
512
  return result;
502
513
  }
503
- function isArray(obj) {
504
- return objToString(obj) === "[object Array]";
514
+ var isArray = _isArray || _isArrayPoly;
515
+ function _isArrayPoly(obj) {
516
+ return !!(obj && _objToString.call(obj) === "[object Array]");
505
517
  }
506
518
  function isString(value) {
507
519
  return typeof value === "string";
@@ -527,24 +539,29 @@
527
539
  }
528
540
  }
529
541
  function arrIndexOf(arr, searchElement, fromIndex) {
530
- var len = arr.length;
531
- var from = fromIndex || 0;
532
- try {
533
- for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
534
- if (lp in arr && arr[lp] === searchElement) {
535
- return lp;
542
+ if (arr) {
543
+ if (arr[strIndexOf]) {
544
+ return arr[strIndexOf](searchElement, fromIndex);
545
+ }
546
+ var len = arr.length;
547
+ var from = fromIndex || 0;
548
+ try {
549
+ for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
550
+ if (lp in arr && arr[lp] === searchElement) {
551
+ return lp;
552
+ }
536
553
  }
537
554
  }
538
- }
539
- catch (e) {
555
+ catch (e) {
556
+ }
540
557
  }
541
558
  return -1;
542
559
  }
543
560
  function strTrim(str) {
544
- if (typeof str !== "string") {
545
- return str;
561
+ if (str) {
562
+ str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
546
563
  }
547
- return str.replace(/^\s+|\s+$/g, "");
564
+ return str;
548
565
  }
549
566
  var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
550
567
  var _objKeysDontEnums = [
@@ -561,6 +578,9 @@
561
578
  if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
562
579
  throwTypeError("objKeys called on non-object");
563
580
  }
581
+ if (!_objKeysHasDontEnumBug && _objKeys) {
582
+ return _objKeys(obj);
583
+ }
564
584
  var result = [];
565
585
  for (var prop in obj) {
566
586
  if (obj && ObjHasOwnProperty.call(obj, prop)) {
@@ -600,10 +620,7 @@
600
620
  }
601
621
  function dateNow() {
602
622
  var dt = Date;
603
- if (dt.now) {
604
- return dt.now();
605
- }
606
- return new dt().getTime();
623
+ return dt.now ? dt.now() : new dt().getTime();
607
624
  }
608
625
  function setValue(target, field, value, valChk, srcChk) {
609
626
  var theValue = value;
@@ -617,8 +634,8 @@
617
634
  return theValue;
618
635
  }
619
636
  function optimizeObject(theObject) {
620
- if (theObject) {
621
- theObject = ObjClass(ObjAssign ? ObjAssign({}, theObject) : theObject);
637
+ if (theObject && ObjAssign) {
638
+ theObject = ObjClass(ObjAssign({}, theObject));
622
639
  }
623
640
  return theObject;
624
641
  }
@@ -1434,10 +1451,11 @@
1434
1451
  var _ExtendedInternalMessageId = __assignFn(__assignFn({}, _InternalMessageId), { AuthHandShakeError: 501, AuthRedirectFail: 502, BrowserCannotReadLocalStorage: 503, BrowserCannotWriteLocalStorage: 504, BrowserDoesNotSupportLocalStorage: 505, CannotParseBiBlobValue: 506, CannotParseDataAttribute: 507, CVPluginNotAvailable: 508, DroppedEvent: 509, ErrorParsingAISessionCookie: 510, ErrorProvidedChannels: 511, FailedToGetCookies: 512, FailedToInitializeCorrelationVector: 513, FailedToInitializeSDK: 514, InvalidContentBlob: 515, InvalidCorrelationValue: 516, SessionRenewalDateIsZero: 517, SendPostOnCompleteFailure: 518, PostResponseHandler: 519, SDKNotInitialized: 520 });
1435
1452
 
1436
1453
  var _a$1;
1437
- var Version = '3.1.10';
1454
+ var Version = '3.1.11';
1438
1455
  var FullVersionString = "1DS-Web-JS-" + Version;
1439
1456
  var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
1440
1457
  var strWithCredentials = "withCredentials";
1458
+ var strTimeout = "timeout";
1441
1459
  var _fieldTypeEventPropMap = (_a$1 = {},
1442
1460
  _a$1[0 ] = EventPropertyType.Unspecified,
1443
1461
  _a$1[2 ] = EventPropertyType.Double,
@@ -1609,7 +1627,7 @@
1609
1627
  function isChromium() {
1610
1628
  return !!getGlobalInst("chrome");
1611
1629
  }
1612
- function openXhr(method, urlString, withCredentials, disabled, isSync) {
1630
+ function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
1613
1631
  if (disabled === void 0) { disabled = false; }
1614
1632
  if (isSync === void 0) { isSync = false; }
1615
1633
  function _wrapSetXhrProp(xhr, prop, value) {
@@ -1630,6 +1648,9 @@
1630
1648
  if (withCredentials) {
1631
1649
  _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
1632
1650
  }
1651
+ if (!isSync && timeout) {
1652
+ _wrapSetXhrProp(xhr, strTimeout, timeout);
1653
+ }
1633
1654
  return xhr;
1634
1655
  }
1635
1656
 
@@ -1658,6 +1679,7 @@
1658
1679
  var strUploadTime = "upload-time";
1659
1680
  var strApiKey = "apikey";
1660
1681
  var strMsaDeviceTicket = "AuthMsaDeviceTicket";
1682
+ var strNoResponseBody = "NoResponseBody";
1661
1683
  var strMsfpc = "msfpc";
1662
1684
 
1663
1685
  function _getEventMsfpc(theEvent) {
@@ -2081,6 +2103,8 @@
2081
2103
  var EVTClockSkewManager = ClockSkewManager;
2082
2104
 
2083
2105
  var _a;
2106
+ var strSendAttempt = "sendAttempt";
2107
+ var _noResponseQs = "&" + strNoResponseBody + "=true";
2084
2108
  var _eventActionMap = (_a = {},
2085
2109
  _a[1 ] = strRequeue,
2086
2110
  _a[100 ] = strRequeue,
@@ -2133,7 +2157,7 @@
2133
2157
  }
2134
2158
  }
2135
2159
  var HttpManager = /** @class */ (function () {
2136
- function HttpManager(maxEventsPerBatch, maxConnections, maxRetries, actions) {
2160
+ function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions) {
2137
2161
  this._responseHandlers = [];
2138
2162
  var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
2139
2163
  var _killSwitch = new EVTKillSwitch();
@@ -2153,6 +2177,8 @@
2153
2177
  var _cookieMgr;
2154
2178
  var _isUnloading = false;
2155
2179
  var _useHeaders = false;
2180
+ var _xhrTimeout;
2181
+ var _disableXhrSync;
2156
2182
  dynamicProto(HttpManager, this, function (_self) {
2157
2183
  var _sendCredentials = true;
2158
2184
  _self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
@@ -2172,9 +2198,13 @@
2172
2198
  if (!isUndefined(channelConfig.enableCompoundKey)) {
2173
2199
  enableCompoundKey = !!channelConfig.enableCompoundKey;
2174
2200
  }
2201
+ _xhrTimeout = channelConfig.xhrTimeout;
2202
+ _disableXhrSync = channelConfig.disableXhrSync;
2175
2203
  _useBeacons = !isReactNative();
2176
2204
  _serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
2177
2205
  var syncHttpInterface = httpInterface;
2206
+ var beaconHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
2207
+ var fetchSyncHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
2178
2208
  if (!httpInterface) {
2179
2209
  _customHttpInterface = false;
2180
2210
  var location_1 = getLocation();
@@ -2206,8 +2236,8 @@
2206
2236
  _sendInterfaces = (_a = {},
2207
2237
  _a[0 ] = httpInterface,
2208
2238
  _a[1 ] = syncHttpInterface || _getSenderInterface([1 , 2 , 3 ], true),
2209
- _a[2 ] = _getSenderInterface([3 , 2 , 1 ], true) || syncHttpInterface,
2210
- _a[3 ] = _getSenderInterface([2 , 3 , 1 ], true) || syncHttpInterface,
2239
+ _a[2 ] = beaconHttpInterface || _getSenderInterface([3 , 2 ], true) || syncHttpInterface || _getSenderInterface([1 ], true),
2240
+ _a[3 ] = fetchSyncHttpInterface || _getSenderInterface([2 , 3 ], true) || syncHttpInterface || _getSenderInterface([1 ], true),
2211
2241
  _a);
2212
2242
  };
2213
2243
  function _getSenderInterface(transports, syncSupport) {
@@ -2247,6 +2277,9 @@
2247
2277
  function _xdrSendPost(payload, oncomplete, sync) {
2248
2278
  var xdr = new XDomainRequest();
2249
2279
  xdr.open(Method, payload.urlString);
2280
+ if (payload.timeout) {
2281
+ xdr.timeout = payload.timeout;
2282
+ }
2250
2283
  xdr.onload = function () {
2251
2284
  var response = _getResponseText(xdr);
2252
2285
  _doOnComplete(oncomplete, 200, {}, response);
@@ -2270,6 +2303,7 @@
2270
2303
  }
2271
2304
  function _fetchSendPost(payload, oncomplete, sync) {
2272
2305
  var _a;
2306
+ var theUrl = payload.urlString;
2273
2307
  var ignoreResponse = false;
2274
2308
  var responseHandled = false;
2275
2309
  var requestInit = (_a = {
@@ -2282,6 +2316,7 @@
2282
2316
  requestInit.keepalive = true;
2283
2317
  if (payload._sendReason === 2 ) {
2284
2318
  ignoreResponse = true;
2319
+ theUrl += _noResponseQs;
2285
2320
  }
2286
2321
  }
2287
2322
  if (_sendCredentials) {
@@ -2290,7 +2325,7 @@
2290
2325
  if (payload.headers && objKeys(payload.headers).length > 0) {
2291
2326
  requestInit.headers = payload.headers;
2292
2327
  }
2293
- fetch(payload.urlString, requestInit).then(function (response) {
2328
+ fetch(theUrl, requestInit).then(function (response) {
2294
2329
  var headerMap = {};
2295
2330
  var responseText = "";
2296
2331
  if (response.headers) {
@@ -2318,8 +2353,17 @@
2318
2353
  responseHandled = true;
2319
2354
  _doOnComplete(oncomplete, 200, {});
2320
2355
  }
2356
+ if (!responseHandled && payload.timeout > 0) {
2357
+ _postManager._setTimeoutOverride(function () {
2358
+ if (!responseHandled) {
2359
+ responseHandled = true;
2360
+ _doOnComplete(oncomplete, 500, {});
2361
+ }
2362
+ }, payload.timeout);
2363
+ }
2321
2364
  }
2322
2365
  function _xhrSendPost(payload, oncomplete, sync) {
2366
+ var theUrl = payload.urlString;
2323
2367
  function _appendHeader(theHeaders, xhr, name) {
2324
2368
  if (!theHeaders[name] && xhr && xhr.getResponseHeader) {
2325
2369
  var value = xhr.getResponseHeader(name);
@@ -2344,22 +2388,25 @@
2344
2388
  function xhrComplete(xhr, responseTxt) {
2345
2389
  _doOnComplete(oncomplete, xhr.status, _getAllResponseHeaders(xhr), responseTxt);
2346
2390
  }
2347
- var xhRequest = openXhr(Method, payload.urlString, _sendCredentials, true, sync);
2391
+ if (sync && payload.disableXhrSync) {
2392
+ sync = false;
2393
+ }
2394
+ var xhrRequest = openXhr(Method, theUrl, _sendCredentials, true, sync, payload.timeout);
2348
2395
  objForEachKey(payload.headers, function (name, value) {
2349
- xhRequest.setRequestHeader(name, value);
2396
+ xhrRequest.setRequestHeader(name, value);
2350
2397
  });
2351
- xhRequest.onload = function () {
2352
- var response = _getResponseText(xhRequest);
2353
- xhrComplete(xhRequest, response);
2398
+ xhrRequest.onload = function () {
2399
+ var response = _getResponseText(xhrRequest);
2400
+ xhrComplete(xhrRequest, response);
2354
2401
  _handleCollectorResponse(response);
2355
2402
  };
2356
- xhRequest.onerror = function () {
2357
- xhrComplete(xhRequest);
2403
+ xhrRequest.onerror = function () {
2404
+ xhrComplete(xhrRequest);
2358
2405
  };
2359
- xhRequest.ontimeout = function () {
2360
- xhrComplete(xhRequest);
2406
+ xhrRequest.ontimeout = function () {
2407
+ xhrComplete(xhrRequest);
2361
2408
  };
2362
- xhRequest.send(payload.data);
2409
+ xhrRequest.send(payload.data);
2363
2410
  }
2364
2411
  function _doOnComplete(oncomplete, status, headers, response) {
2365
2412
  try {
@@ -2373,16 +2420,17 @@
2373
2420
  var internalPayloadData = payload;
2374
2421
  var status = 200;
2375
2422
  var thePayload = internalPayloadData._thePayload;
2423
+ var theUrl = payload.urlString + _noResponseQs;
2376
2424
  try {
2377
2425
  var nav_1 = getNavigator();
2378
- if (!nav_1.sendBeacon(payload.urlString, payload.data)) {
2426
+ if (!nav_1.sendBeacon(theUrl, payload.data)) {
2379
2427
  if (thePayload) {
2380
2428
  var droppedBatches_1 = [];
2381
2429
  arrForEach(thePayload.batches, function (theBatch) {
2382
2430
  if (droppedBatches_1 && theBatch && theBatch.count() > 0) {
2383
2431
  var theEvents = theBatch.events();
2384
2432
  for (var lp = 0; lp < theEvents.length; lp++) {
2385
- if (!nav_1.sendBeacon(payload.urlString, _serializer.getEventBlob(theEvents[lp]))) {
2433
+ if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
2386
2434
  droppedBatches_1.push(theBatch.split(lp));
2387
2435
  break;
2388
2436
  }
@@ -2625,7 +2673,6 @@
2625
2673
  var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
2626
2674
  useHeaders_1 = useHeaders_1 || requestDetails_1.useHdrs;
2627
2675
  var sendEventStart_1 = getTime();
2628
- var strSendAttempt_1 = "sendAttempt";
2629
2676
  doPerf(_core, function () { return "HttpManager:_doPayloadSend"; }, function () {
2630
2677
  for (var batchLp = 0; batchLp < thePayload.batches.length; batchLp++) {
2631
2678
  var theBatch = thePayload.batches[batchLp];
@@ -2638,7 +2685,7 @@
2638
2685
  _setTimingValue(timings, "serializationStart", serializationStart);
2639
2686
  _setTimingValue(timings, "serializationCompleted", serializationCompleted);
2640
2687
  }
2641
- telemetryItem[strSendAttempt_1] > 0 ? telemetryItem[strSendAttempt_1]++ : telemetryItem[strSendAttempt_1] = 1;
2688
+ telemetryItem[strSendAttempt] > 0 ? telemetryItem[strSendAttempt]++ : telemetryItem[strSendAttempt] = 1;
2642
2689
  }
2643
2690
  }
2644
2691
  _sendBatchesNotification(thePayload.batches, (1000 + (sendReason || 0 )), thePayload.sendType, true);
@@ -2647,8 +2694,12 @@
2647
2694
  urlString: requestDetails_1.url,
2648
2695
  headers: requestDetails_1.hdrs,
2649
2696
  _thePayload: thePayload,
2650
- _sendReason: sendReason
2697
+ _sendReason: sendReason,
2698
+ timeout: _xhrTimeout
2651
2699
  };
2700
+ if (!isUndefined(_disableXhrSync)) {
2701
+ orgPayloadData.disableXhrSync = !!_disableXhrSync;
2702
+ }
2652
2703
  if (useHeaders_1) {
2653
2704
  if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
2654
2705
  orgPayloadData.headers[strCacheControl] = defaultCacheControl;
@@ -2686,7 +2737,9 @@
2686
2737
  var hookData_1 = {
2687
2738
  data: orgPayloadData.data,
2688
2739
  urlString: orgPayloadData.urlString,
2689
- headers: extend({}, orgPayloadData.headers)
2740
+ headers: extend({}, orgPayloadData.headers),
2741
+ timeout: orgPayloadData.timeout,
2742
+ disableXhrSync: orgPayloadData.disableXhrSync
2690
2743
  };
2691
2744
  var senderCalled_1 = false;
2692
2745
  doPerf(_core, function () { return "HttpManager:_doPayloadSend.sendHook"; }, function () {
@@ -2751,7 +2804,7 @@
2751
2804
  });
2752
2805
  });
2753
2806
  }
2754
- if (status == 200) {
2807
+ if (status == 200 || status == 204) {
2755
2808
  reason = 200 ;
2756
2809
  return;
2757
2810
  }
@@ -2764,7 +2817,7 @@
2764
2817
  reason = 100 ;
2765
2818
  var retryCount_1 = thePayload.retryCnt;
2766
2819
  if (thePayload.sendType === 0 ) {
2767
- if (retryCount_1 < maxRetries) {
2820
+ if (retryCount_1 < maxRequestRetriesBeforeBackoff) {
2768
2821
  isRetrying = true;
2769
2822
  _doAction(function () {
2770
2823
  if (thePayload.sendType === 0 ) {
@@ -2775,6 +2828,9 @@
2775
2828
  }
2776
2829
  else {
2777
2830
  backOffTrans = true;
2831
+ if (_isUnloading) {
2832
+ reason = 8001 ;
2833
+ }
2778
2834
  }
2779
2835
  }
2780
2836
  }
@@ -2920,19 +2976,22 @@
2920
2976
  var MaxNumberEventPerBatch = 500;
2921
2977
  var EventsDroppedAtOneTime = 20;
2922
2978
  var MaxSendAttempts = 6;
2979
+ var MaxSyncUnloadSendAttempts = 2;
2923
2980
  var MaxBackoffCount = 4;
2924
2981
  var globalContext = isWindowObjectAvailable ? window : undefined;
2925
2982
  var MaxConnections = 2;
2926
- var MaxRetries = 1;
2983
+ var MaxRequestRetriesBeforeBackoff = 1;
2927
2984
  var strEventsDiscarded = "eventsDiscarded";
2928
2985
  var strOverrideInstrumentationKey = "overrideInstrumentationKey";
2986
+ var strMaxEventRetryAttempts = "maxEventRetryAttempts";
2987
+ var strMaxUnloadEventRetryAttempts = "maxUnloadEventRetryAttempts";
2929
2988
  var PostChannel = /** @class */ (function (_super) {
2930
2989
  __extendsFn(PostChannel, _super);
2931
2990
  function PostChannel() {
2932
2991
  var _this = _super.call(this) || this;
2933
2992
  _this.identifier = "PostChannel";
2934
2993
  _this.priority = 1011;
2935
- _this.version = '3.1.10';
2994
+ _this.version = '3.1.11';
2936
2995
  var _config;
2937
2996
  var _isTeardownCalled = false;
2938
2997
  var _flushCallbackQueue = [];
@@ -2957,11 +3016,14 @@
2957
3016
  var _delayedBatchReason;
2958
3017
  var _optimizeObject = true;
2959
3018
  var _isPageUnloadTriggered = false;
3019
+ var _disableXhrSync = false;
3020
+ var _maxEventSendAttempts = MaxSendAttempts;
3021
+ var _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;
2960
3022
  dynamicProto(PostChannel, _this, function (_self, _base) {
2961
3023
  _initializeProfiles();
2962
3024
  _clearQueues();
2963
3025
  _setAutoLimits();
2964
- _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRetries, {
3026
+ _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {
2965
3027
  requeue: _requeueEvents,
2966
3028
  send: _sendingEvent,
2967
3029
  sent: _eventsSentEvent,
@@ -2983,14 +3045,7 @@
2983
3045
  _self._setTimeoutOverride = _config.setTimeoutOverride ? _config.setTimeoutOverride : setTimeout.bind(globalContext);
2984
3046
  _self._clearTimeoutOverride = _config.clearTimeoutOverride ? _config.clearTimeoutOverride : clearTimeout.bind(globalContext);
2985
3047
  _optimizeObject = !_config.disableOptimizeObj && isChromium();
2986
- var existingGetWParamMethod = extendedCore.getWParam;
2987
- extendedCore.getWParam = function () {
2988
- var wparam = 0;
2989
- if (_config.ignoreMc1Ms0CookieProcessing) {
2990
- wparam = wparam | 2;
2991
- }
2992
- return wparam | existingGetWParamMethod();
2993
- };
3048
+ _hookWParam(extendedCore);
2994
3049
  if (_config.eventsLimitInMem > 0) {
2995
3050
  _queueSizeLimit = _config.eventsLimitInMem;
2996
3051
  }
@@ -3000,6 +3055,13 @@
3000
3055
  if (_config.autoFlushEventsLimit > 0) {
3001
3056
  _autoFlushEventsLimit = _config.autoFlushEventsLimit;
3002
3057
  }
3058
+ _disableXhrSync = _config.disableXhrSync;
3059
+ if (isNumber(_config[strMaxEventRetryAttempts])) {
3060
+ _maxEventSendAttempts = _config[strMaxEventRetryAttempts];
3061
+ }
3062
+ if (isNumber(_config[strMaxUnloadEventRetryAttempts])) {
3063
+ _maxUnloadEventSendAttempts = _config[strMaxUnloadEventRetryAttempts];
3064
+ }
3003
3065
  _setAutoLimits();
3004
3066
  if (_config.httpXHROverride && _config.httpXHROverride.sendPOST) {
3005
3067
  _xhrOverride = _config.httpXHROverride;
@@ -3012,21 +3074,10 @@
3012
3074
  var endpointUrl = _config.overrideEndpointUrl ? _config.overrideEndpointUrl : coreConfig.endpointUrl;
3013
3075
  _self._notificationManager = coreConfig.extensionConfig.NotificationManager;
3014
3076
  _httpManager.initialize(endpointUrl, _self.core, _self, _xhrOverride, _config);
3015
- function _handleUnloadEvents(evt) {
3016
- var theEvt = evt || getWindow().event;
3017
- if (theEvt.type !== "beforeunload") {
3018
- _isPageUnloadTriggered = true;
3019
- _httpManager.setUnloading(_isPageUnloadTriggered);
3020
- }
3021
- _releaseAllQueues(2 , 2 );
3022
- }
3023
3077
  var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];
3024
3078
  addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents);
3025
3079
  addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents);
3026
- addPageShowEventListener(function (evt) {
3027
- _isPageUnloadTriggered = false;
3028
- _httpManager.setUnloading(_isPageUnloadTriggered);
3029
- }, coreConfig.disablePageShowEvents);
3080
+ addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents);
3030
3081
  _self.setInitialized(true);
3031
3082
  }, function () { return ({ coreConfig: coreConfig, core: core, extensions: extensions }); });
3032
3083
  };
@@ -3056,6 +3107,28 @@
3056
3107
  }
3057
3108
  _self.processNext(event, itemCtx);
3058
3109
  };
3110
+ function _hookWParam(extendedCore) {
3111
+ var existingGetWParamMethod = extendedCore.getWParam;
3112
+ extendedCore.getWParam = function () {
3113
+ var wparam = 0;
3114
+ if (_config.ignoreMc1Ms0CookieProcessing) {
3115
+ wparam = wparam | 2;
3116
+ }
3117
+ return wparam | existingGetWParamMethod();
3118
+ };
3119
+ }
3120
+ function _handleUnloadEvents(evt) {
3121
+ var theEvt = evt || getWindow().event;
3122
+ if (theEvt.type !== "beforeunload") {
3123
+ _isPageUnloadTriggered = true;
3124
+ _httpManager.setUnloading(_isPageUnloadTriggered);
3125
+ }
3126
+ _releaseAllQueues(2 , 2 );
3127
+ }
3128
+ function _handleShowEvents(evt) {
3129
+ _isPageUnloadTriggered = false;
3130
+ _httpManager.setUnloading(_isPageUnloadTriggered);
3131
+ }
3059
3132
  function _addEventToQueues(event, append) {
3060
3133
  if (!event.sendAttempt) {
3061
3134
  event.sendAttempt = 0;
@@ -3485,6 +3558,10 @@
3485
3558
  }
3486
3559
  function _requeueEvents(batches, reason) {
3487
3560
  var droppedEvents = [];
3561
+ var maxSendAttempts = _maxEventSendAttempts;
3562
+ if (_isPageUnloadTriggered) {
3563
+ maxSendAttempts = _maxUnloadEventSendAttempts;
3564
+ }
3488
3565
  arrForEach(batches, function (theBatch) {
3489
3566
  if (theBatch && theBatch.count() > 0) {
3490
3567
  arrForEach(theBatch.events(), function (theEvent) {
@@ -3493,7 +3570,7 @@
3493
3570
  theEvent.latency = EventLatency.Immediate;
3494
3571
  theEvent.sync = false;
3495
3572
  }
3496
- if (theEvent.sendAttempt < MaxSendAttempts) {
3573
+ if (theEvent.sendAttempt < maxSendAttempts) {
3497
3574
  setProcessTelemetryTimings(theEvent, _self.identifier);
3498
3575
  _addEventToQueues(theEvent, false);
3499
3576
  }
@@ -3592,4 +3669,4 @@
3592
3669
  (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
3593
3670
 
3594
3671
  })(this.oneDS = this.oneDS || {});
3595
- //# sourceMappingURL=ms.post-3.1.10.gbl.js.map
3672
+ //# sourceMappingURL=ms.post-3.1.11.gbl.js.map