I am trying to trigger a HAR log export from the background script of a Firefox extension, but for the life of me cannot figure out how to do it.
I am using the code found here, I would expect this to work and return the HAR export, but keep getting this error TypeError: browser.devtools is undefined
The documentation on that page also points out the browser devtools will export the HAR log of the page the devtools are attached to, but other than manually opening them on the page (which I have tried to no avail) I have no Idea how to do this programmatically. (I suspect this is the part that is going wrong, as the devtools are undefined).
I have included the "devtools" permission in my manifest file, other than that I'm at a loss as to what else I have overlooked.
Here is the exact lines of code I'm trying to get working (these are contained within an async function)
const har = await browser.devtools.network.getHAR();
console.log(har);
Any help or pointing me in the right direction documentation wise will be greatly appreciated!