@microsoft/1ds-post-js 3.1.8 → 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 +124 -5
- package/bundle/{ms.post-3.1.8.gbl.js → ms.post-3.1.11.gbl.js} +353 -172
- 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.8.js → ms.post-3.1.11.js} +353 -172
- 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 +352 -171
- 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 +352 -171
- 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 +238 -116
- 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 +25 -0
- package/dist-esm/src/Constants.js +31 -0
- package/dist-esm/src/Constants.js.map +1 -0
- package/dist-esm/src/DataModels.d.ts +55 -0
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.d.ts +5 -2
- package/dist-esm/src/EventBatch.js +35 -15
- package/dist-esm/src/EventBatch.js.map +1 -1
- package/dist-esm/src/HttpManager.d.ts +2 -2
- package/dist-esm/src/HttpManager.js +172 -85
- 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 +55 -31
- 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 +3 -3
- package/src/Constants.ts +28 -0
- package/src/DataModels.ts +68 -0
- package/src/EventBatch.ts +47 -14
- package/src/HttpManager.ts +206 -84
- package/src/PostChannel.ts +60 -31
- package/bundle/ms.post-3.1.8.gbl.js.map +0 -1
- package/bundle/ms.post-3.1.8.gbl.min.js +0 -7
- package/bundle/ms.post-3.1.8.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.1.8.integrity.json +0 -46
- package/bundle/ms.post-3.1.8.js.map +0 -1
- package/bundle/ms.post-3.1.8.min.js +0 -7
- package/bundle/ms.post-3.1.8.min.js.map +0 -1
|
@@ -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,21 +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
|
-
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var strSending = "send";
|
|
22
|
-
var strRequeue = "requeue";
|
|
23
|
-
var strResponseFail = "rspFail";
|
|
24
|
-
var strOther = "oth";
|
|
25
|
-
var defaultCacheControl = "no-cache, no-store";
|
|
26
|
-
var defaultContentType = "application/x-json-stream";
|
|
27
|
-
var strCacheControl = "cache-control";
|
|
28
|
-
var strContentTypeHeader = "content-type";
|
|
29
|
-
var strKillTokensHeader = "kill-tokens";
|
|
30
|
-
var strKillDurationHeader = "kill-duration";
|
|
31
|
-
var strKillDurationSecondsHeader = "kill-duration-seconds";
|
|
32
|
-
var strTimeDeltaHeader = "time-delta-millis";
|
|
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";
|
|
33
21
|
/**
|
|
34
22
|
* Identifies the default notification reason to the action names
|
|
35
23
|
*/
|
|
@@ -40,6 +28,13 @@ var _eventActionMap = (_a = {},
|
|
|
40
28
|
_a[8004 /* KillSwitch */] = strDropped,
|
|
41
29
|
_a[8003 /* SizeLimitExceeded */] = strDropped,
|
|
42
30
|
_a);
|
|
31
|
+
var _collectorQsHeaders = {};
|
|
32
|
+
var _collectorHeaderToQs = {};
|
|
33
|
+
function _addCollectorHeaderQsMapping(qsName, headerName) {
|
|
34
|
+
_collectorQsHeaders[qsName] = headerName;
|
|
35
|
+
_collectorHeaderToQs[headerName] = qsName;
|
|
36
|
+
}
|
|
37
|
+
_addCollectorHeaderQsMapping(strMsaDeviceTicket, strMsaDeviceTicket);
|
|
43
38
|
function _getResponseText(xhr) {
|
|
44
39
|
try {
|
|
45
40
|
return xhr.responseText;
|
|
@@ -67,6 +62,17 @@ function _hasHeader(headers, header) {
|
|
|
67
62
|
}
|
|
68
63
|
return hasHeader;
|
|
69
64
|
}
|
|
65
|
+
function _addRequestDetails(details, name, value, useHeaders) {
|
|
66
|
+
if (name && value && value.length > 0) {
|
|
67
|
+
if (useHeaders && _collectorQsHeaders[name]) {
|
|
68
|
+
details.hdrs[_collectorQsHeaders[name]] = value;
|
|
69
|
+
details.useHdrs = true;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
details.url += "&" + name + "=" + value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
70
76
|
/**
|
|
71
77
|
* Class managing the sending of requests.
|
|
72
78
|
*/
|
|
@@ -75,10 +81,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
75
81
|
* @constructor
|
|
76
82
|
* @param requestQueue - The queue that contains the requests to be sent.
|
|
77
83
|
*/
|
|
78
|
-
function HttpManager(maxEventsPerBatch, maxConnections,
|
|
84
|
+
function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions) {
|
|
79
85
|
this._responseHandlers = [];
|
|
80
|
-
var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType
|
|
81
|
-
+ FullVersionString;
|
|
86
|
+
var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
|
|
82
87
|
var _killSwitch = new EVTKillSwitch();
|
|
83
88
|
var _paused = false;
|
|
84
89
|
var _clockSkewManager = new EVTClockSkewManager();
|
|
@@ -95,6 +100,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
95
100
|
var _enableEventTimings = false;
|
|
96
101
|
var _cookieMgr;
|
|
97
102
|
var _isUnloading = false;
|
|
103
|
+
var _useHeaders = false;
|
|
104
|
+
var _xhrTimeout;
|
|
105
|
+
var _disableXhrSync;
|
|
98
106
|
dynamicProto(HttpManager, this, function (_self) {
|
|
99
107
|
var _sendCredentials = true;
|
|
100
108
|
_self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
|
|
@@ -103,6 +111,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
103
111
|
channelConfig = {};
|
|
104
112
|
}
|
|
105
113
|
_urlString = endpointUrl + _urlString;
|
|
114
|
+
// Task 12886642: Defaulting to 'false' until the Collector handles sending upload-time header in the OPTIONS call
|
|
115
|
+
_useHeaders = !isUndefined(channelConfig.avoidOptions) ? !channelConfig.avoidOptions : false;
|
|
106
116
|
_core = core;
|
|
107
117
|
_cookieMgr = core.getCookieMgr();
|
|
108
118
|
_enableEventTimings = !_core.config.disableEventTimings;
|
|
@@ -113,15 +123,13 @@ var HttpManager = /** @class */ (function () {
|
|
|
113
123
|
if (!isUndefined(channelConfig.enableCompoundKey)) {
|
|
114
124
|
enableCompoundKey = !!channelConfig.enableCompoundKey;
|
|
115
125
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// if (!!channelConfig.disableCacheHeader) {
|
|
119
|
-
// // Stop Chrome from stalling/throttling requests see task #7178858
|
|
120
|
-
// _self.addHeader("Cache-control", "no-cache, no-store");
|
|
121
|
-
// }
|
|
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,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
229
240
|
}
|
|
230
241
|
function _fetchSendPost(payload, oncomplete, sync) {
|
|
231
242
|
var _a;
|
|
243
|
+
var theUrl = payload.urlString;
|
|
244
|
+
var ignoreResponse = false;
|
|
245
|
+
var responseHandled = false;
|
|
232
246
|
var requestInit = (_a = {
|
|
233
247
|
body: payload.data,
|
|
234
248
|
method: Method
|
|
@@ -237,6 +251,12 @@ var HttpManager = /** @class */ (function () {
|
|
|
237
251
|
_a);
|
|
238
252
|
if (sync) {
|
|
239
253
|
requestInit.keepalive = true;
|
|
254
|
+
if (payload._sendReason === 2 /* Unload */) {
|
|
255
|
+
// As a sync request (during unload), it is unlikely that we will get a chance to process the response so
|
|
256
|
+
// just like beacon send assume that the events have been accepted and processed
|
|
257
|
+
ignoreResponse = true;
|
|
258
|
+
theUrl += _noResponseQs;
|
|
259
|
+
}
|
|
240
260
|
}
|
|
241
261
|
if (_sendCredentials) {
|
|
242
262
|
// Don't send credentials when URL is file://
|
|
@@ -246,7 +266,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
246
266
|
if (payload.headers && objKeys(payload.headers).length > 0) {
|
|
247
267
|
requestInit.headers = payload.headers;
|
|
248
268
|
}
|
|
249
|
-
fetch(
|
|
269
|
+
fetch(theUrl, requestInit).then(function (response) {
|
|
250
270
|
var headerMap = {};
|
|
251
271
|
var responseText = "";
|
|
252
272
|
if (response.headers) {
|
|
@@ -259,15 +279,37 @@ var HttpManager = /** @class */ (function () {
|
|
|
259
279
|
responseText = text;
|
|
260
280
|
});
|
|
261
281
|
}
|
|
262
|
-
|
|
263
|
-
|
|
282
|
+
if (!responseHandled) {
|
|
283
|
+
responseHandled = true;
|
|
284
|
+
_doOnComplete(oncomplete, response.status, headerMap, responseText);
|
|
285
|
+
_handleCollectorResponse(responseText);
|
|
286
|
+
}
|
|
264
287
|
})["catch"](function (error) {
|
|
265
288
|
// In case there is an error in the request. Set the status to 0
|
|
266
289
|
// so that the events can be retried later.
|
|
267
|
-
|
|
290
|
+
if (!responseHandled) {
|
|
291
|
+
responseHandled = true;
|
|
292
|
+
_doOnComplete(oncomplete, 0, {});
|
|
293
|
+
}
|
|
268
294
|
});
|
|
295
|
+
if (ignoreResponse && !responseHandled) {
|
|
296
|
+
// Assume success during unload processing
|
|
297
|
+
responseHandled = true;
|
|
298
|
+
_doOnComplete(oncomplete, 200, {});
|
|
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
|
+
}
|
|
269
310
|
}
|
|
270
311
|
function _xhrSendPost(payload, oncomplete, sync) {
|
|
312
|
+
var theUrl = payload.urlString;
|
|
271
313
|
function _appendHeader(theHeaders, xhr, name) {
|
|
272
314
|
if (!theHeaders[name] && xhr && xhr.getResponseHeader) {
|
|
273
315
|
var value = xhr.getResponseHeader(name);
|
|
@@ -295,23 +337,26 @@ var HttpManager = /** @class */ (function () {
|
|
|
295
337
|
function xhrComplete(xhr, responseTxt) {
|
|
296
338
|
_doOnComplete(oncomplete, xhr.status, _getAllResponseHeaders(xhr), responseTxt);
|
|
297
339
|
}
|
|
298
|
-
|
|
340
|
+
if (sync && payload.disableXhrSync) {
|
|
341
|
+
sync = false;
|
|
342
|
+
}
|
|
343
|
+
var xhrRequest = openXhr(Method, theUrl, _sendCredentials, true, sync, payload.timeout);
|
|
299
344
|
// Set custom headers (e.g. gzip) here (after open())
|
|
300
345
|
objForEachKey(payload.headers, function (name, value) {
|
|
301
|
-
|
|
346
|
+
xhrRequest.setRequestHeader(name, value);
|
|
302
347
|
});
|
|
303
|
-
|
|
304
|
-
var response = _getResponseText(
|
|
305
|
-
xhrComplete(
|
|
348
|
+
xhrRequest.onload = function () {
|
|
349
|
+
var response = _getResponseText(xhrRequest);
|
|
350
|
+
xhrComplete(xhrRequest, response);
|
|
306
351
|
_handleCollectorResponse(response);
|
|
307
352
|
};
|
|
308
|
-
|
|
309
|
-
xhrComplete(
|
|
353
|
+
xhrRequest.onerror = function () {
|
|
354
|
+
xhrComplete(xhrRequest);
|
|
310
355
|
};
|
|
311
|
-
|
|
312
|
-
xhrComplete(
|
|
356
|
+
xhrRequest.ontimeout = function () {
|
|
357
|
+
xhrComplete(xhrRequest);
|
|
313
358
|
};
|
|
314
|
-
|
|
359
|
+
xhrRequest.send(payload.data);
|
|
315
360
|
}
|
|
316
361
|
function _doOnComplete(oncomplete, status, headers, response) {
|
|
317
362
|
try {
|
|
@@ -326,9 +371,10 @@ var HttpManager = /** @class */ (function () {
|
|
|
326
371
|
var internalPayloadData = payload;
|
|
327
372
|
var status = 200;
|
|
328
373
|
var thePayload = internalPayloadData._thePayload;
|
|
374
|
+
var theUrl = payload.urlString + _noResponseQs;
|
|
329
375
|
try {
|
|
330
376
|
var nav_1 = getNavigator();
|
|
331
|
-
if (!nav_1.sendBeacon(
|
|
377
|
+
if (!nav_1.sendBeacon(theUrl, payload.data)) {
|
|
332
378
|
if (thePayload) {
|
|
333
379
|
// Failed to send entire payload so try and split data and try to send as much events as possible
|
|
334
380
|
var droppedBatches_1 = [];
|
|
@@ -336,7 +382,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
336
382
|
if (droppedBatches_1 && theBatch && theBatch.count() > 0) {
|
|
337
383
|
var theEvents = theBatch.events();
|
|
338
384
|
for (var lp = 0; lp < theEvents.length; lp++) {
|
|
339
|
-
if (!nav_1.sendBeacon(
|
|
385
|
+
if (!nav_1.sendBeacon(theUrl, _serializer.getEventBlob(theEvents[lp]))) {
|
|
340
386
|
// Can't send anymore, so split the batch and drop the rest
|
|
341
387
|
droppedBatches_1.push(theBatch.split(lp));
|
|
342
388
|
break;
|
|
@@ -563,8 +609,34 @@ var HttpManager = /** @class */ (function () {
|
|
|
563
609
|
_postManager.diagLog().throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.CannotSerializeObject, "Unexpected Exception sending batch: " + dumpObj(ex));
|
|
564
610
|
}
|
|
565
611
|
}
|
|
566
|
-
function
|
|
567
|
-
var
|
|
612
|
+
function _buildRequestDetails(thePayload, useHeaders) {
|
|
613
|
+
var requestDetails = {
|
|
614
|
+
url: _urlString,
|
|
615
|
+
hdrs: {},
|
|
616
|
+
useHdrs: false // Assume no headers
|
|
617
|
+
};
|
|
618
|
+
// ----------------------------------------------------------------------------------------------------------------
|
|
619
|
+
// Task 12886642: Need to wait until an updated version of the collector is released to return these as allowed in the OPTIONS call
|
|
620
|
+
// ----------------------------------------------------------------------------------------------------------------
|
|
621
|
+
// if (!useHeaders) {
|
|
622
|
+
// // Attempt to map headers to a query string if possible
|
|
623
|
+
// objForEachKey(_headers, (name, value) => {
|
|
624
|
+
// if (_collectorHeaderToQs[name]) {
|
|
625
|
+
// _addRequestDetails(requestDetails, _collectorHeaderToQs[name], value, false);
|
|
626
|
+
// } else {
|
|
627
|
+
// // No mapping, so just include in the headers anyway (may not get sent if using sendBeacon())
|
|
628
|
+
// requestDetails.hdrs[name] = value;
|
|
629
|
+
// requestDetails.useHdrs = true;
|
|
630
|
+
// }
|
|
631
|
+
// });
|
|
632
|
+
// } else {
|
|
633
|
+
// Copy the pre-defined headers into the payload headers
|
|
634
|
+
requestDetails.hdrs = extend(requestDetails.hdrs, _headers);
|
|
635
|
+
requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
|
|
636
|
+
// }
|
|
637
|
+
// ----------------------------------------------------------------------------------------------------------------
|
|
638
|
+
_addRequestDetails(requestDetails, strClientId, "NO_AUTH", useHeaders);
|
|
639
|
+
_addRequestDetails(requestDetails, strClientVersion, FullVersionString, useHeaders);
|
|
568
640
|
var apiQsKeys = "";
|
|
569
641
|
arrForEach(thePayload.apiKeys, function (apiKey) {
|
|
570
642
|
if (apiQsKeys.length > 0) {
|
|
@@ -572,27 +644,25 @@ var HttpManager = /** @class */ (function () {
|
|
|
572
644
|
}
|
|
573
645
|
apiQsKeys += apiKey;
|
|
574
646
|
});
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
urlString += "&upload-time=" + dateNow().toString();
|
|
647
|
+
_addRequestDetails(requestDetails, strApiKey, apiQsKeys, useHeaders);
|
|
648
|
+
_addRequestDetails(requestDetails, strUploadTime, dateNow().toString(), useHeaders);
|
|
579
649
|
var msfpc = _getMsfpc(thePayload);
|
|
580
650
|
if (isValueAssigned(msfpc)) {
|
|
581
|
-
|
|
651
|
+
requestDetails.url += "&ext.intweb.msfpc=" + msfpc;
|
|
582
652
|
}
|
|
583
653
|
if (_clockSkewManager.shouldAddClockSkewHeaders()) {
|
|
584
|
-
|
|
654
|
+
_addRequestDetails(requestDetails, strTimeDeltaToApply, _clockSkewManager.getClockSkewHeaderValue(), useHeaders);
|
|
585
655
|
}
|
|
586
656
|
if (_core.getWParam) {
|
|
587
657
|
var wParam = _core.getWParam();
|
|
588
658
|
if (wParam >= 0) {
|
|
589
|
-
|
|
659
|
+
requestDetails.url += "&w=" + wParam;
|
|
590
660
|
}
|
|
591
661
|
}
|
|
592
662
|
for (var i = 0; i < _queryStringParameters.length; i++) {
|
|
593
|
-
|
|
663
|
+
requestDetails.url += "&" + _queryStringParameters[i].name + "=" + _queryStringParameters[i].value;
|
|
594
664
|
}
|
|
595
|
-
return
|
|
665
|
+
return requestDetails;
|
|
596
666
|
}
|
|
597
667
|
function _canUseSendBeaconApi() {
|
|
598
668
|
return !_customHttpInterface && _useBeacons && isBeaconsSupported();
|
|
@@ -603,9 +673,20 @@ var HttpManager = /** @class */ (function () {
|
|
|
603
673
|
}
|
|
604
674
|
function _doPayloadSend(thePayload, serializationStart, serializationCompleted, sendReason) {
|
|
605
675
|
if (thePayload && thePayload.payloadBlob && thePayload.payloadBlob.length > 0) {
|
|
606
|
-
var
|
|
676
|
+
var useSendHook_1 = !!_self.sendHook;
|
|
677
|
+
var sendInterface_1 = _sendInterfaces[thePayload.sendType];
|
|
678
|
+
// Send all data using a beacon style transport if closing mode is on or channel was teared down
|
|
679
|
+
if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 /* Unload */) {
|
|
680
|
+
sendInterface_1 = _sendInterfaces[2 /* SendBeacon */] || _sendInterfaces[3 /* SyncFetch */] || sendInterface_1;
|
|
681
|
+
}
|
|
682
|
+
var useHeaders_1 = _useHeaders;
|
|
683
|
+
// Disable header usage if we know we are using sendBeacon as additional headers are not supported
|
|
684
|
+
if (thePayload.isBeacon || sendInterface_1._transport === 3 /* Beacon */) {
|
|
685
|
+
useHeaders_1 = false;
|
|
686
|
+
}
|
|
687
|
+
var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
|
|
688
|
+
useHeaders_1 = useHeaders_1 || requestDetails_1.useHdrs;
|
|
607
689
|
var sendEventStart_1 = getTime();
|
|
608
|
-
var strSendAttempt_1 = "sendAttempt";
|
|
609
690
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend"; }, function () {
|
|
610
691
|
// Increment the send attempt count and add timings after packaging (So it's not serialized in the 1st attempt)
|
|
611
692
|
for (var batchLp = 0; batchLp < thePayload.batches.length; batchLp++) {
|
|
@@ -619,7 +700,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
619
700
|
_setTimingValue(timings, "serializationStart", serializationStart);
|
|
620
701
|
_setTimingValue(timings, "serializationCompleted", serializationCompleted);
|
|
621
702
|
}
|
|
622
|
-
telemetryItem[
|
|
703
|
+
telemetryItem[strSendAttempt] > 0 ? telemetryItem[strSendAttempt]++ : telemetryItem[strSendAttempt] = 1;
|
|
623
704
|
}
|
|
624
705
|
}
|
|
625
706
|
// Note: always sending this notification in a synchronous manner.
|
|
@@ -629,25 +710,26 @@ var HttpManager = /** @class */ (function () {
|
|
|
629
710
|
// eslint-disable-next-line prefer-const
|
|
630
711
|
var orgPayloadData = {
|
|
631
712
|
data: thePayload.payloadBlob,
|
|
632
|
-
urlString:
|
|
633
|
-
headers:
|
|
713
|
+
urlString: requestDetails_1.url,
|
|
714
|
+
headers: requestDetails_1.hdrs,
|
|
634
715
|
_thePayload: thePayload,
|
|
635
|
-
_sendReason: sendReason
|
|
716
|
+
_sendReason: sendReason,
|
|
717
|
+
timeout: _xhrTimeout
|
|
636
718
|
};
|
|
637
|
-
if (!
|
|
638
|
-
orgPayloadData.
|
|
719
|
+
if (!isUndefined(_disableXhrSync)) {
|
|
720
|
+
orgPayloadData.disableXhrSync = !!_disableXhrSync;
|
|
639
721
|
}
|
|
640
|
-
if
|
|
641
|
-
|
|
722
|
+
// Only automatically add the following headers if already sending headers and we are not attempting to avoid an options call
|
|
723
|
+
if (useHeaders_1) {
|
|
724
|
+
if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
|
|
725
|
+
orgPayloadData.headers[strCacheControl] = defaultCacheControl;
|
|
726
|
+
}
|
|
727
|
+
if (!_hasHeader(orgPayloadData.headers, strContentTypeHeader)) {
|
|
728
|
+
orgPayloadData.headers[strContentTypeHeader] = defaultContentType;
|
|
729
|
+
}
|
|
642
730
|
}
|
|
643
731
|
var sender = null;
|
|
644
|
-
|
|
645
|
-
var sendInterface = _sendInterfaces[thePayload.sendType];
|
|
646
|
-
// Send all data using a beacon style transport if closing mode is on or channel was teared down
|
|
647
|
-
if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 /* Unload */) {
|
|
648
|
-
sendInterface = _sendInterfaces[2 /* SendBeacon */] || _sendInterfaces[3 /* SyncFetch */] || sendInterface;
|
|
649
|
-
}
|
|
650
|
-
if (sendInterface) {
|
|
732
|
+
if (sendInterface_1) {
|
|
651
733
|
// Send sync requests if the request is immediate or we are tearing down telemetry.
|
|
652
734
|
sender = function (payload) {
|
|
653
735
|
// Notify the clock skew manager that we are sending the first request (Potentially blocking all further requests)
|
|
@@ -657,7 +739,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
657
739
|
};
|
|
658
740
|
var isSync = thePayload.isTeardown || thePayload.isSync;
|
|
659
741
|
try {
|
|
660
|
-
|
|
742
|
+
sendInterface_1.sendPOST(payload, onComplete, isSync);
|
|
661
743
|
if (_self.sendListener) {
|
|
662
744
|
// Send the original payload to the listener
|
|
663
745
|
_self.sendListener(orgPayloadData, payload, isSync, thePayload.isBeacon);
|
|
@@ -675,7 +757,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
675
757
|
_outstandingRequests++;
|
|
676
758
|
}
|
|
677
759
|
// Only call the hook if it's defined and we are not using sendBeacon as additional headers are not supported
|
|
678
|
-
if (
|
|
760
|
+
if (useSendHook_1 && !thePayload.isBeacon && sendInterface_1._transport !== 3 /* Beacon */) {
|
|
679
761
|
// Create a new IPayloadData that is sent into the hook method, so that the hook method
|
|
680
762
|
// can't change the object references to the orgPayloadData (it can still change the content -- mainly the headers)
|
|
681
763
|
// Disabling the use of const because of Issue:
|
|
@@ -684,7 +766,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
684
766
|
var hookData_1 = {
|
|
685
767
|
data: orgPayloadData.data,
|
|
686
768
|
urlString: orgPayloadData.urlString,
|
|
687
|
-
headers: extend({}, orgPayloadData.headers)
|
|
769
|
+
headers: extend({}, orgPayloadData.headers),
|
|
770
|
+
timeout: orgPayloadData.timeout,
|
|
771
|
+
disableXhrSync: orgPayloadData.disableXhrSync
|
|
688
772
|
};
|
|
689
773
|
var senderCalled_1 = false;
|
|
690
774
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend.sendHook"; }, function () {
|
|
@@ -758,7 +842,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
758
842
|
}
|
|
759
843
|
// Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
|
|
760
844
|
// tslint:disable-next-line:triple-equals
|
|
761
|
-
if (status == 200) {
|
|
845
|
+
if (status == 200 || status == 204) {
|
|
762
846
|
// Response was successfully sent
|
|
763
847
|
reason = 200 /* Complete */;
|
|
764
848
|
return;
|
|
@@ -775,7 +859,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
775
859
|
reason = 100 /* RequeueEvents */;
|
|
776
860
|
var retryCount_1 = thePayload.retryCnt;
|
|
777
861
|
if (thePayload.sendType === 0 /* Batched */) {
|
|
778
|
-
|
|
862
|
+
// attempt to resend the entire batch
|
|
863
|
+
if (retryCount_1 < maxRequestRetriesBeforeBackoff) {
|
|
779
864
|
isRetrying = true;
|
|
780
865
|
_doAction(function () {
|
|
781
866
|
// try to resend the same batches
|
|
@@ -790,6 +875,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
790
875
|
}
|
|
791
876
|
else {
|
|
792
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
|
+
}
|
|
793
883
|
}
|
|
794
884
|
}
|
|
795
885
|
}
|
|
@@ -880,12 +970,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
880
970
|
}
|
|
881
971
|
function _getMsfpc(thePayload) {
|
|
882
972
|
for (var lp = 0; lp < thePayload.batches.length; lp++) {
|
|
883
|
-
var
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (isValueAssigned(intWeb["msfpc"])) {
|
|
887
|
-
return encodeURIComponent(intWeb["msfpc"]);
|
|
888
|
-
}
|
|
973
|
+
var msfpc = thePayload.batches[lp].Msfpc();
|
|
974
|
+
if (msfpc) {
|
|
975
|
+
return encodeURIComponent(msfpc);
|
|
889
976
|
}
|
|
890
977
|
}
|
|
891
978
|
return "";
|
|
@@ -903,9 +990,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
903
990
|
}
|
|
904
991
|
if (responseText) {
|
|
905
992
|
var response = JSON.parse(responseText);
|
|
906
|
-
if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult
|
|
993
|
+
if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[strMsfpc])) {
|
|
907
994
|
// Set cookie
|
|
908
|
-
_cookieMgr.set("MSFPC", response.webResult
|
|
995
|
+
_cookieMgr.set("MSFPC", response.webResult[strMsfpc], 365 * 86400);
|
|
909
996
|
}
|
|
910
997
|
}
|
|
911
998
|
}
|
|
@@ -963,5 +1050,5 @@ var HttpManager = /** @class */ (function () {
|
|
|
963
1050
|
// Removed Stub for HttpManager.prototype.sendSynchronousBatch.
|
|
964
1051
|
return HttpManager;
|
|
965
1052
|
}());
|
|
966
|
-
export
|
|
1053
|
+
export { HttpManager };
|
|
967
1054
|
//# sourceMappingURL=HttpManager.js.map
|