@microsoft/1ds-post-js 3.1.9 → 3.1.10
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 -0
- package/bundle/{ms.post-3.1.9.gbl.js → ms.post-3.1.10.gbl.js} +196 -92
- package/bundle/ms.post-3.1.10.gbl.js.map +1 -0
- package/bundle/ms.post-3.1.10.gbl.min.js +7 -0
- package/bundle/ms.post-3.1.10.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.1.10.integrity.json +46 -0
- package/bundle/{ms.post-3.1.9.js → ms.post-3.1.10.js} +196 -92
- package/bundle/ms.post-3.1.10.js.map +1 -0
- package/bundle/ms.post-3.1.10.min.js +7 -0
- package/bundle/ms.post-3.1.10.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +195 -91
- 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 +195 -91
- 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 +140 -72
- package/dist/ms.post.js.map +1 -1
- package/dist/ms.post.min.js +2 -2
- package/dist/ms.post.min.js.map +1 -1
- package/dist-esm/src/BatchNotificationActions.js +1 -1
- package/dist-esm/src/ClockSkewManager.js +1 -1
- package/dist-esm/src/Constants.d.ts +24 -0
- package/dist-esm/src/Constants.js +30 -0
- package/dist-esm/src/Constants.js.map +1 -0
- package/dist-esm/src/DataModels.d.ts +6 -0
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.d.ts +5 -2
- package/dist-esm/src/EventBatch.js +35 -15
- package/dist-esm/src/EventBatch.js.map +1 -1
- package/dist-esm/src/HttpManager.d.ts +1 -1
- package/dist-esm/src/HttpManager.js +112 -64
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/KillSwitch.js +1 -1
- package/dist-esm/src/PostChannel.js +6 -5
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.js +1 -1
- package/dist-esm/src/Serializer.js +1 -1
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +3 -3
- package/src/Constants.ts +27 -0
- package/src/DataModels.ts +8 -1
- package/src/EventBatch.ts +47 -14
- package/src/HttpManager.ts +143 -66
- package/src/PostChannel.ts +4 -3
- package/bundle/ms.post-3.1.9.gbl.js.map +0 -1
- package/bundle/ms.post-3.1.9.gbl.min.js +0 -7
- package/bundle/ms.post-3.1.9.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.1.9.integrity.json +0 -46
- package/bundle/ms.post-3.1.9.js.map +0 -1
- package/bundle/ms.post-3.1.9.min.js +0 -7
- package/bundle/ms.post-3.1.9.min.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const Method = "POST";
|
|
2
|
+
export declare const DisabledPropertyName: string;
|
|
3
|
+
export declare const strDropped = "drop";
|
|
4
|
+
export declare const strSending = "send";
|
|
5
|
+
export declare const strRequeue = "requeue";
|
|
6
|
+
export declare const strResponseFail = "rspFail";
|
|
7
|
+
export declare const strOther = "oth";
|
|
8
|
+
export declare const defaultCacheControl = "no-cache, no-store";
|
|
9
|
+
export declare const defaultContentType = "application/x-json-stream";
|
|
10
|
+
export declare const strCacheControl = "cache-control";
|
|
11
|
+
export declare const strContentTypeHeader = "content-type";
|
|
12
|
+
export declare const strKillTokensHeader = "kill-tokens";
|
|
13
|
+
export declare const strKillDurationHeader = "kill-duration";
|
|
14
|
+
export declare const strKillDurationSecondsHeader = "kill-duration-seconds";
|
|
15
|
+
export declare const strTimeDeltaHeader = "time-delta-millis";
|
|
16
|
+
export declare const strClientVersion = "client-version";
|
|
17
|
+
export declare const strClientId = "client-id";
|
|
18
|
+
export declare const strTimeDeltaToApply = "time-delta-to-apply-millis";
|
|
19
|
+
export declare const strUploadTime = "upload-time";
|
|
20
|
+
export declare const strApiKey = "apikey";
|
|
21
|
+
export declare const strMsaDeviceTicket = "AuthMsaDeviceTicket";
|
|
22
|
+
export declare const strAuthXToken = "AuthXToken";
|
|
23
|
+
export declare const strSdkVersion = "sdk-version";
|
|
24
|
+
export declare const strMsfpc = "msfpc";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.1.10
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
* (Microsoft Internal Only)
|
|
5
|
+
*/
|
|
6
|
+
export var Method = "POST";
|
|
7
|
+
export var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
|
|
8
|
+
export var strDropped = "drop";
|
|
9
|
+
export var strSending = "send";
|
|
10
|
+
export var strRequeue = "requeue";
|
|
11
|
+
export var strResponseFail = "rspFail";
|
|
12
|
+
export var strOther = "oth";
|
|
13
|
+
export var defaultCacheControl = "no-cache, no-store";
|
|
14
|
+
export var defaultContentType = "application/x-json-stream";
|
|
15
|
+
export var strCacheControl = "cache-control";
|
|
16
|
+
export var strContentTypeHeader = "content-type";
|
|
17
|
+
export var strKillTokensHeader = "kill-tokens";
|
|
18
|
+
export var strKillDurationHeader = "kill-duration";
|
|
19
|
+
export var strKillDurationSecondsHeader = "kill-duration-seconds";
|
|
20
|
+
export var strTimeDeltaHeader = "time-delta-millis";
|
|
21
|
+
export var strClientVersion = "client-version";
|
|
22
|
+
export var strClientId = "client-id";
|
|
23
|
+
export var strTimeDeltaToApply = "time-delta-to-apply-millis";
|
|
24
|
+
export var strUploadTime = "upload-time";
|
|
25
|
+
export var strApiKey = "apikey";
|
|
26
|
+
export var strMsaDeviceTicket = "AuthMsaDeviceTicket";
|
|
27
|
+
export var strAuthXToken = "AuthXToken";
|
|
28
|
+
export var strSdkVersion = "sdk-version";
|
|
29
|
+
export var strMsfpc = "msfpc";
|
|
30
|
+
//# sourceMappingURL=Constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.js.map","sources":["Constants.js"],"sourcesContent":["export var Method = \"POST\";\r\nexport var DisabledPropertyName = \"Microsoft_ApplicationInsights_BypassAjaxInstrumentation\";\r\nexport var strDropped = \"drop\";\r\nexport var strSending = \"send\";\r\nexport var strRequeue = \"requeue\";\r\nexport var strResponseFail = \"rspFail\";\r\nexport var strOther = \"oth\";\r\nexport var defaultCacheControl = \"no-cache, no-store\";\r\nexport var defaultContentType = \"application/x-json-stream\";\r\nexport var strCacheControl = \"cache-control\";\r\nexport var strContentTypeHeader = \"content-type\";\r\nexport var strKillTokensHeader = \"kill-tokens\";\r\nexport var strKillDurationHeader = \"kill-duration\";\r\nexport var strKillDurationSecondsHeader = \"kill-duration-seconds\";\r\nexport var strTimeDeltaHeader = \"time-delta-millis\";\r\nexport var strClientVersion = \"client-version\";\r\nexport var strClientId = \"client-id\";\r\nexport var strTimeDeltaToApply = \"time-delta-to-apply-millis\";\r\nexport var strUploadTime = \"upload-time\";\r\nexport var strApiKey = \"apikey\";\r\nexport var strMsaDeviceTicket = \"AuthMsaDeviceTicket\";\r\nexport var strAuthXToken = \"AuthXToken\";\r\nexport var strSdkVersion = \"sdk-version\";\r\nexport var strMsfpc = \"msfpc\";\r\n//# sourceMappingURL=Constants.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -132,6 +132,12 @@ export interface IChannelConfiguration {
|
|
|
132
132
|
* This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided.
|
|
133
133
|
*/
|
|
134
134
|
transports?: number | number[];
|
|
135
|
+
/**
|
|
136
|
+
* [Optional] Avoid adding request headers to the outgoing request that would cause a pre-flight (OPTIONS) request to be sent for each request.
|
|
137
|
+
* This currently defaults to true but will be changed once the collector handles additional settings to allow the browser to better cache any
|
|
138
|
+
* previous OPTIONS response, at which point some of the current dynamic values sent on the query string will be moved to a header.
|
|
139
|
+
*/
|
|
140
|
+
avoidOptions?: boolean;
|
|
135
141
|
}
|
|
136
142
|
/**
|
|
137
143
|
* SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
|
|
@@ -20,6 +20,10 @@ export declare class EventBatch {
|
|
|
20
20
|
* Returns the iKey associated with this batch of events
|
|
21
21
|
*/
|
|
22
22
|
iKey: () => string;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the first msfpc value from the batch
|
|
25
|
+
*/
|
|
26
|
+
Msfpc: () => string;
|
|
23
27
|
/**
|
|
24
28
|
* Returns the number of events contained in the batch
|
|
25
29
|
*/
|
|
@@ -29,10 +33,9 @@ export declare class EventBatch {
|
|
|
29
33
|
* Add all of the events to the current batch, if the max number of events would be exceeded then no
|
|
30
34
|
* events are added.
|
|
31
35
|
* @param theEvents - The events that needs to be batched.
|
|
32
|
-
* @param append - True (default) add the event to the end of the queue otherwise prepend (used for re-queuing)
|
|
33
36
|
* @returns The number of events added.
|
|
34
37
|
*/
|
|
35
|
-
|
|
38
|
+
addEvent: (theEvents: IPostTransmissionTelemetryItem) => boolean;
|
|
36
39
|
/**
|
|
37
40
|
* Split this batch into 2 with any events > fromEvent returned in the new batch and all other
|
|
38
41
|
* events are kept in the current batch.
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.1.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.1.10
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
6
|
-
import { isNullOrUndefined } from "@microsoft/1ds-core-js";
|
|
6
|
+
import { isNullOrUndefined, isValueAssigned } from "@microsoft/1ds-core-js";
|
|
7
|
+
import { strMsfpc } from "./Constants";
|
|
8
|
+
function _getEventMsfpc(theEvent) {
|
|
9
|
+
var intWeb = ((theEvent.ext || {})["intweb"]);
|
|
10
|
+
if (intWeb && isValueAssigned(intWeb[strMsfpc])) {
|
|
11
|
+
return intWeb[strMsfpc];
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function _getMsfpc(theEvents) {
|
|
16
|
+
var msfpc = null;
|
|
17
|
+
for (var lp = 0; msfpc === null && lp < theEvents.length; lp++) {
|
|
18
|
+
msfpc = _getEventMsfpc(theEvents[lp]);
|
|
19
|
+
}
|
|
20
|
+
return msfpc;
|
|
21
|
+
}
|
|
7
22
|
/**
|
|
8
23
|
* This class defines a "batch" events related to a specific iKey, it is used by the PostChannel and HttpManager
|
|
9
24
|
* to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous
|
|
@@ -19,39 +34,44 @@ var EventBatch = /** @class */ (function () {
|
|
|
19
34
|
function EventBatch(iKey, addEvents) {
|
|
20
35
|
var events = addEvents ? [].concat(addEvents) : [];
|
|
21
36
|
var _self = this;
|
|
37
|
+
var _msfpc = _getMsfpc(events);
|
|
22
38
|
_self.iKey = function () {
|
|
23
39
|
return iKey;
|
|
24
40
|
};
|
|
41
|
+
_self.Msfpc = function () {
|
|
42
|
+
// return the cached value unless it's undefined -- used to avoid cpu
|
|
43
|
+
return _msfpc || "";
|
|
44
|
+
};
|
|
25
45
|
_self.count = function () {
|
|
26
46
|
return events.length;
|
|
27
47
|
};
|
|
28
48
|
_self.events = function () {
|
|
29
49
|
return events;
|
|
30
50
|
};
|
|
31
|
-
_self.
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
else {
|
|
38
|
-
events = theEvents.concat(events);
|
|
51
|
+
_self.addEvent = function (theEvent) {
|
|
52
|
+
if (theEvent) {
|
|
53
|
+
events.push(theEvent);
|
|
54
|
+
if (!_msfpc) {
|
|
55
|
+
// Not found so try and find one
|
|
56
|
+
_msfpc = _getEventMsfpc(theEvent);
|
|
39
57
|
}
|
|
40
|
-
return
|
|
58
|
+
return true;
|
|
41
59
|
}
|
|
42
|
-
return
|
|
60
|
+
return false;
|
|
43
61
|
};
|
|
44
62
|
_self.split = function (fromEvent, numEvents) {
|
|
45
63
|
// Create a new batch with the same iKey
|
|
46
|
-
var
|
|
64
|
+
var theEvents;
|
|
47
65
|
if (fromEvent < events.length) {
|
|
48
66
|
var cnt = events.length - fromEvent;
|
|
49
67
|
if (!isNullOrUndefined(numEvents)) {
|
|
50
68
|
cnt = numEvents < cnt ? numEvents : cnt;
|
|
51
69
|
}
|
|
52
|
-
|
|
70
|
+
theEvents = events.splice(fromEvent, cnt);
|
|
71
|
+
// reset the fetched msfpc value
|
|
72
|
+
_msfpc = _getMsfpc(events);
|
|
53
73
|
}
|
|
54
|
-
return
|
|
74
|
+
return new EventBatch(iKey, theEvents);
|
|
55
75
|
};
|
|
56
76
|
}
|
|
57
77
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventBatch.js.map","sources":["EventBatch.js"],"sourcesContent":["import { isNullOrUndefined } from \"@microsoft/1ds-core-js\";\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 _self.iKey = function () {\r\n return iKey;\r\n };\r\n _self.
|
|
1
|
+
{"version":3,"file":"EventBatch.js.map","sources":["EventBatch.js"],"sourcesContent":["import { isNullOrUndefined, isValueAssigned } from \"@microsoft/1ds-core-js\";\r\nimport { strMsfpc } from \"./Constants\";\r\nfunction _getEventMsfpc(theEvent) {\r\n var intWeb = ((theEvent.ext || {})[\"intweb\"]);\r\n if (intWeb && isValueAssigned(intWeb[strMsfpc])) {\r\n return intWeb[strMsfpc];\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"}
|
|
@@ -11,7 +11,7 @@ import { IChannelConfiguration } from "./Index";
|
|
|
11
11
|
/**
|
|
12
12
|
* Class managing the sending of requests.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class HttpManager {
|
|
15
15
|
sendHook: PayloadPreprocessorFunction | undefined;
|
|
16
16
|
sendListener: PayloadListenerFunction | undefined;
|
|
17
17
|
_responseHandlers: Array<(responseText: string) => void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* 1DS JS SDK POST plugin, 3.1.
|
|
2
|
+
* 1DS JS SDK POST plugin, 3.1.10
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
* (Microsoft Internal Only)
|
|
5
5
|
*/
|
|
@@ -15,21 +15,7 @@ import RetryPolicy from "./RetryPolicy";
|
|
|
15
15
|
import EVTKillSwitch from "./KillSwitch";
|
|
16
16
|
import EVTClockSkewManager from "./ClockSkewManager";
|
|
17
17
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
18
|
-
|
|
19
|
-
var DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
|
|
20
|
-
var strDropped = "drop";
|
|
21
|
-
var strSending = "send";
|
|
22
|
-
var strRequeue = "requeue";
|
|
23
|
-
var strResponseFail = "rspFail";
|
|
24
|
-
var strOther = "oth";
|
|
25
|
-
var defaultCacheControl = "no-cache, no-store";
|
|
26
|
-
var defaultContentType = "application/x-json-stream";
|
|
27
|
-
var strCacheControl = "cache-control";
|
|
28
|
-
var strContentTypeHeader = "content-type";
|
|
29
|
-
var strKillTokensHeader = "kill-tokens";
|
|
30
|
-
var strKillDurationHeader = "kill-duration";
|
|
31
|
-
var strKillDurationSecondsHeader = "kill-duration-seconds";
|
|
32
|
-
var strTimeDeltaHeader = "time-delta-millis";
|
|
18
|
+
import { defaultCacheControl, defaultContentType, DisabledPropertyName, Method, strApiKey, strCacheControl, strClientId, strClientVersion, strContentTypeHeader, strDropped, strKillDurationHeader, strKillDurationSecondsHeader, strKillTokensHeader, strMsaDeviceTicket, strMsfpc, strOther, strRequeue, strResponseFail, strSending, strTimeDeltaHeader, strTimeDeltaToApply, strUploadTime } from "./Constants";
|
|
33
19
|
/**
|
|
34
20
|
* Identifies the default notification reason to the action names
|
|
35
21
|
*/
|
|
@@ -40,6 +26,13 @@ var _eventActionMap = (_a = {},
|
|
|
40
26
|
_a[8004 /* KillSwitch */] = strDropped,
|
|
41
27
|
_a[8003 /* SizeLimitExceeded */] = strDropped,
|
|
42
28
|
_a);
|
|
29
|
+
var _collectorQsHeaders = {};
|
|
30
|
+
var _collectorHeaderToQs = {};
|
|
31
|
+
function _addCollectorHeaderQsMapping(qsName, headerName) {
|
|
32
|
+
_collectorQsHeaders[qsName] = headerName;
|
|
33
|
+
_collectorHeaderToQs[headerName] = qsName;
|
|
34
|
+
}
|
|
35
|
+
_addCollectorHeaderQsMapping(strMsaDeviceTicket, strMsaDeviceTicket);
|
|
43
36
|
function _getResponseText(xhr) {
|
|
44
37
|
try {
|
|
45
38
|
return xhr.responseText;
|
|
@@ -67,6 +60,17 @@ function _hasHeader(headers, header) {
|
|
|
67
60
|
}
|
|
68
61
|
return hasHeader;
|
|
69
62
|
}
|
|
63
|
+
function _addRequestDetails(details, name, value, useHeaders) {
|
|
64
|
+
if (name && value && value.length > 0) {
|
|
65
|
+
if (useHeaders && _collectorQsHeaders[name]) {
|
|
66
|
+
details.hdrs[_collectorQsHeaders[name]] = value;
|
|
67
|
+
details.useHdrs = true;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
details.url += "&" + name + "=" + value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
70
74
|
/**
|
|
71
75
|
* Class managing the sending of requests.
|
|
72
76
|
*/
|
|
@@ -77,8 +81,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
77
81
|
*/
|
|
78
82
|
function HttpManager(maxEventsPerBatch, maxConnections, maxRetries, actions) {
|
|
79
83
|
this._responseHandlers = [];
|
|
80
|
-
var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType
|
|
81
|
-
+ FullVersionString;
|
|
84
|
+
var _urlString = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
|
|
82
85
|
var _killSwitch = new EVTKillSwitch();
|
|
83
86
|
var _paused = false;
|
|
84
87
|
var _clockSkewManager = new EVTClockSkewManager();
|
|
@@ -95,6 +98,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
95
98
|
var _enableEventTimings = false;
|
|
96
99
|
var _cookieMgr;
|
|
97
100
|
var _isUnloading = false;
|
|
101
|
+
var _useHeaders = false;
|
|
98
102
|
dynamicProto(HttpManager, this, function (_self) {
|
|
99
103
|
var _sendCredentials = true;
|
|
100
104
|
_self.initialize = function (endpointUrl, core, postChannel, httpInterface, channelConfig) {
|
|
@@ -103,6 +107,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
103
107
|
channelConfig = {};
|
|
104
108
|
}
|
|
105
109
|
_urlString = endpointUrl + _urlString;
|
|
110
|
+
// Task 12886642: Defaulting to 'false' until the Collector handles sending upload-time header in the OPTIONS call
|
|
111
|
+
_useHeaders = !isUndefined(channelConfig.avoidOptions) ? !channelConfig.avoidOptions : false;
|
|
106
112
|
_core = core;
|
|
107
113
|
_cookieMgr = core.getCookieMgr();
|
|
108
114
|
_enableEventTimings = !_core.config.disableEventTimings;
|
|
@@ -113,12 +119,6 @@ var HttpManager = /** @class */ (function () {
|
|
|
113
119
|
if (!isUndefined(channelConfig.enableCompoundKey)) {
|
|
114
120
|
enableCompoundKey = !!channelConfig.enableCompoundKey;
|
|
115
121
|
}
|
|
116
|
-
// For this to work the collection MUST return "Cache-control" in the OPTIONS response in the Allow-Control-Allow-Headers
|
|
117
|
-
// ONLY un-comment the below once the collector has changed and deployed.
|
|
118
|
-
// if (!!channelConfig.disableCacheHeader) {
|
|
119
|
-
// // Stop Chrome from stalling/throttling requests see task #7178858
|
|
120
|
-
// _self.addHeader("Cache-control", "no-cache, no-store");
|
|
121
|
-
// }
|
|
122
122
|
_useBeacons = !isReactNative(); // Only use beacons if not running in React Native
|
|
123
123
|
_serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
|
|
124
124
|
var syncHttpInterface = httpInterface;
|
|
@@ -229,6 +229,8 @@ var HttpManager = /** @class */ (function () {
|
|
|
229
229
|
}
|
|
230
230
|
function _fetchSendPost(payload, oncomplete, sync) {
|
|
231
231
|
var _a;
|
|
232
|
+
var ignoreResponse = false;
|
|
233
|
+
var responseHandled = false;
|
|
232
234
|
var requestInit = (_a = {
|
|
233
235
|
body: payload.data,
|
|
234
236
|
method: Method
|
|
@@ -237,6 +239,11 @@ var HttpManager = /** @class */ (function () {
|
|
|
237
239
|
_a);
|
|
238
240
|
if (sync) {
|
|
239
241
|
requestInit.keepalive = true;
|
|
242
|
+
if (payload._sendReason === 2 /* Unload */) {
|
|
243
|
+
// As a sync request (during unload), it is unlikely that we will get a chance to process the response so
|
|
244
|
+
// just like beacon send assume that the events have been accepted and processed
|
|
245
|
+
ignoreResponse = true;
|
|
246
|
+
}
|
|
240
247
|
}
|
|
241
248
|
if (_sendCredentials) {
|
|
242
249
|
// Don't send credentials when URL is file://
|
|
@@ -259,13 +266,24 @@ var HttpManager = /** @class */ (function () {
|
|
|
259
266
|
responseText = text;
|
|
260
267
|
});
|
|
261
268
|
}
|
|
262
|
-
|
|
263
|
-
|
|
269
|
+
if (!responseHandled) {
|
|
270
|
+
responseHandled = true;
|
|
271
|
+
_doOnComplete(oncomplete, response.status, headerMap, responseText);
|
|
272
|
+
_handleCollectorResponse(responseText);
|
|
273
|
+
}
|
|
264
274
|
})["catch"](function (error) {
|
|
265
275
|
// In case there is an error in the request. Set the status to 0
|
|
266
276
|
// so that the events can be retried later.
|
|
267
|
-
|
|
277
|
+
if (!responseHandled) {
|
|
278
|
+
responseHandled = true;
|
|
279
|
+
_doOnComplete(oncomplete, 0, {});
|
|
280
|
+
}
|
|
268
281
|
});
|
|
282
|
+
if (ignoreResponse && !responseHandled) {
|
|
283
|
+
// Assume success during unload processing
|
|
284
|
+
responseHandled = true;
|
|
285
|
+
_doOnComplete(oncomplete, 200, {});
|
|
286
|
+
}
|
|
269
287
|
}
|
|
270
288
|
function _xhrSendPost(payload, oncomplete, sync) {
|
|
271
289
|
function _appendHeader(theHeaders, xhr, name) {
|
|
@@ -563,8 +581,34 @@ var HttpManager = /** @class */ (function () {
|
|
|
563
581
|
_postManager.diagLog().throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.CannotSerializeObject, "Unexpected Exception sending batch: " + dumpObj(ex));
|
|
564
582
|
}
|
|
565
583
|
}
|
|
566
|
-
function
|
|
567
|
-
var
|
|
584
|
+
function _buildRequestDetails(thePayload, useHeaders) {
|
|
585
|
+
var requestDetails = {
|
|
586
|
+
url: _urlString,
|
|
587
|
+
hdrs: {},
|
|
588
|
+
useHdrs: false // Assume no headers
|
|
589
|
+
};
|
|
590
|
+
// ----------------------------------------------------------------------------------------------------------------
|
|
591
|
+
// Task 12886642: Need to wait until an updated version of the collector is released to return these as allowed in the OPTIONS call
|
|
592
|
+
// ----------------------------------------------------------------------------------------------------------------
|
|
593
|
+
// if (!useHeaders) {
|
|
594
|
+
// // Attempt to map headers to a query string if possible
|
|
595
|
+
// objForEachKey(_headers, (name, value) => {
|
|
596
|
+
// if (_collectorHeaderToQs[name]) {
|
|
597
|
+
// _addRequestDetails(requestDetails, _collectorHeaderToQs[name], value, false);
|
|
598
|
+
// } else {
|
|
599
|
+
// // No mapping, so just include in the headers anyway (may not get sent if using sendBeacon())
|
|
600
|
+
// requestDetails.hdrs[name] = value;
|
|
601
|
+
// requestDetails.useHdrs = true;
|
|
602
|
+
// }
|
|
603
|
+
// });
|
|
604
|
+
// } else {
|
|
605
|
+
// Copy the pre-defined headers into the payload headers
|
|
606
|
+
requestDetails.hdrs = extend(requestDetails.hdrs, _headers);
|
|
607
|
+
requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
|
|
608
|
+
// }
|
|
609
|
+
// ----------------------------------------------------------------------------------------------------------------
|
|
610
|
+
_addRequestDetails(requestDetails, strClientId, "NO_AUTH", useHeaders);
|
|
611
|
+
_addRequestDetails(requestDetails, strClientVersion, FullVersionString, useHeaders);
|
|
568
612
|
var apiQsKeys = "";
|
|
569
613
|
arrForEach(thePayload.apiKeys, function (apiKey) {
|
|
570
614
|
if (apiQsKeys.length > 0) {
|
|
@@ -572,27 +616,25 @@ var HttpManager = /** @class */ (function () {
|
|
|
572
616
|
}
|
|
573
617
|
apiQsKeys += apiKey;
|
|
574
618
|
});
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
urlString += "&upload-time=" + dateNow().toString();
|
|
619
|
+
_addRequestDetails(requestDetails, strApiKey, apiQsKeys, useHeaders);
|
|
620
|
+
_addRequestDetails(requestDetails, strUploadTime, dateNow().toString(), useHeaders);
|
|
579
621
|
var msfpc = _getMsfpc(thePayload);
|
|
580
622
|
if (isValueAssigned(msfpc)) {
|
|
581
|
-
|
|
623
|
+
requestDetails.url += "&ext.intweb.msfpc=" + msfpc;
|
|
582
624
|
}
|
|
583
625
|
if (_clockSkewManager.shouldAddClockSkewHeaders()) {
|
|
584
|
-
|
|
626
|
+
_addRequestDetails(requestDetails, strTimeDeltaToApply, _clockSkewManager.getClockSkewHeaderValue(), useHeaders);
|
|
585
627
|
}
|
|
586
628
|
if (_core.getWParam) {
|
|
587
629
|
var wParam = _core.getWParam();
|
|
588
630
|
if (wParam >= 0) {
|
|
589
|
-
|
|
631
|
+
requestDetails.url += "&w=" + wParam;
|
|
590
632
|
}
|
|
591
633
|
}
|
|
592
634
|
for (var i = 0; i < _queryStringParameters.length; i++) {
|
|
593
|
-
|
|
635
|
+
requestDetails.url += "&" + _queryStringParameters[i].name + "=" + _queryStringParameters[i].value;
|
|
594
636
|
}
|
|
595
|
-
return
|
|
637
|
+
return requestDetails;
|
|
596
638
|
}
|
|
597
639
|
function _canUseSendBeaconApi() {
|
|
598
640
|
return !_customHttpInterface && _useBeacons && isBeaconsSupported();
|
|
@@ -603,7 +645,19 @@ var HttpManager = /** @class */ (function () {
|
|
|
603
645
|
}
|
|
604
646
|
function _doPayloadSend(thePayload, serializationStart, serializationCompleted, sendReason) {
|
|
605
647
|
if (thePayload && thePayload.payloadBlob && thePayload.payloadBlob.length > 0) {
|
|
606
|
-
var
|
|
648
|
+
var useSendHook_1 = !!_self.sendHook;
|
|
649
|
+
var sendInterface_1 = _sendInterfaces[thePayload.sendType];
|
|
650
|
+
// Send all data using a beacon style transport if closing mode is on or channel was teared down
|
|
651
|
+
if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 /* Unload */) {
|
|
652
|
+
sendInterface_1 = _sendInterfaces[2 /* SendBeacon */] || _sendInterfaces[3 /* SyncFetch */] || sendInterface_1;
|
|
653
|
+
}
|
|
654
|
+
var useHeaders_1 = _useHeaders;
|
|
655
|
+
// Disable header usage if we know we are using sendBeacon as additional headers are not supported
|
|
656
|
+
if (thePayload.isBeacon || sendInterface_1._transport === 3 /* Beacon */) {
|
|
657
|
+
useHeaders_1 = false;
|
|
658
|
+
}
|
|
659
|
+
var requestDetails_1 = _buildRequestDetails(thePayload, useHeaders_1);
|
|
660
|
+
useHeaders_1 = useHeaders_1 || requestDetails_1.useHdrs;
|
|
607
661
|
var sendEventStart_1 = getTime();
|
|
608
662
|
var strSendAttempt_1 = "sendAttempt";
|
|
609
663
|
doPerf(_core, function () { return "HttpManager:_doPayloadSend"; }, function () {
|
|
@@ -629,25 +683,22 @@ var HttpManager = /** @class */ (function () {
|
|
|
629
683
|
// eslint-disable-next-line prefer-const
|
|
630
684
|
var orgPayloadData = {
|
|
631
685
|
data: thePayload.payloadBlob,
|
|
632
|
-
urlString:
|
|
633
|
-
headers:
|
|
686
|
+
urlString: requestDetails_1.url,
|
|
687
|
+
headers: requestDetails_1.hdrs,
|
|
634
688
|
_thePayload: thePayload,
|
|
635
689
|
_sendReason: sendReason
|
|
636
690
|
};
|
|
637
|
-
if
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
691
|
+
// Only automatically add the following headers if already sending headers and we are not attempting to avoid an options call
|
|
692
|
+
if (useHeaders_1) {
|
|
693
|
+
if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
|
|
694
|
+
orgPayloadData.headers[strCacheControl] = defaultCacheControl;
|
|
695
|
+
}
|
|
696
|
+
if (!_hasHeader(orgPayloadData.headers, strContentTypeHeader)) {
|
|
697
|
+
orgPayloadData.headers[strContentTypeHeader] = defaultContentType;
|
|
698
|
+
}
|
|
642
699
|
}
|
|
643
700
|
var sender = null;
|
|
644
|
-
|
|
645
|
-
var sendInterface = _sendInterfaces[thePayload.sendType];
|
|
646
|
-
// Send all data using a beacon style transport if closing mode is on or channel was teared down
|
|
647
|
-
if (!_isBeaconPayload(thePayload.sendType) && thePayload.isBeacon && thePayload.sendReason === 2 /* Unload */) {
|
|
648
|
-
sendInterface = _sendInterfaces[2 /* SendBeacon */] || _sendInterfaces[3 /* SyncFetch */] || sendInterface;
|
|
649
|
-
}
|
|
650
|
-
if (sendInterface) {
|
|
701
|
+
if (sendInterface_1) {
|
|
651
702
|
// Send sync requests if the request is immediate or we are tearing down telemetry.
|
|
652
703
|
sender = function (payload) {
|
|
653
704
|
// Notify the clock skew manager that we are sending the first request (Potentially blocking all further requests)
|
|
@@ -657,7 +708,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
657
708
|
};
|
|
658
709
|
var isSync = thePayload.isTeardown || thePayload.isSync;
|
|
659
710
|
try {
|
|
660
|
-
|
|
711
|
+
sendInterface_1.sendPOST(payload, onComplete, isSync);
|
|
661
712
|
if (_self.sendListener) {
|
|
662
713
|
// Send the original payload to the listener
|
|
663
714
|
_self.sendListener(orgPayloadData, payload, isSync, thePayload.isBeacon);
|
|
@@ -675,7 +726,7 @@ var HttpManager = /** @class */ (function () {
|
|
|
675
726
|
_outstandingRequests++;
|
|
676
727
|
}
|
|
677
728
|
// Only call the hook if it's defined and we are not using sendBeacon as additional headers are not supported
|
|
678
|
-
if (
|
|
729
|
+
if (useSendHook_1 && !thePayload.isBeacon && sendInterface_1._transport !== 3 /* Beacon */) {
|
|
679
730
|
// Create a new IPayloadData that is sent into the hook method, so that the hook method
|
|
680
731
|
// can't change the object references to the orgPayloadData (it can still change the content -- mainly the headers)
|
|
681
732
|
// Disabling the use of const because of Issue:
|
|
@@ -880,12 +931,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
880
931
|
}
|
|
881
932
|
function _getMsfpc(thePayload) {
|
|
882
933
|
for (var lp = 0; lp < thePayload.batches.length; lp++) {
|
|
883
|
-
var
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (isValueAssigned(intWeb["msfpc"])) {
|
|
887
|
-
return encodeURIComponent(intWeb["msfpc"]);
|
|
888
|
-
}
|
|
934
|
+
var msfpc = thePayload.batches[lp].Msfpc();
|
|
935
|
+
if (msfpc) {
|
|
936
|
+
return encodeURIComponent(msfpc);
|
|
889
937
|
}
|
|
890
938
|
}
|
|
891
939
|
return "";
|
|
@@ -903,9 +951,9 @@ var HttpManager = /** @class */ (function () {
|
|
|
903
951
|
}
|
|
904
952
|
if (responseText) {
|
|
905
953
|
var response = JSON.parse(responseText);
|
|
906
|
-
if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult
|
|
954
|
+
if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[strMsfpc])) {
|
|
907
955
|
// Set cookie
|
|
908
|
-
_cookieMgr.set("MSFPC", response.webResult
|
|
956
|
+
_cookieMgr.set("MSFPC", response.webResult[strMsfpc], 365 * 86400);
|
|
909
957
|
}
|
|
910
958
|
}
|
|
911
959
|
}
|
|
@@ -963,5 +1011,5 @@ var HttpManager = /** @class */ (function () {
|
|
|
963
1011
|
// Removed Stub for HttpManager.prototype.sendSynchronousBatch.
|
|
964
1012
|
return HttpManager;
|
|
965
1013
|
}());
|
|
966
|
-
export
|
|
1014
|
+
export { HttpManager };
|
|
967
1015
|
//# sourceMappingURL=HttpManager.js.map
|