@microsoft/1ds-post-js 3.2.5 → 3.2.7
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/README.md +4 -1
- package/bundle/{ms.post-3.2.5.gbl.js → ms.post-3.2.7.gbl.js} +44 -30
- package/bundle/ms.post-3.2.7.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.7.gbl.min.js +7 -0
- package/bundle/{ms.post-3.2.5.gbl.min.js.map → ms.post-3.2.7.gbl.min.js.map} +1 -1
- package/bundle/ms.post-3.2.7.integrity.json +46 -0
- package/bundle/{ms.post-3.2.5.js → ms.post-3.2.7.js} +44 -30
- package/bundle/ms.post-3.2.7.js.map +1 -0
- package/bundle/ms.post-3.2.7.min.js +7 -0
- package/bundle/{ms.post-3.2.5.min.js.map → ms.post-3.2.7.min.js.map} +1 -1
- package/bundle/ms.post.gbl.js +43 -29
- package/bundle/ms.post.gbl.js.map +1 -1
- package/bundle/ms.post.gbl.min.js +2 -2
- package/bundle/ms.post.gbl.min.js.map +1 -1
- package/bundle/ms.post.integrity.json +17 -17
- package/bundle/ms.post.js +43 -29
- package/bundle/ms.post.js.map +1 -1
- package/bundle/ms.post.min.js +2 -2
- package/bundle/ms.post.min.js.map +1 -1
- package/dist/ms.post.js +41 -27
- package/dist/ms.post.js.map +1 -1
- package/dist/ms.post.min.js +2 -2
- package/dist/ms.post.min.js.map +1 -1
- package/dist-esm/src/BatchNotificationActions.js +1 -1
- package/dist-esm/src/ClockSkewManager.js +1 -1
- package/dist-esm/src/DataModels.d.ts +19 -3
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.js +1 -1
- package/dist-esm/src/HttpManager.js +39 -24
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/InternalConstants.js +1 -1
- package/dist-esm/src/KillSwitch.js +1 -1
- package/dist-esm/src/PostChannel.js +2 -2
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.js +1 -1
- package/dist-esm/src/Serializer.d.ts +3 -3
- package/dist-esm/src/Serializer.js +3 -3
- package/dist-esm/src/Serializer.js.map +1 -1
- package/dist-esm/src/TimeoutOverrideWrapper.js +1 -1
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +2 -2
- package/src/DataModels.ts +19 -0
- package/src/HttpManager.ts +47 -26
- package/src/Serializer.ts +10 -10
- package/bundle/ms.post-3.2.5.gbl.js.map +0 -1
- package/bundle/ms.post-3.2.5.gbl.min.js +0 -7
- package/bundle/ms.post-3.2.5.integrity.json +0 -46
- package/bundle/ms.post-3.2.5.js.map +0 -1
- package/bundle/ms.post-3.2.5.min.js +0 -7
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ ms.reviewedBy: ramthi
|
|
|
15
15
|
|
|
16
16
|
## npm
|
|
17
17
|
|
|
18
|
-
Packages available [here](https://msasg.visualstudio.com/Shared%20Data/_artifacts/feed/1DS-SDK/Npm/%40microsoft%2F1ds-post-js/overview/3.2.
|
|
18
|
+
Packages available [here](https://msasg.visualstudio.com/Shared%20Data/_artifacts/feed/1DS-SDK/Npm/%40microsoft%2F1ds-post-js/overview/3.2.7).
|
|
19
19
|
|
|
20
20
|
## Basic Usage
|
|
21
21
|
|
|
@@ -66,6 +66,9 @@ appInsightsCore.initialize(coreConfig, []);
|
|
|
66
66
|
| enableCompoundKey | [Optional] Enables support for objects with compound keys which indirectly represent an object eg. event: { "somedata.embeddedvalue": 123 } where the "key" of the object contains a "." as part of it's name. Defaults to false. | boolean
|
|
67
67
|
| disableOptimizeObj | [Optional] Switch to disable the v8 `optimizeObject()` calls used to provide better serialization performance. Defaults to false. | boolean
|
|
68
68
|
| transports | [Optional] Either an array or single value identifying the requested `TransportType` (const enum) type that should be used. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided. | number or number[]
|
|
69
|
+
| useSendBeacon | [Optional] A flag to enable or disable the usage of the sendBeacon() API if available by the runtime. If running on ReactNative this defaults to `false` for all other cases it defaults to `true`.
|
|
70
|
+
| disableFetchKeepAlive | [Optional] A flag to disable the usage of the [fetch with keep-alive](https://javascript.info/fetch-api#keepalive) support.
|
|
71
|
+
| unloadTransports | [Optional] Either an array or single value identifying the requested TransportType type(s) that should be used during unload or events marked as sendBeacon. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided and alwaysUseXhrOverride is true.
|
|
69
72
|
| avoidOptions<br/><sub><i>(Since 3.1.10+)</i></sub><br /><sub>Default: false (Since 3.2.0)<br />Previously true</sub> | [Optional] Avoid adding request headers to the outgoing request that would cause a pre-flight (OPTIONS) request to be sent for each request. | boolean
|
|
70
73
|
| xhrTimeout<br/><sub><i>(Since 3.1.11+)</i></sub> | [Optional] Specify a timeout (in ms) to apply to requests when sending requests using XHR or fetch() requests only, does not affect sendBeacon() or XDR (XDomainRequest) usage. Defaults to undefined and therefore the runtime defaults (normally zero for browser environments) | number
|
|
71
74
|
| disableXhrSync<br/><sub><i>(Since 3.1.11+)</i></sub> | [Optional] When using [Xhr](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) for sending requests disable sending as synchronous during unload or synchronous flush. __You should enable this feature for IE (when there is no sendBeacon() or fetch (with keep-alive) support) and you have clients that end up blocking the UI during page unloading__. <span style="color:red">This will cause ALL XHR requests to be sent asynchronously which during page unload may result in the lose of telemetry</span>. This does not affect any other request type (fetch(), sendBeacon() or XDR (XDomainRequest)) | boolean<br/>Default: undefined
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.7
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -1266,7 +1266,7 @@
|
|
|
1266
1266
|
}
|
|
1267
1267
|
|
|
1268
1268
|
var _objDefineProperty = ObjDefineProperty;
|
|
1269
|
-
var version = '2.8.
|
|
1269
|
+
var version = '2.8.8';
|
|
1270
1270
|
var instanceName = "." + newId(6);
|
|
1271
1271
|
var _dataUid = 0;
|
|
1272
1272
|
function _createAccessor(target, prop, value) {
|
|
@@ -2159,7 +2159,7 @@
|
|
|
2159
2159
|
var STR_EMPTY = "";
|
|
2160
2160
|
|
|
2161
2161
|
var _a$1;
|
|
2162
|
-
var Version = '3.2.
|
|
2162
|
+
var Version = '3.2.7';
|
|
2163
2163
|
var FullVersionString = "1DS-Web-JS-" + Version;
|
|
2164
2164
|
var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
|
|
2165
2165
|
var strWithCredentials = "withCredentials";
|
|
@@ -2582,7 +2582,7 @@
|
|
|
2582
2582
|
var _theSanitizer = valueSanitizer;
|
|
2583
2583
|
var _isReservedCache = {};
|
|
2584
2584
|
dynamicProto(Serializer, this, function (_self) {
|
|
2585
|
-
_self.createPayload = function (retryCnt, isTeardown, isSync,
|
|
2585
|
+
_self.createPayload = function (retryCnt, isTeardown, isSync, isReducedPayload, sendReason, sendType) {
|
|
2586
2586
|
return {
|
|
2587
2587
|
apiKeys: [],
|
|
2588
2588
|
payloadBlob: "",
|
|
@@ -2594,7 +2594,7 @@
|
|
|
2594
2594
|
retryCnt: retryCnt,
|
|
2595
2595
|
isTeardown: isTeardown,
|
|
2596
2596
|
isSync: isSync,
|
|
2597
|
-
isBeacon:
|
|
2597
|
+
isBeacon: isReducedPayload,
|
|
2598
2598
|
sendType: sendType,
|
|
2599
2599
|
sendReason: sendReason
|
|
2600
2600
|
};
|
|
@@ -2872,6 +2872,17 @@
|
|
|
2872
2872
|
}
|
|
2873
2873
|
}
|
|
2874
2874
|
}
|
|
2875
|
+
function _prependTransports(theTransports, newTransports) {
|
|
2876
|
+
if (newTransports) {
|
|
2877
|
+
if (isNumber(newTransports)) {
|
|
2878
|
+
theTransports = [newTransports].concat(theTransports);
|
|
2879
|
+
}
|
|
2880
|
+
else if (isArray(newTransports)) {
|
|
2881
|
+
theTransports = newTransports.concat(theTransports);
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
return theTransports;
|
|
2885
|
+
}
|
|
2875
2886
|
var HttpManager = /** @class */ (function () {
|
|
2876
2887
|
function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions, timeoutOverride) {
|
|
2877
2888
|
this._responseHandlers = [];
|
|
@@ -2896,6 +2907,8 @@
|
|
|
2896
2907
|
var _useHeaders = false;
|
|
2897
2908
|
var _xhrTimeout;
|
|
2898
2909
|
var _disableXhrSync;
|
|
2910
|
+
var _disableFetchKeepAlive;
|
|
2911
|
+
var _canHaveReducedPayload;
|
|
2899
2912
|
dynamicProto(HttpManager, this, function (_self) {
|
|
2900
2913
|
var _sendCredentials = true;
|
|
2901
2914
|
_self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
|
|
@@ -2917,12 +2930,17 @@
|
|
|
2917
2930
|
enableCompoundKey = !!channelConfig.enableCompoundKey;
|
|
2918
2931
|
}
|
|
2919
2932
|
_xhrTimeout = channelConfig.xhrTimeout;
|
|
2920
|
-
_disableXhrSync = channelConfig.disableXhrSync;
|
|
2933
|
+
_disableXhrSync = !!channelConfig.disableXhrSync;
|
|
2934
|
+
_disableFetchKeepAlive = !!channelConfig.disableFetchKeepAlive;
|
|
2921
2935
|
_useBeacons = !isReactNative();
|
|
2922
2936
|
_serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
|
|
2937
|
+
if (!isNullOrUndefined(channelConfig.useSendBeacon)) {
|
|
2938
|
+
_useBeacons = !!channelConfig.useSendBeacon;
|
|
2939
|
+
}
|
|
2923
2940
|
var syncHttpInterface = httpInterface;
|
|
2924
2941
|
var beaconHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
|
|
2925
2942
|
var fetchSyncHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
|
|
2943
|
+
var beaconUnloadTransports = [3 , 2 ];
|
|
2926
2944
|
if (!httpInterface) {
|
|
2927
2945
|
_customHttpInterface = false;
|
|
2928
2946
|
var location_1 = getLocation();
|
|
@@ -2932,29 +2950,27 @@
|
|
|
2932
2950
|
var theTransports = [];
|
|
2933
2951
|
if (isReactNative()) {
|
|
2934
2952
|
theTransports = [2 , 1 ];
|
|
2953
|
+
beaconUnloadTransports = [2 , 1 , 3 ];
|
|
2935
2954
|
}
|
|
2936
2955
|
else {
|
|
2937
2956
|
theTransports = [1 , 2 , 3 ];
|
|
2938
2957
|
}
|
|
2939
|
-
|
|
2940
|
-
if (configTransports) {
|
|
2941
|
-
if (isNumber(configTransports)) {
|
|
2942
|
-
theTransports = [configTransports].concat(theTransports);
|
|
2943
|
-
}
|
|
2944
|
-
else if (isArray(configTransports)) {
|
|
2945
|
-
theTransports = configTransports.concat(theTransports);
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2958
|
+
theTransports = _prependTransports(theTransports, channelConfig.transports);
|
|
2948
2959
|
httpInterface = _getSenderInterface(theTransports, false);
|
|
2949
|
-
syncHttpInterface = _getSenderInterface(theTransports, true);
|
|
2950
2960
|
if (!httpInterface) {
|
|
2951
2961
|
_warnToConsole(_logger, "No available transport to send events");
|
|
2952
2962
|
}
|
|
2963
|
+
syncHttpInterface = _getSenderInterface(theTransports, true);
|
|
2953
2964
|
}
|
|
2965
|
+
if (!beaconHttpInterface) {
|
|
2966
|
+
beaconUnloadTransports = _prependTransports(beaconUnloadTransports, channelConfig.unloadTransports);
|
|
2967
|
+
beaconHttpInterface = _getSenderInterface(beaconUnloadTransports, true);
|
|
2968
|
+
}
|
|
2969
|
+
_canHaveReducedPayload = !_customHttpInterface && ((_useBeacons && isBeaconsSupported()) || (!_disableFetchKeepAlive && isFetchSupported(true)));
|
|
2954
2970
|
_sendInterfaces = (_a = {},
|
|
2955
2971
|
_a[0 ] = httpInterface,
|
|
2956
2972
|
_a[1 ] = syncHttpInterface || _getSenderInterface([1 , 2 , 3 ], true),
|
|
2957
|
-
_a[2 ] = beaconHttpInterface ||
|
|
2973
|
+
_a[2 ] = beaconHttpInterface || syncHttpInterface || _getSenderInterface([1 ], true),
|
|
2958
2974
|
_a[3 ] = fetchSyncHttpInterface || _getSenderInterface([2 , 3 ], true) || syncHttpInterface || _getSenderInterface([1 ], true),
|
|
2959
2975
|
_a);
|
|
2960
2976
|
};
|
|
@@ -2972,7 +2988,7 @@
|
|
|
2972
2988
|
sendPostFunc = _xhrSendPost;
|
|
2973
2989
|
}
|
|
2974
2990
|
}
|
|
2975
|
-
else if (transportType === 2 && isFetchSupported(syncSupport)) {
|
|
2991
|
+
else if (transportType === 2 && isFetchSupported(syncSupport) && (!syncSupport || (syncSupport && !_disableFetchKeepAlive))) {
|
|
2976
2992
|
sendPostFunc = _fetchSendPost;
|
|
2977
2993
|
}
|
|
2978
2994
|
else if (_useBeacons && transportType === 3 && isBeaconsSupported()) {
|
|
@@ -3296,12 +3312,13 @@
|
|
|
3296
3312
|
var thePayload = null;
|
|
3297
3313
|
var serializationStart = getTime();
|
|
3298
3314
|
var sendInterface = _sendInterfaces[sendType] || (isSynchronous_1 ? _sendInterfaces[1 ] : _sendInterfaces[0 ]);
|
|
3299
|
-
var
|
|
3315
|
+
var sendTransport = sendInterface && sendInterface._transport;
|
|
3316
|
+
var isReducedPayload = _canHaveReducedPayload && (_isUnloading || _isBeaconPayload(sendType) || (sendTransport === 3 || (sendInterface._isSync && sendTransport === 2 )));
|
|
3300
3317
|
while (_canSendPayload(theBatches, sendType, retryCount)) {
|
|
3301
3318
|
var theBatch = theBatches.shift();
|
|
3302
3319
|
if (theBatch && theBatch.count() > 0) {
|
|
3303
3320
|
if (!_killSwitch.isTenantKilled(theBatch.iKey())) {
|
|
3304
|
-
thePayload = thePayload || _serializer.createPayload(retryCount, isTeardown, isSynchronous_1,
|
|
3321
|
+
thePayload = thePayload || _serializer.createPayload(retryCount, isTeardown, isSynchronous_1, isReducedPayload, sendReason, sendType);
|
|
3305
3322
|
if (!_serializer.appendPayload(thePayload, theBatch, maxEventsPerBatch)) {
|
|
3306
3323
|
_doPayloadSend(thePayload, serializationStart, getTime(), sendReason);
|
|
3307
3324
|
serializationStart = getTime();
|
|
@@ -3384,9 +3401,6 @@
|
|
|
3384
3401
|
}
|
|
3385
3402
|
return requestDetails;
|
|
3386
3403
|
}
|
|
3387
|
-
function _canUseSendBeaconApi() {
|
|
3388
|
-
return !_customHttpInterface && _useBeacons && isBeaconsSupported();
|
|
3389
|
-
}
|
|
3390
3404
|
function _setTimingValue(timings, name, value) {
|
|
3391
3405
|
timings[name] = timings[name] || {};
|
|
3392
3406
|
timings[name][_postManager.identifier] = value;
|
|
@@ -3427,11 +3441,10 @@
|
|
|
3427
3441
|
headers: requestDetails_1.hdrs,
|
|
3428
3442
|
_thePayload: thePayload,
|
|
3429
3443
|
_sendReason: sendReason,
|
|
3430
|
-
timeout: _xhrTimeout
|
|
3444
|
+
timeout: _xhrTimeout,
|
|
3445
|
+
disableXhrSync: _disableXhrSync,
|
|
3446
|
+
disableFetchKeepAlive: _disableFetchKeepAlive
|
|
3431
3447
|
};
|
|
3432
|
-
if (!isUndefined(_disableXhrSync)) {
|
|
3433
|
-
orgPayloadData.disableXhrSync = !!_disableXhrSync;
|
|
3434
|
-
}
|
|
3435
3448
|
if (useHeaders_1) {
|
|
3436
3449
|
if (!_hasHeader(orgPayloadData.headers, STR_CACHE_CONTROL)) {
|
|
3437
3450
|
orgPayloadData.headers[STR_CACHE_CONTROL] = DEFAULT_CACHE_CONTROL;
|
|
@@ -3471,7 +3484,8 @@
|
|
|
3471
3484
|
urlString: orgPayloadData.urlString,
|
|
3472
3485
|
headers: extend({}, orgPayloadData.headers),
|
|
3473
3486
|
timeout: orgPayloadData.timeout,
|
|
3474
|
-
disableXhrSync: orgPayloadData.disableXhrSync
|
|
3487
|
+
disableXhrSync: orgPayloadData.disableXhrSync,
|
|
3488
|
+
disableFetchKeepAlive: orgPayloadData.disableFetchKeepAlive
|
|
3475
3489
|
};
|
|
3476
3490
|
var senderCalled_1 = false;
|
|
3477
3491
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend.sendHook"; }, function () {
|
|
@@ -3741,7 +3755,7 @@
|
|
|
3741
3755
|
var _this = _super.call(this) || this;
|
|
3742
3756
|
_this.identifier = "PostChannel";
|
|
3743
3757
|
_this.priority = 1011;
|
|
3744
|
-
_this.version = '3.2.
|
|
3758
|
+
_this.version = '3.2.7';
|
|
3745
3759
|
var _config;
|
|
3746
3760
|
var _isTeardownCalled = false;
|
|
3747
3761
|
var _flushCallbackQueue = [];
|
|
@@ -4474,4 +4488,4 @@
|
|
|
4474
4488
|
(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 });
|
|
4475
4489
|
|
|
4476
4490
|
})(this.oneDS = this.oneDS || {});
|
|
4477
|
-
//# sourceMappingURL=ms.post-3.2.
|
|
4491
|
+
//# sourceMappingURL=ms.post-3.2.7.gbl.js.map
|