Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] When using Multiple instances of AI only the first instance is correctly reporting ajax events #1655 #1686

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions extensions/applicationinsights-dependencies-js/src/ajax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,14 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
req: (args:IInstrumentCallDetails, method:string, url:string, async?:boolean) => {
let xhr = args.inst as XMLHttpRequestInstrumented;
let ajaxData = xhr[strAjaxData];
if (!_isDisabledRequest(xhr, url) && _isMonitoredXhrInstance(xhr, true) &&
(!ajaxData || !ajaxData.xhrMonitoringState.openDone)) {
_openHandler(xhr, method, url, async);
if (!_isDisabledRequest(xhr, url) && _isMonitoredXhrInstance(xhr, true)) {
if (!ajaxData || !ajaxData.xhrMonitoringState.openDone) {
// Only create a single ajaxData (even when multiple AI instances are running)
_openHandler(xhr, method, url, async);
}

// always attach to the on ready state change (required for handling multiple instances)
_attachToOnReadyStateChange(xhr);
}
},
hkErr: _createErrorCallbackFunc(_self, _InternalMessageId.FailedMonitorAjaxOpen,
Expand Down Expand Up @@ -643,8 +648,6 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
ajaxData.async = async;
ajaxData.errorStatusText = _enableAjaxErrorStatusText;
xhr[strAjaxData] = ajaxData;

_attachToOnReadyStateChange(xhr);
}

function _attachToOnReadyStateChange(xhr: XMLHttpRequestInstrumented) {
Expand Down