@microsoft/1ds-post-js 4.3.7-nightly3.2504-18 → 4.3.7-nightly3.2505-02

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 (50) hide show
  1. package/README.md +1 -0
  2. package/bundle/es5/{ms.post-4.3.7-nightly3.2504-18.gbl.js → ms.post-4.3.7-nightly3.2505-02.gbl.js} +118 -22
  3. package/bundle/es5/ms.post-4.3.7-nightly3.2505-02.gbl.js.map +1 -0
  4. package/bundle/es5/ms.post-4.3.7-nightly3.2505-02.gbl.min.js +7 -0
  5. package/bundle/es5/ms.post-4.3.7-nightly3.2505-02.gbl.min.js.map +1 -0
  6. package/bundle/es5/ms.post-4.3.7-nightly3.2505-02.integrity.json +46 -0
  7. package/bundle/es5/{ms.post-4.3.7-nightly3.2504-18.js → ms.post-4.3.7-nightly3.2505-02.js} +118 -22
  8. package/bundle/es5/ms.post-4.3.7-nightly3.2505-02.js.map +1 -0
  9. package/bundle/es5/ms.post-4.3.7-nightly3.2505-02.min.js +7 -0
  10. package/bundle/es5/ms.post-4.3.7-nightly3.2505-02.min.js.map +1 -0
  11. package/bundle/es5/ms.post.gbl.js +117 -21
  12. package/bundle/es5/ms.post.gbl.js.map +1 -1
  13. package/bundle/es5/ms.post.gbl.min.js +2 -2
  14. package/bundle/es5/ms.post.gbl.min.js.map +1 -1
  15. package/bundle/es5/ms.post.integrity.json +17 -17
  16. package/bundle/es5/ms.post.js +117 -21
  17. package/bundle/es5/ms.post.js.map +1 -1
  18. package/bundle/es5/ms.post.min.js +2 -2
  19. package/bundle/es5/ms.post.min.js.map +1 -1
  20. package/dist/es5/ms.post.js +115 -19
  21. package/dist/es5/ms.post.js.map +1 -1
  22. package/dist/es5/ms.post.min.js +2 -2
  23. package/dist/es5/ms.post.min.js.map +1 -1
  24. package/dist-es5/BatchNotificationActions.js +1 -1
  25. package/dist-es5/ClockSkewManager.js +1 -1
  26. package/dist-es5/DataModels.js +1 -1
  27. package/dist-es5/EventBatch.js +1 -1
  28. package/dist-es5/HttpManager.js +25 -14
  29. package/dist-es5/HttpManager.js.map +1 -1
  30. package/dist-es5/Index.js +1 -1
  31. package/dist-es5/InternalConstants.js +1 -1
  32. package/dist-es5/KillSwitch.js +1 -1
  33. package/dist-es5/PostChannel.js +4 -3
  34. package/dist-es5/PostChannel.js.map +1 -1
  35. package/dist-es5/RetryPolicy.js +1 -1
  36. package/dist-es5/Serializer.js +26 -4
  37. package/dist-es5/Serializer.js.map +1 -1
  38. package/dist-es5/TimeoutOverrideWrapper.js +1 -1
  39. package/dist-es5/__DynamicConstants.js +1 -1
  40. package/dist-es5/typings/XDomainRequest.js +1 -1
  41. package/package.json +2 -2
  42. package/types/1ds-post-js.d.ts +21 -1
  43. package/types/1ds-post-js.namespaced.d.ts +21 -1
  44. package/bundle/es5/ms.post-4.3.7-nightly3.2504-18.gbl.js.map +0 -1
  45. package/bundle/es5/ms.post-4.3.7-nightly3.2504-18.gbl.min.js +0 -7
  46. package/bundle/es5/ms.post-4.3.7-nightly3.2504-18.gbl.min.js.map +0 -1
  47. package/bundle/es5/ms.post-4.3.7-nightly3.2504-18.integrity.json +0 -46
  48. package/bundle/es5/ms.post-4.3.7-nightly3.2504-18.js.map +0 -1
  49. package/bundle/es5/ms.post-4.3.7-nightly3.2504-18.min.js +0 -7
  50. package/bundle/es5/ms.post-4.3.7-nightly3.2504-18.min.js.map +0 -1
