ApplicationInsights-JS: [BUG] App Insights not auto-capturing from a Web Worker
Description/Screenshot
I am trying to auto-capture fetch
calls from a shared web worker. I can manually track exceptions, but I don’t want to manually track all of the request/response dependencies. I am using a SharedWorker
(a regular Worker
exhibits the same issue) using the Comlink library.
I’ve searched and read the other issues (#1149, #1264, #1436, #1483, and #1727). They are either fixed or don’t apply to my situation, and the most recent one is now over a year old which has since been fixed.
Steps to Reproduce
- Create a worker (either Shared or regular)
- Instrument App Insights using the “npm-style” setup inside the worker
- make a
fetch
call from the worker - see that it does not auto-track
Client Info
- OS/Browser: Windows 10 / Firefox 110
- SDK Version [e.g. 22]:
@microsoft/applicationinsights-web: 2.8.10
- How you initialized the SDK: npm
Expected behavior
App Insights should auto-capture request and response information.
Additional context Add any other context about the problem here.
Here is my initialization code. If I try to call trackPageView
like I have before, it throws an exception (but only when enableDebug
or enableDebugExceptions
is true).
initialize = (config: AppConfig, userId: string, workbookName: string) => {
this._workbookName = workbookName;
if (!config.appInsightsConnectionString) {
return;
}
// https://docs.microsoft.com/en-us/azure/azure-monitor/app/javascript#configuration
const appInsights = new ApplicationInsights({
config: {
connectionString: config.appInsightsConnectionString, // use connection string instead of just key
disableAjaxTracking: true, // we don't use ajax
disableFetchTracking: false, // we do use fetch
disableXhr: true, // don't use XMLHttpRequest
enableCorsCorrelation: true, // correlate requests with backend requests
maxAjaxCallsPerView: 0, //track ALL calls from a single page view
// enableDebug: true,
// enableDebugExceptions: true,
},
});
appInsights.loadAppInsights();
appInsights.setAuthenticatedUserContext(userId, null, true);
appInsights.context.application.ver = config.version;
//add extension data to each request
appInsights.addTelemetryInitializer(this.setWorkbookName);
this._appInsights = appInsights;
};
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 37
Commits related to this issue
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [Master] [BUG] SharedWorker does not Instrument fetch correctly #1996 (#2001) - Merge from `beta` [BUG] SharedWorker does not Instrument fetch correctly #1996 - [BUG] App Insights not auto-capturin... — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
- [BUG] App Insights not auto-capturing from a Web Worker #1995 — committed to microsoft/ApplicationInsights-JS by MSNev a year ago
Last nights
nightly
release for 2.8.11 (2302-05) includes both of the “fixes” (fetch monitoring in the web worker and suppression of the page view performance message). The plan is to create the 2.8.11 release either later this week or early next (for npm).For the beta, I’m currently merging the suppression back to beta and the plan is to start promoting the
beta
to v3.x by the end of March.I took a peek at the PR. I am curious as to how it works - I see there’s a new parameter (
checkParentProto
) but it doesn’t look like it’s actually read anywhere?Sure thing:
Keep in mind you do have to have the
debug
config settings enabled (I didn’t check which one - I had them both set totrue
).I don’t think there was anything else. I saw all of the manual events (Exceptions, Events, etc) just fine. It was only the auto-tracking that was not working. Thank you for taking the time to work with me! I hope to be able to try the beta (again) soon!
I did actually try the latest beta but it did not work. I went back to latest stable before making the issue.
Nope, it returns
undefined
.Not sure if this helps, but using
in
does work: