@microsoft/applicationinsights-dependencies-js 2.8.0-beta.2203-09 → 2.8.0-beta.2203-12
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 +151 -112
- 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 +1 -1
- package/dist/applicationinsights-dependencies-js.d.ts +1 -1
- package/dist/applicationinsights-dependencies-js.js +151 -112
- 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 +1 -1
- package/dist-esm/TraceParent.js +1 -1
- package/dist-esm/ajax.js +145 -111
- 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 +4 -4
- package/src/ajax.ts +171 -125
- package/types/tsdoc-metadata.json +1 -1
package/src/ajax.ts
CHANGED
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
isNullOrUndefined, arrForEach, isString, strTrim, isFunction, LoggingSeverity, _InternalMessageId,
|
|
11
11
|
IAppInsightsCore, BaseTelemetryPlugin, ITelemetryPluginChain, IConfiguration, IPlugin, ITelemetryItem, IProcessTelemetryContext,
|
|
12
12
|
getLocation, getGlobal, strPrototype, IInstrumentCallDetails, InstrumentFunc, InstrumentProto, getPerformance,
|
|
13
|
-
IInstrumentHooksCallbacks, objForEachKey, generateW3CId, getIEVersion, dumpObj, ICustomProperties, isXhrSupported, eventOn,
|
|
13
|
+
IInstrumentHooksCallbacks, objForEachKey, generateW3CId, getIEVersion, dumpObj, ICustomProperties, isXhrSupported, eventOn,
|
|
14
|
+
mergeEvtNamespace, createUniqueNamespace, createProcessTelemetryContext
|
|
14
15
|
} from "@microsoft/applicationinsights-core-js";
|
|
15
16
|
import { ajaxRecord, IAjaxRecordResponse } from "./ajaxRecord";
|
|
16
17
|
import { Traceparent } from "./TraceParent";
|
|
@@ -21,6 +22,7 @@ const strDiagLog = "diagLog";
|
|
|
21
22
|
const strAjaxData = "ajaxData";
|
|
22
23
|
const strThrowInternal = "throwInternal";
|
|
23
24
|
const strFetch = "fetch";
|
|
25
|
+
const strTrackDependencyDataInternal = "trackDependencyDataInternal"; // Using string to help with minification
|
|
24
26
|
|
|
25
27
|
// Using a global value so that to handle same iKey with multiple app insights instances (mostly for testing)
|
|
26
28
|
let _markCount: number = 0;
|
|
@@ -198,23 +200,23 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
198
200
|
|
|
199
201
|
constructor() {
|
|
200
202
|
super();
|
|
201
|
-
let
|
|
202
|
-
let
|
|
203
|
-
let
|
|
204
|
-
let
|
|
205
|
-
let
|
|
206
|
-
let
|
|
207
|
-
let
|
|
208
|
-
let _enableAjaxErrorStatusText = false;
|
|
209
|
-
let _trackAjaxAttempts: number = 0;
|
|
203
|
+
let _fetchInitialized: boolean; // fetch monitoring initialized
|
|
204
|
+
let _xhrInitialized: boolean; // XHR monitoring initialized
|
|
205
|
+
let _currentWindowHost: string;
|
|
206
|
+
let _config: ICorrelationConfig;
|
|
207
|
+
let _enableRequestHeaderTracking: boolean;
|
|
208
|
+
let _enableAjaxErrorStatusText: boolean;
|
|
209
|
+
let _trackAjaxAttempts: number;
|
|
210
210
|
let _context: ITelemetryContext;
|
|
211
211
|
let _isUsingW3CHeaders: boolean;
|
|
212
212
|
let _isUsingAIHeaders: boolean;
|
|
213
213
|
let _markPrefix: string;
|
|
214
|
-
let _enableAjaxPerfTracking:boolean
|
|
215
|
-
let _maxAjaxCallsPerView:number
|
|
216
|
-
let _enableResponseHeaderTracking:boolean
|
|
217
|
-
let _disabledUrls:any
|
|
214
|
+
let _enableAjaxPerfTracking: boolean;
|
|
215
|
+
let _maxAjaxCallsPerView: number;
|
|
216
|
+
let _enableResponseHeaderTracking: boolean;
|
|
217
|
+
let _disabledUrls: any;
|
|
218
|
+
let _disableAjaxTracking: boolean;
|
|
219
|
+
let _disableFetchTracking: boolean;
|
|
218
220
|
let _excludeRequestFromAutoTrackingPatterns: string[] | RegExp[];
|
|
219
221
|
let _addRequestContext: (requestContext?: IRequestContext) => ICustomProperties;
|
|
220
222
|
let _evtNamespace: string | string[];
|
|
@@ -222,63 +224,24 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
222
224
|
dynamicProto(AjaxMonitor, this, (_self, _base) => {
|
|
223
225
|
let _addHook = _base._addHook;
|
|
224
226
|
|
|
227
|
+
_initDefaults();
|
|
228
|
+
|
|
225
229
|
_self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => {
|
|
226
230
|
if (!_self.isInitialized()) {
|
|
227
231
|
_base.initialize(config, core, extensions, pluginChain);
|
|
228
|
-
let ctx = _self._getTelCtx();
|
|
229
|
-
const defaultConfig = AjaxMonitor.getDefaultConfig();
|
|
230
|
-
objForEachKey(defaultConfig, (field, value) => {
|
|
231
|
-
_config[field] = ctx.getConfig(AjaxMonitor.identifier, field, value);
|
|
232
|
-
});
|
|
233
232
|
|
|
234
233
|
_evtNamespace = mergeEvtNamespace(createUniqueNamespace("ajax"), core && core.evtNamespace && core.evtNamespace());
|
|
235
234
|
|
|
236
|
-
|
|
237
|
-
_enableRequestHeaderTracking = _config.enableRequestHeaderTracking;
|
|
238
|
-
_enableAjaxErrorStatusText = _config.enableAjaxErrorStatusText;
|
|
239
|
-
_enableAjaxPerfTracking = _config.enableAjaxPerfTracking;
|
|
240
|
-
_maxAjaxCallsPerView = _config.maxAjaxCallsPerView;
|
|
241
|
-
_enableResponseHeaderTracking = _config.enableResponseHeaderTracking;
|
|
242
|
-
_excludeRequestFromAutoTrackingPatterns = _config.excludeRequestFromAutoTrackingPatterns;
|
|
243
|
-
_addRequestContext = _config.addRequestContext;
|
|
244
|
-
|
|
245
|
-
_isUsingAIHeaders = distributedTracingMode === eDistributedTracingModes.AI || distributedTracingMode === eDistributedTracingModes.AI_AND_W3C;
|
|
246
|
-
_isUsingW3CHeaders = distributedTracingMode === eDistributedTracingModes.AI_AND_W3C || distributedTracingMode === eDistributedTracingModes.W3C;
|
|
247
|
-
if (_enableAjaxPerfTracking) {
|
|
248
|
-
let iKey = config.instrumentationKey || "unkwn";
|
|
249
|
-
if (iKey.length > 5) {
|
|
250
|
-
_markPrefix = AJAX_MONITOR_PREFIX + iKey.substring(iKey.length - 5) + ".";
|
|
251
|
-
} else {
|
|
252
|
-
_markPrefix = AJAX_MONITOR_PREFIX + iKey + ".";
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (_config.disableAjaxTracking === false) {
|
|
257
|
-
_instrumentXhr();
|
|
258
|
-
}
|
|
235
|
+
_populateDefaults(config);
|
|
259
236
|
|
|
237
|
+
_instrumentXhr();
|
|
260
238
|
_instrumentFetch();
|
|
261
|
-
|
|
262
|
-
if (extensions.length > 0 && extensions) {
|
|
263
|
-
let propExt: any, extIx = 0;
|
|
264
|
-
while (!propExt && extIx < extensions.length) {
|
|
265
|
-
if (extensions[extIx] && extensions[extIx].identifier === PropertiesPluginIdentifier) {
|
|
266
|
-
propExt = extensions[extIx];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
extIx++;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (propExt) {
|
|
273
|
-
_context = propExt.context; // we could move IPropertiesPlugin to common as well
|
|
274
|
-
}
|
|
275
|
-
}
|
|
239
|
+
_populateContext();
|
|
276
240
|
}
|
|
277
241
|
};
|
|
278
242
|
|
|
279
243
|
_self._doTeardown = () => {
|
|
280
|
-
|
|
281
|
-
_xhrInitialized = false;
|
|
244
|
+
_initDefaults();
|
|
282
245
|
};
|
|
283
246
|
|
|
284
247
|
_self.trackDependencyData = (dependency: IDependencyTelemetry, properties?: { [key: string]: any }) => {
|
|
@@ -385,6 +348,73 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
385
348
|
++_trackAjaxAttempts;
|
|
386
349
|
}
|
|
387
350
|
|
|
351
|
+
function _initDefaults() {
|
|
352
|
+
let location = getLocation();
|
|
353
|
+
_fetchInitialized = false; // fetch monitoring initialized
|
|
354
|
+
_xhrInitialized = false; // XHR monitoring initialized
|
|
355
|
+
_currentWindowHost = location && location.host && location.host.toLowerCase();
|
|
356
|
+
_config = AjaxMonitor.getEmptyConfig();
|
|
357
|
+
_enableRequestHeaderTracking = false;
|
|
358
|
+
_enableAjaxErrorStatusText = false;
|
|
359
|
+
_trackAjaxAttempts = 0;
|
|
360
|
+
_context = null;
|
|
361
|
+
_isUsingW3CHeaders = false;
|
|
362
|
+
_isUsingAIHeaders = false;
|
|
363
|
+
_markPrefix = null;
|
|
364
|
+
_enableAjaxPerfTracking = false;
|
|
365
|
+
_maxAjaxCallsPerView = 0;
|
|
366
|
+
_enableResponseHeaderTracking = false;
|
|
367
|
+
_disabledUrls = {};
|
|
368
|
+
_disableAjaxTracking = false;
|
|
369
|
+
_disableFetchTracking = true;
|
|
370
|
+
|
|
371
|
+
_excludeRequestFromAutoTrackingPatterns = null
|
|
372
|
+
_addRequestContext = null;
|
|
373
|
+
_evtNamespace = null;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function _populateDefaults(config: IConfiguration) {
|
|
377
|
+
let ctx = createProcessTelemetryContext(null, config, _self.core);
|
|
378
|
+
|
|
379
|
+
// Reset to the empty config
|
|
380
|
+
_config = AjaxMonitor.getEmptyConfig();
|
|
381
|
+
const defaultConfig = AjaxMonitor.getDefaultConfig();
|
|
382
|
+
objForEachKey(defaultConfig, (field, value) => {
|
|
383
|
+
_config[field] = ctx.getConfig(AjaxMonitor.identifier, field, value);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
let distributedTracingMode = _config.distributedTracingMode;
|
|
387
|
+
_enableRequestHeaderTracking = _config.enableRequestHeaderTracking;
|
|
388
|
+
_enableAjaxErrorStatusText = _config.enableAjaxErrorStatusText;
|
|
389
|
+
_enableAjaxPerfTracking = _config.enableAjaxPerfTracking;
|
|
390
|
+
_maxAjaxCallsPerView = _config.maxAjaxCallsPerView;
|
|
391
|
+
_enableResponseHeaderTracking = _config.enableResponseHeaderTracking;
|
|
392
|
+
_excludeRequestFromAutoTrackingPatterns = _config.excludeRequestFromAutoTrackingPatterns;
|
|
393
|
+
_addRequestContext = _config.addRequestContext;
|
|
394
|
+
|
|
395
|
+
_isUsingAIHeaders = distributedTracingMode === eDistributedTracingModes.AI || distributedTracingMode === eDistributedTracingModes.AI_AND_W3C;
|
|
396
|
+
_isUsingW3CHeaders = distributedTracingMode === eDistributedTracingModes.AI_AND_W3C || distributedTracingMode === eDistributedTracingModes.W3C;
|
|
397
|
+
|
|
398
|
+
if (_enableAjaxPerfTracking) {
|
|
399
|
+
let iKey = config.instrumentationKey || "unkwn";
|
|
400
|
+
if (iKey.length > 5) {
|
|
401
|
+
_markPrefix = AJAX_MONITOR_PREFIX + iKey.substring(iKey.length - 5) + ".";
|
|
402
|
+
} else {
|
|
403
|
+
_markPrefix = AJAX_MONITOR_PREFIX + iKey + ".";
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
_disableAjaxTracking = !!_config.disableAjaxTracking;
|
|
408
|
+
_disableFetchTracking = !!_config.disableFetchTracking;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function _populateContext() {
|
|
412
|
+
let propExt = _self.core.getPlugin<any>(PropertiesPluginIdentifier);
|
|
413
|
+
if (propExt) {
|
|
414
|
+
_context = propExt.plugin.context; // we could move IPropertiesPlugin to common as well
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
388
418
|
// discard the header if it's defined as ignoreHeaders in ICorrelationConfig
|
|
389
419
|
function _canIncludeHeaders(header: string) {
|
|
390
420
|
let rlt = true;
|
|
@@ -408,13 +438,13 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
408
438
|
|
|
409
439
|
let global = getGlobal();
|
|
410
440
|
let isPolyfill = (fetch as any).polyfill;
|
|
411
|
-
if (
|
|
441
|
+
if (!_disableFetchTracking && !_fetchInitialized) {
|
|
412
442
|
_addHook(InstrumentFunc(global, strFetch, {
|
|
413
443
|
ns: _evtNamespace,
|
|
414
444
|
// Add request hook
|
|
415
445
|
req: (callDetails: IInstrumentCallDetails, input, init) => {
|
|
416
446
|
let fetchData: ajaxRecord;
|
|
417
|
-
if (_fetchInitialized &&
|
|
447
|
+
if (!_disableFetchTracking && _fetchInitialized &&
|
|
418
448
|
!_isDisabledRequest(null, input, init) &&
|
|
419
449
|
// If we have a polyfil and XHR instrumented then let XHR report otherwise we get duplicates
|
|
420
450
|
!(isPolyfill && _xhrInitialized)) {
|
|
@@ -428,35 +458,39 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
428
458
|
}
|
|
429
459
|
},
|
|
430
460
|
rsp: (callDetails: IInstrumentCallDetails, input) => {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
461
|
+
if (!_disableFetchTracking) {
|
|
462
|
+
let fetchData = callDetails.ctx().data;
|
|
463
|
+
if (fetchData) {
|
|
464
|
+
// Replace the result with the new promise from this code
|
|
465
|
+
callDetails.rslt = callDetails.rslt.then((response: any) => {
|
|
466
|
+
_reportFetchMetrics(callDetails, (response||{}).status, input, response, fetchData, () => {
|
|
467
|
+
let ajaxResponse:IAjaxRecordResponse = {
|
|
468
|
+
statusText: response.statusText,
|
|
469
|
+
headerMap: null,
|
|
470
|
+
correlationContext: _getFetchCorrelationContext(response)
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
if (_enableResponseHeaderTracking) {
|
|
474
|
+
const responseHeaderMap = {};
|
|
475
|
+
response.headers.forEach((value: string, name: string) => {
|
|
476
|
+
if (_canIncludeHeaders(name)) {
|
|
477
|
+
responseHeaderMap[name] = value;
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
ajaxResponse.headerMap = responseHeaderMap;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return ajaxResponse;
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
return response;
|
|
488
|
+
})
|
|
489
|
+
.catch((reason: any) => {
|
|
490
|
+
_reportFetchMetrics(callDetails, 0, input, null, fetchData, null, { error: reason.message });
|
|
491
|
+
throw reason;
|
|
492
|
+
});
|
|
493
|
+
}
|
|
460
494
|
}
|
|
461
495
|
},
|
|
462
496
|
// Create an error callback to report any hook errors
|
|
@@ -493,21 +527,23 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
493
527
|
}
|
|
494
528
|
|
|
495
529
|
function _instrumentXhr():void {
|
|
496
|
-
if (_supportsAjaxMonitoring(_self) && !_xhrInitialized) {
|
|
530
|
+
if (_supportsAjaxMonitoring(_self) && !_disableAjaxTracking && !_xhrInitialized) {
|
|
497
531
|
// Instrument open
|
|
498
532
|
_hookProto(XMLHttpRequest, "open", {
|
|
499
533
|
ns: _evtNamespace,
|
|
500
534
|
req: (args:IInstrumentCallDetails, method:string, url:string, async?:boolean) => {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (!
|
|
505
|
-
|
|
506
|
-
|
|
535
|
+
if (!_disableAjaxTracking) {
|
|
536
|
+
let xhr = args.inst as XMLHttpRequestInstrumented;
|
|
537
|
+
let ajaxData = xhr[strAjaxData];
|
|
538
|
+
if (!_isDisabledRequest(xhr, url) && _isMonitoredXhrInstance(xhr, true)) {
|
|
539
|
+
if (!ajaxData || !ajaxData.xhrMonitoringState.openDone) {
|
|
540
|
+
// Only create a single ajaxData (even when multiple AI instances are running)
|
|
541
|
+
_openHandler(xhr, method, url, async);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// always attach to the on ready state change (required for handling multiple instances)
|
|
545
|
+
_attachToOnReadyStateChange(xhr);
|
|
507
546
|
}
|
|
508
|
-
|
|
509
|
-
// always attach to the on ready state change (required for handling multiple instances)
|
|
510
|
-
_attachToOnReadyStateChange(xhr);
|
|
511
547
|
}
|
|
512
548
|
},
|
|
513
549
|
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxOpen,
|
|
@@ -518,13 +554,15 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
518
554
|
_hookProto(XMLHttpRequest, "send", {
|
|
519
555
|
ns: _evtNamespace,
|
|
520
556
|
req: (args:IInstrumentCallDetails, context?: Document | BodyInit | null) => {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
557
|
+
if (!_disableAjaxTracking) {
|
|
558
|
+
let xhr = args.inst as XMLHttpRequestInstrumented;
|
|
559
|
+
let ajaxData = xhr[strAjaxData];
|
|
560
|
+
if (_isMonitoredXhrInstance(xhr) && !ajaxData.xhrMonitoringState.sendDone) {
|
|
561
|
+
_createMarkId("xhr", ajaxData);
|
|
562
|
+
ajaxData.requestSentTime = dateTimeUtilsNow();
|
|
563
|
+
_self.includeCorrelationHeaders(ajaxData, undefined, undefined, xhr);
|
|
564
|
+
ajaxData.xhrMonitoringState.sendDone = true;
|
|
565
|
+
}
|
|
528
566
|
}
|
|
529
567
|
},
|
|
530
568
|
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxSend,
|
|
@@ -533,12 +571,15 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
533
571
|
|
|
534
572
|
// Instrument abort
|
|
535
573
|
_hookProto(XMLHttpRequest, "abort", {
|
|
574
|
+
ns: _evtNamespace,
|
|
536
575
|
req: (args:IInstrumentCallDetails) => {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
ajaxData.
|
|
541
|
-
|
|
576
|
+
if (!_disableAjaxTracking) {
|
|
577
|
+
let xhr = args.inst as XMLHttpRequestInstrumented;
|
|
578
|
+
let ajaxData = xhr[strAjaxData];
|
|
579
|
+
if (_isMonitoredXhrInstance(xhr) && !ajaxData.xhrMonitoringState.abortDone) {
|
|
580
|
+
ajaxData.aborted = 1;
|
|
581
|
+
ajaxData.xhrMonitoringState.abortDone = true;
|
|
582
|
+
}
|
|
542
583
|
}
|
|
543
584
|
},
|
|
544
585
|
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxAbort,
|
|
@@ -546,18 +587,19 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
546
587
|
});
|
|
547
588
|
|
|
548
589
|
// Instrument setRequestHeader
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
590
|
+
_hookProto(XMLHttpRequest, "setRequestHeader", {
|
|
591
|
+
ns: _evtNamespace,
|
|
592
|
+
req: (args: IInstrumentCallDetails, header: string, value: string) => {
|
|
593
|
+
if (!_disableAjaxTracking && _enableRequestHeaderTracking) {
|
|
552
594
|
let xhr = args.inst as XMLHttpRequestInstrumented;
|
|
553
595
|
if (_isMonitoredXhrInstance(xhr) && _canIncludeHeaders(header)) {
|
|
554
596
|
xhr[strAjaxData].requestHeaders[header] = value;
|
|
555
597
|
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxSetRequestHeader,
|
|
601
|
+
"Failed to monitor XMLHttpRequest.setRequestHeader, monitoring data for this ajax call may be incorrect.")
|
|
602
|
+
});
|
|
561
603
|
|
|
562
604
|
_xhrInitialized = true;
|
|
563
605
|
}
|
|
@@ -733,7 +775,9 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
733
775
|
const parts = line.split(": ");
|
|
734
776
|
const header = parts.shift();
|
|
735
777
|
const value = parts.join(": ");
|
|
736
|
-
if(_canIncludeHeaders(header)) {
|
|
778
|
+
if(_canIncludeHeaders(header)) {
|
|
779
|
+
responseHeaderMap[header] = value;
|
|
780
|
+
}
|
|
737
781
|
});
|
|
738
782
|
|
|
739
783
|
ajaxResponse.headerMap = responseHeaderMap;
|
|
@@ -761,9 +805,9 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
761
805
|
_self[strTrackDependencyDataInternal](dependency);
|
|
762
806
|
} else {
|
|
763
807
|
_reportXhrError(null, {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
808
|
+
requestSentTime: ajaxData.requestSentTime,
|
|
809
|
+
responseFinishedTime: ajaxData.responseFinishedTime
|
|
810
|
+
});
|
|
767
811
|
}
|
|
768
812
|
} finally {
|
|
769
813
|
// cleanup telemetry data
|
|
@@ -903,7 +947,9 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
903
947
|
if (_enableRequestHeaderTracking) {
|
|
904
948
|
let headers = new Headers((init ? init.headers : 0) || (input instanceof Request ? (input.headers || {}) : {}));
|
|
905
949
|
headers.forEach((value, key) => {
|
|
906
|
-
if (_canIncludeHeaders(key)) {
|
|
950
|
+
if (_canIncludeHeaders(key)) {
|
|
951
|
+
requestHeaders[key] = value;
|
|
952
|
+
}
|
|
907
953
|
});
|
|
908
954
|
}
|
|
909
955
|
|