@microsoft/1ds-post-js 3.2.6 → 3.2.8
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 +5 -1
- package/bundle/{ms.post-3.2.6.gbl.js → ms.post-3.2.8.gbl.js} +132 -85
- package/bundle/ms.post-3.2.8.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.8.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.8.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.8.integrity.json +46 -0
- package/bundle/{ms.post-3.2.6.js → ms.post-3.2.8.js} +132 -85
- package/bundle/ms.post-3.2.8.js.map +1 -0
- package/bundle/ms.post-3.2.8.min.js +7 -0
- package/bundle/ms.post-3.2.8.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +131 -84
- 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 +131 -84
- 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 +56 -37
- 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 +24 -3
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.js +3 -3
- package/dist-esm/src/EventBatch.js.map +1 -1
- package/dist-esm/src/HttpManager.js +51 -32
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/InternalConstants.d.ts +1 -0
- package/dist-esm/src/InternalConstants.js +2 -1
- package/dist-esm/src/InternalConstants.js.map +1 -1
- package/dist-esm/src/KillSwitch.js +1 -1
- package/dist-esm/src/PostChannel.js +3 -3
- 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 +5 -4
- 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 +4 -4
- package/src/DataModels.ts +26 -1
- package/src/EventBatch.ts +2 -2
- package/src/HttpManager.ts +59 -34
- package/src/InternalConstants.ts +1 -0
- package/src/PostChannel.ts +1 -1
- package/src/Serializer.ts +12 -11
- package/bundle/ms.post-3.2.6.gbl.js.map +0 -1
- package/bundle/ms.post-3.2.6.gbl.min.js +0 -7
- package/bundle/ms.post-3.2.6.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.2.6.integrity.json +0 -46
- package/bundle/ms.post-3.2.6.js.map +0 -1
- package/bundle/ms.post-3.2.6.min.js +0 -7
- package/bundle/ms.post-3.2.6.min.js.map +0 -1
|
@@ -14,6 +14,7 @@ export interface IPayloadData {
|
|
|
14
14
|
};
|
|
15
15
|
timeout?: number;
|
|
16
16
|
disableXhrSync?: boolean;
|
|
17
|
+
disableFetchKeepAlive?: boolean;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Defines the function signature for the Payload Preprocessor.
|
|
@@ -139,10 +140,25 @@ export interface IChannelConfiguration {
|
|
|
139
140
|
*/
|
|
140
141
|
transports?: number | number[];
|
|
141
142
|
/**
|
|
142
|
-
* [Optional]
|
|
143
|
-
*
|
|
144
|
-
*
|
|
143
|
+
* [Optional] Either an array or single value identifying the requested TransportType type(s) that should be used during unload or events
|
|
144
|
+
* marked as sendBeacon. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride
|
|
145
|
+
* is provided and alwaysUseXhrOverride is true.
|
|
145
146
|
*/
|
|
147
|
+
unloadTransports?: number | number[];
|
|
148
|
+
/**
|
|
149
|
+
* [Optional] A flag to enable or disable the usage of the sendBeacon() API (if available). If running on ReactNative this defaults
|
|
150
|
+
* to `false` for all other cases it defaults to `true`.
|
|
151
|
+
*/
|
|
152
|
+
useSendBeacon?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* [Optional] A flag to disable the usage of the [fetch with keep-alive](https://javascript.info/fetch-api#keepalive) support.
|
|
155
|
+
*/
|
|
156
|
+
disableFetchKeepAlive?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* [Optional] Avoid adding request headers to the outgoing request that would cause a pre-flight (OPTIONS) request to be sent for each request.
|
|
159
|
+
* This currently defaults to true but will be changed once the collector handles additional settings to allow the browser to better cache any
|
|
160
|
+
* previous OPTIONS response, at which point some of the current dynamic values sent on the query string will be moved to a header.
|
|
161
|
+
*/
|
|
146
162
|
avoidOptions?: boolean;
|
|
147
163
|
/**
|
|
148
164
|
* [Optional] Specify a timeout (in ms) to apply to requests when sending requests using XHR, XDR or fetch requests. Defaults to undefined
|
|
@@ -187,6 +203,11 @@ export interface IChannelConfiguration {
|
|
|
187
203
|
* configuration setting and/or changing this value to 0 or 1.
|
|
188
204
|
*/
|
|
189
205
|
maxUnloadEventRetryAttempts?: number;
|
|
206
|
+
/**
|
|
207
|
+
* [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string
|
|
208
|
+
* value to indicate that the server should return a 204 for successful requests. Defaults to true
|
|
209
|
+
*/
|
|
210
|
+
addNoResponse?: boolean;
|
|
190
211
|
}
|
|
191
212
|
/**
|
|
192
213
|
* SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.8
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @copyright Microsoft 2020
|
|
10
10
|
*/
|
|
11
11
|
import { isNullOrUndefined, isValueAssigned } from "@microsoft/1ds-core-js";
|
|
12
|
-
import { STR_MSFPC } from "./InternalConstants";
|
|
12
|
+
import { STR_EMPTY, STR_MSFPC } from "./InternalConstants";
|
|
13
13
|
function _getEventMsfpc(theEvent) {
|
|
14
14
|
var intWeb = ((theEvent.ext || {})["intweb"]);
|
|
15
15
|
if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {
|
|
@@ -45,7 +45,7 @@ var EventBatch = /** @class */ (function () {
|
|
|
45
45
|
};
|
|
46
46
|
_self.Msfpc = function () {
|
|
47
47
|
// return the cached value unless it's undefined -- used to avoid cpu
|
|
48
|
-
return _msfpc ||
|
|
48
|
+
return _msfpc || STR_EMPTY;
|
|
49
49
|
};
|
|
50
50
|
_self.count = function () {
|
|
51
51
|
return events.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventBatch.js.map","sources":["EventBatch.js"],"sourcesContent":["/**\r\n* EventBatch.ts\r\n* @author Nev Wylie (newylie)\r\n* @copyright Microsoft 2020\r\n*/\r\nimport { isNullOrUndefined, isValueAssigned } from \"@microsoft/1ds-core-js\";\r\nimport { STR_MSFPC } from \"./InternalConstants\";\r\nfunction _getEventMsfpc(theEvent) {\r\n var intWeb = ((theEvent.ext || {})[\"intweb\"]);\r\n if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {\r\n return intWeb[STR_MSFPC];\r\n }\r\n return null;\r\n}\r\nfunction _getMsfpc(theEvents) {\r\n var msfpc = null;\r\n for (var lp = 0; msfpc === null && lp < theEvents.length; lp++) {\r\n msfpc = _getEventMsfpc(theEvents[lp]);\r\n }\r\n return msfpc;\r\n}\r\n/**\r\n* This class defines a \"batch\" events related to a specific iKey, it is used by the PostChannel and HttpManager\r\n* to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous\r\n* array duplication and shared ownership issues that occurred due to race conditions caused by the async nature\r\n* of sending requests.\r\n*/\r\nvar EventBatch = /** @class */ (function () {\r\n /**\r\n * Private constructor so that caller is forced to use the static create method.\r\n * @param iKey - The iKey to associate with the events (not validated)\r\n * @param addEvents - The optional collection of events to assign to this batch - defaults to an empty array.\r\n */\r\n function EventBatch(iKey, addEvents) {\r\n var events = addEvents ? [].concat(addEvents) : [];\r\n var _self = this;\r\n var _msfpc = _getMsfpc(events);\r\n _self.iKey = function () {\r\n return iKey;\r\n };\r\n _self.Msfpc = function () {\r\n // return the cached value unless it's undefined -- used to avoid cpu\r\n return _msfpc ||
|
|
1
|
+
{"version":3,"file":"EventBatch.js.map","sources":["EventBatch.js"],"sourcesContent":["/**\r\n* EventBatch.ts\r\n* @author Nev Wylie (newylie)\r\n* @copyright Microsoft 2020\r\n*/\r\nimport { isNullOrUndefined, isValueAssigned } from \"@microsoft/1ds-core-js\";\r\nimport { STR_EMPTY, STR_MSFPC } from \"./InternalConstants\";\r\nfunction _getEventMsfpc(theEvent) {\r\n var intWeb = ((theEvent.ext || {})[\"intweb\"]);\r\n if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {\r\n return intWeb[STR_MSFPC];\r\n }\r\n return null;\r\n}\r\nfunction _getMsfpc(theEvents) {\r\n var msfpc = null;\r\n for (var lp = 0; msfpc === null && lp < theEvents.length; lp++) {\r\n msfpc = _getEventMsfpc(theEvents[lp]);\r\n }\r\n return msfpc;\r\n}\r\n/**\r\n* This class defines a \"batch\" events related to a specific iKey, it is used by the PostChannel and HttpManager\r\n* to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous\r\n* array duplication and shared ownership issues that occurred due to race conditions caused by the async nature\r\n* of sending requests.\r\n*/\r\nvar EventBatch = /** @class */ (function () {\r\n /**\r\n * Private constructor so that caller is forced to use the static create method.\r\n * @param iKey - The iKey to associate with the events (not validated)\r\n * @param addEvents - The optional collection of events to assign to this batch - defaults to an empty array.\r\n */\r\n function EventBatch(iKey, addEvents) {\r\n var events = addEvents ? [].concat(addEvents) : [];\r\n var _self = this;\r\n var _msfpc = _getMsfpc(events);\r\n _self.iKey = function () {\r\n return iKey;\r\n };\r\n _self.Msfpc = function () {\r\n // return the cached value unless it's undefined -- used to avoid cpu\r\n return _msfpc || STR_EMPTY;\r\n };\r\n _self.count = function () {\r\n return events.length;\r\n };\r\n _self.events = function () {\r\n return events;\r\n };\r\n _self.addEvent = function (theEvent) {\r\n if (theEvent) {\r\n events.push(theEvent);\r\n if (!_msfpc) {\r\n // Not found so try and find one\r\n _msfpc = _getEventMsfpc(theEvent);\r\n }\r\n return true;\r\n }\r\n return false;\r\n };\r\n _self.split = function (fromEvent, numEvents) {\r\n // Create a new batch with the same iKey\r\n var theEvents;\r\n if (fromEvent < events.length) {\r\n var cnt = events.length - fromEvent;\r\n if (!isNullOrUndefined(numEvents)) {\r\n cnt = numEvents < cnt ? numEvents : cnt;\r\n }\r\n theEvents = events.splice(fromEvent, cnt);\r\n // reset the fetched msfpc value\r\n _msfpc = _getMsfpc(events);\r\n }\r\n return new EventBatch(iKey, theEvents);\r\n };\r\n }\r\n /**\r\n * Creates a new Event Batch object\r\n * @param iKey The iKey associated with this batch of events\r\n */\r\n EventBatch.create = function (iKey, theEvents) {\r\n return new EventBatch(iKey, theEvents);\r\n };\r\n return EventBatch;\r\n}());\r\nexport { EventBatch };\r\n//# sourceMappingURL=EventBatch.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.8
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -13,7 +13,7 @@ import dynamicProto from "@microsoft/dynamicproto-js";
|
|
|
13
13
|
import EVTClockSkewManager from "./ClockSkewManager";
|
|
14
14
|
import EVTKillSwitch from "./KillSwitch";
|
|
15
15
|
import { FullVersionString, _throwInternal, _warnToConsole, arrForEach, dateNow, doPerf, dumpObj, extend, getLocation, getNavigator, getTime, hasOwnProperty, isArray, isBeaconsSupported, isFetchSupported, isNullOrUndefined, isNumber, isReactNative, isString, isUndefined, isValueAssigned, isXhrSupported, objForEachKey, objKeys, openXhr, strTrim, strUndefined, useXDomainRequest } from "@microsoft/1ds-core-js";
|
|
16
|
-
import { DEFAULT_CACHE_CONTROL, DEFAULT_CONTENT_TYPE, STR_API_KEY, STR_AUTH_XTOKEN, STR_CACHE_CONTROL, STR_CLIENT_ID, STR_CLIENT_VERSION, STR_CONTENT_TYPE_HEADER, STR_DISABLED_PROPERTY_NAME, STR_DROPPED, STR_KILL_DURATION_HEADER, STR_KILL_DURATION_SECONDS_HEADER, STR_KILL_TOKENS_HEADER, STR_MSA_DEVICE_TICKET, STR_MSFPC, STR_NO_RESPONSE_BODY, STR_OTHER, STR_POST_METHOD, STR_REQUEUE, STR_RESPONSE_FAIL, STR_SENDING, STR_TIME_DELTA_HEADER, STR_TIME_DELTA_TO_APPLY, STR_UPLOAD_TIME } from "./InternalConstants";
|
|
16
|
+
import { DEFAULT_CACHE_CONTROL, DEFAULT_CONTENT_TYPE, STR_API_KEY, STR_AUTH_XTOKEN, STR_CACHE_CONTROL, STR_CLIENT_ID, STR_CLIENT_VERSION, STR_CONTENT_TYPE_HEADER, STR_DISABLED_PROPERTY_NAME, STR_DROPPED, STR_EMPTY, STR_KILL_DURATION_HEADER, STR_KILL_DURATION_SECONDS_HEADER, STR_KILL_TOKENS_HEADER, STR_MSA_DEVICE_TICKET, STR_MSFPC, STR_NO_RESPONSE_BODY, STR_OTHER, STR_POST_METHOD, STR_REQUEUE, STR_RESPONSE_FAIL, STR_SENDING, STR_TIME_DELTA_HEADER, STR_TIME_DELTA_TO_APPLY, STR_UPLOAD_TIME } from "./InternalConstants";
|
|
17
17
|
import { retryPolicyGetMillisToBackoffForRetry, retryPolicyShouldRetryForStatus } from "./RetryPolicy";
|
|
18
18
|
import { Serializer } from "./Serializer";
|
|
19
19
|
var strSendAttempt = "sendAttempt";
|
|
@@ -50,7 +50,7 @@ function _getResponseText(xhr) {
|
|
|
50
50
|
catch (e) {
|
|
51
51
|
// Best effort, as XHR may throw while XDR wont so just ignore
|
|
52
52
|
}
|
|
53
|
-
return
|
|
53
|
+
return STR_EMPTY;
|
|
54
54
|
}
|
|
55
55
|
function _hasHeader(headers, header) {
|
|
56
56
|
var hasHeader = false;
|
|
@@ -81,6 +81,17 @@ function _addRequestDetails(details, name, value, useHeaders) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
function _prependTransports(theTransports, newTransports) {
|
|
85
|
+
if (newTransports) {
|
|
86
|
+
if (isNumber(newTransports)) {
|
|
87
|
+
theTransports = [newTransports].concat(theTransports);
|
|
88
|
+
}
|
|
89
|
+
else if (isArray(newTransports)) {
|
|
90
|
+
theTransports = newTransports.concat(theTransports);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return theTransports;
|
|
94
|
+
}
|
|
84
95
|
/**
|
|
85
96
|
* Class managing the sending of requests.
|
|
86
97
|
*/
|
|
@@ -112,6 +123,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
112
123
|
var _useHeaders = false;
|
|
113
124
|
var _xhrTimeout;
|
|
114
125
|
var _disableXhrSync;
|
|
126
|
+
var _disableFetchKeepAlive;
|
|
127
|
+
var _canHaveReducedPayload;
|
|
128
|
+
var _addNoResponse;
|
|
115
129
|
dynamicProto(HttpManager, this, function (_self) {
|
|
116
130
|
var _sendCredentials = true;
|
|
117
131
|
_self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
|
|
@@ -133,12 +147,18 @@ var HttpManager = /** @class */ (function () {
|
|
|
133
147
|
enableCompoundKey = !!channelConfig.enableCompoundKey;
|
|
134
148
|
}
|
|
135
149
|
_xhrTimeout = channelConfig.xhrTimeout;
|
|
136
|
-
_disableXhrSync = channelConfig.disableXhrSync;
|
|
150
|
+
_disableXhrSync = !!channelConfig.disableXhrSync;
|
|
151
|
+
_disableFetchKeepAlive = !!channelConfig.disableFetchKeepAlive;
|
|
152
|
+
_addNoResponse = channelConfig.addNoResponse !== false;
|
|
137
153
|
_useBeacons = !isReactNative(); // Only use beacons if not running in React Native
|
|
138
154
|
_serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
|
|
155
|
+
if (!isNullOrUndefined(channelConfig.useSendBeacon)) {
|
|
156
|
+
_useBeacons = !!channelConfig.useSendBeacon;
|
|
157
|
+
}
|
|
139
158
|
var syncHttpInterface = httpInterface;
|
|
140
159
|
var beaconHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
|
|
141
160
|
var fetchSyncHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
|
|
161
|
+
var beaconUnloadTransports = [3 /* TransportType.Beacon */, 2 /* TransportType.Fetch */];
|
|
142
162
|
if (!httpInterface) {
|
|
143
163
|
_customHttpInterface = false;
|
|
144
164
|
var location_1 = getLocation();
|
|
@@ -150,31 +170,30 @@ var HttpManager = /** @class */ (function () {
|
|
|
150
170
|
if (isReactNative()) {
|
|
151
171
|
// Use Fetch or XDR/XHR
|
|
152
172
|
theTransports = [2 /* TransportType.Fetch */, 1 /* TransportType.Xhr */];
|
|
173
|
+
beaconUnloadTransports = [2 /* TransportType.Fetch */, 1 /* TransportType.Xhr */, 3 /* TransportType.Beacon */];
|
|
153
174
|
}
|
|
154
175
|
else {
|
|
155
176
|
// Use XDR/XHR, Fetch or beacons
|
|
156
177
|
theTransports = [1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */];
|
|
157
178
|
}
|
|
158
179
|
// Prefix any user requested transport(s) values
|
|
159
|
-
|
|
160
|
-
if (configTransports) {
|
|
161
|
-
if (isNumber(configTransports)) {
|
|
162
|
-
theTransports = [configTransports].concat(theTransports);
|
|
163
|
-
}
|
|
164
|
-
else if (isArray(configTransports)) {
|
|
165
|
-
theTransports = configTransports.concat(theTransports);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
180
|
+
theTransports = _prependTransports(theTransports, channelConfig.transports);
|
|
168
181
|
httpInterface = _getSenderInterface(theTransports, false);
|
|
169
|
-
syncHttpInterface = _getSenderInterface(theTransports, true);
|
|
170
182
|
if (!httpInterface) {
|
|
171
183
|
_warnToConsole(_logger, "No available transport to send events");
|
|
172
184
|
}
|
|
185
|
+
syncHttpInterface = _getSenderInterface(theTransports, true);
|
|
186
|
+
}
|
|
187
|
+
if (!beaconHttpInterface) {
|
|
188
|
+
// Allow overriding the usage of sendBeacon
|
|
189
|
+
beaconUnloadTransports = _prependTransports(beaconUnloadTransports, channelConfig.unloadTransports);
|
|
190
|
+
beaconHttpInterface = _getSenderInterface(beaconUnloadTransports, true);
|
|
173
191
|
}
|
|
192
|
+
_canHaveReducedPayload = !_customHttpInterface && ((_useBeacons && isBeaconsSupported()) || (!_disableFetchKeepAlive && isFetchSupported(true)));
|
|
174
193
|
_sendInterfaces = (_a = {},
|
|
175
194
|
_a[0 /* EventSendType.Batched */] = httpInterface,
|
|
176
195
|
_a[1 /* EventSendType.Synchronous */] = syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], true),
|
|
177
|
-
_a[2 /* EventSendType.SendBeacon */] = beaconHttpInterface ||
|
|
196
|
+
_a[2 /* EventSendType.SendBeacon */] = beaconHttpInterface || syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */], true),
|
|
178
197
|
_a[3 /* EventSendType.SyncFetch */] = fetchSyncHttpInterface || _getSenderInterface([2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], true) || syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */], true),
|
|
179
198
|
_a);
|
|
180
199
|
};
|
|
@@ -193,7 +212,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
193
212
|
sendPostFunc = _xhrSendPost;
|
|
194
213
|
}
|
|
195
214
|
}
|
|
196
|
-
else if (transportType === 2 /* TransportType.Fetch */ && isFetchSupported(syncSupport)) {
|
|
215
|
+
else if (transportType === 2 /* TransportType.Fetch */ && isFetchSupported(syncSupport) && (!syncSupport || (syncSupport && !_disableFetchKeepAlive))) {
|
|
197
216
|
sendPostFunc = _fetchSendPost;
|
|
198
217
|
}
|
|
199
218
|
else if (_useBeacons && transportType === 3 /* TransportType.Beacon */ && isBeaconsSupported()) {
|
|
@@ -264,7 +283,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
264
283
|
// As a sync request (during unload), it is unlikely that we will get a chance to process the response so
|
|
265
284
|
// just like beacon send assume that the events have been accepted and processed
|
|
266
285
|
ignoreResponse = true;
|
|
267
|
-
|
|
286
|
+
if (_addNoResponse) {
|
|
287
|
+
theUrl += _noResponseQs;
|
|
288
|
+
}
|
|
268
289
|
}
|
|
269
290
|
}
|
|
270
291
|
if (_sendCredentials) {
|
|
@@ -277,7 +298,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
277
298
|
}
|
|
278
299
|
fetch(theUrl, requestInit).then(function (response) {
|
|
279
300
|
var headerMap = {};
|
|
280
|
-
var responseText =
|
|
301
|
+
var responseText = STR_EMPTY;
|
|
281
302
|
var headers = response.headers;
|
|
282
303
|
if (headers) {
|
|
283
304
|
headers["forEach"](function (value, name) {
|
|
@@ -381,7 +402,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
381
402
|
var internalPayloadData = payload;
|
|
382
403
|
var status = 200;
|
|
383
404
|
var thePayload = internalPayloadData._thePayload;
|
|
384
|
-
var theUrl = payload.urlString + _noResponseQs;
|
|
405
|
+
var theUrl = payload.urlString + (_addNoResponse ? _noResponseQs : STR_EMPTY);
|
|
385
406
|
try {
|
|
386
407
|
var nav_1 = getNavigator();
|
|
387
408
|
if (!nav_1.sendBeacon(theUrl, payload.data)) {
|
|
@@ -416,7 +437,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
416
437
|
status = 0;
|
|
417
438
|
}
|
|
418
439
|
finally {
|
|
419
|
-
_doOnComplete(oncomplete, status, {},
|
|
440
|
+
_doOnComplete(oncomplete, status, {}, STR_EMPTY);
|
|
420
441
|
}
|
|
421
442
|
}
|
|
422
443
|
function _isBeaconPayload(sendType) {
|
|
@@ -573,14 +594,15 @@ var HttpManager = /** @class */ (function () {
|
|
|
573
594
|
var thePayload = null;
|
|
574
595
|
var serializationStart = getTime();
|
|
575
596
|
var sendInterface = _sendInterfaces[sendType] || (isSynchronous_1 ? _sendInterfaces[1 /* EventSendType.Synchronous */] : _sendInterfaces[0 /* EventSendType.Batched */]);
|
|
597
|
+
var sendTransport = sendInterface && sendInterface._transport;
|
|
576
598
|
// Sync Fetch has the same payload limitation as sendBeacon -- 64kb limit
|
|
577
|
-
var
|
|
599
|
+
var isReducedPayload = _canHaveReducedPayload && (_isUnloading || _isBeaconPayload(sendType) || (sendTransport === 3 /* TransportType.Beacon */ || (sendInterface._isSync && sendTransport === 2 /* TransportType.Fetch */)));
|
|
578
600
|
while (_canSendPayload(theBatches, sendType, retryCount)) {
|
|
579
601
|
var theBatch = theBatches.shift();
|
|
580
602
|
if (theBatch && theBatch.count() > 0) {
|
|
581
603
|
if (!_killSwitch.isTenantKilled(theBatch.iKey())) {
|
|
582
604
|
// Make sure we have a payload object
|
|
583
|
-
thePayload = thePayload || _serializer.createPayload(retryCount, isTeardown, isSynchronous_1,
|
|
605
|
+
thePayload = thePayload || _serializer.createPayload(retryCount, isTeardown, isSynchronous_1, isReducedPayload, sendReason, sendType);
|
|
584
606
|
// Add the batch to the current payload
|
|
585
607
|
if (!_serializer.appendPayload(thePayload, theBatch, maxEventsPerBatch)) {
|
|
586
608
|
// Entire batch was not added so send the payload and retry adding this batch
|
|
@@ -645,7 +667,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
645
667
|
}
|
|
646
668
|
_addRequestDetails(requestDetails, STR_CLIENT_ID, "NO_AUTH", useHeaders);
|
|
647
669
|
_addRequestDetails(requestDetails, STR_CLIENT_VERSION, FullVersionString, useHeaders);
|
|
648
|
-
var apiQsKeys =
|
|
670
|
+
var apiQsKeys = STR_EMPTY;
|
|
649
671
|
arrForEach(thePayload.apiKeys, function (apiKey) {
|
|
650
672
|
if (apiQsKeys.length > 0) {
|
|
651
673
|
apiQsKeys += ",";
|
|
@@ -672,9 +694,6 @@ var HttpManager = /** @class */ (function () {
|
|
|
672
694
|
}
|
|
673
695
|
return requestDetails;
|
|
674
696
|
}
|
|
675
|
-
function _canUseSendBeaconApi() {
|
|
676
|
-
return !_customHttpInterface && _useBeacons && isBeaconsSupported();
|
|
677
|
-
}
|
|
678
697
|
function _setTimingValue(timings, name, value) {
|
|
679
698
|
timings[name] = timings[name] || {};
|
|
680
699
|
timings[name][_postManager.identifier] = value;
|
|
@@ -722,11 +741,10 @@ var HttpManager = /** @class */ (function () {
|
|
|
722
741
|
headers: requestDetails_1.hdrs,
|
|
723
742
|
_thePayload: thePayload,
|
|
724
743
|
_sendReason: sendReason,
|
|
725
|
-
timeout: _xhrTimeout
|
|
744
|
+
timeout: _xhrTimeout,
|
|
745
|
+
disableXhrSync: _disableXhrSync,
|
|
746
|
+
disableFetchKeepAlive: _disableFetchKeepAlive
|
|
726
747
|
};
|
|
727
|
-
if (!isUndefined(_disableXhrSync)) {
|
|
728
|
-
orgPayloadData.disableXhrSync = !!_disableXhrSync;
|
|
729
|
-
}
|
|
730
748
|
// Only automatically add the following headers if already sending headers and we are not attempting to avoid an options call
|
|
731
749
|
if (useHeaders_1) {
|
|
732
750
|
if (!_hasHeader(orgPayloadData.headers, STR_CACHE_CONTROL)) {
|
|
@@ -776,7 +794,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
776
794
|
urlString: orgPayloadData.urlString,
|
|
777
795
|
headers: extend({}, orgPayloadData.headers),
|
|
778
796
|
timeout: orgPayloadData.timeout,
|
|
779
|
-
disableXhrSync: orgPayloadData.disableXhrSync
|
|
797
|
+
disableXhrSync: orgPayloadData.disableXhrSync,
|
|
798
|
+
disableFetchKeepAlive: orgPayloadData.disableFetchKeepAlive
|
|
780
799
|
};
|
|
781
800
|
var senderCalled_1 = false;
|
|
782
801
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend.sendHook"; }, function () {
|
|
@@ -983,7 +1002,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
983
1002
|
return encodeURIComponent(msfpc);
|
|
984
1003
|
}
|
|
985
1004
|
}
|
|
986
|
-
return
|
|
1005
|
+
return STR_EMPTY;
|
|
987
1006
|
}
|
|
988
1007
|
function _handleCollectorResponse(responseText) {
|
|
989
1008
|
var responseHandlers = _self._responseHandlers;
|