Describe the bug
tslog fails if used in Manifest V3 Chrome Extensions. More specifically it fails in background pages which now use service workers. The reason is that service workers do not have a window object. So the following code in tslog/dist/esm/runtime/browser/index.js fails:
const meta = { runtime: "Browser", browser: window?.["navigator"].userAgent, };
To Reproduce
Steps to reproduce the behavior:
- Create a basic Chrome Extension
- Add tslog to a background script
- Load the unpacked extension to your Chrome. To do that turn on the Developer mode on Extensions page.
- Click on the "background page" link on your extension on Extensions page to open DevTools
- Check the error in the Console of DevTools
Expected behavior
Extension should not fail.
Screenshots

Solution
Use self if window is not defined.
Describe the bug
tslog fails if used in Manifest V3 Chrome Extensions. More specifically it fails in background pages which now use service workers. The reason is that service workers do not have a window object. So the following code in tslog/dist/esm/runtime/browser/index.js fails:
const meta = { runtime: "Browser", browser: window?.["navigator"].userAgent, };To Reproduce
Steps to reproduce the behavior:
Expected behavior
Extension should not fail.
Screenshots

Solution
Use self if window is not defined.