@microsoft/applicationinsights-channel-js 2.8.5-nightly.2206-03 → 2.8.5-nightly.2207-01
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/browser/applicationinsights-channel-js.integrity.json +9 -9
- package/browser/applicationinsights-channel-js.js +1463 -1286
- package/browser/applicationinsights-channel-js.js.map +1 -1
- package/browser/applicationinsights-channel-js.min.js +2 -2
- package/browser/applicationinsights-channel-js.min.js.map +1 -1
- package/dist/applicationinsights-channel-js.api.json +5 -2
- package/dist/applicationinsights-channel-js.d.ts +1 -1
- package/dist/applicationinsights-channel-js.js +1463 -1286
- package/dist/applicationinsights-channel-js.js.map +1 -1
- package/dist/applicationinsights-channel-js.min.js +2 -2
- package/dist/applicationinsights-channel-js.min.js.map +1 -1
- package/dist/applicationinsights-channel-js.rollup.d.ts +1 -1
- package/dist-esm/EnvelopeCreator.js +64 -63
- package/dist-esm/EnvelopeCreator.js.map +1 -1
- package/dist-esm/Interfaces.js +1 -1
- package/dist-esm/InternalConstants.js +13 -0
- package/dist-esm/InternalConstants.js.map +1 -0
- package/dist-esm/Offline.js +7 -6
- package/dist-esm/Offline.js.map +1 -1
- package/dist-esm/SendBuffer.js +51 -50
- package/dist-esm/SendBuffer.js.map +1 -1
- package/dist-esm/Sender.js +178 -172
- package/dist-esm/Sender.js.map +1 -1
- package/dist-esm/Serializer.js +11 -10
- package/dist-esm/Serializer.js.map +1 -1
- package/dist-esm/TelemetryProcessors/Sample.js +6 -5
- package/dist-esm/TelemetryProcessors/Sample.js.map +1 -1
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +4 -3
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js.map +1 -1
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +11 -10
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js.map +1 -1
- package/dist-esm/__DynamicConstants.js +70 -0
- package/dist-esm/__DynamicConstants.js.map +1 -0
- package/dist-esm/applicationinsights-channel-js.js +1 -1
- package/package.json +7 -4
- package/src/EnvelopeCreator.ts +19 -24
- package/src/InternalConstants.ts +11 -0
- package/src/Offline.ts +5 -3
- package/src/SendBuffer.ts +9 -6
- package/src/Sender.ts +46 -46
- package/src/Serializer.ts +7 -7
- package/src/TelemetryProcessors/Sample.ts +10 -10
- package/src/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.ts +4 -4
- package/src/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.ts +8 -8
- package/src/__DynamicConstants.ts +68 -0
- package/types/EnvelopeCreator.d.ts +1 -1
- package/types/InternalConstants.d.ts +1 -0
- package/types/Sender.d.ts +3 -3
- package/types/Serializer.d.ts +1 -1
- package/types/__DynamicConstants.d.ts +56 -0
- package/types/tsdoc-metadata.json +1 -1
package/dist-esm/Sender.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Channel, 2.8.5-nightly.
|
|
2
|
+
* Application Insights JavaScript SDK - Channel, 2.8.5-nightly.2207-01
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
var _a;
|
|
6
6
|
import { __assignFn as __assign, __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
7
|
-
import
|
|
7
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
8
|
+
import { BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, DisabledPropertyName, Event, Exception, Metric, PageView, PageViewPerformance, ProcessLegacy, RemoteDependencyData, RequestHeaders, SampleRate, Trace, isInternalApplicationInsightsEndpoint, utlCanUseSessionStorage } from "@microsoft/applicationinsights-common";
|
|
9
|
+
import { BaseTelemetryPlugin, _throwInternal, _warnToConsole, arrForEach, createUniqueNamespace, dateNow, dumpObj, getExceptionName, getIEVersion, getJSON, getNavigator, getWindow, isArray, isBeaconsSupported, isFetchSupported, isNullOrUndefined, isXhrSupported, mergeEvtNamespace, objForEachKey, objKeys, useXDomainRequest } from "@microsoft/applicationinsights-core-js";
|
|
8
10
|
import { DependencyEnvelopeCreator, EventEnvelopeCreator, ExceptionEnvelopeCreator, MetricEnvelopeCreator, PageViewEnvelopeCreator, PageViewPerformanceEnvelopeCreator, TraceEnvelopeCreator } from "./EnvelopeCreator";
|
|
9
|
-
import { Serializer } from "./Serializer"; // todo move to channel
|
|
10
|
-
import { DisabledPropertyName, RequestHeaders, PageView, Event, Trace, Exception, Metric, PageViewPerformance, RemoteDependencyData, ProcessLegacy, BreezeChannelIdentifier, SampleRate, isInternalApplicationInsightsEndpoint, utlCanUseSessionStorage } from "@microsoft/applicationinsights-common";
|
|
11
|
-
import { getWindow, getNavigator, getJSON, BaseTelemetryPlugin, objForEachKey, isNullOrUndefined, arrForEach, dateNow, dumpObj, getExceptionName, getIEVersion, objKeys, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, isArray, createUniqueNamespace, mergeEvtNamespace, _throwInternal, _warnToConsole } from "@microsoft/applicationinsights-core-js";
|
|
12
11
|
import { createOfflineListener } from "./Offline";
|
|
12
|
+
import { ArraySendBuffer, SessionStorageSendBuffer } from "./SendBuffer";
|
|
13
|
+
import { Serializer } from "./Serializer";
|
|
13
14
|
import { Sample } from "./TelemetryProcessors/Sample";
|
|
14
|
-
import
|
|
15
|
+
import { _DYN_BASE_TYPE, _DYN_BATCH_PAYLOADS, _DYN_CLEAR, _DYN_CLEAR_SENT, _DYN_CONVERT_UNDEFINED, _DYN_COUNT, _DYN_CUSTOM_HEADERS, _DYN_DIAG_LOG, _DYN_DISABLE_INSTRUMENTAT7, _DYN_DISABLE_TELEMETRY, _DYN_DISABLE_XHR, _DYN_EMIT_LINE_DELIMITED_0, _DYN_ENABLE_SESSION_STORA4, _DYN_ENDPOINT_URL, _DYN_ENQUEUE, _DYN_EVENTS_SEND_REQUEST, _DYN_INSTRUMENTATION_KEY, _DYN_IS_BEACON_API_DISABL3, _DYN_IS_RETRY_DISABLED, _DYN_ITEMS_ACCEPTED, _DYN_ITEMS_RECEIVED, _DYN_LENGTH, _DYN_MARK_AS_SENT, _DYN_MAX_BATCH_INTERVAL, _DYN_MAX_BATCH_SIZE_IN_BY1, _DYN_NAME_PREFIX, _DYN_ONUNLOAD_DISABLE_BEA2, _DYN_ONUNLOAD_DISABLE_FET5, _DYN_PUSH, _DYN_SAMPLE_RATE, _DYN_SAMPLING_PERCENTAGE, _DYN_SET_REQUEST_HEADER, _DYN_TAGS, _DYN_TRIGGER_SEND, _DYN__BUFFER, _DYN__ON_ERROR, _DYN__ON_PARTIAL_SUCCESS, _DYN__ON_SUCCESS, _DYN__SENDER, _DYN__SENDER_CONFIG, _DYN__XHR_READY_STATE_CHA6 } from "./__DynamicConstants";
|
|
15
16
|
var FetchSyncRequestSizeLimitBytes = 65000; // approx 64kb (the current Edge, Firefox and Chrome max limit)
|
|
16
17
|
function _getResponseText(xhr) {
|
|
17
18
|
try {
|
|
@@ -23,26 +24,30 @@ function _getResponseText(xhr) {
|
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
26
|
function _getDefaultAppInsightsChannelConfig() {
|
|
27
|
+
var _a;
|
|
28
|
+
var defaultValue;
|
|
29
|
+
var defaultCustomHeaders;
|
|
26
30
|
// set default values
|
|
27
|
-
return {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
return _a = {
|
|
32
|
+
endpointUrl: function () { return DEFAULT_BREEZE_ENDPOINT + DEFAULT_BREEZE_PATH; }
|
|
33
|
+
},
|
|
34
|
+
_a[_DYN_EMIT_LINE_DELIMITED_0 /* @min:emitLineDelimitedJson */] = function () { return false; },
|
|
35
|
+
_a[_DYN_MAX_BATCH_INTERVAL /* @min:maxBatchInterval */] = function () { return 15000; },
|
|
36
|
+
_a[_DYN_MAX_BATCH_SIZE_IN_BY1 /* @min:maxBatchSizeInBytes */] = function () { return 102400; },
|
|
37
|
+
_a[_DYN_DISABLE_TELEMETRY /* @min:disableTelemetry */] = function () { return false; },
|
|
38
|
+
_a[_DYN_ENABLE_SESSION_STORA4 /* @min:enableSessionStorageBuffer */] = function () { return true; },
|
|
39
|
+
_a[_DYN_IS_RETRY_DISABLED /* @min:isRetryDisabled */] = function () { return false; },
|
|
40
|
+
_a[_DYN_IS_BEACON_API_DISABL3 /* @min:isBeaconApiDisabled */] = function () { return true; },
|
|
41
|
+
_a[_DYN_DISABLE_XHR /* @min:disableXhr */] = function () { return false; },
|
|
42
|
+
_a[_DYN_ONUNLOAD_DISABLE_FET5 /* @min:onunloadDisableFetch */] = function () { return false; },
|
|
43
|
+
_a[_DYN_ONUNLOAD_DISABLE_BEA2 /* @min:onunloadDisableBeacon */] = function () { return false; },
|
|
44
|
+
_a[_DYN_INSTRUMENTATION_KEY /* @min:instrumentationKey */] = function () { return defaultValue; },
|
|
45
|
+
_a[_DYN_NAME_PREFIX /* @min:namePrefix */] = function () { return defaultValue; },
|
|
46
|
+
_a[_DYN_SAMPLING_PERCENTAGE /* @min:samplingPercentage */] = function () { return 100; },
|
|
47
|
+
_a[_DYN_CUSTOM_HEADERS /* @min:customHeaders */] = function () { return defaultCustomHeaders; },
|
|
48
|
+
_a[_DYN_CONVERT_UNDEFINED /* @min:convertUndefined */] = function () { return defaultValue; },
|
|
49
|
+
_a.eventsLimitInMem = function () { return 10000; },
|
|
50
|
+
_a;
|
|
46
51
|
}
|
|
47
52
|
var EnvelopeTypeCreator = (_a = {},
|
|
48
53
|
_a[Event.dataType] = EventEnvelopeCreator,
|
|
@@ -88,8 +93,8 @@ var Sender = /** @class */ (function (_super) {
|
|
|
88
93
|
_paused = false;
|
|
89
94
|
_retryAt = null;
|
|
90
95
|
// flush if we have exceeded the max-size already
|
|
91
|
-
if (_self._buffer.size() > _self._senderConfig
|
|
92
|
-
_self
|
|
96
|
+
if (_self._buffer.size() > _self._senderConfig[_DYN_MAX_BATCH_SIZE_IN_BY1 /* @min:%2emaxBatchSizeInBytes */]()) {
|
|
97
|
+
_self[_DYN_TRIGGER_SEND /* @min:%2etriggerSend */](true, null, 10 /* SendRequestReason.MaxBatchSize */);
|
|
93
98
|
}
|
|
94
99
|
_setupTimer();
|
|
95
100
|
}
|
|
@@ -100,21 +105,21 @@ var Sender = /** @class */ (function (_super) {
|
|
|
100
105
|
// Clear the normal schedule timer as we are going to try and flush ASAP
|
|
101
106
|
_clearScheduledTimer();
|
|
102
107
|
try {
|
|
103
|
-
_self
|
|
108
|
+
_self[_DYN_TRIGGER_SEND /* @min:%2etriggerSend */](isAsync, null, sendReason || 1 /* SendRequestReason.ManualFlush */);
|
|
104
109
|
}
|
|
105
110
|
catch (e) {
|
|
106
|
-
_throwInternal(_self
|
|
111
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 22 /* _eInternalMessageId.FlushFailed */, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
};
|
|
110
115
|
_self.onunloadFlush = function () {
|
|
111
116
|
if (!_paused) {
|
|
112
|
-
if ((_self._senderConfig
|
|
117
|
+
if ((_self._senderConfig[_DYN_ONUNLOAD_DISABLE_BEA2 /* @min:%2eonunloadDisableBeacon */]() === false || _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_IS_BEACON_API_DISABL3 /* @min:%2eisBeaconApiDisabled */]() === false) && isBeaconsSupported()) {
|
|
113
118
|
try {
|
|
114
|
-
_self
|
|
119
|
+
_self[_DYN_TRIGGER_SEND /* @min:%2etriggerSend */](true, _doUnloadSend, 2 /* SendRequestReason.Unload */);
|
|
115
120
|
}
|
|
116
121
|
catch (e) {
|
|
117
|
-
_throwInternal(_self
|
|
122
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 20 /* _eInternalMessageId.FailedToSendQueuedTelemetry */, "failed to flush with beacon sender on page unload, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
else {
|
|
@@ -127,7 +132,7 @@ var Sender = /** @class */ (function (_super) {
|
|
|
127
132
|
};
|
|
128
133
|
_self.initialize = function (config, core, extensions, pluginChain) {
|
|
129
134
|
if (_self.isInitialized()) {
|
|
130
|
-
_throwInternal(_self
|
|
135
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 28 /* _eInternalMessageId.SenderNotInitialized */, "Sender is already initialized");
|
|
131
136
|
}
|
|
132
137
|
_base.initialize(config, core, extensions, pluginChain);
|
|
133
138
|
var ctx = _self._getTelCtx();
|
|
@@ -136,32 +141,32 @@ var Sender = /** @class */ (function (_super) {
|
|
|
136
141
|
_consecutiveErrors = 0;
|
|
137
142
|
_retryAt = null;
|
|
138
143
|
_lastSend = 0;
|
|
139
|
-
_self
|
|
144
|
+
_self[_DYN__SENDER /* @min:%2e_sender */] = null;
|
|
140
145
|
_stamp_specific_redirects = 0;
|
|
141
|
-
var diagLog = _self
|
|
146
|
+
var diagLog = _self[_DYN_DIAG_LOG /* @min:%2ediagLog */]();
|
|
142
147
|
_evtNamespace = mergeEvtNamespace(createUniqueNamespace("Sender"), core.evtNamespace && core.evtNamespace());
|
|
143
148
|
_offlineListener = createOfflineListener(_evtNamespace);
|
|
144
149
|
var defaultConfig = _getDefaultAppInsightsChannelConfig();
|
|
145
150
|
objForEachKey(defaultConfig, function (field, value) {
|
|
146
|
-
_self
|
|
151
|
+
_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][field] = function () { return ctx.getConfig(identifier, field, value()); };
|
|
147
152
|
});
|
|
148
|
-
_self._buffer = (_self
|
|
149
|
-
? new SessionStorageSendBuffer(diagLog, _self
|
|
150
|
-
_self._sample = new Sample(_self
|
|
153
|
+
_self._buffer = (_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENABLE_SESSION_STORA4 /* @min:%2eenableSessionStorageBuffer */]() && utlCanUseSessionStorage())
|
|
154
|
+
? new SessionStorageSendBuffer(diagLog, _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */]) : new ArraySendBuffer(diagLog, _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */]);
|
|
155
|
+
_self._sample = new Sample(_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_SAMPLING_PERCENTAGE /* @min:%2esamplingPercentage */](), diagLog);
|
|
151
156
|
if (!_validateInstrumentationKey(config)) {
|
|
152
|
-
_throwInternal(diagLog, 1 /* eLoggingSeverity.CRITICAL */, 100 /* _eInternalMessageId.InvalidInstrumentationKey */, "Invalid Instrumentation key " + config
|
|
157
|
+
_throwInternal(diagLog, 1 /* eLoggingSeverity.CRITICAL */, 100 /* _eInternalMessageId.InvalidInstrumentationKey */, "Invalid Instrumentation key " + config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */]);
|
|
153
158
|
}
|
|
154
|
-
if (!isInternalApplicationInsightsEndpoint(_self._senderConfig.endpointUrl()) && _self._senderConfig.customHeaders() && _self._senderConfig.customHeaders()
|
|
155
|
-
arrForEach(_self
|
|
159
|
+
if (!isInternalApplicationInsightsEndpoint(_self._senderConfig.endpointUrl()) && _self._senderConfig.customHeaders() && _self._senderConfig.customHeaders()[_DYN_LENGTH /* @min:%2elength */] > 0) {
|
|
160
|
+
arrForEach(_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_CUSTOM_HEADERS /* @min:%2ecustomHeaders */](), function (customHeader) {
|
|
156
161
|
_this.addHeader(customHeader.header, customHeader.value);
|
|
157
162
|
});
|
|
158
163
|
}
|
|
159
|
-
var senderConfig = _self
|
|
164
|
+
var senderConfig = _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */];
|
|
160
165
|
var sendPostFunc = null;
|
|
161
|
-
if (!senderConfig
|
|
166
|
+
if (!senderConfig[_DYN_DISABLE_XHR /* @min:%2edisableXhr */]() && useXDomainRequest()) {
|
|
162
167
|
sendPostFunc = _xdrSender; // IE 8 and 9
|
|
163
168
|
}
|
|
164
|
-
else if (!senderConfig
|
|
169
|
+
else if (!senderConfig[_DYN_DISABLE_XHR /* @min:%2edisableXhr */]() && isXhrSupported()) {
|
|
165
170
|
sendPostFunc = _xhrSender;
|
|
166
171
|
}
|
|
167
172
|
if (!sendPostFunc && isFetchSupported()) {
|
|
@@ -169,12 +174,12 @@ var Sender = /** @class */ (function (_super) {
|
|
|
169
174
|
}
|
|
170
175
|
// always fallback to XHR
|
|
171
176
|
_fallbackSender = sendPostFunc || _xhrSender;
|
|
172
|
-
if (!senderConfig
|
|
177
|
+
if (!senderConfig[_DYN_IS_BEACON_API_DISABL3 /* @min:%2eisBeaconApiDisabled */]() && isBeaconsSupported()) {
|
|
173
178
|
// Config is set to always used beacon sending
|
|
174
179
|
sendPostFunc = _beaconSender;
|
|
175
180
|
}
|
|
176
|
-
_self
|
|
177
|
-
if (!senderConfig
|
|
181
|
+
_self[_DYN__SENDER /* @min:%2e_sender */] = sendPostFunc || _xhrSender;
|
|
182
|
+
if (!senderConfig[_DYN_ONUNLOAD_DISABLE_FET5 /* @min:%2eonunloadDisableFetch */]() && isFetchSupported(true)) {
|
|
178
183
|
// Try and use the fetch with keepalive
|
|
179
184
|
_syncUnloadSender = _fetchKeepAliveSender;
|
|
180
185
|
}
|
|
@@ -182,10 +187,10 @@ var Sender = /** @class */ (function (_super) {
|
|
|
182
187
|
// Try and use sendBeacon
|
|
183
188
|
_syncUnloadSender = _beaconSender;
|
|
184
189
|
}
|
|
185
|
-
else if (!senderConfig
|
|
190
|
+
else if (!senderConfig[_DYN_DISABLE_XHR /* @min:%2edisableXhr */]() && useXDomainRequest()) {
|
|
186
191
|
_syncUnloadSender = _xdrSender; // IE 8 and 9
|
|
187
192
|
}
|
|
188
|
-
else if (!senderConfig
|
|
193
|
+
else if (!senderConfig[_DYN_DISABLE_XHR /* @min:%2edisableXhr */]() && isXhrSupported()) {
|
|
189
194
|
_syncUnloadSender = _xhrSender;
|
|
190
195
|
}
|
|
191
196
|
else {
|
|
@@ -194,66 +199,67 @@ var Sender = /** @class */ (function (_super) {
|
|
|
194
199
|
};
|
|
195
200
|
_self.processTelemetry = function (telemetryItem, itemCtx) {
|
|
196
201
|
itemCtx = _self._getTelCtx(itemCtx);
|
|
202
|
+
var diagLogger = itemCtx[_DYN_DIAG_LOG /* @min:%2ediagLog */]();
|
|
197
203
|
try {
|
|
198
204
|
// if master off switch is set, don't send any data
|
|
199
|
-
if (_self
|
|
205
|
+
if (_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_DISABLE_TELEMETRY /* @min:%2edisableTelemetry */]()) {
|
|
200
206
|
// Do not send/save data
|
|
201
207
|
return;
|
|
202
208
|
}
|
|
203
209
|
// validate input
|
|
204
210
|
if (!telemetryItem) {
|
|
205
|
-
_throwInternal(
|
|
211
|
+
_throwInternal(diagLogger, 1 /* eLoggingSeverity.CRITICAL */, 7 /* _eInternalMessageId.CannotSendEmptyTelemetry */, "Cannot send empty telemetry");
|
|
206
212
|
return;
|
|
207
213
|
}
|
|
208
214
|
// validate event
|
|
209
|
-
if (telemetryItem.baseData && !telemetryItem
|
|
210
|
-
_throwInternal(
|
|
215
|
+
if (telemetryItem.baseData && !telemetryItem[_DYN_BASE_TYPE /* @min:%2ebaseType */]) {
|
|
216
|
+
_throwInternal(diagLogger, 1 /* eLoggingSeverity.CRITICAL */, 70 /* _eInternalMessageId.InvalidEvent */, "Cannot send telemetry without baseData and baseType");
|
|
211
217
|
return;
|
|
212
218
|
}
|
|
213
|
-
if (!telemetryItem
|
|
219
|
+
if (!telemetryItem[_DYN_BASE_TYPE /* @min:%2ebaseType */]) {
|
|
214
220
|
// Default
|
|
215
|
-
telemetryItem
|
|
221
|
+
telemetryItem[_DYN_BASE_TYPE /* @min:%2ebaseType */] = "EventData";
|
|
216
222
|
}
|
|
217
223
|
// ensure a sender was constructed
|
|
218
|
-
if (!_self
|
|
219
|
-
_throwInternal(
|
|
224
|
+
if (!_self[_DYN__SENDER /* @min:%2e_sender */]) {
|
|
225
|
+
_throwInternal(diagLogger, 1 /* eLoggingSeverity.CRITICAL */, 28 /* _eInternalMessageId.SenderNotInitialized */, "Sender was not initialized");
|
|
220
226
|
return;
|
|
221
227
|
}
|
|
222
228
|
// check if this item should be sampled in, else add sampleRate tag
|
|
223
229
|
if (!_isSampledIn(telemetryItem)) {
|
|
224
230
|
// Item is sampled out, do not send it
|
|
225
|
-
_throwInternal(
|
|
231
|
+
_throwInternal(diagLogger, 2 /* eLoggingSeverity.WARNING */, 33 /* _eInternalMessageId.TelemetrySampledAndNotSent */, "Telemetry item was sampled out and not sent", { SampleRate: _self._sample[_DYN_SAMPLE_RATE /* @min:%2esampleRate */] });
|
|
226
232
|
return;
|
|
227
233
|
}
|
|
228
234
|
else {
|
|
229
|
-
telemetryItem[SampleRate] = _self._sample
|
|
235
|
+
telemetryItem[SampleRate] = _self._sample[_DYN_SAMPLE_RATE /* @min:%2esampleRate */];
|
|
230
236
|
}
|
|
231
|
-
var convertUndefined = _self
|
|
237
|
+
var convertUndefined = _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_CONVERT_UNDEFINED /* @min:%2econvertUndefined */]() || undefined;
|
|
232
238
|
// construct an envelope that Application Insights endpoint can understand
|
|
233
239
|
// if ikey of telemetry is provided and not empty, envelope will use this iKey instead of senderConfig iKey
|
|
234
|
-
var defaultEnvelopeIkey = telemetryItem.iKey || _self
|
|
235
|
-
var aiEnvelope_1 = Sender.constructEnvelope(telemetryItem, defaultEnvelopeIkey,
|
|
240
|
+
var defaultEnvelopeIkey = telemetryItem.iKey || _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */]();
|
|
241
|
+
var aiEnvelope_1 = Sender.constructEnvelope(telemetryItem, defaultEnvelopeIkey, diagLogger, convertUndefined);
|
|
236
242
|
if (!aiEnvelope_1) {
|
|
237
|
-
_throwInternal(
|
|
243
|
+
_throwInternal(diagLogger, 1 /* eLoggingSeverity.CRITICAL */, 47 /* _eInternalMessageId.CreateEnvelopeError */, "Unable to create an AppInsights envelope");
|
|
238
244
|
return;
|
|
239
245
|
}
|
|
240
246
|
var doNotSendItem_1 = false;
|
|
241
247
|
// this is for running in legacy mode, where customer may already have a custom initializer present
|
|
242
|
-
if (telemetryItem
|
|
243
|
-
arrForEach(telemetryItem
|
|
248
|
+
if (telemetryItem[_DYN_TAGS /* @min:%2etags */] && telemetryItem[_DYN_TAGS /* @min:%2etags */][ProcessLegacy]) {
|
|
249
|
+
arrForEach(telemetryItem[_DYN_TAGS /* @min:%2etags */][ProcessLegacy], function (callBack) {
|
|
244
250
|
try {
|
|
245
251
|
if (callBack && callBack(aiEnvelope_1) === false) {
|
|
246
252
|
doNotSendItem_1 = true;
|
|
247
|
-
_warnToConsole(
|
|
253
|
+
_warnToConsole(diagLogger, "Telemetry processor check returns false");
|
|
248
254
|
}
|
|
249
255
|
}
|
|
250
256
|
catch (e) {
|
|
251
257
|
// log error but dont stop executing rest of the telemetry initializers
|
|
252
258
|
// doNotSendItem = true;
|
|
253
|
-
_throwInternal(
|
|
259
|
+
_throwInternal(diagLogger, 1 /* eLoggingSeverity.CRITICAL */, 64 /* _eInternalMessageId.TelemetryInitializerFailed */, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
|
|
254
260
|
}
|
|
255
261
|
});
|
|
256
|
-
delete telemetryItem
|
|
262
|
+
delete telemetryItem[_DYN_TAGS /* @min:%2etags */][ProcessLegacy];
|
|
257
263
|
}
|
|
258
264
|
if (doNotSendItem_1) {
|
|
259
265
|
return; // do not send, no need to execute next plugin
|
|
@@ -261,18 +267,18 @@ var Sender = /** @class */ (function (_super) {
|
|
|
261
267
|
// check if the incoming payload is too large, truncate if necessary
|
|
262
268
|
var payload = _serializer.serialize(aiEnvelope_1);
|
|
263
269
|
// flush if we would exceed the max-size limit by adding this item
|
|
264
|
-
var buffer = _self
|
|
270
|
+
var buffer = _self[_DYN__BUFFER /* @min:%2e_buffer */];
|
|
265
271
|
var bufferSize = buffer.size();
|
|
266
|
-
if ((bufferSize + payload
|
|
267
|
-
_self
|
|
272
|
+
if ((bufferSize + payload[_DYN_LENGTH /* @min:%2elength */]) > _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_MAX_BATCH_SIZE_IN_BY1 /* @min:%2emaxBatchSizeInBytes */]()) {
|
|
273
|
+
_self[_DYN_TRIGGER_SEND /* @min:%2etriggerSend */](true, null, 10 /* SendRequestReason.MaxBatchSize */);
|
|
268
274
|
}
|
|
269
275
|
// enqueue the payload
|
|
270
|
-
buffer
|
|
276
|
+
buffer[_DYN_ENQUEUE /* @min:%2eenqueue */](payload);
|
|
271
277
|
// ensure an invocation timeout is set
|
|
272
278
|
_setupTimer();
|
|
273
279
|
}
|
|
274
280
|
catch (e) {
|
|
275
|
-
_throwInternal(
|
|
281
|
+
_throwInternal(diagLogger, 2 /* eLoggingSeverity.WARNING */, 12 /* _eInternalMessageId.FailedAddingTelemetryToBuffer */, "Failed adding telemetry to the sender's buffer, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
276
282
|
}
|
|
277
283
|
// hand off the telemetry item to the next plugin
|
|
278
284
|
_self.processNext(telemetryItem, itemCtx);
|
|
@@ -280,7 +286,7 @@ var Sender = /** @class */ (function (_super) {
|
|
|
280
286
|
/**
|
|
281
287
|
* xhr state changes
|
|
282
288
|
*/
|
|
283
|
-
_self
|
|
289
|
+
_self[_DYN__XHR_READY_STATE_CHA6 /* @min:%2e_xhrReadyStateChange */] = function (xhr, payload, countOfItemsInPayload) {
|
|
284
290
|
if (xhr.readyState === 4) {
|
|
285
291
|
_checkResponsStatus(xhr.status, payload, xhr.responseURL, countOfItemsInPayload, _formatErrorMessageXhr(xhr), _getResponseText(xhr) || xhr.response);
|
|
286
292
|
}
|
|
@@ -290,14 +296,14 @@ var Sender = /** @class */ (function (_super) {
|
|
|
290
296
|
* @param async {boolean} - Indicates if the events should be sent asynchronously
|
|
291
297
|
* @param forcedSender {SenderFunction} - Indicates the forcedSender, undefined if not passed
|
|
292
298
|
*/
|
|
293
|
-
_self
|
|
299
|
+
_self[_DYN_TRIGGER_SEND /* @min:%2etriggerSend */] = function (async, forcedSender, sendReason) {
|
|
294
300
|
if (async === void 0) { async = true; }
|
|
295
301
|
if (!_paused) {
|
|
296
302
|
try {
|
|
297
|
-
var buffer = _self
|
|
303
|
+
var buffer = _self[_DYN__BUFFER /* @min:%2e_buffer */];
|
|
298
304
|
// Send data only if disableTelemetry is false
|
|
299
|
-
if (!_self
|
|
300
|
-
if (buffer
|
|
305
|
+
if (!_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_DISABLE_TELEMETRY /* @min:%2edisableTelemetry */]()) {
|
|
306
|
+
if (buffer[_DYN_COUNT /* @min:%2ecount */]() > 0) {
|
|
301
307
|
var payload = buffer.getItems();
|
|
302
308
|
_notifySendRequest(sendReason || 0 /* SendRequestReason.Undefined */, async);
|
|
303
309
|
// invoke send
|
|
@@ -305,14 +311,14 @@ var Sender = /** @class */ (function (_super) {
|
|
|
305
311
|
forcedSender.call(_this, payload, async);
|
|
306
312
|
}
|
|
307
313
|
else {
|
|
308
|
-
_self
|
|
314
|
+
_self[_DYN__SENDER /* @min:%2e_sender */](payload, async);
|
|
309
315
|
}
|
|
310
316
|
}
|
|
311
317
|
// update lastSend time to enable throttling
|
|
312
318
|
_lastSend = +new Date;
|
|
313
319
|
}
|
|
314
320
|
else {
|
|
315
|
-
buffer
|
|
321
|
+
buffer[_DYN_CLEAR /* @min:%2eclear */]();
|
|
316
322
|
}
|
|
317
323
|
_clearScheduledTimer();
|
|
318
324
|
}
|
|
@@ -320,7 +326,7 @@ var Sender = /** @class */ (function (_super) {
|
|
|
320
326
|
/* Ignore this error for IE under v10 */
|
|
321
327
|
var ieVer = getIEVersion();
|
|
322
328
|
if (!ieVer || ieVer > 9) {
|
|
323
|
-
_throwInternal(_self
|
|
329
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 40 /* _eInternalMessageId.TransmissionFailed */, "Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
324
330
|
}
|
|
325
331
|
}
|
|
326
332
|
}
|
|
@@ -333,14 +339,14 @@ var Sender = /** @class */ (function (_super) {
|
|
|
333
339
|
/**
|
|
334
340
|
* error handler
|
|
335
341
|
*/
|
|
336
|
-
_self
|
|
337
|
-
_throwInternal(_self
|
|
338
|
-
_self._buffer
|
|
342
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */] = function (payload, message, event) {
|
|
343
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 2 /* eLoggingSeverity.WARNING */, 26 /* _eInternalMessageId.OnError */, "Failed to send telemetry.", { message: message });
|
|
344
|
+
_self._buffer[_DYN_CLEAR_SENT /* @min:%2eclearSent */](payload);
|
|
339
345
|
};
|
|
340
346
|
/**
|
|
341
347
|
* partial success handler
|
|
342
348
|
*/
|
|
343
|
-
_self
|
|
349
|
+
_self[_DYN__ON_PARTIAL_SUCCESS /* @min:%2e_onPartialSuccess */] = function (payload, results) {
|
|
344
350
|
var failed = [];
|
|
345
351
|
var retry = [];
|
|
346
352
|
// Iterate through the reversed array of errors so that splicing doesn't have invalid indexes after the first item.
|
|
@@ -349,31 +355,31 @@ var Sender = /** @class */ (function (_super) {
|
|
|
349
355
|
var error = errors_1[_i];
|
|
350
356
|
var extracted = payload.splice(error.index, 1)[0];
|
|
351
357
|
if (_isRetriable(error.statusCode)) {
|
|
352
|
-
retry
|
|
358
|
+
retry[_DYN_PUSH /* @min:%2epush */](extracted);
|
|
353
359
|
}
|
|
354
360
|
else {
|
|
355
361
|
// All other errors, including: 402 (Monthly quota exceeded) and 439 (Too many requests and refresh cache).
|
|
356
|
-
failed
|
|
362
|
+
failed[_DYN_PUSH /* @min:%2epush */](extracted);
|
|
357
363
|
}
|
|
358
364
|
}
|
|
359
|
-
if (payload
|
|
360
|
-
_self
|
|
365
|
+
if (payload[_DYN_LENGTH /* @min:%2elength */] > 0) {
|
|
366
|
+
_self[_DYN__ON_SUCCESS /* @min:%2e_onSuccess */](payload, results[_DYN_ITEMS_ACCEPTED /* @min:%2eitemsAccepted */]);
|
|
361
367
|
}
|
|
362
|
-
if (failed
|
|
363
|
-
_self
|
|
368
|
+
if (failed[_DYN_LENGTH /* @min:%2elength */] > 0) {
|
|
369
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](failed, _formatErrorMessageXhr(null, ["partial success", results[_DYN_ITEMS_ACCEPTED /* @min:%2eitemsAccepted */], "of", results.itemsReceived].join(" ")));
|
|
364
370
|
}
|
|
365
|
-
if (retry
|
|
371
|
+
if (retry[_DYN_LENGTH /* @min:%2elength */] > 0) {
|
|
366
372
|
_resendPayload(retry);
|
|
367
|
-
_throwInternal(_self
|
|
368
|
-
"Delivered: " + payload
|
|
369
|
-
". Will retry to send " + retry
|
|
373
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 2 /* eLoggingSeverity.WARNING */, 40 /* _eInternalMessageId.TransmissionFailed */, "Partial success. " +
|
|
374
|
+
"Delivered: " + payload[_DYN_LENGTH /* @min:%2elength */] + ", Failed: " + failed[_DYN_LENGTH /* @min:%2elength */] +
|
|
375
|
+
". Will retry to send " + retry[_DYN_LENGTH /* @min:%2elength */] + " our of " + results[_DYN_ITEMS_RECEIVED /* @min:%2eitemsReceived */] + " items");
|
|
370
376
|
}
|
|
371
377
|
};
|
|
372
378
|
/**
|
|
373
379
|
* success handler
|
|
374
380
|
*/
|
|
375
|
-
_self
|
|
376
|
-
_self._buffer
|
|
381
|
+
_self[_DYN__ON_SUCCESS /* @min:%2e_onSuccess */] = function (payload, countOfItemsInPayload) {
|
|
382
|
+
_self._buffer[_DYN_CLEAR_SENT /* @min:%2eclearSent */](payload);
|
|
377
383
|
};
|
|
378
384
|
/**
|
|
379
385
|
* xdr state changes
|
|
@@ -382,16 +388,16 @@ var Sender = /** @class */ (function (_super) {
|
|
|
382
388
|
var responseText = _getResponseText(xdr);
|
|
383
389
|
if (xdr && (responseText + "" === "200" || responseText === "")) {
|
|
384
390
|
_consecutiveErrors = 0;
|
|
385
|
-
_self
|
|
391
|
+
_self[_DYN__ON_SUCCESS /* @min:%2e_onSuccess */](payload, 0);
|
|
386
392
|
}
|
|
387
393
|
else {
|
|
388
394
|
var results = _parseResponse(responseText);
|
|
389
|
-
if (results && results.itemsReceived && results.itemsReceived > results
|
|
390
|
-
&& !_self
|
|
391
|
-
_self
|
|
395
|
+
if (results && results.itemsReceived && results.itemsReceived > results[_DYN_ITEMS_ACCEPTED /* @min:%2eitemsAccepted */]
|
|
396
|
+
&& !_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_IS_RETRY_DISABLED /* @min:%2eisRetryDisabled */]()) {
|
|
397
|
+
_self[_DYN__ON_PARTIAL_SUCCESS /* @min:%2e_onPartialSuccess */](payload, results);
|
|
392
398
|
}
|
|
393
399
|
else {
|
|
394
|
-
_self
|
|
400
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, _formatErrorMessageXdr(xdr));
|
|
395
401
|
}
|
|
396
402
|
}
|
|
397
403
|
};
|
|
@@ -411,25 +417,25 @@ var Sender = /** @class */ (function (_super) {
|
|
|
411
417
|
// Updates the end point url before retry
|
|
412
418
|
if (status === 301 || status === 307 || status === 308) {
|
|
413
419
|
if (!_checkAndUpdateEndPointUrl(responseUrl)) {
|
|
414
|
-
_self
|
|
420
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, errorMessage);
|
|
415
421
|
return;
|
|
416
422
|
}
|
|
417
423
|
}
|
|
418
|
-
if (!_self
|
|
424
|
+
if (!_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_IS_RETRY_DISABLED /* @min:%2eisRetryDisabled */]() && _isRetriable(status)) {
|
|
419
425
|
_resendPayload(payload);
|
|
420
|
-
_throwInternal(_self
|
|
421
|
-
"Response code " + status + ". Will retry to send " + payload
|
|
426
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 2 /* eLoggingSeverity.WARNING */, 40 /* _eInternalMessageId.TransmissionFailed */, ". " +
|
|
427
|
+
"Response code " + status + ". Will retry to send " + payload[_DYN_LENGTH /* @min:%2elength */] + " items.");
|
|
422
428
|
}
|
|
423
429
|
else {
|
|
424
|
-
_self
|
|
430
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, errorMessage);
|
|
425
431
|
}
|
|
426
432
|
}
|
|
427
433
|
else if (_offlineListener && !_offlineListener.isOnline()) { // offline
|
|
428
434
|
// Note: Don't check for status == 0, since adblock gives this code
|
|
429
|
-
if (!_self
|
|
435
|
+
if (!_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_IS_RETRY_DISABLED /* @min:%2eisRetryDisabled */]()) {
|
|
430
436
|
var offlineBackOffMultiplier = 10; // arbritrary number
|
|
431
437
|
_resendPayload(payload, offlineBackOffMultiplier);
|
|
432
|
-
_throwInternal(_self
|
|
438
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 2 /* eLoggingSeverity.WARNING */, 40 /* _eInternalMessageId.TransmissionFailed */, ". Offline - Response Code: ".concat(status, ". Offline status: ").concat(!_offlineListener.isOnline(), ". Will retry to send ").concat(payload.length, " items."));
|
|
433
439
|
}
|
|
434
440
|
}
|
|
435
441
|
else {
|
|
@@ -440,16 +446,16 @@ var Sender = /** @class */ (function (_super) {
|
|
|
440
446
|
if (!response) {
|
|
441
447
|
response = _parseResponse(res);
|
|
442
448
|
}
|
|
443
|
-
if (response && !_self
|
|
444
|
-
_self
|
|
449
|
+
if (response && !_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_IS_RETRY_DISABLED /* @min:%2eisRetryDisabled */]()) {
|
|
450
|
+
_self[_DYN__ON_PARTIAL_SUCCESS /* @min:%2e_onPartialSuccess */](payload, response);
|
|
445
451
|
}
|
|
446
452
|
else {
|
|
447
|
-
_self
|
|
453
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, errorMessage);
|
|
448
454
|
}
|
|
449
455
|
}
|
|
450
456
|
else {
|
|
451
457
|
_consecutiveErrors = 0;
|
|
452
|
-
_self
|
|
458
|
+
_self[_DYN__ON_SUCCESS /* @min:%2e_onSuccess */](payload, countOfItemsInPayload);
|
|
453
459
|
}
|
|
454
460
|
}
|
|
455
461
|
}
|
|
@@ -461,8 +467,8 @@ var Sender = /** @class */ (function (_super) {
|
|
|
461
467
|
return false;
|
|
462
468
|
}
|
|
463
469
|
if (!isNullOrUndefined(responseUrl) && responseUrl !== "") {
|
|
464
|
-
if (responseUrl !== _self
|
|
465
|
-
_self
|
|
470
|
+
if (responseUrl !== _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENDPOINT_URL /* @min:%2eendpointUrl */]()) {
|
|
471
|
+
_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENDPOINT_URL /* @min:%2eendpointUrl */] = function () { return responseUrl; };
|
|
466
472
|
++_stamp_specific_redirects;
|
|
467
473
|
return true;
|
|
468
474
|
}
|
|
@@ -481,18 +487,18 @@ var Sender = /** @class */ (function (_super) {
|
|
|
481
487
|
}
|
|
482
488
|
function _doBeaconSend(payload) {
|
|
483
489
|
var nav = getNavigator();
|
|
484
|
-
var buffer = _self
|
|
485
|
-
var url = _self
|
|
486
|
-
var batch = _self._buffer
|
|
490
|
+
var buffer = _self[_DYN__BUFFER /* @min:%2e_buffer */];
|
|
491
|
+
var url = _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENDPOINT_URL /* @min:%2eendpointUrl */]();
|
|
492
|
+
var batch = _self._buffer[_DYN_BATCH_PAYLOADS /* @min:%2ebatchPayloads */](payload);
|
|
487
493
|
// Chrome only allows CORS-safelisted values for the sendBeacon data argument
|
|
488
494
|
// see: https://bugs.chromium.org/p/chromium/issues/detail?id=720283
|
|
489
495
|
var plainTextBatch = new Blob([batch], { type: "text/plain;charset=UTF-8" });
|
|
490
496
|
// The sendBeacon method returns true if the user agent is able to successfully queue the data for transfer. Otherwise it returns false.
|
|
491
497
|
var queued = nav.sendBeacon(url, plainTextBatch);
|
|
492
498
|
if (queued) {
|
|
493
|
-
buffer
|
|
499
|
+
buffer[_DYN_MARK_AS_SENT /* @min:%2emarkAsSent */](payload);
|
|
494
500
|
// no response from beaconSender, clear buffer
|
|
495
|
-
_self._onSuccess(payload, payload
|
|
501
|
+
_self._onSuccess(payload, payload[_DYN_LENGTH /* @min:%2elength */]);
|
|
496
502
|
}
|
|
497
503
|
return queued;
|
|
498
504
|
}
|
|
@@ -504,21 +510,21 @@ var Sender = /** @class */ (function (_super) {
|
|
|
504
510
|
* appId from the backend for the correct correlation.
|
|
505
511
|
*/
|
|
506
512
|
function _beaconSender(payload, isAsync) {
|
|
507
|
-
if (isArray(payload) && payload
|
|
513
|
+
if (isArray(payload) && payload[_DYN_LENGTH /* @min:%2elength */] > 0) {
|
|
508
514
|
// The sendBeacon method returns true if the user agent is able to successfully queue the data for transfer. Otherwise it returns false.
|
|
509
515
|
if (!_doBeaconSend(payload)) {
|
|
510
516
|
// Failed to send entire payload so try and split data and try to send as much events as possible
|
|
511
517
|
var droppedPayload = [];
|
|
512
|
-
for (var lp = 0; lp < payload
|
|
518
|
+
for (var lp = 0; lp < payload[_DYN_LENGTH /* @min:%2elength */]; lp++) {
|
|
513
519
|
var thePayload = payload[lp];
|
|
514
520
|
if (!_doBeaconSend([thePayload])) {
|
|
515
521
|
// Can't send anymore, so split the batch and drop the rest
|
|
516
|
-
droppedPayload
|
|
522
|
+
droppedPayload[_DYN_PUSH /* @min:%2epush */](thePayload);
|
|
517
523
|
}
|
|
518
524
|
}
|
|
519
|
-
if (droppedPayload
|
|
525
|
+
if (droppedPayload[_DYN_LENGTH /* @min:%2elength */] > 0) {
|
|
520
526
|
_fallbackSender && _fallbackSender(droppedPayload, true);
|
|
521
|
-
_throwInternal(_self
|
|
527
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 2 /* eLoggingSeverity.WARNING */, 40 /* _eInternalMessageId.TransmissionFailed */, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
|
|
522
528
|
}
|
|
523
529
|
}
|
|
524
530
|
}
|
|
@@ -530,7 +536,7 @@ var Sender = /** @class */ (function (_super) {
|
|
|
530
536
|
*/
|
|
531
537
|
function _xhrSender(payload, isAsync) {
|
|
532
538
|
var xhr = new XMLHttpRequest();
|
|
533
|
-
var endPointUrl = _self
|
|
539
|
+
var endPointUrl = _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENDPOINT_URL /* @min:%2eendpointUrl */]();
|
|
534
540
|
try {
|
|
535
541
|
xhr[DisabledPropertyName] = true;
|
|
536
542
|
}
|
|
@@ -539,26 +545,26 @@ var Sender = /** @class */ (function (_super) {
|
|
|
539
545
|
// cause the request to fail and we no telemetry would be sent
|
|
540
546
|
}
|
|
541
547
|
xhr.open("POST", endPointUrl, isAsync);
|
|
542
|
-
xhr
|
|
548
|
+
xhr[_DYN_SET_REQUEST_HEADER /* @min:%2esetRequestHeader */]("Content-type", "application/json");
|
|
543
549
|
// append Sdk-Context request header only in case of breeze endpoint
|
|
544
550
|
if (isInternalApplicationInsightsEndpoint(endPointUrl)) {
|
|
545
|
-
xhr
|
|
551
|
+
xhr[_DYN_SET_REQUEST_HEADER /* @min:%2esetRequestHeader */](RequestHeaders[6 /* eRequestHeaders.sdkContextHeader */], RequestHeaders[7 /* eRequestHeaders.sdkContextHeaderAppIdRequest */]);
|
|
546
552
|
}
|
|
547
553
|
arrForEach(objKeys(_headers), function (headerName) {
|
|
548
|
-
xhr
|
|
554
|
+
xhr[_DYN_SET_REQUEST_HEADER /* @min:%2esetRequestHeader */](headerName, _headers[headerName]);
|
|
549
555
|
});
|
|
550
|
-
xhr.onreadystatechange = function () { return _self._xhrReadyStateChange(xhr, payload, payload
|
|
551
|
-
xhr.onerror = function (event) { return _self
|
|
556
|
+
xhr.onreadystatechange = function () { return _self._xhrReadyStateChange(xhr, payload, payload[_DYN_LENGTH /* @min:%2elength */]); };
|
|
557
|
+
xhr.onerror = function (event) { return _self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, _formatErrorMessageXhr(xhr), event); };
|
|
552
558
|
// compose an array of payloads
|
|
553
|
-
var batch = _self._buffer
|
|
559
|
+
var batch = _self._buffer[_DYN_BATCH_PAYLOADS /* @min:%2ebatchPayloads */](payload);
|
|
554
560
|
xhr.send(batch);
|
|
555
|
-
_self._buffer
|
|
561
|
+
_self._buffer[_DYN_MARK_AS_SENT /* @min:%2emarkAsSent */](payload);
|
|
556
562
|
}
|
|
557
563
|
function _fetchKeepAliveSender(payload, isAsync) {
|
|
558
564
|
if (isArray(payload)) {
|
|
559
|
-
var payloadSize = payload
|
|
560
|
-
for (var lp = 0; lp < payload
|
|
561
|
-
payloadSize += payload[lp]
|
|
565
|
+
var payloadSize = payload[_DYN_LENGTH /* @min:%2elength */];
|
|
566
|
+
for (var lp = 0; lp < payload[_DYN_LENGTH /* @min:%2elength */]; lp++) {
|
|
567
|
+
payloadSize += payload[lp][_DYN_LENGTH /* @min:%2elength */];
|
|
562
568
|
}
|
|
563
569
|
if ((_syncFetchPayload + payloadSize) <= FetchSyncRequestSizeLimitBytes) {
|
|
564
570
|
_doFetchSender(payload, false);
|
|
@@ -570,7 +576,7 @@ var Sender = /** @class */ (function (_super) {
|
|
|
570
576
|
else {
|
|
571
577
|
// Payload is going to be too big so just try and send via XHR
|
|
572
578
|
_fallbackSender && _fallbackSender(payload, true);
|
|
573
|
-
_throwInternal(_self
|
|
579
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 2 /* eLoggingSeverity.WARNING */, 40 /* _eInternalMessageId.TransmissionFailed */, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
|
|
574
580
|
}
|
|
575
581
|
}
|
|
576
582
|
}
|
|
@@ -589,16 +595,16 @@ var Sender = /** @class */ (function (_super) {
|
|
|
589
595
|
*/
|
|
590
596
|
function _doFetchSender(payload, isAsync) {
|
|
591
597
|
var _a;
|
|
592
|
-
var endPointUrl = _self
|
|
593
|
-
var batch = _self._buffer
|
|
598
|
+
var endPointUrl = _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENDPOINT_URL /* @min:%2eendpointUrl */]();
|
|
599
|
+
var batch = _self._buffer[_DYN_BATCH_PAYLOADS /* @min:%2ebatchPayloads */](payload);
|
|
594
600
|
var plainTextBatch = new Blob([batch], { type: "application/json" });
|
|
595
601
|
var requestHeaders = new Headers();
|
|
596
|
-
var batchLength = batch
|
|
602
|
+
var batchLength = batch[_DYN_LENGTH /* @min:%2elength */];
|
|
597
603
|
var ignoreResponse = false;
|
|
598
604
|
var responseHandled = false;
|
|
599
605
|
// append Sdk-Context request header only in case of breeze endpoint
|
|
600
606
|
if (isInternalApplicationInsightsEndpoint(endPointUrl)) {
|
|
601
|
-
requestHeaders.append(RequestHeaders.sdkContextHeader, RequestHeaders.sdkContextHeaderAppIdRequest);
|
|
607
|
+
requestHeaders.append(RequestHeaders[6 /* eRequestHeaders.sdkContextHeader */], RequestHeaders[7 /* eRequestHeaders.sdkContextHeaderAppIdRequest */]);
|
|
602
608
|
}
|
|
603
609
|
arrForEach(objKeys(_headers), function (headerName) {
|
|
604
610
|
requestHeaders.append(headerName, _headers[headerName]);
|
|
@@ -627,7 +633,7 @@ var Sender = /** @class */ (function (_super) {
|
|
|
627
633
|
// If the environment has locked down the XMLHttpRequest (preventExtensions and/or freeze), this would
|
|
628
634
|
// cause the request to fail and we no telemetry would be sent
|
|
629
635
|
}
|
|
630
|
-
_self._buffer
|
|
636
|
+
_self._buffer[_DYN_MARK_AS_SENT /* @min:%2emarkAsSent */](payload);
|
|
631
637
|
try {
|
|
632
638
|
fetch(request).then(function (response) {
|
|
633
639
|
if (!isAsync) {
|
|
@@ -642,11 +648,11 @@ var Sender = /** @class */ (function (_super) {
|
|
|
642
648
|
* or if anything prevented the request from completing.
|
|
643
649
|
*/
|
|
644
650
|
if (!response.ok) {
|
|
645
|
-
_self
|
|
651
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, response.statusText);
|
|
646
652
|
}
|
|
647
653
|
else {
|
|
648
654
|
response.text().then(function (text) {
|
|
649
|
-
_checkResponsStatus(response.status, payload, response.url, payload
|
|
655
|
+
_checkResponsStatus(response.status, payload, response.url, payload[_DYN_LENGTH /* @min:%2elength */], response.statusText, text);
|
|
650
656
|
});
|
|
651
657
|
}
|
|
652
658
|
}
|
|
@@ -657,19 +663,19 @@ var Sender = /** @class */ (function (_super) {
|
|
|
657
663
|
}
|
|
658
664
|
if (!responseHandled) {
|
|
659
665
|
responseHandled = true;
|
|
660
|
-
_self
|
|
666
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, error.message);
|
|
661
667
|
}
|
|
662
668
|
});
|
|
663
669
|
}
|
|
664
670
|
catch (e) {
|
|
665
671
|
if (!responseHandled) {
|
|
666
|
-
_self
|
|
672
|
+
_self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, dumpObj(e));
|
|
667
673
|
}
|
|
668
674
|
}
|
|
669
675
|
if (ignoreResponse && !responseHandled) {
|
|
670
676
|
// Assume success during unload processing as we most likely won't get the response
|
|
671
677
|
responseHandled = true;
|
|
672
|
-
_self._onSuccess(payload, payload
|
|
678
|
+
_self._onSuccess(payload, payload[_DYN_LENGTH /* @min:%2elength */]);
|
|
673
679
|
}
|
|
674
680
|
}
|
|
675
681
|
/**
|
|
@@ -680,14 +686,14 @@ var Sender = /** @class */ (function (_super) {
|
|
|
680
686
|
try {
|
|
681
687
|
if (response && response !== "") {
|
|
682
688
|
var result = getJSON().parse(response);
|
|
683
|
-
if (result && result.itemsReceived && result.itemsReceived >= result
|
|
684
|
-
result.itemsReceived - result.itemsAccepted === result.errors
|
|
689
|
+
if (result && result.itemsReceived && result.itemsReceived >= result[_DYN_ITEMS_ACCEPTED /* @min:%2eitemsAccepted */] &&
|
|
690
|
+
result.itemsReceived - result.itemsAccepted === result.errors[_DYN_LENGTH /* @min:%2elength */]) {
|
|
685
691
|
return result;
|
|
686
692
|
}
|
|
687
693
|
}
|
|
688
694
|
}
|
|
689
695
|
catch (e) {
|
|
690
|
-
_throwInternal(_self
|
|
696
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 43 /* _eInternalMessageId.InvalidBackendResponse */, "Cannot parse the response. " + getExceptionName(e), {
|
|
691
697
|
response: response
|
|
692
698
|
});
|
|
693
699
|
}
|
|
@@ -699,15 +705,15 @@ var Sender = /** @class */ (function (_super) {
|
|
|
699
705
|
*/
|
|
700
706
|
function _resendPayload(payload, linearFactor) {
|
|
701
707
|
if (linearFactor === void 0) { linearFactor = 1; }
|
|
702
|
-
if (!payload || payload
|
|
708
|
+
if (!payload || payload[_DYN_LENGTH /* @min:%2elength */] === 0) {
|
|
703
709
|
return;
|
|
704
710
|
}
|
|
705
|
-
var buffer = _self
|
|
706
|
-
buffer
|
|
711
|
+
var buffer = _self[_DYN__BUFFER /* @min:%2e_buffer */];
|
|
712
|
+
buffer[_DYN_CLEAR_SENT /* @min:%2eclearSent */](payload);
|
|
707
713
|
_consecutiveErrors++;
|
|
708
714
|
for (var _i = 0, payload_1 = payload; _i < payload_1.length; _i++) {
|
|
709
715
|
var item = payload_1[_i];
|
|
710
|
-
buffer
|
|
716
|
+
buffer[_DYN_ENQUEUE /* @min:%2eenqueue */](item);
|
|
711
717
|
}
|
|
712
718
|
// setup timer
|
|
713
719
|
_setRetryTime(linearFactor);
|
|
@@ -741,10 +747,10 @@ var Sender = /** @class */ (function (_super) {
|
|
|
741
747
|
function _setupTimer() {
|
|
742
748
|
if (!_timeoutHandle && !_paused) {
|
|
743
749
|
var retryInterval = _retryAt ? Math.max(0, _retryAt - dateNow()) : 0;
|
|
744
|
-
var timerValue = Math.max(_self
|
|
750
|
+
var timerValue = Math.max(_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_MAX_BATCH_INTERVAL /* @min:%2emaxBatchInterval */](), retryInterval);
|
|
745
751
|
_timeoutHandle = setTimeout(function () {
|
|
746
752
|
_timeoutHandle = null;
|
|
747
|
-
_self
|
|
753
|
+
_self[_DYN_TRIGGER_SEND /* @min:%2etriggerSend */](true, null, 1 /* SendRequestReason.NormalSchedule */);
|
|
748
754
|
}, timerValue);
|
|
749
755
|
}
|
|
750
756
|
}
|
|
@@ -780,26 +786,26 @@ var Sender = /** @class */ (function (_super) {
|
|
|
780
786
|
* appId from the backend for the correct correlation.
|
|
781
787
|
*/
|
|
782
788
|
function _xdrSender(payload, isAsync) {
|
|
783
|
-
var buffer = _self
|
|
789
|
+
var buffer = _self[_DYN__BUFFER /* @min:%2e_buffer */];
|
|
784
790
|
var _window = getWindow();
|
|
785
791
|
var xdr = new XDomainRequest();
|
|
786
792
|
xdr.onload = function () { return _self._xdrOnLoad(xdr, payload); };
|
|
787
|
-
xdr.onerror = function (event) { return _self
|
|
793
|
+
xdr.onerror = function (event) { return _self[_DYN__ON_ERROR /* @min:%2e_onError */](payload, _formatErrorMessageXdr(xdr), event); };
|
|
788
794
|
// XDomainRequest requires the same protocol as the hosting page.
|
|
789
795
|
// If the protocol doesn't match, we can't send the telemetry :(.
|
|
790
796
|
var hostingProtocol = _window && _window.location && _window.location.protocol || "";
|
|
791
|
-
if (_self
|
|
792
|
-
_throwInternal(_self
|
|
797
|
+
if (_self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENDPOINT_URL /* @min:%2eendpointUrl */]().lastIndexOf(hostingProtocol, 0) !== 0) {
|
|
798
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 2 /* eLoggingSeverity.WARNING */, 40 /* _eInternalMessageId.TransmissionFailed */, ". " +
|
|
793
799
|
"Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");
|
|
794
|
-
buffer
|
|
800
|
+
buffer[_DYN_CLEAR /* @min:%2eclear */]();
|
|
795
801
|
return;
|
|
796
802
|
}
|
|
797
|
-
var endpointUrl = _self
|
|
803
|
+
var endpointUrl = _self[_DYN__SENDER_CONFIG /* @min:%2e_senderConfig */][_DYN_ENDPOINT_URL /* @min:%2eendpointUrl */]().replace(/^(https?:)/, "");
|
|
798
804
|
xdr.open("POST", endpointUrl);
|
|
799
805
|
// compose an array of payloads
|
|
800
|
-
var batch = buffer
|
|
806
|
+
var batch = buffer[_DYN_BATCH_PAYLOADS /* @min:%2ebatchPayloads */](payload);
|
|
801
807
|
xdr.send(batch);
|
|
802
|
-
buffer
|
|
808
|
+
buffer[_DYN_MARK_AS_SENT /* @min:%2emarkAsSent */](payload);
|
|
803
809
|
}
|
|
804
810
|
function _formatErrorMessageXdr(xdr, message) {
|
|
805
811
|
if (xdr) {
|
|
@@ -818,12 +824,12 @@ var Sender = /** @class */ (function (_super) {
|
|
|
818
824
|
}
|
|
819
825
|
function _notifySendRequest(sendRequest, isAsync) {
|
|
820
826
|
var manager = _getNotifyMgr();
|
|
821
|
-
if (manager && manager
|
|
827
|
+
if (manager && manager[_DYN_EVENTS_SEND_REQUEST /* @min:%2eeventsSendRequest */]) {
|
|
822
828
|
try {
|
|
823
|
-
manager
|
|
829
|
+
manager[_DYN_EVENTS_SEND_REQUEST /* @min:%2eeventsSendRequest */](sendRequest, isAsync);
|
|
824
830
|
}
|
|
825
831
|
catch (e) {
|
|
826
|
-
_throwInternal(_self
|
|
832
|
+
_throwInternal(_self[_DYN_DIAG_LOG /* @min:%2ediagLog */](), 1 /* eLoggingSeverity.CRITICAL */, 74 /* _eInternalMessageId.NotificationException */, "send request notification failed: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
827
833
|
}
|
|
828
834
|
}
|
|
829
835
|
}
|
|
@@ -832,17 +838,17 @@ var Sender = /** @class */ (function (_super) {
|
|
|
832
838
|
* Specs taken from https://tools.ietf.org/html/rfc4122 and breeze repo
|
|
833
839
|
*/
|
|
834
840
|
function _validateInstrumentationKey(config) {
|
|
835
|
-
var disableIKeyValidationFlag = isNullOrUndefined(config
|
|
841
|
+
var disableIKeyValidationFlag = isNullOrUndefined(config[_DYN_DISABLE_INSTRUMENTAT7 /* @min:%2edisableInstrumentationKeyValidation */]) ? false : config[_DYN_DISABLE_INSTRUMENTAT7 /* @min:%2edisableInstrumentationKeyValidation */];
|
|
836
842
|
if (disableIKeyValidationFlag) {
|
|
837
843
|
return true;
|
|
838
844
|
}
|
|
839
845
|
var UUID_Regex = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
|
|
840
846
|
var regexp = new RegExp(UUID_Regex);
|
|
841
|
-
return regexp.test(config
|
|
847
|
+
return regexp.test(config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */]);
|
|
842
848
|
}
|
|
843
849
|
function _initDefaults() {
|
|
844
|
-
_self
|
|
845
|
-
_self
|
|
850
|
+
_self[_DYN__SENDER /* @min:%2e_sender */] = null;
|
|
851
|
+
_self[_DYN__BUFFER /* @min:%2e_buffer */] = null;
|
|
846
852
|
_self._appId = null;
|
|
847
853
|
_self._sample = null;
|
|
848
854
|
_headers = {};
|