Using TrackJS in Web Workers

Web Workers run in a separate process from the main browser window and do not have access to the DOM. If you install TrackJS on your page, it won’t capture errors and events from inside workers unless you also install TrackJS in your worker process.

The TrackJS agent can be either imported directly using importScripts, or bundled as a module with your worker code. You do not need to add additional configuration for the agent to run in a worker. Worker support was added in 3.8.0.

importScripts("https://cdn.trackjs.com/agent/v3/canary/t.js");

TrackJS.install({
  token: 'YOUR_TOKEN',
});

console.log('I am the worker thread');
TrackJS Worker Integration using importScripts

The agent will record global errors, network errors, console errors, promise rejections, and catch from callbacks within the worker context. Console messages and network requests will be included as Telemetry.