@microsoft/1ds-post-js 3.2.0 → 3.2.3
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 +1 -1
- package/bundle/{ms.post-3.2.0.gbl.js → ms.post-3.2.3.gbl.js} +1022 -986
- package/bundle/ms.post-3.2.3.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.3.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.3.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.3.integrity.json +46 -0
- package/bundle/{ms.post-3.2.0.js → ms.post-3.2.3.js} +1022 -986
- package/bundle/ms.post-3.2.3.js.map +1 -0
- package/bundle/ms.post-3.2.3.min.js +7 -0
- package/bundle/ms.post-3.2.3.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +1021 -985
- 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 +1021 -985
- package/bundle/ms.post.js.map +1 -1
- package/bundle/ms.post.min.js +2 -2
- package/bundle/ms.post.min.js.map +1 -1
- package/dist/ms.post.js +56 -27
- package/dist/ms.post.js.map +1 -1
- package/dist/ms.post.min.js +2 -2
- package/dist/ms.post.min.js.map +1 -1
- package/dist-esm/src/BatchNotificationActions.js +1 -1
- package/dist-esm/src/ClockSkewManager.js +1 -1
- package/dist-esm/src/Constants.js +1 -1
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.js +1 -1
- package/dist-esm/src/HttpManager.d.ts +2 -1
- package/dist-esm/src/HttpManager.js +67 -67
- 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.d.ts +2 -5
- package/dist-esm/src/PostChannel.js +84 -66
- 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/TimeoutOverrideWrapper.d.ts +18 -0
- package/dist-esm/src/TimeoutOverrideWrapper.js +28 -0
- package/dist-esm/src/TimeoutOverrideWrapper.js.map +1 -0
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +3 -3
- package/src/HttpManager.ts +5 -4
- package/src/PostChannel.ts +59 -27
- package/src/TimeoutOverrideWrapper.ts +29 -0
- package/bundle/ms.post-3.2.0.gbl.js.map +0 -1
- package/bundle/ms.post-3.2.0.gbl.min.js +0 -7
- package/bundle/ms.post-3.2.0.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.2.0.integrity.json +0 -46
- package/bundle/ms.post-3.2.0.js.map +0 -1
- package/bundle/ms.post-3.2.0.min.js +0 -7
- package/bundle/ms.post-3.2.0.min.js.map +0 -1
|
@@ -8,6 +8,7 @@ import { IXHROverride, IPostChannel, PayloadPreprocessorFunction, PayloadListene
|
|
|
8
8
|
import { BatchNotificationActions } from "./BatchNotificationActions";
|
|
9
9
|
import { EventBatch } from "./EventBatch";
|
|
10
10
|
import { IChannelConfiguration } from "./Index";
|
|
11
|
+
import { ITimeoutOverrideWrapper } from "./TimeoutOverrideWrapper";
|
|
11
12
|
/**
|
|
12
13
|
* Class managing the sending of requests.
|
|
13
14
|
*/
|
|
@@ -19,7 +20,7 @@ export declare class HttpManager {
|
|
|
19
20
|
* @constructor
|
|
20
21
|
* @param requestQueue - The queue that contains the requests to be sent.
|
|
21
22
|
*/
|
|
22
|
-
constructor(maxEventsPerBatch: number, maxConnections: number, maxRequestRetriesBeforeBackoff: number, actions: BatchNotificationActions);
|
|
23
|
+
constructor(maxEventsPerBatch: number, maxConnections: number, maxRequestRetriesBeforeBackoff: number, actions: BatchNotificationActions, timeoutOverride: ITimeoutOverrideWrapper);
|
|
23
24
|
/**
|
|
24
25
|
* @constructor
|
|
25
26
|
* @param requestQueue - The queue that contains the requests to be sent.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.3
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -22,11 +22,11 @@ var _noResponseQs = "&" + strNoResponseBody + "=true";
|
|
|
22
22
|
* Identifies the default notification reason to the action names
|
|
23
23
|
*/
|
|
24
24
|
var _eventActionMap = (_a = {},
|
|
25
|
-
_a[1 /* Paused */] = strRequeue,
|
|
26
|
-
_a[100 /* RequeueEvents */] = strRequeue,
|
|
27
|
-
_a[200 /* Complete */] = "sent",
|
|
28
|
-
_a[8004 /* KillSwitch */] = strDropped,
|
|
29
|
-
_a[8003 /* SizeLimitExceeded */] = strDropped,
|
|
25
|
+
_a[1 /* EventBatchNotificationReason.Paused */] = strRequeue,
|
|
26
|
+
_a[100 /* EventBatchNotificationReason.RequeueEvents */] = strRequeue,
|
|
27
|
+
_a[200 /* EventBatchNotificationReason.Complete */] = "sent",
|
|
28
|
+
_a[8004 /* EventBatchNotificationReason.KillSwitch */] = strDropped,
|
|
29
|
+
_a[8003 /* EventBatchNotificationReason.SizeLimitExceeded */] = strDropped,
|
|
30
30
|
_a);
|
|
31
31
|
var _collectorQsHeaders = {};
|
|
32
32
|
var _collectorHeaderToQs = {};
|
|
@@ -89,7 +89,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
89
89
|
* @constructor
|
|
90
90
|
* @param requestQueue - The queue that contains the requests to be sent.
|
|
91
91
|
*/
|
|
92
|
-
function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions) {
|
|
92
|
+
function HttpManager(maxEventsPerBatch, maxConnections, maxRequestRetriesBeforeBackoff, actions, timeoutOverride) {
|
|
93
93
|
this._responseHandlers = [];
|
|
94
94
|
var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
|
|
95
95
|
var _killSwitch = new EVTKillSwitch();
|
|
@@ -147,11 +147,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
147
147
|
var theTransports = [];
|
|
148
148
|
if (isReactNative()) {
|
|
149
149
|
// Use Fetch or XDR/XHR
|
|
150
|
-
theTransports = [2 /* Fetch */, 1 /* Xhr */];
|
|
150
|
+
theTransports = [2 /* TransportType.Fetch */, 1 /* TransportType.Xhr */];
|
|
151
151
|
}
|
|
152
152
|
else {
|
|
153
153
|
// Use XDR/XHR, Fetch or beacons
|
|
154
|
-
theTransports = [1 /* Xhr */, 2 /* Fetch */, 3 /* Beacon */];
|
|
154
|
+
theTransports = [1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */];
|
|
155
155
|
}
|
|
156
156
|
// Prefix any user requested transport(s) values
|
|
157
157
|
var configTransports = channelConfig.transports;
|
|
@@ -170,20 +170,20 @@ var HttpManager = /** @class */ (function () {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
_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),
|
|
173
|
+
_a[0 /* EventSendType.Batched */] = httpInterface,
|
|
174
|
+
_a[1 /* EventSendType.Synchronous */] = syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], true),
|
|
175
|
+
_a[2 /* EventSendType.SendBeacon */] = beaconHttpInterface || _getSenderInterface([3 /* TransportType.Beacon */, 2 /* TransportType.Fetch */], true) || syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */], true),
|
|
176
|
+
_a[3 /* EventSendType.SyncFetch */] = fetchSyncHttpInterface || _getSenderInterface([2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], true) || syncHttpInterface || _getSenderInterface([1 /* TransportType.Xhr */], true),
|
|
177
177
|
_a);
|
|
178
178
|
};
|
|
179
179
|
// Special internal method to allow the DebugPlugin to hook embedded objects
|
|
180
180
|
function _getSenderInterface(transports, syncSupport) {
|
|
181
|
-
var transportType = 0 /* NotSet */;
|
|
181
|
+
var transportType = 0 /* TransportType.NotSet */;
|
|
182
182
|
var sendPostFunc = null;
|
|
183
183
|
var lp = 0;
|
|
184
184
|
while (sendPostFunc == null && lp < transports.length) {
|
|
185
185
|
transportType = transports[lp];
|
|
186
|
-
if (transportType === 1 /* Xhr */) {
|
|
186
|
+
if (transportType === 1 /* TransportType.Xhr */) {
|
|
187
187
|
if (useXDomainRequest()) {
|
|
188
188
|
sendPostFunc = _xdrSendPost;
|
|
189
189
|
}
|
|
@@ -191,10 +191,10 @@ var HttpManager = /** @class */ (function () {
|
|
|
191
191
|
sendPostFunc = _xhrSendPost;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
else if (transportType === 2 /* Fetch */ && isFetchSupported(syncSupport)) {
|
|
194
|
+
else if (transportType === 2 /* TransportType.Fetch */ && isFetchSupported(syncSupport)) {
|
|
195
195
|
sendPostFunc = _fetchSendPost;
|
|
196
196
|
}
|
|
197
|
-
else if (_useBeacons && transportType === 3 /* Beacon */ && isBeaconsSupported()) {
|
|
197
|
+
else if (_useBeacons && transportType === 3 /* TransportType.Beacon */ && isBeaconsSupported()) {
|
|
198
198
|
sendPostFunc = _beaconSendPost;
|
|
199
199
|
}
|
|
200
200
|
lp++;
|
|
@@ -209,7 +209,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
209
209
|
return null;
|
|
210
210
|
}
|
|
211
211
|
_self["_getDbgPlgTargets"] = function () {
|
|
212
|
-
return [_sendInterfaces[0 /* Batched */], _killSwitch, _serializer, _sendInterfaces];
|
|
212
|
+
return [_sendInterfaces[0 /* EventSendType.Batched */], _killSwitch, _serializer, _sendInterfaces];
|
|
213
213
|
};
|
|
214
214
|
function _xdrSendPost(payload, oncomplete, sync) {
|
|
215
215
|
// It doesn't support custom headers, so no action is taken with current requestHeaders
|
|
@@ -240,7 +240,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
240
240
|
xdr.send(payload.data);
|
|
241
241
|
}
|
|
242
242
|
else {
|
|
243
|
-
|
|
243
|
+
timeoutOverride.set(function () {
|
|
244
244
|
xdr.send(payload.data);
|
|
245
245
|
}, 0);
|
|
246
246
|
}
|
|
@@ -258,7 +258,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
258
258
|
_a);
|
|
259
259
|
if (sync) {
|
|
260
260
|
requestInit.keepalive = true;
|
|
261
|
-
if (payload._sendReason === 2 /* Unload */) {
|
|
261
|
+
if (payload._sendReason === 2 /* SendRequestReason.Unload */) {
|
|
262
262
|
// As a sync request (during unload), it is unlikely that we will get a chance to process the response so
|
|
263
263
|
// just like beacon send assume that the events have been accepted and processed
|
|
264
264
|
ignoreResponse = true;
|
|
@@ -306,7 +306,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
306
306
|
}
|
|
307
307
|
if (!responseHandled && payload.timeout > 0) {
|
|
308
308
|
// Simulate timeout
|
|
309
|
-
|
|
309
|
+
timeoutOverride.set(function () {
|
|
310
310
|
if (!responseHandled) {
|
|
311
311
|
// Assume a 500 response (which will cause a retry)
|
|
312
312
|
responseHandled = true;
|
|
@@ -370,7 +370,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
370
370
|
oncomplete(status, headers, response);
|
|
371
371
|
}
|
|
372
372
|
catch (e) {
|
|
373
|
-
_throwInternal(_postManager.diagLog(), 2 /* WARNING */, 518 /* SendPostOnCompleteFailure */, dumpObj(e));
|
|
373
|
+
_throwInternal(_postManager.diagLog(), 2 /* eLoggingSeverity.WARNING */, 518 /* _eExtendedInternalMessageId.SendPostOnCompleteFailure */, dumpObj(e));
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
function _beaconSendPost(payload, oncomplete, sync) {
|
|
@@ -401,7 +401,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
401
401
|
droppedBatches_1.push(theBatch.split(0));
|
|
402
402
|
}
|
|
403
403
|
});
|
|
404
|
-
_sendBatchesNotification(droppedBatches_1, 8003 /* SizeLimitExceeded */, thePayload.sendType, true);
|
|
404
|
+
_sendBatchesNotification(droppedBatches_1, 8003 /* EventBatchNotificationReason.SizeLimitExceeded */, thePayload.sendType, true);
|
|
405
405
|
}
|
|
406
406
|
else {
|
|
407
407
|
status = 0;
|
|
@@ -418,11 +418,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
418
418
|
}
|
|
419
419
|
function _isBeaconPayload(sendType) {
|
|
420
420
|
// 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 */;
|
|
421
|
+
return sendType === 2 /* EventSendType.SendBeacon */ || sendType === 3 /* EventSendType.SyncFetch */;
|
|
422
422
|
}
|
|
423
423
|
function _adjustSendType(sendType) {
|
|
424
424
|
if (_isUnloading && _isBeaconPayload(sendType)) {
|
|
425
|
-
sendType = 2 /* SendBeacon */;
|
|
425
|
+
sendType = 2 /* EventSendType.SendBeacon */;
|
|
426
426
|
}
|
|
427
427
|
return sendType;
|
|
428
428
|
}
|
|
@@ -443,14 +443,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
443
443
|
};
|
|
444
444
|
_self.sendQueuedRequests = function (sendType, sendReason) {
|
|
445
445
|
if (isUndefined(sendType)) {
|
|
446
|
-
sendType = 0 /* Batched */;
|
|
446
|
+
sendType = 0 /* EventSendType.Batched */;
|
|
447
447
|
}
|
|
448
448
|
if (_isUnloading) {
|
|
449
449
|
sendType = _adjustSendType(sendType);
|
|
450
|
-
sendReason = 2 /* Unload */;
|
|
450
|
+
sendReason = 2 /* SendRequestReason.Unload */;
|
|
451
451
|
}
|
|
452
452
|
if (_canSendPayload(_batchQueue, sendType, 0)) {
|
|
453
|
-
_sendBatches(_clearQueue(), 0, false, sendType, sendReason || 0 /* Undefined */);
|
|
453
|
+
_sendBatches(_clearQueue(), 0, false, sendType, sendReason || 0 /* SendRequestReason.Undefined */);
|
|
454
454
|
}
|
|
455
455
|
};
|
|
456
456
|
_self.isCompletelyIdle = function () {
|
|
@@ -475,7 +475,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
475
475
|
*/
|
|
476
476
|
_self.teardown = function () {
|
|
477
477
|
if (_batchQueue.length > 0) {
|
|
478
|
-
_sendBatches(_clearQueue(), 0, true, 2 /* SendBeacon */, 2 /* Unload */);
|
|
478
|
+
_sendBatches(_clearQueue(), 0, true, 2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
481
|
/**
|
|
@@ -489,7 +489,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
489
489
|
*/
|
|
490
490
|
_self.resume = function () {
|
|
491
491
|
_paused = false;
|
|
492
|
-
_self.sendQueuedRequests(0 /* Batched */, 4 /* Resumed */);
|
|
492
|
+
_self.sendQueuedRequests(0 /* EventSendType.Batched */, 4 /* SendRequestReason.Resumed */);
|
|
493
493
|
};
|
|
494
494
|
/**
|
|
495
495
|
* Sends a request synchronously to the Aria collector. This api is used to send
|
|
@@ -505,14 +505,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
505
505
|
// Increment active connection since we are still going to use a connection to send the request.
|
|
506
506
|
if (batch && batch.count() > 0) {
|
|
507
507
|
if (isNullOrUndefined(sendType)) {
|
|
508
|
-
sendType = 1 /* Synchronous */;
|
|
508
|
+
sendType = 1 /* EventSendType.Synchronous */;
|
|
509
509
|
}
|
|
510
510
|
if (_isUnloading) {
|
|
511
511
|
sendType = _adjustSendType(sendType);
|
|
512
|
-
sendReason = 2 /* Unload */;
|
|
512
|
+
sendReason = 2 /* SendRequestReason.Unload */;
|
|
513
513
|
}
|
|
514
514
|
// For sync requests we will not wait for the clock skew.
|
|
515
|
-
_sendBatches([batch], 0, false, sendType, sendReason || 0 /* Undefined */);
|
|
515
|
+
_sendBatches([batch], 0, false, sendType, sendReason || 0 /* SendRequestReason.Undefined */);
|
|
516
516
|
}
|
|
517
517
|
};
|
|
518
518
|
function _hasIdleConnection() {
|
|
@@ -528,7 +528,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
528
528
|
if (theBatches && theBatches.length > 0 && !_paused && _sendInterfaces[sendType] && _serializer) {
|
|
529
529
|
// Always attempt to send synchronous events don't wait for idle or clockSkew
|
|
530
530
|
// and don't block retry requests if clockSkew is not yet set
|
|
531
|
-
result = (sendType !== 0 /* Batched */) || (_hasIdleConnection() && (retryCnt > 0 || _clockSkewManager.allowRequestSending()));
|
|
531
|
+
result = (sendType !== 0 /* EventSendType.Batched */) || (_hasIdleConnection() && (retryCnt > 0 || _clockSkewManager.allowRequestSending()));
|
|
532
532
|
}
|
|
533
533
|
return result;
|
|
534
534
|
}
|
|
@@ -550,14 +550,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
550
550
|
return;
|
|
551
551
|
}
|
|
552
552
|
if (_paused) {
|
|
553
|
-
_sendBatchesNotification(theBatches, 1 /* Paused */, sendType);
|
|
553
|
+
_sendBatchesNotification(theBatches, 1 /* EventBatchNotificationReason.Paused */, sendType);
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
556
|
// Make sure that if we are unloading the sendType is a supported version
|
|
557
557
|
sendType = _adjustSendType(sendType);
|
|
558
558
|
try {
|
|
559
559
|
var orgBatches_1 = theBatches;
|
|
560
|
-
var isSynchronous_1 = sendType !== 0 /* Batched */;
|
|
560
|
+
var isSynchronous_1 = sendType !== 0 /* EventSendType.Batched */;
|
|
561
561
|
doPerf(_core, function () { return "HttpManager:_sendBatches"; }, function (perfEvt) {
|
|
562
562
|
if (perfEvt) {
|
|
563
563
|
// Perf Monitoring is enabled, so create a "Quick" copy of the original batches so we still report
|
|
@@ -569,9 +569,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
569
569
|
var droppedBatches = [];
|
|
570
570
|
var thePayload = null;
|
|
571
571
|
var serializationStart = getTime();
|
|
572
|
-
var sendInterface = _sendInterfaces[sendType] || (isSynchronous_1 ? _sendInterfaces[1 /* Synchronous */] : _sendInterfaces[0 /* Batched */]);
|
|
572
|
+
var sendInterface = _sendInterfaces[sendType] || (isSynchronous_1 ? _sendInterfaces[1 /* EventSendType.Synchronous */] : _sendInterfaces[0 /* EventSendType.Batched */]);
|
|
573
573
|
// Sync Fetch has the same payload limitation as sendBeacon -- 64kb limit
|
|
574
|
-
var isBeaconTransport = (_isUnloading || _isBeaconPayload(sendType) || (sendInterface && sendInterface._transport === 3 /* Beacon */)) && _canUseSendBeaconApi();
|
|
574
|
+
var isBeaconTransport = (_isUnloading || _isBeaconPayload(sendType) || (sendInterface && sendInterface._transport === 3 /* TransportType.Beacon */)) && _canUseSendBeaconApi();
|
|
575
575
|
while (_canSendPayload(theBatches, sendType, retryCount)) {
|
|
576
576
|
var theBatch = theBatches.shift();
|
|
577
577
|
if (theBatch && theBatch.count() > 0) {
|
|
@@ -609,11 +609,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
609
609
|
_batchQueue = theBatches.concat(_batchQueue);
|
|
610
610
|
}
|
|
611
611
|
// Now send notification about any dropped events
|
|
612
|
-
_sendBatchesNotification(droppedBatches, 8004 /* KillSwitch */, sendType);
|
|
612
|
+
_sendBatchesNotification(droppedBatches, 8004 /* EventBatchNotificationReason.KillSwitch */, sendType);
|
|
613
613
|
}, function () { return ({ batches: _createDebugBatches(orgBatches_1), retryCount: retryCount, isTeardown: isTeardown, isSynchronous: isSynchronous_1, sendReason: sendReason, useSendBeacon: _isBeaconPayload(sendType), sendType: sendType }); }, !isSynchronous_1);
|
|
614
614
|
}
|
|
615
615
|
catch (ex) {
|
|
616
|
-
_throwInternal(_postManager.diagLog(), 2 /* WARNING */, 48 /* CannotSerializeObject */, "Unexpected Exception sending batch: " + dumpObj(ex));
|
|
616
|
+
_throwInternal(_postManager.diagLog(), 2 /* eLoggingSeverity.WARNING */, 48 /* _eInternalMessageId.CannotSerializeObject */, "Unexpected Exception sending batch: " + dumpObj(ex));
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
function _buildRequestDetails(thePayload, useHeaders) {
|
|
@@ -681,12 +681,12 @@ var HttpManager = /** @class */ (function () {
|
|
|
681
681
|
var useSendHook_1 = !!_self.sendHook;
|
|
682
682
|
var sendInterface_1 = _sendInterfaces[thePayload.sendType];
|
|
683
683
|
// 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;
|
|
684
|
+
if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 /* SendRequestReason.Unload */) {
|
|
685
|
+
sendInterface_1 = _sendInterfaces[2 /* EventSendType.SendBeacon */] || _sendInterfaces[3 /* EventSendType.SyncFetch */] || sendInterface_1;
|
|
686
686
|
}
|
|
687
687
|
var useHeaders_1 = _useHeaders;
|
|
688
688
|
// 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 */) {
|
|
689
|
+
if (thePayload.isBeacon || sendInterface_1._transport === 3 /* TransportType.Beacon */) {
|
|
690
690
|
useHeaders_1 = false;
|
|
691
691
|
}
|
|
692
692
|
var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
|
|
@@ -709,7 +709,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
709
709
|
}
|
|
710
710
|
}
|
|
711
711
|
// Note: always sending this notification in a synchronous manner.
|
|
712
|
-
_sendBatchesNotification(thePayload.batches, (1000 /* SendingUndefined */ + (sendReason || 0 /* Undefined */)), thePayload.sendType, true);
|
|
712
|
+
_sendBatchesNotification(thePayload.batches, (1000 /* EventBatchNotificationReason.SendingUndefined */ + (sendReason || 0 /* SendRequestReason.Undefined */)), thePayload.sendType, true);
|
|
713
713
|
// Disabling the use of const because of Issue:
|
|
714
714
|
// - Task 9227844: [1DS] Some environments and packagers automatically "freeze" objects which are defined as const which causes any mutations to throw
|
|
715
715
|
// eslint-disable-next-line prefer-const
|
|
@@ -758,11 +758,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
758
758
|
}
|
|
759
759
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend.sender"; }, function () {
|
|
760
760
|
if (sender) {
|
|
761
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
761
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
762
762
|
_outstandingRequests++;
|
|
763
763
|
}
|
|
764
764
|
// 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 */) {
|
|
765
|
+
if (useSendHook_1 && !thePayload.isBeacon && sendInterface_1._transport !== 3 /* TransportType.Beacon */) {
|
|
766
766
|
// Create a new IPayloadData that is sent into the hook method, so that the hook method
|
|
767
767
|
// can't change the object references to the orgPayloadData (it can still change the content -- mainly the headers)
|
|
768
768
|
// Disabling the use of const because of Issue:
|
|
@@ -805,11 +805,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
805
805
|
}
|
|
806
806
|
if (thePayload.sizeExceed && thePayload.sizeExceed.length > 0) {
|
|
807
807
|
// 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);
|
|
808
|
+
_sendBatchesNotification(thePayload.sizeExceed, 8003 /* EventBatchNotificationReason.SizeLimitExceeded */, thePayload.sendType);
|
|
809
809
|
}
|
|
810
810
|
if (thePayload.failedEvts && thePayload.failedEvts.length > 0) {
|
|
811
811
|
// 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);
|
|
812
|
+
_sendBatchesNotification(thePayload.failedEvts, 8002 /* EventBatchNotificationReason.InvalidEvent */, thePayload.sendType);
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
function _addEventCompletedTimings(theEvents, sendEventCompleted) {
|
|
@@ -821,7 +821,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
823
|
function _retryRequestIfNeeded(status, headers, thePayload, sendReason) {
|
|
824
|
-
var reason = 9000 /* ResponseFailure */;
|
|
824
|
+
var reason = 9000 /* EventBatchNotificationReason.ResponseFailure */;
|
|
825
825
|
var droppedBatches = null;
|
|
826
826
|
var isRetrying = false;
|
|
827
827
|
var backOffTrans = false;
|
|
@@ -849,7 +849,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
849
849
|
// tslint:disable-next-line:triple-equals
|
|
850
850
|
if (status == 200 || status == 204) {
|
|
851
851
|
// Response was successfully sent
|
|
852
|
-
reason = 200 /* Complete */;
|
|
852
|
+
reason = 200 /* EventBatchNotificationReason.Complete */;
|
|
853
853
|
return;
|
|
854
854
|
}
|
|
855
855
|
if (!retryPolicyShouldRetryForStatus(status) || thePayload.numEvents <= 0) {
|
|
@@ -857,25 +857,25 @@ var HttpManager = /** @class */ (function () {
|
|
|
857
857
|
shouldRetry = false;
|
|
858
858
|
}
|
|
859
859
|
// Derive the notification response from the HttpStatus Code
|
|
860
|
-
reason = 9000 /* ResponseFailure */ + (status % 1000);
|
|
860
|
+
reason = 9000 /* EventBatchNotificationReason.ResponseFailure */ + (status % 1000);
|
|
861
861
|
}
|
|
862
862
|
if (shouldRetry) {
|
|
863
863
|
// The events should be retried -- so change notification to requeue them
|
|
864
|
-
reason = 100 /* RequeueEvents */;
|
|
864
|
+
reason = 100 /* EventBatchNotificationReason.RequeueEvents */;
|
|
865
865
|
var retryCount_1 = thePayload.retryCnt;
|
|
866
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
866
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
867
867
|
// attempt to resend the entire batch
|
|
868
868
|
if (retryCount_1 < maxRequestRetriesBeforeBackoff) {
|
|
869
869
|
isRetrying = true;
|
|
870
870
|
_doAction(function () {
|
|
871
871
|
// try to resend the same batches
|
|
872
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
872
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
873
873
|
// Reduce the outstanding request count (if this was an async request) as we didn't reduce the count
|
|
874
874
|
// previously and we are about to reschedule our retry attempt and we want an attempt to send
|
|
875
875
|
// to occur, it's also required to ensure that a follow up handleRequestFinished() call occurs
|
|
876
876
|
_outstandingRequests--;
|
|
877
877
|
}
|
|
878
|
-
_sendBatches(thePayload.batches, retryCount_1 + 1, thePayload.isTeardown, _isUnloading ? 2 /* SendBeacon */ : thePayload.sendType, 5 /* Retry */);
|
|
878
|
+
_sendBatches(thePayload.batches, retryCount_1 + 1, thePayload.isTeardown, _isUnloading ? 2 /* EventSendType.SendBeacon */ : thePayload.sendType, 5 /* SendRequestReason.Retry */);
|
|
879
879
|
}, _isUnloading, retryPolicyGetMillisToBackoffForRetry(retryCount_1));
|
|
880
880
|
}
|
|
881
881
|
else {
|
|
@@ -883,7 +883,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
883
883
|
if (_isUnloading) {
|
|
884
884
|
// we are unloading so don't try and requeue the events otherwise let the events get requeued and resent during the backoff sending
|
|
885
885
|
// This will also cause the events to be purged based on the priority (if necessary)
|
|
886
|
-
reason = 8001 /* NonRetryableStatus */;
|
|
886
|
+
reason = 8001 /* EventBatchNotificationReason.NonRetryableStatus */;
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
}
|
|
@@ -896,7 +896,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
896
896
|
_clockSkewManager.setClockSkew();
|
|
897
897
|
_handleRequestFinished(thePayload, reason, sendReason, backOffTrans);
|
|
898
898
|
}
|
|
899
|
-
_sendBatchesNotification(droppedBatches, 8004 /* KillSwitch */, thePayload.sendType);
|
|
899
|
+
_sendBatchesNotification(droppedBatches, 8004 /* EventBatchNotificationReason.KillSwitch */, thePayload.sendType);
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
902
|
function _handleRequestFinished(thePayload, batchReason, sendReason, backOffTrans) {
|
|
@@ -905,7 +905,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
905
905
|
// Slow down the transmission requests
|
|
906
906
|
_postManager._backOffTransmission();
|
|
907
907
|
}
|
|
908
|
-
if (batchReason === 200 /* Complete */) {
|
|
908
|
+
if (batchReason === 200 /* EventBatchNotificationReason.Complete */) {
|
|
909
909
|
if (!backOffTrans && !thePayload.isSync) {
|
|
910
910
|
// We have a successful async response, so the lets open the floodgates
|
|
911
911
|
// The reason for checking isSync is to avoid unblocking if beacon send occurred as it
|
|
@@ -918,12 +918,12 @@ var HttpManager = /** @class */ (function () {
|
|
|
918
918
|
_sendBatchesNotification(thePayload.batches, batchReason, thePayload.sendType, true);
|
|
919
919
|
}
|
|
920
920
|
finally {
|
|
921
|
-
if (thePayload.sendType === 0 /* Batched */) {
|
|
921
|
+
if (thePayload.sendType === 0 /* EventSendType.Batched */) {
|
|
922
922
|
// we always need to decrement this value otherwise the httpmanager locks up and won't send any more events
|
|
923
923
|
_outstandingRequests--;
|
|
924
924
|
// Don't try to send additional queued events if this is a retry operation as the retried
|
|
925
925
|
// response will eventually call _handleRequestFinished for the retried event
|
|
926
|
-
if (sendReason !== 5 /* Retry */) {
|
|
926
|
+
if (sendReason !== 5 /* SendRequestReason.Retry */) {
|
|
927
927
|
// Try and send any other queued batched events
|
|
928
928
|
_self.sendQueuedRequests(thePayload.sendType, sendReason);
|
|
929
929
|
}
|
|
@@ -945,7 +945,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
945
945
|
cb();
|
|
946
946
|
}
|
|
947
947
|
else {
|
|
948
|
-
|
|
948
|
+
timeoutOverride.set(cb, interval);
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
951
|
/**
|
|
@@ -990,7 +990,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
990
990
|
responseHandlers[i](responseText);
|
|
991
991
|
}
|
|
992
992
|
catch (e) {
|
|
993
|
-
_throwInternal(_postManager.diagLog(), 1 /* CRITICAL */, 519 /* PostResponseHandler */, "Response handler failed: " + e);
|
|
993
|
+
_throwInternal(_postManager.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 519 /* _eExtendedInternalMessageId.PostResponseHandler */, "Response handler failed: " + e);
|
|
994
994
|
}
|
|
995
995
|
}
|
|
996
996
|
if (responseText) {
|
|
@@ -1009,14 +1009,14 @@ var HttpManager = /** @class */ (function () {
|
|
|
1009
1009
|
if (theBatches && theBatches.length > 0 && actions) {
|
|
1010
1010
|
var theAction_1 = actions[_getNotificationAction(batchReason)];
|
|
1011
1011
|
if (theAction_1) {
|
|
1012
|
-
var isSyncRequest_1 = sendType !== 0 /* Batched */;
|
|
1012
|
+
var isSyncRequest_1 = sendType !== 0 /* EventSendType.Batched */;
|
|
1013
1013
|
doPerf(_core, function () { return "HttpManager:_sendBatchesNotification"; }, function () {
|
|
1014
1014
|
_doAction(function () {
|
|
1015
1015
|
try {
|
|
1016
1016
|
theAction_1.call(actions, theBatches, batchReason, isSyncRequest_1, sendType);
|
|
1017
1017
|
}
|
|
1018
1018
|
catch (e) {
|
|
1019
|
-
_throwInternal(_postManager.diagLog(), 1 /* CRITICAL */, 74 /* NotificationException */, "send request notification failed: " + e);
|
|
1019
|
+
_throwInternal(_postManager.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 74 /* _eInternalMessageId.NotificationException */, "send request notification failed: " + e);
|
|
1020
1020
|
}
|
|
1021
1021
|
}, sendSync || isSyncRequest_1, 0);
|
|
1022
1022
|
}, function () { return ({ batches: _createDebugBatches(theBatches), reason: batchReason, isSync: isSyncRequest_1, sendSync: sendSync, sendType: sendType }); }, !isSyncRequest_1);
|
|
@@ -1027,13 +1027,13 @@ var HttpManager = /** @class */ (function () {
|
|
|
1027
1027
|
var action = _eventActionMap[reason];
|
|
1028
1028
|
if (!isValueAssigned(action)) {
|
|
1029
1029
|
action = strOther;
|
|
1030
|
-
if (reason >= 9000 /* ResponseFailure */ && reason <= 9999 /* ResponseFailureMax */) {
|
|
1030
|
+
if (reason >= 9000 /* EventBatchNotificationReason.ResponseFailure */ && reason <= 9999 /* EventBatchNotificationReason.ResponseFailureMax */) {
|
|
1031
1031
|
action = strResponseFail;
|
|
1032
1032
|
}
|
|
1033
|
-
else if (reason >= 8000 /* EventsDropped */ && reason <= 8999 /* EventsDroppedMax */) {
|
|
1033
|
+
else if (reason >= 8000 /* EventBatchNotificationReason.EventsDropped */ && reason <= 8999 /* EventBatchNotificationReason.EventsDroppedMax */) {
|
|
1034
1034
|
action = strDropped;
|
|
1035
1035
|
}
|
|
1036
|
-
else if (reason >= 1000 /* SendingUndefined */ && reason <= 1999 /* SendingEventMax */) {
|
|
1036
|
+
else if (reason >= 1000 /* EventBatchNotificationReason.SendingUndefined */ && reason <= 1999 /* EventBatchNotificationReason.SendingEventMax */) {
|
|
1037
1037
|
action = strSending;
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|