@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.
- package/README.md +123 -5
- package/bundle/{ms.post-3.1.10.gbl.js → ms.post-3.1.11.gbl.js} +163 -86
- package/bundle/ms.post-3.1.11.gbl.js.map +1 -0
- package/bundle/ms.post-3.1.11.gbl.min.js +7 -0
- package/bundle/ms.post-3.1.11.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.1.11.integrity.json +46 -0
- package/bundle/{ms.post-3.1.10.js → ms.post-3.1.11.js} +163 -86
- package/bundle/ms.post-3.1.11.js.map +1 -0
- package/bundle/ms.post-3.1.11.min.js +7 -0
- package/bundle/ms.post-3.1.11.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +162 -85
- 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 +162 -85
- 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 +101 -47
- 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/Constants.d.ts +1 -0
- package/dist-esm/src/Constants.js +2 -1
- package/dist-esm/src/Constants.js.map +1 -1
- package/dist-esm/src/DataModels.d.ts +49 -0
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.js +1 -1
- package/dist-esm/src/HttpManager.d.ts +1 -1
- package/dist-esm/src/HttpManager.js +63 -24
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/KillSwitch.js +1 -1
- package/dist-esm/src/PostChannel.js +51 -28
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.js +1 -1
- package/dist-esm/src/Serializer.js +1 -1
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +2 -2
- package/src/Constants.ts +1 -0
- package/src/DataModels.ts +62 -1
- package/src/HttpManager.ts +67 -22
- package/src/PostChannel.ts +56 -28
- package/bundle/ms.post-3.1.10.gbl.js.map +0 -1
- package/bundle/ms.post-3.1.10.gbl.min.js +0 -7
- package/bundle/ms.post-3.1.10.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.1.10.integrity.json +0 -46
- package/bundle/ms.post-3.1.10.js.map +0 -1
- package/bundle/ms.post-3.1.10.min.js +0 -7
- package/bundle/ms.post-3.1.10.min.js.map +0 -1
|
@@ -21,4 +21,5 @@ export declare const strApiKey = "apikey";
|
|
|
21
21
|
export declare const strMsaDeviceTicket = "AuthMsaDeviceTicket";
|
|
22
22
|
export declare const strAuthXToken = "AuthXToken";
|
|
23
23
|
export declare const strSdkVersion = "sdk-version";
|
|
24
|
+
export declare const strNoResponseBody = "NoResponseBody";
|
|
24
25
|
export declare const strMsfpc = "msfpc";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.1.
|
|
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
|
*/
|
|
@@ -26,5 +26,6 @@ export var strApiKey = "apikey";
|
|
|
26
26
|
export var strMsaDeviceTicket = "AuthMsaDeviceTicket";
|
|
27
27
|
export var strAuthXToken = "AuthXToken";
|
|
28
28
|
export var strSdkVersion = "sdk-version";
|
|
29
|
+
export var strNoResponseBody = "NoResponseBody";
|
|
29
30
|
export var strMsfpc = "msfpc";
|
|
30
31
|
//# sourceMappingURL=Constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js.map","sources":["Constants.js"],"sourcesContent":["export var Method = \"POST\";\r\nexport var DisabledPropertyName = \"Microsoft_ApplicationInsights_BypassAjaxInstrumentation\";\r\nexport var strDropped = \"drop\";\r\nexport var strSending = \"send\";\r\nexport var strRequeue = \"requeue\";\r\nexport var strResponseFail = \"rspFail\";\r\nexport var strOther = \"oth\";\r\nexport var defaultCacheControl = \"no-cache, no-store\";\r\nexport var defaultContentType = \"application/x-json-stream\";\r\nexport var strCacheControl = \"cache-control\";\r\nexport var strContentTypeHeader = \"content-type\";\r\nexport var strKillTokensHeader = \"kill-tokens\";\r\nexport var strKillDurationHeader = \"kill-duration\";\r\nexport var strKillDurationSecondsHeader = \"kill-duration-seconds\";\r\nexport var strTimeDeltaHeader = \"time-delta-millis\";\r\nexport var strClientVersion = \"client-version\";\r\nexport var strClientId = \"client-id\";\r\nexport var strTimeDeltaToApply = \"time-delta-to-apply-millis\";\r\nexport var strUploadTime = \"upload-time\";\r\nexport var strApiKey = \"apikey\";\r\nexport var strMsaDeviceTicket = \"AuthMsaDeviceTicket\";\r\nexport var strAuthXToken = \"AuthXToken\";\r\nexport var strSdkVersion = \"sdk-version\";\r\nexport var strMsfpc = \"msfpc\";\r\n//# sourceMappingURL=Constants.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"}
|
|
1
|
+
{"version":3,"file":"Constants.js.map","sources":["Constants.js"],"sourcesContent":["export var Method = \"POST\";\r\nexport var DisabledPropertyName = \"Microsoft_ApplicationInsights_BypassAjaxInstrumentation\";\r\nexport var strDropped = \"drop\";\r\nexport var strSending = \"send\";\r\nexport var strRequeue = \"requeue\";\r\nexport var strResponseFail = \"rspFail\";\r\nexport var strOther = \"oth\";\r\nexport var defaultCacheControl = \"no-cache, no-store\";\r\nexport var defaultContentType = \"application/x-json-stream\";\r\nexport var strCacheControl = \"cache-control\";\r\nexport var strContentTypeHeader = \"content-type\";\r\nexport var strKillTokensHeader = \"kill-tokens\";\r\nexport var strKillDurationHeader = \"kill-duration\";\r\nexport var strKillDurationSecondsHeader = \"kill-duration-seconds\";\r\nexport var strTimeDeltaHeader = \"time-delta-millis\";\r\nexport var strClientVersion = \"client-version\";\r\nexport var strClientId = \"client-id\";\r\nexport var strTimeDeltaToApply = \"time-delta-to-apply-millis\";\r\nexport var strUploadTime = \"upload-time\";\r\nexport var strApiKey = \"apikey\";\r\nexport var strMsaDeviceTicket = \"AuthMsaDeviceTicket\";\r\nexport var strAuthXToken = \"AuthXToken\";\r\nexport var strSdkVersion = \"sdk-version\";\r\nexport var strNoResponseBody = \"NoResponseBody\";\r\nexport var strMsfpc = \"msfpc\";\r\n//# sourceMappingURL=Constants.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"}
|
|
@@ -12,6 +12,8 @@ export interface IPayloadData {
|
|
|
12
12
|
headers?: {
|
|
13
13
|
[name: string]: string;
|
|
14
14
|
};
|
|
15
|
+
timeout?: number;
|
|
16
|
+
disableXhrSync?: boolean;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Defines the function signature for the Payload Preprocessor.
|
|
@@ -60,6 +62,10 @@ export interface IChannelConfiguration {
|
|
|
60
62
|
disableAutoBatchFlushLimit?: boolean;
|
|
61
63
|
/**
|
|
62
64
|
* [Optional] The HTTP override that should be used to send requests, as an IXHROverride object.
|
|
65
|
+
* By default during the unload of a page or if the event specifies that it wants to use sendBeacon() or sync fetch (with keep-alive),
|
|
66
|
+
* this override will NOT be called. You can now change this behavior by enabling the 'alwaysUseXhrOverride' configuration value.
|
|
67
|
+
* The payload data (first argument) now also includes any configured 'timeout' (defaults to undefined) and whether you should avoid
|
|
68
|
+
* creating any synchronous XHR requests 'disableXhrSync' (defaults to false/undefined)
|
|
63
69
|
*/
|
|
64
70
|
httpXHROverride?: IXHROverride;
|
|
65
71
|
/**
|
|
@@ -138,6 +144,49 @@ export interface IChannelConfiguration {
|
|
|
138
144
|
* previous OPTIONS response, at which point some of the current dynamic values sent on the query string will be moved to a header.
|
|
139
145
|
*/
|
|
140
146
|
avoidOptions?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* [Optional] Specify a timeout (in ms) to apply to requests when sending requests using XHR, XDR or fetch requests. Defaults to undefined
|
|
149
|
+
* and therefore the runtime defaults (normally zero for browser environments)
|
|
150
|
+
*/
|
|
151
|
+
xhrTimeout?: number;
|
|
152
|
+
/**
|
|
153
|
+
* [Optional] When using Xhr for sending requests disable sending as synchronous during unload or synchronous flush.
|
|
154
|
+
* You should enable this feature for IE (when there is no sendBeacon() or fetch (with keep-alive)) and you have clients
|
|
155
|
+
* that end up blocking the UI during page unloading. This will cause ALL XHR requests to be sent asynchronously which
|
|
156
|
+
* during page unload may result in the lose of telemetry.
|
|
157
|
+
*/
|
|
158
|
+
disableXhrSync?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* [Optional] By default during unload (or when you specify to use sendBeacon() or sync fetch (with keep-alive) for an event) the SDK
|
|
161
|
+
* ignores any provided httpXhrOverride and attempts to use sendBeacon() or fetch(with keep-alive) when they are available.
|
|
162
|
+
* When this configuration option is true any provided httpXhrOverride will always be used, so any provided httpXhrOverride will
|
|
163
|
+
* also need to "handle" the synchronous unload scenario.
|
|
164
|
+
*/
|
|
165
|
+
alwaysUseXhrOverride?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* [Optional] Identifies the number of times any single event will be retried if it receives a failed (retirable) response, this
|
|
168
|
+
* causes the event to be internally "requeued" and resent in the next batch. As each normal batched send request is retried at
|
|
169
|
+
* least once before starting to increase the internal backoff send interval, normally batched events will generally be attempted
|
|
170
|
+
* the next nearest even number of times. This means that the total number of actual send attempts will almost always be even
|
|
171
|
+
* (setting to 5 will cause 6 requests), unless using manual synchronous flushing (calling flush(false)) which is not subject to
|
|
172
|
+
* request level retry attempts.
|
|
173
|
+
* Defaults to 6 times.
|
|
174
|
+
*/
|
|
175
|
+
maxEventRetryAttempts?: number;
|
|
176
|
+
/**
|
|
177
|
+
* [Optional] Identifies the number of times any single event will be retried if it receives a failed (retriable) response as part
|
|
178
|
+
* of processing / flushing events once a page unload state has been detected, this causes the event to be internally "requeued"
|
|
179
|
+
* and resent in the next batch, which during page unload. Unlike the normal batching process, send requests are never retried,
|
|
180
|
+
* so the value listed here is always the maximum number of attempts for any single event.
|
|
181
|
+
* Defaults to 2 times.
|
|
182
|
+
* Notes:
|
|
183
|
+
* The SDK by default will use the sendBeacon() API if it exists which is treated as a fire and forget successful response, so for
|
|
184
|
+
* environments that support or supply this API the events won't be retried (because they will be deeded to be successfully sent).
|
|
185
|
+
* When an environment (IE) doesn't support sendBeacon(), this will cause multiple synchronous (by default) XMLHttpRequests to be sent,
|
|
186
|
+
* which will block the UI until a response is received. You can disable ALL synchronous XHR requests by setting the 'disableXhrSync'
|
|
187
|
+
* configuration setting and/or changing this value to 0 or 1.
|
|
188
|
+
*/
|
|
189
|
+
maxUnloadEventRetryAttempts?: number;
|
|
141
190
|
}
|
|
142
191
|
/**
|
|
143
192
|
* SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
|
|
@@ -19,7 +19,7 @@ export declare class HttpManager {
|
|
|
19
19
|
* @constructor
|
|
20
20
|
* @param requestQueue - The queue that contains the requests to be sent.
|
|
21
21
|
*/
|
|
22
|
-
constructor(maxEventsPerBatch: number, maxConnections: number,
|
|
22
|
+
constructor(maxEventsPerBatch: number, maxConnections: number, maxRequestRetriesBeforeBackoff: number, actions: BatchNotificationActions);
|
|
23
23
|
/**
|
|
24
24
|
* @constructor
|
|
25
25
|
* @param requestQueue - The queue that contains the requests to be sent.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.1.
|
|
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
|
*/
|
|
@@ -15,7 +15,9 @@ import RetryPolicy from "./RetryPolicy";
|
|
|
15
15
|
import EVTKillSwitch from "./KillSwitch";
|
|
16
16
|
import EVTClockSkewManager from "./ClockSkewManager";
|
|
17
17
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
18
|
-
import { defaultCacheControl, defaultContentType, DisabledPropertyName, Method, strApiKey, strCacheControl, strClientId, strClientVersion, strContentTypeHeader, strDropped, strKillDurationHeader, strKillDurationSecondsHeader, strKillTokensHeader, strMsaDeviceTicket, strMsfpc, strOther, strRequeue, strResponseFail, strSending, strTimeDeltaHeader, strTimeDeltaToApply, strUploadTime } from "./Constants";
|
|
18
|
+
import { defaultCacheControl, defaultContentType, DisabledPropertyName, Method, strApiKey, strCacheControl, strClientId, strClientVersion, strContentTypeHeader, strDropped, strKillDurationHeader, strKillDurationSecondsHeader, strKillTokensHeader, strMsaDeviceTicket, strMsfpc, strNoResponseBody, strOther, strRequeue, strResponseFail, strSending, strTimeDeltaHeader, strTimeDeltaToApply, strUploadTime } from "./Constants";
|
|
19
|
+
var strSendAttempt = "sendAttempt";
|
|
20
|
+
var _noResponseQs = "&" + strNoResponseBody + "=true";
|
|
19
21
|
/**
|
|
20
22
|
* Identifies the default notification reason to the action names
|
|
21
23
|
*/
|
|
@@ -79,7 +81,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
79
81
|
* @constructor
|
|
80
82
|
* @param requestQueue - The queue that contains the requests to be sent.
|
|
81
83
|
*/
|
|
82
|
-
function HttpManager(maxEventsPerBatch, maxConnections,
|
|
84
|
+
function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions) {
|
|
83
85
|
this._responseHandlers = [];
|
|
84
86
|
var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
|
|
85
87
|
var _killSwitch = new EVTKillSwitch();
|
|
@@ -99,6 +101,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
99
101
|
var _cookieMgr;
|
|
100
102
|
var _isUnloading = false;
|
|
101
103
|
var _useHeaders = false;
|
|
104
|
+
var _xhrTimeout;
|
|
105
|
+
var _disableXhrSync;
|
|
102
106
|
dynamicProto(HttpManager, this, function (_self) {
|
|
103
107
|
var _sendCredentials = true;
|
|
104
108
|
_self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
|
|
@@ -119,9 +123,13 @@ var HttpManager = /** @class */ (function () {
|
|
|
119
123
|
if (!isUndefined(channelConfig.enableCompoundKey)) {
|
|
120
124
|
enableCompoundKey = !!channelConfig.enableCompoundKey;
|
|
121
125
|
}
|
|
126
|
+
_xhrTimeout = channelConfig.xhrTimeout;
|
|
127
|
+
_disableXhrSync = channelConfig.disableXhrSync;
|
|
122
128
|
_useBeacons = !isReactNative(); // Only use beacons if not running in React Native
|
|
123
129
|
_serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
|
|
124
130
|
var syncHttpInterface = httpInterface;
|
|
131
|
+
var beaconHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
|
|
132
|
+
var fetchSyncHttpInterface = channelConfig.alwaysUseXhrOverride ? httpInterface : null;
|
|
125
133
|
if (!httpInterface) {
|
|
126
134
|
_customHttpInterface = false;
|
|
127
135
|
var location_1 = getLocation();
|
|
@@ -157,8 +165,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
157
165
|
_sendInterfaces = (_a = {},
|
|
158
166
|
_a[0 /* Batched */] = httpInterface,
|
|
159
167
|
_a[1 /* Synchronous */] = syncHttpInterface || _getSenderInterface([1 /* Xhr */, 2 /* Fetch */, 3 /* Beacon */], true),
|
|
160
|
-
_a[2 /* SendBeacon */] = _getSenderInterface([3 /* Beacon */, 2 /* Fetch
|
|
161
|
-
_a[3 /* SyncFetch */] = _getSenderInterface([2 /* Fetch */, 3 /* Beacon
|
|
168
|
+
_a[2 /* SendBeacon */] = beaconHttpInterface || _getSenderInterface([3 /* Beacon */, 2 /* Fetch */], true) || syncHttpInterface || _getSenderInterface([1 /* Xhr */], true),
|
|
169
|
+
_a[3 /* SyncFetch */] = fetchSyncHttpInterface || _getSenderInterface([2 /* Fetch */, 3 /* Beacon */], true) || syncHttpInterface || _getSenderInterface([1 /* Xhr */], true),
|
|
162
170
|
_a);
|
|
163
171
|
};
|
|
164
172
|
// Special internal method to allow the DebugPlugin to hook embedded objects
|
|
@@ -200,6 +208,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
200
208
|
// It doesn't support custom headers, so no action is taken with current requestHeaders
|
|
201
209
|
var xdr = new XDomainRequest();
|
|
202
210
|
xdr.open(Method, payload.urlString);
|
|
211
|
+
if (payload.timeout) {
|
|
212
|
+
xdr.timeout = payload.timeout;
|
|
213
|
+
}
|
|
203
214
|
// can't get the status code in xdr.
|
|
204
215
|
xdr.onload = function () {
|
|
205
216
|
// we will assume onload means the request succeeded.
|
|
@@ -229,6 +240,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
229
240
|
}
|
|
230
241
|
function _fetchSendPost(payload, oncomplete, sync) {
|
|
231
242
|
var _a;
|
|
243
|
+
var theUrl = payload.urlString;
|
|
232
244
|
var ignoreResponse = false;
|
|
233
245
|
var responseHandled = false;
|
|
234
246
|
var requestInit = (_a = {
|
|
@@ -243,6 +255,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
243
255
|
// As a sync request (during unload), it is unlikely that we will get a chance to process the response so
|
|
244
256
|
// just like beacon send assume that the events have been accepted and processed
|
|
245
257
|
ignoreResponse = true;
|
|
258
|
+
theUrl += _noResponseQs;
|
|
246
259
|
}
|
|
247
260
|
}
|
|
248
261
|
if (_sendCredentials) {
|
|
@@ -253,7 +266,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
253
266
|
if (payload.headers && objKeys(payload.headers).length > 0) {
|
|
254
267
|
requestInit.headers = payload.headers;
|
|
255
268
|
}
|
|
256
|
-
fetch(
|
|
269
|
+
fetch(theUrl, requestInit).then(function (response) {
|
|
257
270
|
var headerMap = {};
|
|
258
271
|
var responseText = "";
|
|
259
272
|
if (response.headers) {
|
|
@@ -284,8 +297,19 @@ var HttpManager = /** @class */ (function () {
|
|
|
284
297
|
responseHandled = true;
|
|
285
298
|
_doOnComplete(oncomplete, 200, {});
|
|
286
299
|
}
|
|
300
|
+
if (!responseHandled && payload.timeout > 0) {
|
|
301
|
+
// Simulate timeout
|
|
302
|
+
_postManager._setTimeoutOverride(function () {
|
|
303
|
+
if (!responseHandled) {
|
|
304
|
+
// Assume a 500 response (which will cause a retry)
|
|
305
|
+
responseHandled = true;
|
|
306
|
+
_doOnComplete(oncomplete, 500, {});
|
|
307
|
+
}
|
|
308
|
+
}, payload.timeout);
|
|
309
|
+
}
|
|
287
310
|
}
|
|
288
311
|
function _xhrSendPost(payload, oncomplete, sync) {
|
|
312
|
+
var theUrl = payload.urlString;
|
|
289
313
|
function _appendHeader(theHeaders, xhr, name) {
|
|
290
314
|
if (!theHeaders[name] && xhr && xhr.getResponseHeader) {
|
|
291
315
|
var value = xhr.getResponseHeader(name);
|
|
@@ -313,23 +337,26 @@ var HttpManager = /** @class */ (function () {
|
|
|
313
337
|
function xhrComplete(xhr, responseTxt) {
|
|
314
338
|
_doOnComplete(oncomplete, xhr.status, _getAllResponseHeaders(xhr), responseTxt);
|
|
315
339
|
}
|
|
316
|
-
|
|
340
|
+
if (sync && payload.disableXhrSync) {
|
|
341
|
+
sync = false;
|
|
342
|
+
}
|
|
343
|
+
var xhrRequest = openXhr(Method, theUrl, _sendCredentials, true, sync, payload.timeout);
|
|
317
344
|
// Set custom headers (e.g. gzip) here (after open())
|
|
318
345
|
objForEachKey(payload.headers, function (name, value) {
|
|
319
|
-
|
|
346
|
+
xhrRequest.setRequestHeader(name, value);
|
|
320
347
|
});
|
|
321
|
-
|
|
322
|
-
var response = _getResponseText(
|
|
323
|
-
xhrComplete(
|
|
348
|
+
xhrRequest.onload = function () {
|
|
349
|
+
var response = _getResponseText(xhrRequest);
|
|
350
|
+
xhrComplete(xhrRequest, response);
|
|
324
351
|
_handleCollectorResponse(response);
|
|
325
352
|
};
|
|
326
|
-
|
|
327
|
-
xhrComplete(
|
|
353
|
+
xhrRequest.onerror = function () {
|
|
354
|
+
xhrComplete(xhrRequest);
|
|
328
355
|
};
|
|
329
|
-
|
|
330
|
-
xhrComplete(
|
|
356
|
+
xhrRequest.ontimeout = function () {
|
|
357
|
+
xhrComplete(xhrRequest);
|
|
331
358
|
};
|
|
332
|
-
|
|
359
|
+
xhrRequest.send(payload.data);
|
|
333
360
|
}
|
|
334
361
|
function _doOnComplete(oncomplete, status, headers, response) {
|
|
335
362
|
try {
|
|
@@ -344,9 +371,10 @@ var HttpManager = /** @class */ (function () {
|
|
|
344
371
|
var internalPayloadData = payload;
|
|
345
372
|
var status = 200;
|
|
346
373
|
var thePayload = internalPayloadData._thePayload;
|
|
374
|
+
var theUrl = payload.urlString + _noResponseQs;
|
|
347
375
|
try {
|
|
348
376
|
var nav_1 = getNavigator();
|
|
349
|
-
if (!nav_1.sendBeacon(
|
|
377
|
+
if (!nav_1.sendBeacon(theUrl, payload.data)) {
|
|
350
378
|
if (thePayload) {
|
|
351
379
|
// Failed to send entire payload so try and split data and try to send as much events as possible
|
|
352
380
|
var droppedBatches_1 = [];
|
|
@@ -354,7 +382,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
354
382
|
if (droppedBatches_1 && theBatch && theBatch.count() > 0) {
|
|
355
383
|
var theEvents = theBatch.events();
|
|
356
384
|
for (var lp = 0; lp < theEvents.length; lp++) {
|
|
357
|
-
if (!nav_1.sendBeacon(
|
|
385
|
+
if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
|
|
358
386
|
// Can't send anymore, so split the batch and drop the rest
|
|
359
387
|
droppedBatches_1.push(theBatch.split(lp));
|
|
360
388
|
break;
|
|
@@ -659,7 +687,6 @@ var HttpManager = /** @class */ (function () {
|
|
|
659
687
|
var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
|
|
660
688
|
useHeaders_1 = useHeaders_1 || requestDetails_1.useHdrs;
|
|
661
689
|
var sendEventStart_1 = getTime();
|
|
662
|
-
var strSendAttempt_1 = "sendAttempt";
|
|
663
690
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend"; }, function () {
|
|
664
691
|
// Increment the send attempt count and add timings after packaging (So it's not serialized in the 1st attempt)
|
|
665
692
|
for (var batchLp = 0; batchLp < thePayload.batches.length; batchLp++) {
|
|
@@ -673,7 +700,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
673
700
|
_setTimingValue(timings, "serializationStart", serializationStart);
|
|
674
701
|
_setTimingValue(timings, "serializationCompleted", serializationCompleted);
|
|
675
702
|
}
|
|
676
|
-
telemetryItem[
|
|
703
|
+
telemetryItem[strSendAttempt] > 0 ? telemetryItem[strSendAttempt]++ : telemetryItem[strSendAttempt] = 1;
|
|
677
704
|
}
|
|
678
705
|
}
|
|
679
706
|
// Note: always sending this notification in a synchronous manner.
|
|
@@ -686,8 +713,12 @@ var HttpManager = /** @class */ (function () {
|
|
|
686
713
|
urlString: requestDetails_1.url,
|
|
687
714
|
headers: requestDetails_1.hdrs,
|
|
688
715
|
_thePayload: thePayload,
|
|
689
|
-
_sendReason: sendReason
|
|
716
|
+
_sendReason: sendReason,
|
|
717
|
+
timeout: _xhrTimeout
|
|
690
718
|
};
|
|
719
|
+
if (!isUndefined(_disableXhrSync)) {
|
|
720
|
+
orgPayloadData.disableXhrSync = !!_disableXhrSync;
|
|
721
|
+
}
|
|
691
722
|
// Only automatically add the following headers if already sending headers and we are not attempting to avoid an options call
|
|
692
723
|
if (useHeaders_1) {
|
|
693
724
|
if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
|
|
@@ -735,7 +766,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
735
766
|
var hookData_1 = {
|
|
736
767
|
data: orgPayloadData.data,
|
|
737
768
|
urlString: orgPayloadData.urlString,
|
|
738
|
-
headers: extend({}, orgPayloadData.headers)
|
|
769
|
+
headers: extend({}, orgPayloadData.headers),
|
|
770
|
+
timeout: orgPayloadData.timeout,
|
|
771
|
+
disableXhrSync: orgPayloadData.disableXhrSync
|
|
739
772
|
};
|
|
740
773
|
var senderCalled_1 = false;
|
|
741
774
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend.sendHook"; }, function () {
|
|
@@ -809,7 +842,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
809
842
|
}
|
|
810
843
|
// Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
|
|
811
844
|
// tslint:disable-next-line:triple-equals
|
|
812
|
-
if (status == 200) {
|
|
845
|
+
if (status == 200 || status == 204) {
|
|
813
846
|
// Response was successfully sent
|
|
814
847
|
reason = 200 /* Complete */;
|
|
815
848
|
return;
|
|
@@ -826,7 +859,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
826
859
|
reason = 100 /* RequeueEvents */;
|
|
827
860
|
var retryCount_1 = thePayload.retryCnt;
|
|
828
861
|
if (thePayload.sendType === 0 /* Batched */) {
|
|
829
|
-
|
|
862
|
+
// attempt to resend the entire batch
|
|
863
|
+
if (retryCount_1 < maxRequestRetriesBeforeBackoff) {
|
|
830
864
|
isRetrying = true;
|
|
831
865
|
_doAction(function () {
|
|
832
866
|
// try to resend the same batches
|
|
@@ -841,6 +875,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
841
875
|
}
|
|
842
876
|
else {
|
|
843
877
|
backOffTrans = true;
|
|
878
|
+
if (_isUnloading) {
|
|
879
|
+
// we are unloading so don't try and requeue the events otherwise let the events get requeued and resent during the backoff sending
|
|
880
|
+
// This will also cause the events to be purged based on the priority (if necessary)
|
|
881
|
+
reason = 8001 /* NonRetryableStatus */;
|
|
882
|
+
}
|
|
844
883
|
}
|
|
845
884
|
}
|
|
846
885
|
}
|