@microsoft/1ds-post-js 3.2.3 → 3.2.6
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.3.gbl.js → ms.post-3.2.6.gbl.js} +507 -438
- package/bundle/ms.post-3.2.6.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.6.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.6.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.6.integrity.json +46 -0
- package/bundle/{ms.post-3.2.3.js → ms.post-3.2.6.js} +507 -438
- package/bundle/ms.post-3.2.6.js.map +1 -0
- package/bundle/ms.post-3.2.6.min.js +7 -0
- package/bundle/ms.post-3.2.6.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +506 -437
- 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 +506 -437
- 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 +197 -187
- 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 +62 -54
- 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 +16 -10
- 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 +16 -20
- package/src/Serializer.ts +7 -5
- package/src/TimeoutOverrideWrapper.ts +6 -6
- package/bundle/ms.post-3.2.3.gbl.js.map +0 -1
- package/bundle/ms.post-3.2.3.gbl.min.js +0 -7
- package/bundle/ms.post-3.2.3.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.2.3.integrity.json +0 -46
- package/bundle/ms.post-3.2.3.js.map +0 -1
- package/bundle/ms.post-3.2.3.min.js +0 -7
- package/bundle/ms.post-3.2.3.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.6
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -81,6 +81,11 @@ var ClockSkewManager = /** @class */ (function () {
|
|
|
81
81
|
// Removed Stub for ClockSkewManager.prototype.shouldAddClockSkewHeaders.
|
|
82
82
|
// Removed Stub for ClockSkewManager.prototype.getClockSkewHeaderValue.
|
|
83
83
|
// Removed Stub for ClockSkewManager.prototype.setClockSkew.
|
|
84
|
+
// This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
|
|
85
|
+
// non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
|
|
86
|
+
// this will be removed when ES3 support is dropped.
|
|
87
|
+
ClockSkewManager.__ieDyn=1;
|
|
88
|
+
|
|
84
89
|
return ClockSkewManager;
|
|
85
90
|
}());
|
|
86
91
|
export default ClockSkewManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClockSkewManager.js.map","sources":["ClockSkewManager.js"],"sourcesContent":["/**\r\n* ClockSkewManager.ts\r\n* @author Abhilash Panwar (abpanwar)\r\n* @copyright Microsoft 2018\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\n/**\r\n* Class to manage clock skew correction.\r\n*/\r\nvar ClockSkewManager = /** @class */ (function () {\r\n function ClockSkewManager() {\r\n var _allowRequestSending = true;\r\n var _shouldAddClockSkewHeaders = true;\r\n var _isFirstRequest = true;\r\n var _clockSkewHeaderValue = \"use-collector-delta\";\r\n var _clockSkewSet = false;\r\n dynamicProto(ClockSkewManager, this, function (_self) {\r\n /**\r\n * Determine if requests can be sent.\r\n * @returns True if requests can be sent, false otherwise.\r\n */\r\n _self.allowRequestSending = function () {\r\n return _allowRequestSending;\r\n };\r\n /**\r\n * Tells the ClockSkewManager that it should assume that the first request has now been sent,\r\n * If this method had not yet been called AND the clock Skew had not been set this will set\r\n * allowRequestSending to false until setClockSet() is called.\r\n */\r\n _self.firstRequestSent = function () {\r\n if (_isFirstRequest) {\r\n _isFirstRequest = false;\r\n if (!_clockSkewSet) {\r\n // Block sending until we get the first clock Skew\r\n _allowRequestSending = false;\r\n }\r\n }\r\n };\r\n /**\r\n * Determine if clock skew headers should be added to the request.\r\n * @returns True if clock skew headers should be added, false otherwise.\r\n */\r\n _self.shouldAddClockSkewHeaders = function () {\r\n return _shouldAddClockSkewHeaders;\r\n };\r\n /**\r\n * Gets the clock skew header value.\r\n * @returns The clock skew header value.\r\n */\r\n _self.getClockSkewHeaderValue = function () {\r\n return _clockSkewHeaderValue;\r\n };\r\n /**\r\n * Sets the clock skew header value. Once clock skew is set this method\r\n * is no-op.\r\n * @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.\r\n */\r\n _self.setClockSkew = function (timeDeltaInMillis) {\r\n if (!_clockSkewSet) {\r\n if (timeDeltaInMillis) {\r\n _clockSkewHeaderValue = timeDeltaInMillis;\r\n _shouldAddClockSkewHeaders = true;\r\n _clockSkewSet = true;\r\n }\r\n else {\r\n _shouldAddClockSkewHeaders = false;\r\n }\r\n // Unblock sending\r\n _allowRequestSending = true;\r\n }\r\n };\r\n });\r\n }\r\n /**\r\n * Determine if the request can be sent.\r\n * @returns True if requests can be sent, false otherwise.\r\n */\r\n ClockSkewManager.prototype.allowRequestSending = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Tells the ClockSkewManager that it should assume that the first request has now been sent,\r\n * If this method had not yet been called AND the clock Skew had not been set this will set\r\n * allowRequestSending to false until setClockSet() is called.\r\n */\r\n ClockSkewManager.prototype.firstRequestSent = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Determine if clock skew headers should be added to the request.\r\n * @returns True if clock skew headers should be added, false otherwise.\r\n */\r\n ClockSkewManager.prototype.shouldAddClockSkewHeaders = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Gets the clock skew header value.\r\n * @returns The clock skew header value.\r\n */\r\n ClockSkewManager.prototype.getClockSkewHeaderValue = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Sets the clock skew header value. Once clock skew is set this method\r\n * is no-op.\r\n * @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.\r\n */\r\n ClockSkewManager.prototype.setClockSkew = function (timeDeltaInMillis) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n return ClockSkewManager;\r\n}());\r\nexport default ClockSkewManager;\r\n//# sourceMappingURL=ClockSkewManager.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;4DAuCM;
|
|
1
|
+
{"version":3,"file":"ClockSkewManager.js.map","sources":["ClockSkewManager.js"],"sourcesContent":["/**\r\n* ClockSkewManager.ts\r\n* @author Abhilash Panwar (abpanwar)\r\n* @copyright Microsoft 2018\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\n/**\r\n* Class to manage clock skew correction.\r\n*/\r\nvar ClockSkewManager = /** @class */ (function () {\r\n function ClockSkewManager() {\r\n var _allowRequestSending = true;\r\n var _shouldAddClockSkewHeaders = true;\r\n var _isFirstRequest = true;\r\n var _clockSkewHeaderValue = \"use-collector-delta\";\r\n var _clockSkewSet = false;\r\n dynamicProto(ClockSkewManager, this, function (_self) {\r\n /**\r\n * Determine if requests can be sent.\r\n * @returns True if requests can be sent, false otherwise.\r\n */\r\n _self.allowRequestSending = function () {\r\n return _allowRequestSending;\r\n };\r\n /**\r\n * Tells the ClockSkewManager that it should assume that the first request has now been sent,\r\n * If this method had not yet been called AND the clock Skew had not been set this will set\r\n * allowRequestSending to false until setClockSet() is called.\r\n */\r\n _self.firstRequestSent = function () {\r\n if (_isFirstRequest) {\r\n _isFirstRequest = false;\r\n if (!_clockSkewSet) {\r\n // Block sending until we get the first clock Skew\r\n _allowRequestSending = false;\r\n }\r\n }\r\n };\r\n /**\r\n * Determine if clock skew headers should be added to the request.\r\n * @returns True if clock skew headers should be added, false otherwise.\r\n */\r\n _self.shouldAddClockSkewHeaders = function () {\r\n return _shouldAddClockSkewHeaders;\r\n };\r\n /**\r\n * Gets the clock skew header value.\r\n * @returns The clock skew header value.\r\n */\r\n _self.getClockSkewHeaderValue = function () {\r\n return _clockSkewHeaderValue;\r\n };\r\n /**\r\n * Sets the clock skew header value. Once clock skew is set this method\r\n * is no-op.\r\n * @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.\r\n */\r\n _self.setClockSkew = function (timeDeltaInMillis) {\r\n if (!_clockSkewSet) {\r\n if (timeDeltaInMillis) {\r\n _clockSkewHeaderValue = timeDeltaInMillis;\r\n _shouldAddClockSkewHeaders = true;\r\n _clockSkewSet = true;\r\n }\r\n else {\r\n _shouldAddClockSkewHeaders = false;\r\n }\r\n // Unblock sending\r\n _allowRequestSending = true;\r\n }\r\n };\r\n });\r\n }\r\n /**\r\n * Determine if the request can be sent.\r\n * @returns True if requests can be sent, false otherwise.\r\n */\r\n ClockSkewManager.prototype.allowRequestSending = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Tells the ClockSkewManager that it should assume that the first request has now been sent,\r\n * If this method had not yet been called AND the clock Skew had not been set this will set\r\n * allowRequestSending to false until setClockSet() is called.\r\n */\r\n ClockSkewManager.prototype.firstRequestSent = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Determine if clock skew headers should be added to the request.\r\n * @returns True if clock skew headers should be added, false otherwise.\r\n */\r\n ClockSkewManager.prototype.shouldAddClockSkewHeaders = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Gets the clock skew header value.\r\n * @returns The clock skew header value.\r\n */\r\n ClockSkewManager.prototype.getClockSkewHeaderValue = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Sets the clock skew header value. Once clock skew is set this method\r\n * is no-op.\r\n * @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.\r\n */\r\n ClockSkewManager.prototype.setClockSkew = function (timeDeltaInMillis) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n return ClockSkewManager;\r\n}());\r\nexport default ClockSkewManager;\r\n//# sourceMappingURL=ClockSkewManager.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;4DAuCM,CAAC;;;;;;4BACqB;AAC5B;AACA;AACA"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EventBatch.ts
|
|
3
|
-
* @author Nev Wylie (newylie)
|
|
4
|
-
* @copyright Microsoft 2020
|
|
5
|
-
*/
|
|
6
1
|
import { IPostTransmissionTelemetryItem } from "./DataModels";
|
|
7
2
|
/**
|
|
8
3
|
* This class defines a "batch" events related to a specific iKey, it is used by the PostChannel and HttpManager
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.6
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* EventBatch.ts
|
|
8
|
+
* @author Nev Wylie (newylie)
|
|
9
|
+
* @copyright Microsoft 2020
|
|
10
|
+
*/
|
|
6
11
|
import { isNullOrUndefined, isValueAssigned } from "@microsoft/1ds-core-js";
|
|
7
|
-
import {
|
|
12
|
+
import { STR_MSFPC } from "./InternalConstants";
|
|
8
13
|
function _getEventMsfpc(theEvent) {
|
|
9
14
|
var intWeb = ((theEvent.ext || {})["intweb"]);
|
|
10
|
-
if (intWeb && isValueAssigned(intWeb[
|
|
11
|
-
return intWeb[
|
|
15
|
+
if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {
|
|
16
|
+
return intWeb[STR_MSFPC];
|
|
12
17
|
}
|
|
13
18
|
return null;
|
|
14
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventBatch.js.map","sources":["EventBatch.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"EventBatch.js.map","sources":["EventBatch.js"],"sourcesContent":["/**\r\n* EventBatch.ts\r\n* @author Nev Wylie (newylie)\r\n* @copyright Microsoft 2020\r\n*/\r\nimport { isNullOrUndefined, isValueAssigned } from \"@microsoft/1ds-core-js\";\r\nimport { STR_MSFPC } from \"./InternalConstants\";\r\nfunction _getEventMsfpc(theEvent) {\r\n var intWeb = ((theEvent.ext || {})[\"intweb\"]);\r\n if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {\r\n return intWeb[STR_MSFPC];\r\n }\r\n return null;\r\n}\r\nfunction _getMsfpc(theEvents) {\r\n var msfpc = null;\r\n for (var lp = 0; msfpc === null && lp < theEvents.length; lp++) {\r\n msfpc = _getEventMsfpc(theEvents[lp]);\r\n }\r\n return msfpc;\r\n}\r\n/**\r\n* This class defines a \"batch\" events related to a specific iKey, it is used by the PostChannel and HttpManager\r\n* to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous\r\n* array duplication and shared ownership issues that occurred due to race conditions caused by the async nature\r\n* of sending requests.\r\n*/\r\nvar EventBatch = /** @class */ (function () {\r\n /**\r\n * Private constructor so that caller is forced to use the static create method.\r\n * @param iKey - The iKey to associate with the events (not validated)\r\n * @param addEvents - The optional collection of events to assign to this batch - defaults to an empty array.\r\n */\r\n function EventBatch(iKey, addEvents) {\r\n var events = addEvents ? [].concat(addEvents) : [];\r\n var _self = this;\r\n var _msfpc = _getMsfpc(events);\r\n _self.iKey = function () {\r\n return iKey;\r\n };\r\n _self.Msfpc = function () {\r\n // return the cached value unless it's undefined -- used to avoid cpu\r\n return _msfpc || \"\";\r\n };\r\n _self.count = function () {\r\n return events.length;\r\n };\r\n _self.events = function () {\r\n return events;\r\n };\r\n _self.addEvent = function (theEvent) {\r\n if (theEvent) {\r\n events.push(theEvent);\r\n if (!_msfpc) {\r\n // Not found so try and find one\r\n _msfpc = _getEventMsfpc(theEvent);\r\n }\r\n return true;\r\n }\r\n return false;\r\n };\r\n _self.split = function (fromEvent, numEvents) {\r\n // Create a new batch with the same iKey\r\n var theEvents;\r\n if (fromEvent < events.length) {\r\n var cnt = events.length - fromEvent;\r\n if (!isNullOrUndefined(numEvents)) {\r\n cnt = numEvents < cnt ? numEvents : cnt;\r\n }\r\n theEvents = events.splice(fromEvent, cnt);\r\n // reset the fetched msfpc value\r\n _msfpc = _getMsfpc(events);\r\n }\r\n return new EventBatch(iKey, theEvents);\r\n };\r\n }\r\n /**\r\n * Creates a new Event Batch object\r\n * @param iKey The iKey associated with this batch of events\r\n */\r\n EventBatch.create = function (iKey, theEvents) {\r\n return new EventBatch(iKey, theEvents);\r\n };\r\n return EventBatch;\r\n}());\r\nexport { EventBatch };\r\n//# sourceMappingURL=EventBatch.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* HttpManager.ts
|
|
3
|
-
* @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)
|
|
4
|
-
* @copyright Microsoft 2018-2020
|
|
5
|
-
*/
|
|
6
|
-
import { IExtendedAppInsightsCore, SendRequestReason, EventSendType } from "@microsoft/1ds-core-js";
|
|
7
|
-
import { IXHROverride, IPostChannel, PayloadPreprocessorFunction, PayloadListenerFunction } from "./DataModels";
|
|
1
|
+
import { EventSendType, IExtendedAppInsightsCore, SendRequestReason } from "@microsoft/1ds-core-js";
|
|
8
2
|
import { BatchNotificationActions } from "./BatchNotificationActions";
|
|
3
|
+
import { IPostChannel, IXHROverride, PayloadListenerFunction, PayloadPreprocessorFunction } from "./DataModels";
|
|
9
4
|
import { EventBatch } from "./EventBatch";
|
|
10
5
|
import { IChannelConfiguration } from "./Index";
|
|
11
6
|
import { ITimeoutOverrideWrapper } from "./TimeoutOverrideWrapper";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.2.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.2.6
|
|
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 /* EventBatchNotificationReason.Paused */] =
|
|
26
|
-
_a[100 /* EventBatchNotificationReason.RequeueEvents */] =
|
|
25
|
+
_a[1 /* EventBatchNotificationReason.Paused */] = STR_REQUEUE,
|
|
26
|
+
_a[100 /* EventBatchNotificationReason.RequeueEvents */] = STR_REQUEUE,
|
|
27
27
|
_a[200 /* EventBatchNotificationReason.Complete */] = "sent",
|
|
28
|
-
_a[8004 /* EventBatchNotificationReason.KillSwitch */] =
|
|
29
|
-
_a[8003 /* EventBatchNotificationReason.SizeLimitExceeded */] =
|
|
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)) {
|
|
@@ -166,7 +168,7 @@ 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 = {},
|
|
@@ -214,7 +216,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
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,9 +254,9 @@ 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;
|
|
@@ -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) {
|
|
@@ -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 {
|
|
@@ -613,7 +616,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
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();
|
|
@@ -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,7 +754,7 @@ 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
|
};
|
|
@@ -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
|
|
@@ -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
|
}
|
|
@@ -1016,7 +1019,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
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 =
|
|
1032
|
+
action = STR_OTHER;
|
|
1030
1033
|
if (reason >= 9000 /* EventBatchNotificationReason.ResponseFailure */ && reason <= 9999 /* EventBatchNotificationReason.ResponseFailureMax */) {
|
|
1031
|
-
action =
|
|
1034
|
+
action = STR_RESPONSE_FAIL;
|
|
1032
1035
|
}
|
|
1033
1036
|
else if (reason >= 8000 /* EventBatchNotificationReason.EventsDropped */ && reason <= 8999 /* EventBatchNotificationReason.EventsDroppedMax */) {
|
|
1034
|
-
action =
|
|
1037
|
+
action = STR_DROPPED;
|
|
1035
1038
|
}
|
|
1036
1039
|
else if (reason >= 1000 /* EventBatchNotificationReason.SendingUndefined */ && reason <= 1999 /* EventBatchNotificationReason.SendingEventMax */) {
|
|
1037
|
-
action =
|
|
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 };
|