@microsoft/applicationinsights-dependencies-js 2.7.5-nightly.2203-03 → 2.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/applicationinsights-dependencies-js.integrity.json +9 -9
- package/browser/applicationinsights-dependencies-js.js +512 -1088
- package/browser/applicationinsights-dependencies-js.js.map +1 -1
- package/browser/applicationinsights-dependencies-js.min.js +2 -2
- package/browser/applicationinsights-dependencies-js.min.js.map +1 -1
- package/dist/applicationinsights-dependencies-js.api.json +81 -29
- package/dist/applicationinsights-dependencies-js.api.md +2 -0
- package/dist/applicationinsights-dependencies-js.d.ts +2 -1
- package/dist/applicationinsights-dependencies-js.js +512 -1088
- package/dist/applicationinsights-dependencies-js.js.map +1 -1
- package/dist/applicationinsights-dependencies-js.min.js +2 -2
- package/dist/applicationinsights-dependencies-js.min.js.map +1 -1
- package/dist/applicationinsights-dependencies-js.rollup.d.ts +2 -1
- package/dist-esm/TraceParent.js +1 -1
- package/dist-esm/ajax.js +131 -164
- package/dist-esm/ajax.js.map +1 -1
- package/dist-esm/ajaxRecord.js +1 -1
- package/dist-esm/ajaxUtils.js +1 -1
- package/dist-esm/applicationinsights-dependencies-js.js +1 -1
- package/package.json +57 -60
- package/src/ajax.ts +148 -192
- package/src/ajaxRecord.ts +1 -1
- package/types/ajax.d.ts +1 -0
- package/types/tsdoc-metadata.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights XHR dependencies plugin, 2.7.5
|
|
2
|
+
* Microsoft Application Insights XHR dependencies plugin, 2.7.5
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -33,6 +33,7 @@ export declare class AjaxPlugin extends BaseTelemetryPlugin implements IDependen
|
|
|
33
33
|
priority: number;
|
|
34
34
|
constructor();
|
|
35
35
|
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
36
|
+
teardown(): void;
|
|
36
37
|
processTelemetry(item: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
37
38
|
/**
|
|
38
39
|
* Logs dependency call
|
package/dist-esm/TraceParent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Dependencies Plugin, 2.7.5
|
|
2
|
+
* Application Insights JavaScript SDK - Dependencies Plugin, 2.7.5
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { generateW3CId } from "@microsoft/applicationinsights-core-js";
|
package/dist-esm/ajax.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Dependencies Plugin, 2.7.5
|
|
2
|
+
* Application Insights JavaScript SDK - Dependencies Plugin, 2.7.5
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
import { __assignFn as __assign, __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
8
|
-
import { RequestHeaders, CorrelationIdHelper, TelemetryItemCreator, RemoteDependencyData, dateTimeUtilsNow, DisabledPropertyName, PropertiesPluginIdentifier, isInternalApplicationInsightsEndpoint } from "@microsoft/applicationinsights-common";
|
|
9
|
-
import { isNullOrUndefined, arrForEach, isString, strTrim, isFunction, LoggingSeverity, _InternalMessageId, BaseTelemetryPlugin, getLocation, getGlobal, strPrototype, InstrumentFunc, InstrumentProto, getPerformance, objForEachKey, generateW3CId, getIEVersion, dumpObj, isXhrSupported,
|
|
8
|
+
import { RequestHeaders, CorrelationIdHelper, TelemetryItemCreator, RemoteDependencyData, dateTimeUtilsNow, DisabledPropertyName, PropertiesPluginIdentifier, DistributedTracingModes, isInternalApplicationInsightsEndpoint } from "@microsoft/applicationinsights-common";
|
|
9
|
+
import { isNullOrUndefined, arrForEach, isString, strTrim, isFunction, LoggingSeverity, _InternalMessageId, BaseTelemetryPlugin, getLocation, getGlobal, strPrototype, InstrumentFunc, InstrumentProto, getPerformance, objForEachKey, generateW3CId, getIEVersion, dumpObj, isXhrSupported, attachEvent } from "@microsoft/applicationinsights-core-js";
|
|
10
10
|
import { ajaxRecord } from "./ajaxRecord";
|
|
11
11
|
import { Traceparent } from "./TraceParent";
|
|
12
12
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
@@ -15,7 +15,6 @@ var strDiagLog = "diagLog";
|
|
|
15
15
|
var strAjaxData = "ajaxData";
|
|
16
16
|
var strThrowInternal = "throwInternal";
|
|
17
17
|
var strFetch = "fetch";
|
|
18
|
-
var strTrackDependencyDataInternal = "trackDependencyDataInternal"; // Using string to help with minification
|
|
19
18
|
// Using a global value so that to handle same iKey with multiple app insights instances (mostly for testing)
|
|
20
19
|
var _markCount = 0;
|
|
21
20
|
/** @Ignore */
|
|
@@ -111,41 +110,81 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
111
110
|
var _this = _super.call(this) || this;
|
|
112
111
|
_this.identifier = AjaxMonitor.identifier;
|
|
113
112
|
_this.priority = 120;
|
|
114
|
-
var
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
-
var
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
var
|
|
113
|
+
var strTrackDependencyDataInternal = "trackDependencyDataInternal"; // Using string to help with minification
|
|
114
|
+
var location = getLocation();
|
|
115
|
+
var _fetchInitialized = false; // fetch monitoring initialized
|
|
116
|
+
var _xhrInitialized = false; // XHR monitoring initialized
|
|
117
|
+
var _currentWindowHost = location && location.host && location.host.toLowerCase();
|
|
118
|
+
var _config = AjaxMonitor.getEmptyConfig();
|
|
119
|
+
var _enableRequestHeaderTracking = false;
|
|
120
|
+
var _enableAjaxErrorStatusText = false;
|
|
121
|
+
var _trackAjaxAttempts = 0;
|
|
121
122
|
var _context;
|
|
122
123
|
var _isUsingW3CHeaders;
|
|
123
124
|
var _isUsingAIHeaders;
|
|
124
125
|
var _markPrefix;
|
|
125
|
-
var _enableAjaxPerfTracking;
|
|
126
|
-
var _maxAjaxCallsPerView;
|
|
127
|
-
var _enableResponseHeaderTracking;
|
|
128
|
-
var
|
|
129
|
-
var
|
|
130
|
-
var _disableFetchTracking;
|
|
126
|
+
var _enableAjaxPerfTracking = false;
|
|
127
|
+
var _maxAjaxCallsPerView = 0;
|
|
128
|
+
var _enableResponseHeaderTracking = false;
|
|
129
|
+
var _hooks = [];
|
|
130
|
+
var _disabledUrls = {};
|
|
131
131
|
var _excludeRequestFromAutoTrackingPatterns;
|
|
132
132
|
var _addRequestContext;
|
|
133
|
-
|
|
134
|
-
dynamicProto(AjaxMonitor, _this, function (_self, _base) {
|
|
135
|
-
var _addHook = _base._addHook;
|
|
136
|
-
_initDefaults();
|
|
133
|
+
dynamicProto(AjaxMonitor, _this, function (_self, base) {
|
|
137
134
|
_self.initialize = function (config, core, extensions, pluginChain) {
|
|
138
135
|
if (!_self.isInitialized()) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
base.initialize(config, core, extensions, pluginChain);
|
|
137
|
+
var ctx_1 = _self._getTelCtx();
|
|
138
|
+
var defaultConfig = AjaxMonitor.getDefaultConfig();
|
|
139
|
+
objForEachKey(defaultConfig, function (field, value) {
|
|
140
|
+
_config[field] = ctx_1.getConfig(AjaxMonitor.identifier, field, value);
|
|
141
|
+
});
|
|
142
|
+
var distributedTracingMode = _config.distributedTracingMode;
|
|
143
|
+
_enableRequestHeaderTracking = _config.enableRequestHeaderTracking;
|
|
144
|
+
_enableAjaxErrorStatusText = _config.enableAjaxErrorStatusText;
|
|
145
|
+
_enableAjaxPerfTracking = _config.enableAjaxPerfTracking;
|
|
146
|
+
_maxAjaxCallsPerView = _config.maxAjaxCallsPerView;
|
|
147
|
+
_enableResponseHeaderTracking = _config.enableResponseHeaderTracking;
|
|
148
|
+
_excludeRequestFromAutoTrackingPatterns = _config.excludeRequestFromAutoTrackingPatterns;
|
|
149
|
+
_addRequestContext = _config.addRequestContext;
|
|
150
|
+
_isUsingAIHeaders = distributedTracingMode === DistributedTracingModes.AI || distributedTracingMode === DistributedTracingModes.AI_AND_W3C;
|
|
151
|
+
_isUsingW3CHeaders = distributedTracingMode === DistributedTracingModes.AI_AND_W3C || distributedTracingMode === DistributedTracingModes.W3C;
|
|
152
|
+
if (_enableAjaxPerfTracking) {
|
|
153
|
+
var iKey = config.instrumentationKey || "unkwn";
|
|
154
|
+
if (iKey.length > 5) {
|
|
155
|
+
_markPrefix = AJAX_MONITOR_PREFIX + iKey.substring(iKey.length - 5) + ".";
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
_markPrefix = AJAX_MONITOR_PREFIX + iKey + ".";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (_config.disableAjaxTracking === false) {
|
|
162
|
+
_instrumentXhr();
|
|
163
|
+
}
|
|
143
164
|
_instrumentFetch();
|
|
144
|
-
|
|
165
|
+
if (extensions.length > 0 && extensions) {
|
|
166
|
+
var propExt = void 0, extIx = 0;
|
|
167
|
+
while (!propExt && extIx < extensions.length) {
|
|
168
|
+
if (extensions[extIx] && extensions[extIx].identifier === PropertiesPluginIdentifier) {
|
|
169
|
+
propExt = extensions[extIx];
|
|
170
|
+
}
|
|
171
|
+
extIx++;
|
|
172
|
+
}
|
|
173
|
+
if (propExt) {
|
|
174
|
+
_context = propExt.context; // we could move IPropertiesPlugin to common as well
|
|
175
|
+
}
|
|
176
|
+
}
|
|
145
177
|
}
|
|
146
178
|
};
|
|
147
|
-
_self.
|
|
148
|
-
|
|
179
|
+
_self.teardown = function () {
|
|
180
|
+
// Remove all instrumentation hooks
|
|
181
|
+
arrForEach(_hooks, function (fn) {
|
|
182
|
+
fn.rm();
|
|
183
|
+
});
|
|
184
|
+
_hooks = [];
|
|
185
|
+
_fetchInitialized = false;
|
|
186
|
+
_xhrInitialized = false;
|
|
187
|
+
_self.setInitialized(false);
|
|
149
188
|
};
|
|
150
189
|
_self.trackDependencyData = function (dependency, properties) {
|
|
151
190
|
_self[strTrackDependencyDataInternal](dependency, properties);
|
|
@@ -219,8 +258,8 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
219
258
|
// Hack since expected format in w3c mode is |abc.def.
|
|
220
259
|
// Non-w3c format is |abc.def
|
|
221
260
|
// @todo Remove if better solution is available, e.g. handle in portal
|
|
222
|
-
if ((_config.distributedTracingMode ===
|
|
223
|
-
|| _config.distributedTracingMode ===
|
|
261
|
+
if ((_config.distributedTracingMode === DistributedTracingModes.W3C
|
|
262
|
+
|| _config.distributedTracingMode === DistributedTracingModes.AI_AND_W3C)
|
|
224
263
|
&& typeof dependency.id === "string" && dependency.id[dependency.id.length - 1] !== ".") {
|
|
225
264
|
dependency.id += ".";
|
|
226
265
|
}
|
|
@@ -235,65 +274,6 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
235
274
|
}
|
|
236
275
|
++_trackAjaxAttempts;
|
|
237
276
|
};
|
|
238
|
-
function _initDefaults() {
|
|
239
|
-
var location = getLocation();
|
|
240
|
-
_fetchInitialized = false; // fetch monitoring initialized
|
|
241
|
-
_xhrInitialized = false; // XHR monitoring initialized
|
|
242
|
-
_currentWindowHost = location && location.host && location.host.toLowerCase();
|
|
243
|
-
_config = AjaxMonitor.getEmptyConfig();
|
|
244
|
-
_enableRequestHeaderTracking = false;
|
|
245
|
-
_enableAjaxErrorStatusText = false;
|
|
246
|
-
_trackAjaxAttempts = 0;
|
|
247
|
-
_context = null;
|
|
248
|
-
_isUsingW3CHeaders = false;
|
|
249
|
-
_isUsingAIHeaders = false;
|
|
250
|
-
_markPrefix = null;
|
|
251
|
-
_enableAjaxPerfTracking = false;
|
|
252
|
-
_maxAjaxCallsPerView = 0;
|
|
253
|
-
_enableResponseHeaderTracking = false;
|
|
254
|
-
_disabledUrls = {};
|
|
255
|
-
_disableAjaxTracking = false;
|
|
256
|
-
_disableFetchTracking = true;
|
|
257
|
-
_excludeRequestFromAutoTrackingPatterns = null;
|
|
258
|
-
_addRequestContext = null;
|
|
259
|
-
_evtNamespace = null;
|
|
260
|
-
}
|
|
261
|
-
function _populateDefaults(config) {
|
|
262
|
-
var ctx = createProcessTelemetryContext(null, config, _self.core);
|
|
263
|
-
// Reset to the empty config
|
|
264
|
-
_config = AjaxMonitor.getEmptyConfig();
|
|
265
|
-
var defaultConfig = AjaxMonitor.getDefaultConfig();
|
|
266
|
-
objForEachKey(defaultConfig, function (field, value) {
|
|
267
|
-
_config[field] = ctx.getConfig(AjaxMonitor.identifier, field, value);
|
|
268
|
-
});
|
|
269
|
-
var distributedTracingMode = _config.distributedTracingMode;
|
|
270
|
-
_enableRequestHeaderTracking = _config.enableRequestHeaderTracking;
|
|
271
|
-
_enableAjaxErrorStatusText = _config.enableAjaxErrorStatusText;
|
|
272
|
-
_enableAjaxPerfTracking = _config.enableAjaxPerfTracking;
|
|
273
|
-
_maxAjaxCallsPerView = _config.maxAjaxCallsPerView;
|
|
274
|
-
_enableResponseHeaderTracking = _config.enableResponseHeaderTracking;
|
|
275
|
-
_excludeRequestFromAutoTrackingPatterns = _config.excludeRequestFromAutoTrackingPatterns;
|
|
276
|
-
_addRequestContext = _config.addRequestContext;
|
|
277
|
-
_isUsingAIHeaders = distributedTracingMode === 0 /* AI */ || distributedTracingMode === 1 /* AI_AND_W3C */;
|
|
278
|
-
_isUsingW3CHeaders = distributedTracingMode === 1 /* AI_AND_W3C */ || distributedTracingMode === 2 /* W3C */;
|
|
279
|
-
if (_enableAjaxPerfTracking) {
|
|
280
|
-
var iKey = config.instrumentationKey || "unkwn";
|
|
281
|
-
if (iKey.length > 5) {
|
|
282
|
-
_markPrefix = AJAX_MONITOR_PREFIX + iKey.substring(iKey.length - 5) + ".";
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
_markPrefix = AJAX_MONITOR_PREFIX + iKey + ".";
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
_disableAjaxTracking = !!_config.disableAjaxTracking;
|
|
289
|
-
_disableFetchTracking = !!_config.disableFetchTracking;
|
|
290
|
-
}
|
|
291
|
-
function _populateContext() {
|
|
292
|
-
var propExt = _self.core.getPlugin(PropertiesPluginIdentifier);
|
|
293
|
-
if (propExt) {
|
|
294
|
-
_context = propExt.plugin.context; // we could move IPropertiesPlugin to common as well
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
277
|
// discard the header if it's defined as ignoreHeaders in ICorrelationConfig
|
|
298
278
|
function _canIncludeHeaders(header) {
|
|
299
279
|
var rlt = true;
|
|
@@ -315,13 +295,12 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
315
295
|
}
|
|
316
296
|
var global = getGlobal();
|
|
317
297
|
var isPolyfill = fetch.polyfill;
|
|
318
|
-
if (
|
|
319
|
-
|
|
320
|
-
ns: _evtNamespace,
|
|
298
|
+
if (_config.disableFetchTracking === false) {
|
|
299
|
+
_hooks.push(InstrumentFunc(global, strFetch, {
|
|
321
300
|
// Add request hook
|
|
322
301
|
req: function (callDetails, input, init) {
|
|
323
302
|
var fetchData;
|
|
324
|
-
if (
|
|
303
|
+
if (_fetchInitialized &&
|
|
325
304
|
!_isDisabledRequest(null, input, init) &&
|
|
326
305
|
// If we have a polyfil and XHR instrumented then let XHR report otherwise we get duplicates
|
|
327
306
|
!(isPolyfill && _xhrInitialized)) {
|
|
@@ -335,34 +314,32 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
335
314
|
}
|
|
336
315
|
},
|
|
337
316
|
rsp: function (callDetails, input) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
callDetails.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return ajaxResponse;
|
|
359
|
-
});
|
|
360
|
-
return response;
|
|
361
|
-
})["catch"](function (reason) {
|
|
362
|
-
_reportFetchMetrics(callDetails, 0, input, null, fetchData_1, null, { error: reason.message });
|
|
363
|
-
throw reason;
|
|
317
|
+
var fetchData = callDetails.ctx().data;
|
|
318
|
+
if (fetchData) {
|
|
319
|
+
// Replace the result with the new promise from this code
|
|
320
|
+
callDetails.rslt = callDetails.rslt.then(function (response) {
|
|
321
|
+
_reportFetchMetrics(callDetails, (response || {}).status, input, response, fetchData, function () {
|
|
322
|
+
var ajaxResponse = {
|
|
323
|
+
statusText: response.statusText,
|
|
324
|
+
headerMap: null,
|
|
325
|
+
correlationContext: _getFetchCorrelationContext(response)
|
|
326
|
+
};
|
|
327
|
+
if (_enableResponseHeaderTracking) {
|
|
328
|
+
var responseHeaderMap_1 = {};
|
|
329
|
+
response.headers.forEach(function (value, name) {
|
|
330
|
+
if (_canIncludeHeaders(name)) {
|
|
331
|
+
responseHeaderMap_1[name] = value;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
ajaxResponse.headerMap = responseHeaderMap_1;
|
|
335
|
+
}
|
|
336
|
+
return ajaxResponse;
|
|
364
337
|
});
|
|
365
|
-
|
|
338
|
+
return response;
|
|
339
|
+
})["catch"](function (reason) {
|
|
340
|
+
_reportFetchMetrics(callDetails, 0, input, null, fetchData, null, { error: reason.message });
|
|
341
|
+
throw reason;
|
|
342
|
+
});
|
|
366
343
|
}
|
|
367
344
|
},
|
|
368
345
|
// Create an error callback to report any hook errors
|
|
@@ -377,8 +354,7 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
377
354
|
// Note: Polyfill implementations that don't support the "poyyfill" tag are not supported
|
|
378
355
|
// the workaround is to add a polyfill property to your fetch implementation before initializing
|
|
379
356
|
// App Insights
|
|
380
|
-
|
|
381
|
-
ns: _evtNamespace,
|
|
357
|
+
_hooks.push(InstrumentFunc(global, strFetch, {
|
|
382
358
|
req: function (callDetails, input, init) {
|
|
383
359
|
// Just call so that we record any disabled URL
|
|
384
360
|
_isDisabledRequest(null, input, init);
|
|
@@ -392,74 +368,64 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
392
368
|
}
|
|
393
369
|
}
|
|
394
370
|
function _hookProto(target, funcName, callbacks) {
|
|
395
|
-
|
|
371
|
+
_hooks.push(InstrumentProto(target, funcName, callbacks));
|
|
396
372
|
}
|
|
397
373
|
function _instrumentXhr() {
|
|
398
|
-
if (_supportsAjaxMonitoring(_self) && !
|
|
374
|
+
if (_supportsAjaxMonitoring(_self) && !_xhrInitialized) {
|
|
399
375
|
// Instrument open
|
|
400
376
|
_hookProto(XMLHttpRequest, "open", {
|
|
401
|
-
ns: _evtNamespace,
|
|
402
377
|
req: function (args, method, url, async) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (!
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
_openHandler(xhr, method, url, async);
|
|
410
|
-
}
|
|
411
|
-
// always attach to the on ready state change (required for handling multiple instances)
|
|
412
|
-
_attachToOnReadyStateChange(xhr);
|
|
378
|
+
var xhr = args.inst;
|
|
379
|
+
var ajaxData = xhr[strAjaxData];
|
|
380
|
+
if (!_isDisabledRequest(xhr, url) && _isMonitoredXhrInstance(xhr, true)) {
|
|
381
|
+
if (!ajaxData || !ajaxData.xhrMonitoringState.openDone) {
|
|
382
|
+
// Only create a single ajaxData (even when multiple AI instances are running)
|
|
383
|
+
_openHandler(xhr, method, url, async);
|
|
413
384
|
}
|
|
385
|
+
// always attach to the on ready state change (required for handling multiple instances)
|
|
386
|
+
_attachToOnReadyStateChange(xhr);
|
|
414
387
|
}
|
|
415
388
|
},
|
|
416
389
|
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxOpen, "Failed to monitor XMLHttpRequest.open, monitoring data for this ajax call may be incorrect.")
|
|
417
390
|
});
|
|
418
391
|
// Instrument send
|
|
419
392
|
_hookProto(XMLHttpRequest, "send", {
|
|
420
|
-
ns: _evtNamespace,
|
|
421
393
|
req: function (args, context) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
ajaxData.xhrMonitoringState.sendDone = true;
|
|
430
|
-
}
|
|
394
|
+
var xhr = args.inst;
|
|
395
|
+
var ajaxData = xhr[strAjaxData];
|
|
396
|
+
if (_isMonitoredXhrInstance(xhr) && !ajaxData.xhrMonitoringState.sendDone) {
|
|
397
|
+
_createMarkId("xhr", ajaxData);
|
|
398
|
+
ajaxData.requestSentTime = dateTimeUtilsNow();
|
|
399
|
+
_self.includeCorrelationHeaders(ajaxData, undefined, undefined, xhr);
|
|
400
|
+
ajaxData.xhrMonitoringState.sendDone = true;
|
|
431
401
|
}
|
|
432
402
|
},
|
|
433
403
|
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxSend, "Failed to monitor XMLHttpRequest, monitoring data for this ajax call may be incorrect.")
|
|
434
404
|
});
|
|
435
405
|
// Instrument abort
|
|
436
406
|
_hookProto(XMLHttpRequest, "abort", {
|
|
437
|
-
ns: _evtNamespace,
|
|
438
407
|
req: function (args) {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
ajaxData.xhrMonitoringState.abortDone = true;
|
|
445
|
-
}
|
|
408
|
+
var xhr = args.inst;
|
|
409
|
+
var ajaxData = xhr[strAjaxData];
|
|
410
|
+
if (_isMonitoredXhrInstance(xhr) && !ajaxData.xhrMonitoringState.abortDone) {
|
|
411
|
+
ajaxData.aborted = 1;
|
|
412
|
+
ajaxData.xhrMonitoringState.abortDone = true;
|
|
446
413
|
}
|
|
447
414
|
},
|
|
448
415
|
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxAbort, "Failed to monitor XMLHttpRequest.abort, monitoring data for this ajax call may be incorrect.")
|
|
449
416
|
});
|
|
450
417
|
// Instrument setRequestHeader
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
if (!_disableAjaxTracking && _enableRequestHeaderTracking) {
|
|
418
|
+
if (_enableRequestHeaderTracking) {
|
|
419
|
+
_hookProto(XMLHttpRequest, "setRequestHeader", {
|
|
420
|
+
req: function (args, header, value) {
|
|
455
421
|
var xhr = args.inst;
|
|
456
422
|
if (_isMonitoredXhrInstance(xhr) && _canIncludeHeaders(header)) {
|
|
457
423
|
xhr[strAjaxData].requestHeaders[header] = value;
|
|
458
424
|
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
425
|
+
},
|
|
426
|
+
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxSetRequestHeader, "Failed to monitor XMLHttpRequest.setRequestHeader, monitoring data for this ajax call may be incorrect.")
|
|
427
|
+
});
|
|
428
|
+
}
|
|
463
429
|
_xhrInitialized = true;
|
|
464
430
|
}
|
|
465
431
|
}
|
|
@@ -544,7 +510,7 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
544
510
|
xhr[strAjaxData] = ajaxData;
|
|
545
511
|
}
|
|
546
512
|
function _attachToOnReadyStateChange(xhr) {
|
|
547
|
-
xhr[strAjaxData].xhrMonitoringState.stateChangeAttached =
|
|
513
|
+
xhr[strAjaxData].xhrMonitoringState.stateChangeAttached = attachEvent(xhr, "readystatechange", function () {
|
|
548
514
|
try {
|
|
549
515
|
if (xhr && xhr.readyState === 4 && _isMonitoredXhrInstance(xhr)) {
|
|
550
516
|
_onAjaxComplete(xhr);
|
|
@@ -560,7 +526,7 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
560
526
|
});
|
|
561
527
|
}
|
|
562
528
|
}
|
|
563
|
-
}
|
|
529
|
+
});
|
|
564
530
|
}
|
|
565
531
|
function _getResponseText(xhr) {
|
|
566
532
|
try {
|
|
@@ -858,7 +824,7 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
858
824
|
disableFetchTracking: true,
|
|
859
825
|
excludeRequestFromAutoTrackingPatterns: undefined,
|
|
860
826
|
disableCorrelationHeaders: false,
|
|
861
|
-
distributedTracingMode:
|
|
827
|
+
distributedTracingMode: DistributedTracingModes.AI_AND_W3C,
|
|
862
828
|
correlationHeaderExcludedDomains: [
|
|
863
829
|
"*.blob.core.windows.net",
|
|
864
830
|
"*.blob.core.chinacloudapi.cn",
|
|
@@ -892,6 +858,7 @@ var AjaxMonitor = /** @class */ (function (_super) {
|
|
|
892
858
|
return emptyConfig;
|
|
893
859
|
};
|
|
894
860
|
// Removed Stub for AjaxMonitor.prototype.initialize.
|
|
861
|
+
// Removed Stub for AjaxMonitor.prototype.teardown.
|
|
895
862
|
AjaxMonitor.prototype.processTelemetry = function (item, itemCtx) {
|
|
896
863
|
this.processNext(item, itemCtx);
|
|
897
864
|
};
|