@microsoft/1ds-post-js 3.2.2 → 3.2.5
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/CODE_OF_CONDUCT.md +9 -0
- package/CONTRIBUTING.md +14 -0
- package/LICENSE.TXT +3 -3
- package/NOTICE +17 -0
- package/PRIVACY +3 -0
- package/README.md +16 -2
- package/SECURITY.md +41 -0
- package/SUPPORT.md +14 -0
- package/bundle/{ms.post-3.2.2.gbl.js → ms.post-3.2.5.gbl.js} +933 -858
- package/bundle/ms.post-3.2.5.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.5.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.5.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.5.integrity.json +46 -0
- package/bundle/{ms.post-3.2.2.js → ms.post-3.2.5.js} +933 -858
- package/bundle/ms.post-3.2.5.js.map +1 -0
- package/bundle/ms.post-3.2.5.min.js +7 -0
- package/bundle/ms.post-3.2.5.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +932 -857
- 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 +932 -857
- 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 +213 -197
- 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 +6 -1
- package/dist-esm/src/ClockSkewManager.js.map +1 -1
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.d.ts +0 -5
- package/dist-esm/src/EventBatch.js +9 -4
- package/dist-esm/src/EventBatch.js.map +1 -1
- package/dist-esm/src/HttpManager.d.ts +2 -7
- package/dist-esm/src/HttpManager.js +116 -108
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/InternalConstants.d.ts +27 -0
- package/dist-esm/src/InternalConstants.js +40 -0
- package/dist-esm/src/InternalConstants.js.map +1 -0
- package/dist-esm/src/KillSwitch.js +7 -2
- package/dist-esm/src/KillSwitch.js.map +1 -1
- package/dist-esm/src/PostChannel.d.ts +1 -1
- package/dist-esm/src/PostChannel.js +79 -65
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.js +1 -1
- package/dist-esm/src/Serializer.d.ts +1 -1
- package/dist-esm/src/Serializer.js +9 -3
- package/dist-esm/src/Serializer.js.map +1 -1
- package/dist-esm/src/TimeoutOverrideWrapper.d.ts +5 -5
- package/dist-esm/src/TimeoutOverrideWrapper.js +6 -6
- package/dist-esm/src/TimeoutOverrideWrapper.js.map +1 -1
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +4 -2
- package/src/EventBatch.ts +4 -4
- package/src/HttpManager.ts +70 -68
- package/src/InternalConstants.ts +41 -0
- package/src/KillSwitch.ts +1 -1
- package/src/PostChannel.ts +45 -36
- package/src/Serializer.ts +7 -5
- package/src/TimeoutOverrideWrapper.ts +6 -6
- package/bundle/ms.post-3.2.2.gbl.js.map +0 -1
- package/bundle/ms.post-3.2.2.gbl.min.js +0 -7
- package/bundle/ms.post-3.2.2.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.2.2.integrity.json +0 -46
- package/bundle/ms.post-3.2.2.js.map +0 -1
- package/bundle/ms.post-3.2.2.min.js +0 -7
- package/bundle/ms.post-3.2.2.min.js.map +0 -1
- package/dist-esm/src/Constants.d.ts +0 -25
- package/dist-esm/src/Constants.js +0 -31
- package/dist-esm/src/Constants.js.map +0 -1
- package/src/Constants.ts +0 -28
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.5
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -9,24 +9,24 @@ var _a;
|
|
|
9
9
|
* @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)
|
|
10
10
|
* @copyright Microsoft 2018-2020
|
|
11
11
|
*/
|
|
12
|
-
import { isReactNative, isValueAssigned, isString, getTime, arrForEach, getLocation, strTrim, isFetchSupported, isXhrSupported, isBeaconsSupported, FullVersionString, useXDomainRequest, strUndefined, getNavigator, doPerf, dateNow, isUndefined, isNullOrUndefined, objForEachKey, isNumber, isArray, dumpObj, objKeys, extend, hasOwnProperty, openXhr, _throwInternal } from "@microsoft/1ds-core-js";
|
|
13
|
-
import { Serializer } from "./Serializer";
|
|
14
|
-
import { retryPolicyGetMillisToBackoffForRetry, retryPolicyShouldRetryForStatus } from "./RetryPolicy";
|
|
15
|
-
import EVTKillSwitch from "./KillSwitch";
|
|
16
|
-
import EVTClockSkewManager from "./ClockSkewManager";
|
|
17
12
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
18
|
-
import
|
|
13
|
+
import EVTClockSkewManager from "./ClockSkewManager";
|
|
14
|
+
import EVTKillSwitch from "./KillSwitch";
|
|
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";
|
|
17
|
+
import { retryPolicyGetMillisToBackoffForRetry, retryPolicyShouldRetryForStatus } from "./RetryPolicy";
|
|
18
|
+
import { Serializer } from "./Serializer";
|
|
19
19
|
var strSendAttempt = "sendAttempt";
|
|
20
|
-
var _noResponseQs = "&" +
|
|
20
|
+
var _noResponseQs = "&" + STR_NO_RESPONSE_BODY + "=true";
|
|
21
21
|
/**
|
|
22
22
|
* Identifies the default notification reason to the action names
|
|
23
23
|
*/
|
|
24
24
|
var _eventActionMap = (_a = {},
|
|
25
|
-
_a[1 /* Paused */] =
|
|
26
|
-
_a[100 /* RequeueEvents */] =
|
|
27
|
-
_a[200 /* Complete */] = "sent",
|
|
28
|
-
_a[8004 /* KillSwitch */] =
|
|
29
|
-
_a[8003 /* SizeLimitExceeded */] =
|
|
25
|
+
_a[1 /* EventBatchNotificationReason.Paused */] = STR_REQUEUE,
|
|
26
|
+
_a[100 /* EventBatchNotificationReason.RequeueEvents */] = STR_REQUEUE,
|
|
27
|
+
_a[200 /* EventBatchNotificationReason.Complete */] = "sent",
|
|
28
|
+
_a[8004 /* EventBatchNotificationReason.KillSwitch */] = STR_DROPPED,
|
|
29
|
+
_a[8003 /* EventBatchNotificationReason.SizeLimitExceeded */] = STR_DROPPED,
|
|
30
30
|
_a);
|
|
31
31
|
var _collectorQsHeaders = {};
|
|
32
32
|
var _collectorHeaderToQs = {};
|
|
@@ -36,13 +36,13 @@ function _addCollectorHeaderQsMapping(qsName, headerName, allowQs) {
|
|
|
36
36
|
_collectorHeaderToQs[headerName] = qsName;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
_addCollectorHeaderQsMapping(
|
|
40
|
-
_addCollectorHeaderQsMapping(
|
|
41
|
-
_addCollectorHeaderQsMapping(
|
|
42
|
-
_addCollectorHeaderQsMapping(
|
|
43
|
-
_addCollectorHeaderQsMapping(
|
|
44
|
-
_addCollectorHeaderQsMapping(
|
|
45
|
-
_addCollectorHeaderQsMapping(
|
|
39
|
+
_addCollectorHeaderQsMapping(STR_MSA_DEVICE_TICKET, STR_MSA_DEVICE_TICKET, false);
|
|
40
|
+
_addCollectorHeaderQsMapping(STR_CLIENT_VERSION, STR_CLIENT_VERSION);
|
|
41
|
+
_addCollectorHeaderQsMapping(STR_CLIENT_ID, "Client-Id");
|
|
42
|
+
_addCollectorHeaderQsMapping(STR_API_KEY, STR_API_KEY);
|
|
43
|
+
_addCollectorHeaderQsMapping(STR_TIME_DELTA_TO_APPLY, STR_TIME_DELTA_TO_APPLY);
|
|
44
|
+
_addCollectorHeaderQsMapping(STR_UPLOAD_TIME, STR_UPLOAD_TIME);
|
|
45
|
+
_addCollectorHeaderQsMapping(STR_AUTH_XTOKEN, STR_AUTH_XTOKEN);
|
|
46
46
|
function _getResponseText(xhr) {
|
|
47
47
|
try {
|
|
48
48
|
return xhr.responseText;
|
|
@@ -91,13 +91,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
91
91
|
*/
|
|
92
92
|
function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions, timeoutOverride) {
|
|
93
93
|
this._responseHandlers = [];
|
|
94
|
-
var _urlString = "?cors=true&" +
|
|
94
|
+
var _urlString = "?cors=true&" + STR_CONTENT_TYPE_HEADER.toLowerCase() + "=" + DEFAULT_CONTENT_TYPE;
|
|
95
95
|
var _killSwitch = new EVTKillSwitch();
|
|
96
96
|
var _paused = false;
|
|
97
97
|
var _clockSkewManager = new EVTClockSkewManager();
|
|
98
98
|
var _useBeacons = false;
|
|
99
99
|
var _outstandingRequests = 0; // Holds the number of outstanding async requests that have not returned a response yet
|
|
100
100
|
var _postManager;
|
|
101
|
+
var _logger;
|
|
101
102
|
var _sendInterfaces;
|
|
102
103
|
var _core;
|
|
103
104
|
var _customHttpInterface = true;
|
|
@@ -125,6 +126,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
125
126
|
_enableEventTimings = !_core.config.disableEventTimings;
|
|
126
127
|
var enableCompoundKey = !!_core.config.enableCompoundKey;
|
|
127
128
|
_postManager = postChannel;
|
|
129
|
+
_logger = _postManager.diagLog();
|
|
128
130
|
var valueSanitizer = channelConfig.valueSanitizer;
|
|
129
131
|
var stringifyObjects = channelConfig.stringifyObjects;
|
|
130
132
|
if (!isUndefined(channelConfig.enableCompoundKey)) {
|
|
@@ -147,11 +149,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
147
149
|
var theTransports = [];
|
|
148
150
|
if (isReactNative()) {
|
|
149
151
|
// Use Fetch or XDR/XHR
|
|
150
|
-
theTransports = [2 /* Fetch */, 1 /* Xhr */];
|
|
152
|
+
theTransports = [2 /* TransportType.Fetch */, 1 /* TransportType.Xhr */];
|
|
151
153
|
}
|
|
152
154
|
else {
|
|
153
155
|
// Use XDR/XHR, Fetch or beacons
|
|
154
|
-
theTransports = [1 /* Xhr */, 2 /* Fetch */, 3 /* Beacon */];
|
|
156
|
+
theTransports = [1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */];
|
|
155
157
|
}
|
|
156
158
|
// Prefix any user requested transport(s) values
|
|
157
159
|
var configTransports = channelConfig.transports;
|
|
@@ -166,24 +168,24 @@ var HttpManager = /** @class */ (function () {
|
|
|
166
168
|
httpInterface = _getSenderInterface(theTransports, false);
|
|
167
169
|
syncHttpInterface = _getSenderInterface(theTransports, true);
|
|
168
170
|
if (!httpInterface) {
|
|
169
|
-
|
|
171
|
+
_warnToConsole(_logger, "No available transport to send events");
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
_sendInterfaces = (_a = {},
|
|
173
|
-
_a[0 /* Batched */] = httpInterface,
|
|
174
|
-
_a[1 /* Synchronous */] = syncHttpInterface || _getSenderInterface([1 /* Xhr */, 2 /* Fetch */, 3 /* Beacon */], true),
|
|
175
|
-
_a[2 /* SendBeacon */] = beaconHttpInterface || _getSenderInterface([3 /* Beacon */, 2 /* Fetch */], true) || syncHttpInterface || _getSenderInterface([1 /* Xhr */], true),
|
|
176
|
-
_a[3 /* SyncFetch */] = fetchSyncHttpInterface || _getSenderInterface([2 /* Fetch */, 3 /* Beacon */], true) || syncHttpInterface || _getSenderInterface([1 /* Xhr */], true),
|
|
175
|
+
_a[0 /* EventSendType.Batched */] = httpInterface,
|
|
176
|
+
_a[1 /* EventSendType.Synchronous */] = syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], true),
|
|
177
|
+
_a[2 /* EventSendType.SendBeacon */] = beaconHttpInterface || _getSenderInterface([3 /* TransportType.Beacon */, 2 /* TransportType.Fetch */], true) || syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */], true),
|
|
178
|
+
_a[3 /* EventSendType.SyncFetch */] = fetchSyncHttpInterface || _getSenderInterface([2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], true) || syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */], true),
|
|
177
179
|
_a);
|
|
178
180
|
};
|
|
179
181
|
// Special internal method to allow the DebugPlugin to hook embedded objects
|
|
180
182
|
function _getSenderInterface(transports, syncSupport) {
|
|
181
|
-
var transportType = 0 /* NotSet */;
|
|
183
|
+
var transportType = 0 /* TransportType.NotSet */;
|
|
182
184
|
var sendPostFunc = null;
|
|
183
185
|
var lp = 0;
|
|
184
186
|
while (sendPostFunc == null && lp < transports.length) {
|
|
185
187
|
transportType = transports[lp];
|
|
186
|
-
if (transportType === 1 /* Xhr */) {
|
|
188
|
+
if (transportType === 1 /* TransportType.Xhr */) {
|
|
187
189
|
if (useXDomainRequest()) {
|
|
188
190
|
sendPostFunc = _xdrSendPost;
|
|
189
191
|
}
|
|
@@ -191,10 +193,10 @@ var HttpManager = /** @class */ (function () {
|
|
|
191
193
|
sendPostFunc = _xhrSendPost;
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
|
-
else if (transportType === 2 /* Fetch */ && isFetchSupported(syncSupport)) {
|
|
196
|
+
else if (transportType === 2 /* TransportType.Fetch */ && isFetchSupported(syncSupport)) {
|
|
195
197
|
sendPostFunc = _fetchSendPost;
|
|
196
198
|
}
|
|
197
|
-
else if (_useBeacons && transportType === 3 /* Beacon */ && isBeaconsSupported()) {
|
|
199
|
+
else if (_useBeacons && transportType === 3 /* TransportType.Beacon */ && isBeaconsSupported()) {
|
|
198
200
|
sendPostFunc = _beaconSendPost;
|
|
199
201
|
}
|
|
200
202
|
lp++;
|
|
@@ -209,12 +211,12 @@ var HttpManager = /** @class */ (function () {
|
|
|
209
211
|
return null;
|
|
210
212
|
}
|
|
211
213
|
_self["_getDbgPlgTargets"] = function () {
|
|
212
|
-
return [_sendInterfaces[0 /* Batched */], _killSwitch, _serializer, _sendInterfaces];
|
|
214
|
+
return [_sendInterfaces[0 /* EventSendType.Batched */], _killSwitch, _serializer, _sendInterfaces];
|
|
213
215
|
};
|
|
214
216
|
function _xdrSendPost(payload, oncomplete, sync) {
|
|
215
217
|
// It doesn't support custom headers, so no action is taken with current requestHeaders
|
|
216
218
|
var xdr = new XDomainRequest();
|
|
217
|
-
xdr.open(
|
|
219
|
+
xdr.open(STR_POST_METHOD, payload.urlString);
|
|
218
220
|
if (payload.timeout) {
|
|
219
221
|
xdr.timeout = payload.timeout;
|
|
220
222
|
}
|
|
@@ -252,13 +254,13 @@ var HttpManager = /** @class */ (function () {
|
|
|
252
254
|
var responseHandled = false;
|
|
253
255
|
var requestInit = (_a = {
|
|
254
256
|
body: payload.data,
|
|
255
|
-
method:
|
|
257
|
+
method: STR_POST_METHOD
|
|
256
258
|
},
|
|
257
|
-
_a[
|
|
259
|
+
_a[STR_DISABLED_PROPERTY_NAME] = true,
|
|
258
260
|
_a);
|
|
259
261
|
if (sync) {
|
|
260
262
|
requestInit.keepalive = true;
|
|
261
|
-
if (payload._sendReason === 2 /* Unload */) {
|
|
263
|
+
if (payload._sendReason === 2 /* SendRequestReason.Unload */) {
|
|
262
264
|
// As a sync request (during unload), it is unlikely that we will get a chance to process the response so
|
|
263
265
|
// just like beacon send assume that the events have been accepted and processed
|
|
264
266
|
ignoreResponse = true;
|
|
@@ -276,8 +278,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
276
278
|
fetch(theUrl, requestInit).then(function (response) {
|
|
277
279
|
var headerMap = {};
|
|
278
280
|
var responseText = "";
|
|
279
|
-
|
|
280
|
-
|
|
281
|
+
var headers = response.headers;
|
|
282
|
+
if (headers) {
|
|
283
|
+
headers["forEach"](function (value, name) {
|
|
281
284
|
headerMap[name] = value;
|
|
282
285
|
});
|
|
283
286
|
}
|
|
@@ -332,9 +335,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
332
335
|
// Firefox 2-63 doesn't have getAllResponseHeaders function but it does have getResponseHeader
|
|
333
336
|
// Only call these if getAllResponseHeaders doesn't exist, otherwise we can get invalid response errors
|
|
334
337
|
// as collector is not currently returning the correct header to allow JS to access these headers
|
|
335
|
-
theHeaders = _appendHeader(theHeaders, xhr,
|
|
336
|
-
theHeaders = _appendHeader(theHeaders, xhr,
|
|
337
|
-
theHeaders = _appendHeader(theHeaders, xhr,
|
|
338
|
+
theHeaders = _appendHeader(theHeaders, xhr, STR_TIME_DELTA_HEADER);
|
|
339
|
+
theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_HEADER);
|
|
340
|
+
theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_SECONDS_HEADER);
|
|
338
341
|
}
|
|
339
342
|
else {
|
|
340
343
|
theHeaders = _convertAllHeadersToMap(xhr.getAllResponseHeaders());
|
|
@@ -347,7 +350,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
347
350
|
if (sync && payload.disableXhrSync) {
|
|
348
351
|
sync = false;
|
|
349
352
|
}
|
|
350
|
-
var xhrRequest = openXhr(
|
|
353
|
+
var xhrRequest = openXhr(STR_POST_METHOD, theUrl, _sendCredentials, true, sync, payload.timeout);
|
|
351
354
|
// Set custom headers (e.g. gzip) here (after open())
|
|
352
355
|
objForEachKey(payload.headers, function (name, value) {
|
|
353
356
|
xhrRequest.setRequestHeader(name, value);
|
|
@@ -370,7 +373,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
370
373
|
oncomplete(status, headers, response);
|
|
371
374
|
}
|
|
372
375
|
catch (e) {
|
|
373
|
-
_throwInternal(
|
|
376
|
+
_throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 518 /* _eExtendedInternalMessageId.SendPostOnCompleteFailure */, dumpObj(e));
|
|
374
377
|
}
|
|
375
378
|
}
|
|
376
379
|
function _beaconSendPost(payload, oncomplete, sync) {
|
|
@@ -401,7 +404,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
401
404
|
droppedBatches_1.push(theBatch.split(0));
|
|
402
405
|
}
|
|
403
406
|
});
|
|
404
|
-
_sendBatchesNotification(droppedBatches_1, 8003 /* SizeLimitExceeded */, thePayload.sendType, true);
|
|
407
|
+
_sendBatchesNotification(droppedBatches_1, 8003 /* EventBatchNotificationReason.SizeLimitExceeded */, thePayload.sendType, true);
|
|
405
408
|
}
|
|
406
409
|
else {
|
|
407
410
|
status = 0;
|
|
@@ -409,7 +412,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
409
412
|
}
|
|
410
413
|
}
|
|
411
414
|
catch (ex) {
|
|
412
|
-
|
|
415
|
+
_warnToConsole(_logger, "Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(ex));
|
|
413
416
|
status = 0;
|
|
414
417
|
}
|
|
415
418
|
finally {
|
|
@@ -418,11 +421,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
418
421
|
}
|
|
419
422
|
function _isBeaconPayload(sendType) {
|
|
420
423
|
// Sync Fetch has the same payload limitation as sendBeacon -- 64kb limit, so treat both as a beacon send
|
|
421
|
-
return sendType === 2 /* SendBeacon */ || sendType === 3 /* SyncFetch */;
|
|
424
|
+
return sendType === 2 /* EventSendType.SendBeacon */ || sendType === 3 /* EventSendType.SyncFetch */;
|
|
422
425
|
}
|
|
423
426
|
function _adjustSendType(sendType) {
|
|
424
427
|
if (_isUnloading && _isBeaconPayload(sendType)) {
|
|
425
|
-
sendType = 2 /* SendBeacon */;
|
|
428
|
+
sendType = 2 /* EventSendType.SendBeacon */;
|
|
426
429
|
}
|
|
427
430
|
return sendType;
|
|
428
431
|
}
|
|
@@ -443,14 +446,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
443
446
|
};
|
|
444
447
|
_self.sendQueuedRequests = function (sendType, sendReason) {
|
|
445
448
|
if (isUndefined(sendType)) {
|
|
446
|
-
sendType = 0 /* Batched */;
|
|
449
|
+
sendType = 0 /* EventSendType.Batched */;
|
|
447
450
|
}
|
|
448
451
|
if (_isUnloading) {
|
|
449
452
|
sendType = _adjustSendType(sendType);
|
|
450
|
-
sendReason = 2 /* Unload */;
|
|
453
|
+
sendReason = 2 /* SendRequestReason.Unload */;
|
|
451
454
|
}
|
|
452
455
|
if (_canSendPayload(_batchQueue, sendType, 0)) {
|
|
453
|
-
_sendBatches(_clearQueue(), 0, false, sendType, sendReason || 0 /* Undefined */);
|
|
456
|
+
_sendBatches(_clearQueue(), 0, false, sendType, sendReason || 0 /* SendRequestReason.Undefined */);
|
|
454
457
|
}
|
|
455
458
|
};
|
|
456
459
|
_self.isCompletelyIdle = function () {
|
|
@@ -475,7 +478,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
475
478
|
*/
|
|
476
479
|
_self.teardown = function () {
|
|
477
480
|
if (_batchQueue.length > 0) {
|
|
478
|
-
_sendBatches(_clearQueue(), 0, true, 2 /* SendBeacon */, 2 /* Unload */);
|
|
481
|
+
_sendBatches(_clearQueue(), 0, true, 2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
|
|
479
482
|
}
|
|
480
483
|
};
|
|
481
484
|
/**
|
|
@@ -489,7 +492,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
489
492
|
*/
|
|
490
493
|
_self.resume = function () {
|
|
491
494
|
_paused = false;
|
|
492
|
-
_self.sendQueuedRequests(0 /* Batched */, 4 /* Resumed */);
|
|
495
|
+
_self.sendQueuedRequests(0 /* EventSendType.Batched */, 4 /* SendRequestReason.Resumed */);
|
|
493
496
|
};
|
|
494
497
|
/**
|
|
495
498
|
* Sends a request synchronously to the Aria collector. This api is used to send
|
|
@@ -505,14 +508,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
505
508
|
// Increment active connection since we are still going to use a connection to send the request.
|
|
506
509
|
if (batch && batch.count() > 0) {
|
|
507
510
|
if (isNullOrUndefined(sendType)) {
|
|
508
|
-
sendType = 1 /* Synchronous */;
|
|
511
|
+
sendType = 1 /* EventSendType.Synchronous */;
|
|
509
512
|
}
|
|
510
513
|
if (_isUnloading) {
|
|
511
514
|
sendType = _adjustSendType(sendType);
|
|
512
|
-
sendReason = 2 /* Unload */;
|
|
515
|
+
sendReason = 2 /* SendRequestReason.Unload */;
|
|
513
516
|
}
|
|
514
517
|
// For sync requests we will not wait for the clock skew.
|
|
515
|
-
_sendBatches([batch], 0, false, sendType, sendReason || 0 /* Undefined */);
|
|
518
|
+
_sendBatches([batch], 0, false, sendType, sendReason || 0 /* SendRequestReason.Undefined */);
|
|
516
519
|
}
|
|
517
520
|
};
|
|
518
521
|
function _hasIdleConnection() {
|
|
@@ -528,7 +531,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
528
531
|
if (theBatches && theBatches.length > 0 && !_paused && _sendInterfaces[sendType] && _serializer) {
|
|
529
532
|
// Always attempt to send synchronous events don't wait for idle or clockSkew
|
|
530
533
|
// and don't block retry requests if clockSkew is not yet set
|
|
531
|
-
result = (sendType !== 0 /* Batched */) || (_hasIdleConnection() && (retryCnt > 0 || _clockSkewManager.allowRequestSending()));
|
|
534
|
+
result = (sendType !== 0 /* EventSendType.Batched */) || (_hasIdleConnection() && (retryCnt > 0 || _clockSkewManager.allowRequestSending()));
|
|
532
535
|
}
|
|
533
536
|
return result;
|
|
534
537
|
}
|
|
@@ -550,14 +553,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
550
553
|
return;
|
|
551
554
|
}
|
|
552
555
|
if (_paused) {
|
|
553
|
-
_sendBatchesNotification(theBatches, 1 /* Paused */, sendType);
|
|
556
|
+
_sendBatchesNotification(theBatches, 1 /* EventBatchNotificationReason.Paused */, sendType);
|
|
554
557
|
return;
|
|
555
558
|
}
|
|
556
559
|
// Make sure that if we are unloading the sendType is a supported version
|
|
557
560
|
sendType = _adjustSendType(sendType);
|
|
558
561
|
try {
|
|
559
562
|
var orgBatches_1 = theBatches;
|
|
560
|
-
var isSynchronous_1 = sendType !== 0 /* Batched */;
|
|
563
|
+
var isSynchronous_1 = sendType !== 0 /* EventSendType.Batched */;
|
|
561
564
|
doPerf(_core, function () { return "HttpManager:_sendBatches"; }, function (perfEvt) {
|
|
562
565
|
if (perfEvt) {
|
|
563
566
|
// Perf Monitoring is enabled, so create a "Quick" copy of the original batches so we still report
|
|
@@ -569,9 +572,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
569
572
|
var droppedBatches = [];
|
|
570
573
|
var thePayload = null;
|
|
571
574
|
var serializationStart = getTime();
|
|
572
|
-
var sendInterface = _sendInterfaces[sendType] || (isSynchronous_1 ? _sendInterfaces[1 /* Synchronous */] : _sendInterfaces[0 /* Batched */]);
|
|
575
|
+
var sendInterface = _sendInterfaces[sendType] || (isSynchronous_1 ? _sendInterfaces[1 /* EventSendType.Synchronous */] : _sendInterfaces[0 /* EventSendType.Batched */]);
|
|
573
576
|
// Sync Fetch has the same payload limitation as sendBeacon -- 64kb limit
|
|
574
|
-
var isBeaconTransport = (_isUnloading || _isBeaconPayload(sendType) || (sendInterface && sendInterface._transport === 3 /* Beacon */)) && _canUseSendBeaconApi();
|
|
577
|
+
var isBeaconTransport = (_isUnloading || _isBeaconPayload(sendType) || (sendInterface && sendInterface._transport === 3 /* TransportType.Beacon */)) && _canUseSendBeaconApi();
|
|
575
578
|
while (_canSendPayload(theBatches, sendType, retryCount)) {
|
|
576
579
|
var theBatch = theBatches.shift();
|
|
577
580
|
if (theBatch && theBatch.count() > 0) {
|
|
@@ -609,11 +612,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
609
612
|
_batchQueue = theBatches.concat(_batchQueue);
|
|
610
613
|
}
|
|
611
614
|
// Now send notification about any dropped events
|
|
612
|
-
_sendBatchesNotification(droppedBatches, 8004 /* KillSwitch */, sendType);
|
|
615
|
+
_sendBatchesNotification(droppedBatches, 8004 /* EventBatchNotificationReason.KillSwitch */, sendType);
|
|
613
616
|
}, function () { return ({ batches: _createDebugBatches(orgBatches_1), retryCount: retryCount, isTeardown: isTeardown, isSynchronous: isSynchronous_1, sendReason: sendReason, useSendBeacon: _isBeaconPayload(sendType), sendType: sendType }); }, !isSynchronous_1);
|
|
614
617
|
}
|
|
615
618
|
catch (ex) {
|
|
616
|
-
_throwInternal(
|
|
619
|
+
_throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 48 /* _eInternalMessageId.CannotSerializeObject */, "Unexpected Exception sending batch: " + dumpObj(ex));
|
|
617
620
|
}
|
|
618
621
|
}
|
|
619
622
|
function _buildRequestDetails(thePayload, useHeaders) {
|
|
@@ -640,8 +643,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
640
643
|
requestDetails.hdrs = extend(requestDetails.hdrs, _headers);
|
|
641
644
|
requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
|
|
642
645
|
}
|
|
643
|
-
_addRequestDetails(requestDetails,
|
|
644
|
-
_addRequestDetails(requestDetails,
|
|
646
|
+
_addRequestDetails(requestDetails, STR_CLIENT_ID, "NO_AUTH", useHeaders);
|
|
647
|
+
_addRequestDetails(requestDetails, STR_CLIENT_VERSION, FullVersionString, useHeaders);
|
|
645
648
|
var apiQsKeys = "";
|
|
646
649
|
arrForEach(thePayload.apiKeys, function (apiKey) {
|
|
647
650
|
if (apiQsKeys.length > 0) {
|
|
@@ -649,14 +652,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
649
652
|
}
|
|
650
653
|
apiQsKeys += apiKey;
|
|
651
654
|
});
|
|
652
|
-
_addRequestDetails(requestDetails,
|
|
653
|
-
_addRequestDetails(requestDetails,
|
|
655
|
+
_addRequestDetails(requestDetails, STR_API_KEY, apiQsKeys, useHeaders);
|
|
656
|
+
_addRequestDetails(requestDetails, STR_UPLOAD_TIME, dateNow().toString(), useHeaders);
|
|
654
657
|
var msfpc = _getMsfpc(thePayload);
|
|
655
658
|
if (isValueAssigned(msfpc)) {
|
|
656
659
|
requestDetails.url += "&ext.intweb.msfpc=" + msfpc;
|
|
657
660
|
}
|
|
658
661
|
if (_clockSkewManager.shouldAddClockSkewHeaders()) {
|
|
659
|
-
_addRequestDetails(requestDetails,
|
|
662
|
+
_addRequestDetails(requestDetails, STR_TIME_DELTA_TO_APPLY, _clockSkewManager.getClockSkewHeaderValue(), useHeaders);
|
|
660
663
|
}
|
|
661
664
|
if (_core.getWParam) {
|
|
662
665
|
var wParam = _core.getWParam();
|
|
@@ -681,12 +684,12 @@ var HttpManager = /** @class */ (function () {
|
|
|
681
684
|
var useSendHook_1 = !!_self.sendHook;
|
|
682
685
|
var sendInterface_1 = _sendInterfaces[thePayload.sendType];
|
|
683
686
|
// Send all data using a beacon style transport if closing mode is on or channel was teared down
|
|
684
|
-
if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 /* Unload */) {
|
|
685
|
-
sendInterface_1 = _sendInterfaces[2 /* SendBeacon */] || _sendInterfaces[3 /* SyncFetch */] || sendInterface_1;
|
|
687
|
+
if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 /* SendRequestReason.Unload */) {
|
|
688
|
+
sendInterface_1 = _sendInterfaces[2 /* EventSendType.SendBeacon */] || _sendInterfaces[3 /* EventSendType.SyncFetch */] || sendInterface_1;
|
|
686
689
|
}
|
|
687
690
|
var useHeaders_1 = _useHeaders;
|
|
688
691
|
// Disable header usage if we know we are using sendBeacon as additional headers are not supported
|
|
689
|
-
if (thePayload.isBeacon || sendInterface_1._transport === 3 /* Beacon */) {
|
|
692
|
+
if (thePayload.isBeacon || sendInterface_1._transport === 3 /* TransportType.Beacon */) {
|
|
690
693
|
useHeaders_1 = false;
|
|
691
694
|
}
|
|
692
695
|
var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
|
|
@@ -709,7 +712,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
709
712
|
}
|
|
710
713
|
}
|
|
711
714
|
// Note: always sending this notification in a synchronous manner.
|
|
712
|
-
_sendBatchesNotification(thePayload.batches, (1000 /* SendingUndefined */ + (sendReason || 0 /* Undefined */)), thePayload.sendType, true);
|
|
715
|
+
_sendBatchesNotification(thePayload.batches, (1000 /* EventBatchNotificationReason.SendingUndefined */ + (sendReason || 0 /* SendRequestReason.Undefined */)), thePayload.sendType, true);
|
|
713
716
|
// Disabling the use of const because of Issue:
|
|
714
717
|
// - Task 9227844: [1DS] Some environments and packagers automatically "freeze" objects which are defined as const which causes any mutations to throw
|
|
715
718
|
// eslint-disable-next-line prefer-const
|
|
@@ -726,11 +729,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
726
729
|
}
|
|
727
730
|
// Only automatically add the following headers if already sending headers and we are not attempting to avoid an options call
|
|
728
731
|
if (useHeaders_1) {
|
|
729
|
-
if (!_hasHeader(orgPayloadData.headers,
|
|
730
|
-
orgPayloadData.headers[
|
|
732
|
+
if (!_hasHeader(orgPayloadData.headers, STR_CACHE_CONTROL)) {
|
|
733
|
+
orgPayloadData.headers[STR_CACHE_CONTROL] = DEFAULT_CACHE_CONTROL;
|
|
731
734
|
}
|
|
732
|
-
if (!_hasHeader(orgPayloadData.headers,
|
|
733
|
-
orgPayloadData.headers[
|
|
735
|
+
if (!_hasHeader(orgPayloadData.headers, STR_CONTENT_TYPE_HEADER)) {
|
|
736
|
+
orgPayloadData.headers[STR_CONTENT_TYPE_HEADER] = DEFAULT_CONTENT_TYPE;
|
|
734
737
|
}
|
|
735
738
|
}
|
|
736
739
|
var sender = null;
|
|
@@ -751,18 +754,18 @@ var HttpManager = /** @class */ (function () {
|
|
|
751
754
|
}
|
|
752
755
|
}
|
|
753
756
|
catch (ex) {
|
|
754
|
-
|
|
757
|
+
_warnToConsole(_logger, "Unexpected exception sending payload. Ex:" + dumpObj(ex));
|
|
755
758
|
_doOnComplete(onComplete, 0, {});
|
|
756
759
|
}
|
|
757
760
|
};
|
|
758
761
|
}
|
|
759
762
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend.sender"; }, function () {
|
|
760
763
|
if (sender) {
|
|
761
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
764
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
762
765
|
_outstandingRequests++;
|
|
763
766
|
}
|
|
764
767
|
// Only call the hook if it's defined and we are not using sendBeacon as additional headers are not supported
|
|
765
|
-
if (useSendHook_1 && !thePayload.isBeacon && sendInterface_1._transport !== 3 /* Beacon */) {
|
|
768
|
+
if (useSendHook_1 && !thePayload.isBeacon && sendInterface_1._transport !== 3 /* TransportType.Beacon */) {
|
|
766
769
|
// Create a new IPayloadData that is sent into the hook method, so that the hook method
|
|
767
770
|
// can't change the object references to the orgPayloadData (it can still change the content -- mainly the headers)
|
|
768
771
|
// Disabling the use of const because of Issue:
|
|
@@ -805,11 +808,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
805
808
|
}
|
|
806
809
|
if (thePayload.sizeExceed && thePayload.sizeExceed.length > 0) {
|
|
807
810
|
// Ensure that we send any discard events for oversize events even when there was no payload to send
|
|
808
|
-
_sendBatchesNotification(thePayload.sizeExceed, 8003 /* SizeLimitExceeded */, thePayload.sendType);
|
|
811
|
+
_sendBatchesNotification(thePayload.sizeExceed, 8003 /* EventBatchNotificationReason.SizeLimitExceeded */, thePayload.sendType);
|
|
809
812
|
}
|
|
810
813
|
if (thePayload.failedEvts && thePayload.failedEvts.length > 0) {
|
|
811
814
|
// Ensure that we send any discard events for events that could not be serialized even when there was no payload to send
|
|
812
|
-
_sendBatchesNotification(thePayload.failedEvts, 8002 /* InvalidEvent */, thePayload.sendType);
|
|
815
|
+
_sendBatchesNotification(thePayload.failedEvts, 8002 /* EventBatchNotificationReason.InvalidEvent */, thePayload.sendType);
|
|
813
816
|
}
|
|
814
817
|
}
|
|
815
818
|
function _addEventCompletedTimings(theEvents, sendEventCompleted) {
|
|
@@ -821,7 +824,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
821
824
|
}
|
|
822
825
|
}
|
|
823
826
|
function _retryRequestIfNeeded(status, headers, thePayload, sendReason) {
|
|
824
|
-
var reason = 9000 /* ResponseFailure */;
|
|
827
|
+
var reason = 9000 /* EventBatchNotificationReason.ResponseFailure */;
|
|
825
828
|
var droppedBatches = null;
|
|
826
829
|
var isRetrying = false;
|
|
827
830
|
var backOffTrans = false;
|
|
@@ -829,9 +832,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
829
832
|
var shouldRetry = true;
|
|
830
833
|
if (typeof status !== strUndefined) {
|
|
831
834
|
if (headers) {
|
|
832
|
-
_clockSkewManager.setClockSkew(headers[
|
|
833
|
-
var killDuration = headers[
|
|
834
|
-
arrForEach(_killSwitch.setKillSwitchTenants(headers[
|
|
835
|
+
_clockSkewManager.setClockSkew(headers[STR_TIME_DELTA_HEADER]);
|
|
836
|
+
var killDuration = headers[STR_KILL_DURATION_HEADER] || headers["kill-duration-seconds"];
|
|
837
|
+
arrForEach(_killSwitch.setKillSwitchTenants(headers[STR_KILL_TOKENS_HEADER], killDuration), function (killToken) {
|
|
835
838
|
arrForEach(thePayload.batches, function (theBatch) {
|
|
836
839
|
if (theBatch.iKey() === killToken) {
|
|
837
840
|
// Make sure we have initialized the array
|
|
@@ -849,7 +852,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
849
852
|
// tslint:disable-next-line:triple-equals
|
|
850
853
|
if (status == 200 || status == 204) {
|
|
851
854
|
// Response was successfully sent
|
|
852
|
-
reason = 200 /* Complete */;
|
|
855
|
+
reason = 200 /* EventBatchNotificationReason.Complete */;
|
|
853
856
|
return;
|
|
854
857
|
}
|
|
855
858
|
if (!retryPolicyShouldRetryForStatus(status) || thePayload.numEvents <= 0) {
|
|
@@ -857,25 +860,25 @@ var HttpManager = /** @class */ (function () {
|
|
|
857
860
|
shouldRetry = false;
|
|
858
861
|
}
|
|
859
862
|
// Derive the notification response from the HttpStatus Code
|
|
860
|
-
reason = 9000 /* ResponseFailure */ + (status % 1000);
|
|
863
|
+
reason = 9000 /* EventBatchNotificationReason.ResponseFailure */ + (status % 1000);
|
|
861
864
|
}
|
|
862
865
|
if (shouldRetry) {
|
|
863
866
|
// The events should be retried -- so change notification to requeue them
|
|
864
|
-
reason = 100 /* RequeueEvents */;
|
|
867
|
+
reason = 100 /* EventBatchNotificationReason.RequeueEvents */;
|
|
865
868
|
var retryCount_1 = thePayload.retryCnt;
|
|
866
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
869
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
867
870
|
// attempt to resend the entire batch
|
|
868
871
|
if (retryCount_1 < maxRequestRetriesBeforeBackoff) {
|
|
869
872
|
isRetrying = true;
|
|
870
873
|
_doAction(function () {
|
|
871
874
|
// try to resend the same batches
|
|
872
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
875
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
873
876
|
// Reduce the outstanding request count (if this was an async request) as we didn't reduce the count
|
|
874
877
|
// previously and we are about to reschedule our retry attempt and we want an attempt to send
|
|
875
878
|
// to occur, it's also required to ensure that a follow up handleRequestFinished() call occurs
|
|
876
879
|
_outstandingRequests--;
|
|
877
880
|
}
|
|
878
|
-
_sendBatches(thePayload.batches, retryCount_1 + 1, thePayload.isTeardown, _isUnloading ? 2 /* SendBeacon */ : thePayload.sendType, 5 /* Retry */);
|
|
881
|
+
_sendBatches(thePayload.batches, retryCount_1 + 1, thePayload.isTeardown, _isUnloading ? 2 /* EventSendType.SendBeacon */ : thePayload.sendType, 5 /* SendRequestReason.Retry */);
|
|
879
882
|
}, _isUnloading, retryPolicyGetMillisToBackoffForRetry(retryCount_1));
|
|
880
883
|
}
|
|
881
884
|
else {
|
|
@@ -883,7 +886,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
883
886
|
if (_isUnloading) {
|
|
884
887
|
// we are unloading so don't try and requeue the events otherwise let the events get requeued and resent during the backoff sending
|
|
885
888
|
// This will also cause the events to be purged based on the priority (if necessary)
|
|
886
|
-
reason = 8001 /* NonRetryableStatus */;
|
|
889
|
+
reason = 8001 /* EventBatchNotificationReason.NonRetryableStatus */;
|
|
887
890
|
}
|
|
888
891
|
}
|
|
889
892
|
}
|
|
@@ -896,7 +899,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
896
899
|
_clockSkewManager.setClockSkew();
|
|
897
900
|
_handleRequestFinished(thePayload, reason, sendReason, backOffTrans);
|
|
898
901
|
}
|
|
899
|
-
_sendBatchesNotification(droppedBatches, 8004 /* KillSwitch */, thePayload.sendType);
|
|
902
|
+
_sendBatchesNotification(droppedBatches, 8004 /* EventBatchNotificationReason.KillSwitch */, thePayload.sendType);
|
|
900
903
|
}
|
|
901
904
|
}
|
|
902
905
|
function _handleRequestFinished(thePayload, batchReason, sendReason, backOffTrans) {
|
|
@@ -905,7 +908,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
905
908
|
// Slow down the transmission requests
|
|
906
909
|
_postManager._backOffTransmission();
|
|
907
910
|
}
|
|
908
|
-
if (batchReason === 200 /* Complete */) {
|
|
911
|
+
if (batchReason === 200 /* EventBatchNotificationReason.Complete */) {
|
|
909
912
|
if (!backOffTrans && !thePayload.isSync) {
|
|
910
913
|
// We have a successful async response, so the lets open the floodgates
|
|
911
914
|
// The reason for checking isSync is to avoid unblocking if beacon send occurred as it
|
|
@@ -918,12 +921,12 @@ var HttpManager = /** @class */ (function () {
|
|
|
918
921
|
_sendBatchesNotification(thePayload.batches, batchReason, thePayload.sendType, true);
|
|
919
922
|
}
|
|
920
923
|
finally {
|
|
921
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
924
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
922
925
|
// we always need to decrement this value otherwise the httpmanager locks up and won't send any more events
|
|
923
926
|
_outstandingRequests--;
|
|
924
927
|
// Don't try to send additional queued events if this is a retry operation as the retried
|
|
925
928
|
// response will eventually call _handleRequestFinished for the retried event
|
|
926
|
-
if (sendReason !== 5 /* Retry */) {
|
|
929
|
+
if (sendReason !== 5 /* SendRequestReason.Retry */) {
|
|
927
930
|
// Try and send any other queued batched events
|
|
928
931
|
_self.sendQueuedRequests(thePayload.sendType, sendReason);
|
|
929
932
|
}
|
|
@@ -990,14 +993,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
990
993
|
responseHandlers[i](responseText);
|
|
991
994
|
}
|
|
992
995
|
catch (e) {
|
|
993
|
-
_throwInternal(
|
|
996
|
+
_throwInternal(_logger, 1 /* eLoggingSeverity.CRITICAL */, 519 /* _eExtendedInternalMessageId.PostResponseHandler */, "Response handler failed: " + e);
|
|
994
997
|
}
|
|
995
998
|
}
|
|
996
999
|
if (responseText) {
|
|
997
1000
|
var response = JSON.parse(responseText);
|
|
998
|
-
if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[
|
|
1001
|
+
if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[STR_MSFPC])) {
|
|
999
1002
|
// Set cookie
|
|
1000
|
-
_cookieMgr.set("MSFPC", response.webResult[
|
|
1003
|
+
_cookieMgr.set("MSFPC", response.webResult[STR_MSFPC], 365 * 86400);
|
|
1001
1004
|
}
|
|
1002
1005
|
}
|
|
1003
1006
|
}
|
|
@@ -1009,14 +1012,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
1009
1012
|
if (theBatches && theBatches.length > 0 && actions) {
|
|
1010
1013
|
var theAction_1 = actions[_getNotificationAction(batchReason)];
|
|
1011
1014
|
if (theAction_1) {
|
|
1012
|
-
var isSyncRequest_1 = sendType !== 0 /* Batched */;
|
|
1015
|
+
var isSyncRequest_1 = sendType !== 0 /* EventSendType.Batched */;
|
|
1013
1016
|
doPerf(_core, function () { return "HttpManager:_sendBatchesNotification"; }, function () {
|
|
1014
1017
|
_doAction(function () {
|
|
1015
1018
|
try {
|
|
1016
1019
|
theAction_1.call(actions, theBatches, batchReason, isSyncRequest_1, sendType);
|
|
1017
1020
|
}
|
|
1018
1021
|
catch (e) {
|
|
1019
|
-
_throwInternal(
|
|
1022
|
+
_throwInternal(_logger, 1 /* eLoggingSeverity.CRITICAL */, 74 /* _eInternalMessageId.NotificationException */, "send request notification failed: " + e);
|
|
1020
1023
|
}
|
|
1021
1024
|
}, sendSync || isSyncRequest_1, 0);
|
|
1022
1025
|
}, function () { return ({ batches: _createDebugBatches(theBatches), reason: batchReason, isSync: isSyncRequest_1, sendSync: sendSync, sendType: sendType }); }, !isSyncRequest_1);
|
|
@@ -1026,15 +1029,15 @@ var HttpManager = /** @class */ (function () {
|
|
|
1026
1029
|
function _getNotificationAction(reason) {
|
|
1027
1030
|
var action = _eventActionMap[reason];
|
|
1028
1031
|
if (!isValueAssigned(action)) {
|
|
1029
|
-
action =
|
|
1030
|
-
if (reason >= 9000 /* ResponseFailure */ && reason <= 9999 /* ResponseFailureMax */) {
|
|
1031
|
-
action =
|
|
1032
|
+
action = STR_OTHER;
|
|
1033
|
+
if (reason >= 9000 /* EventBatchNotificationReason.ResponseFailure */ && reason <= 9999 /* EventBatchNotificationReason.ResponseFailureMax */) {
|
|
1034
|
+
action = STR_RESPONSE_FAIL;
|
|
1032
1035
|
}
|
|
1033
|
-
else if (reason >= 8000 /* EventsDropped */ && reason <= 8999 /* EventsDroppedMax */) {
|
|
1034
|
-
action =
|
|
1036
|
+
else if (reason >= 8000 /* EventBatchNotificationReason.EventsDropped */ && reason <= 8999 /* EventBatchNotificationReason.EventsDroppedMax */) {
|
|
1037
|
+
action = STR_DROPPED;
|
|
1035
1038
|
}
|
|
1036
|
-
else if (reason >= 1000 /* SendingUndefined */ && reason <= 1999 /* SendingEventMax */) {
|
|
1037
|
-
action =
|
|
1039
|
+
else if (reason >= 1000 /* EventBatchNotificationReason.SendingUndefined */ && reason <= 1999 /* EventBatchNotificationReason.SendingEventMax */) {
|
|
1040
|
+
action = STR_SENDING;
|
|
1038
1041
|
}
|
|
1039
1042
|
}
|
|
1040
1043
|
return action;
|
|
@@ -1053,6 +1056,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
1053
1056
|
// Removed Stub for HttpManager.prototype.pause.
|
|
1054
1057
|
// Removed Stub for HttpManager.prototype.resume.
|
|
1055
1058
|
// Removed Stub for HttpManager.prototype.sendSynchronousBatch.
|
|
1059
|
+
// This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
|
|
1060
|
+
// non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
|
|
1061
|
+
// this will be removed when ES3 support is dropped.
|
|
1062
|
+
HttpManager.__ieDyn=1;
|
|
1063
|
+
|
|
1056
1064
|
return HttpManager;
|
|
1057
1065
|
}());
|
|
1058
1066
|
export { HttpManager };
|