package/README.md CHANGED
@@ -66,6 +66,7 @@ appInsightsCore.initialize(coreConfig, []);
66
66
  | maxEventRetryAttempts<br /><sub><i>(Since 3.1.11+)</i></sub> | [Optional] Identifies the number of times any single event will be retried if it receives a failed (retirable) response, this causes the event to be internally "requeued" and resent in the next batch. As each normal batched send request is retried at least once before starting to increase the internal backoff send interval, normally batched events will generally be attempted the next nearest even number of times. This means that the total number of actual send attempts will almost always be even (setting to 5 will cause 6 requests), unless using manual synchronous flushing (calling flush(false)) which is not subject to request level retry attempts. | number<br/>Default: 6
67
67
  | maxUnloadEventRetryAttempts<br /><sub><i>(Since 3.1.11+)</i></sub> | [Optional] Identifies the number of times any single event will be retried if it receives a failed (retriable) response as part of processing / flushing events once a page unload state has been detected, this causes the event to be internally "requeued" and resent in the next batch, which during page unload. Unlike the normal batching process, send requests are never retried, so the value listed here is always the maximum number of attempts for any single event.<br/>Notes: The SDK by default will use the sendBeacon() API if it exists which is treated as a fire and forget successful response, so for environments that support or supply this API the events won't be retried (because they will be deeded to be successfully sent). When an environment (IE) doesn't support sendBeacon(), this will cause multiple synchronous (by default) XMLHttpRequests to be sent, which will block the UI until a response is received. You can disable ALL synchronous XHR requests by setting the 'disableXhrSync' configuration setting and/or changing this value to 0 or 1. | number<br/>Default: 2
