0
import MatomoTracker from "@datapunt/matomo-tracker-js";


//codes
//....
//...
const tracker = new MatomoTracker({
    urlBase: "https://example.com/",
    siteId: 1,
  
    // linkTracking: false, // optional, default value: true
    // configurations: { // optional, default value: {}
    //   // any valid matomo configuration, all below are optional
    //   disableCookies: true,
    //   setSecureCookie: true,
    //   setRequestMethod: 'POST'
    // }
  })

how can i instantiate the external package class in my service worker of chrome extension

tried doing the same in contentscript but did'nt work.

any suggestions on how can i instantiate external package class in service worker of chrome extension?

is it possible?

  • Conceptually it should be used in the content script, but it might be unable to send a cross-origin network request in modern Chrome, so you'll either need to patch `window.fetch` to relay the request as shown [here](/a/55292071) or not use a library and just construct the API request yourself (see the same link). – wOxxOm Aug 24 '23 at 14:37
  • 1
    Does this answer your question? [Is it possible to require npm modules in a chrome extension ?](https://stackoverflow.com/questions/43684452/is-it-possible-to-require-npm-modules-in-a-chrome-extension) – wOxxOm Aug 24 '23 at 14:40

0 Answers0