Kibana version: 7.4.0
Elasticsearch version: 7.4.0
APM Server version: 7.4.0
APM Agent language and version: @elastic/apm-rum@4.7.0
Original install method (e.g. download page, yum, deb, from source, etc.) and version: Downloaded the JavaScript agent from GitHub
Fresh install or upgraded from other version? Fresh
Is there anything special in your setup? No
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
I want to use APM RUM with a service worker. This service worker is used for fetch catching. It enqueues some requests that are sent in offline mode and send them again as soon as the navigator is online.
I am trying to use APM RUM importing the agent script via importScripts() without getting any error at all. This is the line:
importScripts('/lib/localforage.min.js', 'elastic-apm-rum.umd.min.js');
Then I get an error in the following line:
var apm = elasticApm.init({ serviceName: 'ServiceName', serverUrl: 'http://localhost:8200' });
This is the error:
Uncaught ReferenceError: elasticApm is not defined
NOTE: The line that produces the error is inside another function which is called when I am sending the requests.
I also have tried importing a custom .js file which instantiates the elasticApm object but I get the same error so I guess the agent script is not loaded at the moment I am trying to access it.
Is there a way to use it inside my service worker?
Actual behavior:
I cant use the elasticApm object inside a service worker.
Expected behavior:
Use the elasticApm object inside a service worker just as I do in other .js files for starting transactions and spans and also capturing errors.
Errors in browser console (if relevant): Uncaught ReferenceError: elasticApm is not defined