68
68
  | addNoResponse <br /><sub><i>(Since 3.2.8+)</i></sub> | [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string value to indicate that the server should return a 204 for successful requests. | boolean<br/>Default: true
69
+ | disableZip <br /><sub><i>(Since 4.3.7+)</i></sub> | [Optional] flag to use CompressionStream API to compress the payload. Compression will only occur if the event is asynchronous. For events like unloads, compression will not be applied. * Note: if user set payloadPreprocessor, this zip compression will not be applied. | boolean<br/>Default: true
69
70
 
70
71
  ### [IXHROverride](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IXHROverride.html)
71
72
 
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * 1DS JS SDK POST plugin, 4.3.7-nightly3.2504-18
2
+ * 1DS JS SDK POST plugin, 4.3.7-nightly3.2505-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
6
6
  (function (global, factory) {
7
7
  var undef = "undefined";
8
- var nsKey, key, nm, theExports = {}, modName = "es5_ms_post_4_3_7_nightly3_2504_18", msMod="__ms$mod__";
9
- var mods={}, modDetail=mods[modName]={}, ver="4.3.7-nightly3.2504-18";
8
+ var nsKey, key, nm, theExports = {}, modName = "es5_ms_post_4_3_7_nightly3_2505_02", msMod="__ms$mod__";
9
+ var mods={}, modDetail=mods[modName]={}, ver="4.3.7-nightly3.2505-02";
10
10
  // Versioned namespace "oneDS4"
11
11
  var exportNs=global, nsKey="oneDS4", exportNs=exportNs[nsKey]=(exportNs[nsKey]||{});
12
12
  // Global namespace "oneDS"
@@ -1193,8 +1193,8 @@ var _DYN_IS_CHILD_EVT = "isChildEvt";
1193
1193
  var _DYN_DATA = "data";
1194
1194
  var _DYN_GET_CTX = "getCtx";
1195
1195
  var _DYN_SET_CTX = "setCtx";
1196
- var _DYN_URL_STRING = "urlString";
1197
1196
  var _DYN_HEADERS$1 = "headers";
1197
+ var _DYN_URL_STRING = "urlString";
1198
1198
  var _DYN_TIMEOUT = "timeout";
1199
1199
 
1200
1200
  var aggregationErrorType;
@@ -1607,6 +1607,20 @@ function optimizeObject(theObject) {
1607
1607
  }
1608
1608
  return theObject;
1609
1609
  }
1610
+ function isFeatureEnabled(feature, cfg) {
1611
+ var ft = cfg && cfg.featureOptIn && cfg.featureOptIn[feature];
1612
+ if (feature && ft) {
1613
+ var mode = ft.mode;
1614
+ if (mode === 3 ) {
1615
+ return true;
1616
+ }
1617
+ else if (mode === 2 ) {
1618
+ return false;
1619
+ }
1620
+ return UNDEFINED_VALUE;
1621
+ }
1622
+ return UNDEFINED_VALUE;
1623
+ }
1610
1624
  function getResponseText(xhr) {
1611
1625
  try {
1612
1626
  return xhr.responseText;
@@ -1911,7 +1925,7 @@ function newId(maxLength) {
1911
1925
  return result;
1912
1926
  }
1913
1927
 
1914
- var version = '3.3.7-nightly3.2504-18';
1928
+ var version = '3.3.7-nightly3.2505-02';
1915
1929
  var instanceName = "." + newId(6);
1916
1930
  var _dataUid = 0;
1917
1931
  function _canAcceptData(target) {
@@ -3524,6 +3538,58 @@ var SenderPostManager = /** @class */ (function () {
3524
3538
  _self[_DYN__DO_TEARDOWN ] = function (unloadCtx, unloadState) {
3525
3539
  _initDefaults();
3526
3540
  };
3541
+ _self.preparePayload = function (callback, zipPayload, payload, isSync) {
3542
+ if (!zipPayload || isSync || !payload[_DYN_DATA ]) {
3543
+ callback(payload);
3544
+ return;
3545
+ }
3546
+ try {
3547
+ var csStream = getInst("CompressionStream");
3548
+ if (!isFunction(csStream)) {
3549
+ callback(payload);
3550
+ return;
3551
+ }
3552
+ var body = new ReadableStream({
3553
+ start: function (controller) {
3554
+ controller.enqueue(isString(payload[_DYN_DATA ]) ? new TextEncoder().encode(payload[_DYN_DATA ]) : payload[_DYN_DATA ]);
3555
+ controller.close();
3556
+ }
3557
+ });
3558
+ var compressedStream = body.pipeThrough(new csStream("gzip"));
3559
+ var reader_1 = compressedStream.getReader();
3560
+ var chunks_1 = [];
3561
+ var totalLength_1 = 0;
3562
+ var callbackCalled_1 = false;
3563
+ doAwaitResponse(reader_1.read(), function processChunk(response) {
3564
+ if (!callbackCalled_1 && !response.rejected) {
3565
+ var result = response[_DYN_VALUE$1 ];
3566
+ if (!result.done) {
3567
+ chunks_1[_DYN_PUSH$1 ](result[_DYN_VALUE$1 ]);
3568
+ totalLength_1 += result.value[_DYN_LENGTH$2 ];
3569
+ return doAwaitResponse(reader_1.read(), processChunk);
3570
+ }
3571
+ var combined = new Uint8Array(totalLength_1);
3572
+ var offset = 0;
3573
+ for (var _i = 0, chunks_2 = chunks_1; _i < chunks_2.length; _i++) {
3574
+ var chunk = chunks_2[_i];
3575
+ combined.set(chunk, offset);
3576
+ offset += chunk[_DYN_LENGTH$2 ];
3577
+ }
3578
+ payload[_DYN_DATA ] = combined;
3579
+ payload[_DYN_HEADERS$1 ]["Content-Encoding"] = "gzip";
3580
+ }
3581
+ if (!callbackCalled_1) {
3582
+ callbackCalled_1 = true;
3583
+ callback(payload);
3584
+ }
3585
+ });
3586
+ return reader_1;
3587
+ }
3588
+ catch (error) {
3589
+ callback(payload);
3590
+ return;
3591
+ }
3592
+ };
3527
3593
  function _onSuccess(res, onComplete) {
3528
3594
  _doOnComplete(onComplete, 200, {}, res);
3529
3595
  }
@@ -4185,7 +4251,7 @@ var _DYN_LENGTH$1 = "length";
4185
4251
  var _DYN_PROCESS_TELEMETRY_ST0 = "processTelemetryStart";
4186
4252
 
4187
4253
  var _a$1;
4188
- var Version = '4.3.7-nightly3.2504-18';
4254
+ var Version = '4.3.7-nightly3.2505-02';
4189
4255
  var FullVersionString = "1DS-Web-JS-" + Version;
4190
4256
  var ObjHasOwnProperty = ObjProto$1.hasOwnProperty;
4191
4257
  var _fieldTypeEventPropMap = (_a$1 = {},
@@ -4623,7 +4689,7 @@ var metadata = "metadata";
4623
4689
  var f = "f";
4624
4690
  var rCheckDot = /\./;
4625
4691
  var Serializer = /** @class */ (function () {
4626
- function Serializer(perfManager, valueSanitizer, stringifyObjects, enableCompoundKey, getEncodedTypeOverride, excludeCsMetaData) {
4692
+ function Serializer(perfManager, valueSanitizer, stringifyObjects, enableCompoundKey, getEncodedTypeOverride, excludeCsMetaData, cfg) {
4627
4693
  var strData = "data";
4628
4694
  var strBaseData = "baseData";
4629
4695
  var strExt = "ext";
@@ -4633,6 +4699,11 @@ var Serializer = /** @class */ (function () {
4633
4699
  var _isReservedCache = {};
4634
4700
  var _excludeCsMetaData = !!excludeCsMetaData;
4635
4701
  var _getEncodedType = getEncodedTypeOverride || getCommonSchemaMetaData;
4702
+ var _sizeCfg = _getSizeLimtCfg(cfg);
4703
+ var _requestSizeLimitBytes = _validateSizeLimit(_sizeCfg.requestLimit, RequestSizeLimitBytes, 0);
4704
+ var _beaconRequestSizeLimitBytes = _validateSizeLimit(_sizeCfg.requestLimit, BeaconRequestSizeLimitBytes, 1);
4705
+ var _maxRecordSize = _validateSizeLimit(_sizeCfg.recordLimit, MaxRecordSize, 0);
4706
+ var _maxBeaconRecordSize = Math.min(_validateSizeLimit(_sizeCfg.recordLimit, MaxBeaconRecordSize, 1), _beaconRequestSizeLimitBytes);
4636
4707
  dynamicProto(Serializer, this, function (_self) {
4637
4708
  _self.createPayload = function (retryCnt, isTeardown, isSync, isReducedPayload, sendReason, sendType) {
4638
4709
  return {
@@ -4662,8 +4733,8 @@ var Serializer = /** @class */ (function () {
4662
4733
  var sizeExceeded = [];
4663
4734
  var failedEvts = [];
4664
4735
  var isBeaconPayload = payload.isBeacon;
4665
- var requestMaxSize = isBeaconPayload ? BeaconRequestSizeLimitBytes : RequestSizeLimitBytes;
4666
- var recordMaxSize = isBeaconPayload ? MaxBeaconRecordSize : MaxRecordSize;
4736
+ var requestMaxSize = isBeaconPayload ? _beaconRequestSizeLimitBytes : _requestSizeLimitBytes;
4737
+ var recordMaxSize = isBeaconPayload ? _maxBeaconRecordSize : _maxRecordSize;
4667
4738
  var lp = 0;
4668
4739
  var joinCount = 0;
4669
4740
  while (lp < theEvents.length) {
@@ -4826,6 +4897,22 @@ var Serializer = /** @class */ (function () {
4826
4897
  Serializer.__ieDyn=1;
4827
4898
  return Serializer;
4828
4899
  }());
4900
+ function _validateSizeLimit(cfgVal, defaultVal, idx) {
4901
+ if (isArray(cfgVal)) {
4902
+ var val = cfgVal[idx];
4903
+ if (val > 0 && val <= defaultVal) {
4904
+ return val;
4905
+ }
4906
+ }
4907
+ return defaultVal;
4908
+ }
4909
+ function _getSizeLimtCfg(cfg) {
4910
+ var defaultCfg = {};
4911
+ if (cfg && cfg.requestLimit) {
4912
+ return cfg.requestLimit;
4913
+ }
4914
+ return defaultCfg;
4915
+ }
4829
4916
  function _addJSONPropertyMetaData(getEncodedType, json, propKeys, name, propertyValue) {
4830
4917
  if (propertyValue && json) {
4831
4918
  var encodedTypeValue = getEncodedType(propertyValue.value, propertyValue.kind, propertyValue.propertyType);
@@ -4970,6 +5057,7 @@ var HttpManager = /** @class */ (function () {
4970
5057
  var _isUnloading;
4971
5058
  var _useHeaders;
4972
5059
  var _xhrTimeout;
5060
+ var _zipPayload;
4973
5061
  var _disableXhrSync;
4974
5062
  var _disableFetchKeepAlive;
4975
5063
  var _canHaveReducedPayload;
@@ -5017,6 +5105,11 @@ var HttpManager = /** @class */ (function () {
5017
5105
  enableCompoundKey = !!channelConfig[_DYN_ENABLE_COMPOUND_KEY ];
5018
5106
  }
5019
5107
  _xhrTimeout = channelConfig.xhrTimeout;
5108
+ var csStream = getInst("CompressionStream");
5109
+ _zipPayload = isFeatureEnabled("zipPayload", coreConfig);
5110
+ if (!isFunction(csStream) || _sendHook) {
5111
+ _zipPayload = false;
5112
+ }
5020
5113
  _disableXhrSync = !!channelConfig[_DYN_DISABLE_XHR_SYNC ];
5021
5114
  _disableFetchKeepAlive = !!channelConfig[_DYN_DISABLE_FETCH_KEEP_A6 ];
5022
5115
  _addNoResponse = channelConfig[_DYN_ADD_NO_RESPONSE ] !== false;
@@ -5025,7 +5118,7 @@ var HttpManager = /** @class */ (function () {
5025
5118
  _disableFetchKeepAlive = true;
5026
5119
  }
5027
5120
  _useBeacons = !isReactNative();
5028
- _serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey, getCommonSchemaMetaData, _excludeCsMetaData);
5121
+ _serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey, getCommonSchemaMetaData, _excludeCsMetaData, channelConfig);
5029
5122
  if (!isNullOrUndefined(channelConfig[_DYN_USE_SEND_BEACON ])) {
5030
5123
  _useBeacons = !!channelConfig[_DYN_USE_SEND_BEACON ];
5031
5124
  }
@@ -5568,16 +5661,18 @@ var HttpManager = /** @class */ (function () {
5568
5661
  _retryRequestIfNeeded(status, headers, thePayload, sendReason);
5569
5662
  };
5570
5663
  var isSync = thePayload[_DYN_IS_TEARDOWN ] || thePayload.isSync;
5571
- try {
5572
- sendInterface_1.sendPOST(payload, onComplete, isSync);
5573
- if (_sendListener) {
5574
- _sendListener(orgPayloadData, payload, isSync, thePayload[_DYN_IS_BEACON ]);
5664
+ _sendPostMgr.preparePayload(function (processedPayload) {
5665
+ try {
5666
+ sendInterface_1.sendPOST(processedPayload, onComplete, isSync);
5667
+ if (_sendListener) {
5668
+ _sendListener(orgPayloadData, processedPayload, isSync, thePayload[_DYN_IS_BEACON ]);
5669
+ }
5575
5670
  }
5576
- }
5577
- catch (ex) {
5578
- _warnToConsole(_logger, "Unexpected exception sending payload. Ex:" + dumpObj(ex));
5579
- _doOnComplete(onComplete, 0, {});
5580
- }
5671
+ catch (ex) {
5672
+ _doOnComplete(onComplete, 0, {});
5673
+ _warnToConsole(_logger, "Unexpected exception sending payload. Ex:" + dumpObj(ex));
5674
+ }
5675
+ }, _zipPayload, payload, isSync);
5581
5676
  };
5582
5677
  }
5583
5678
  doPerf(_core, function () { return "HttpManager:_doPayloadSend.sender"; }, function () {
@@ -5851,7 +5946,8 @@ var defaultPostChannelConfig = objDeepFreeze({
5851
5946
  maxEventRetryAttempts: { isVal: isNumber, v: MaxSendAttempts },
5852
5947
  maxUnloadEventRetryAttempts: { isVal: isNumber, v: MaxSyncUnloadSendAttempts },
5853
5948
  addNoResponse: undefValue,
5854
- excludeCsMetaData: undefValue
5949
+ excludeCsMetaData: undefValue,
5950
+ requestLimit: {}
5855
5951
  });
5856
5952
  function isOverrideFn(httpXHROverride) {
5857
5953
  return httpXHROverride && httpXHROverride.sendPOST;
@@ -5862,7 +5958,7 @@ var PostChannel = /** @class */ (function (_super) {
5862
5958
  var _this = _super.call(this) || this;
5863
5959
  _this.identifier = "PostChannel";
5864
5960
  _this.priority = 1011;
5865
- _this.version = '4.3.7-nightly3.2504-18';
5961
+ _this.version = '4.3.7-nightly3.2505-02';
5866
5962
  var _postConfig;
5867
5963
  var _isTeardownCalled = false;
5868
5964
  var _flushCallbackQueue = [];
@@ -6647,4 +6743,4 @@ exports.PostChannel = PostChannel;
6647
6743
  exports.RT_PROFILE = RT_PROFILE;
6648
6744
 
6649
6745
  }));
6650
- //# sourceMappingURL=ms.post-4.3.7-nightly3.2504-18.gbl.js.map
6746
+ //# sourceMappingURL=ms.post-4.3.7-nightly3.2505-02.gbl.js.map