logdna / logdna/logdna-browser

Cannot use in worker because window is not defined

Open
#64 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
23
Forks
10
PR merge metrics
No merged PRs in 30d

Description

In `src/utils.ts`, the [console methods are cached](https://github.com/logdna/logdna-browser/blob/2f42857457fa8be92fdc8583379b1bb3f9f7331c/src/utils.ts#L96-L113). However, in a JS worker, `window` is undefined, and, so, this code fails with "ReferenceError: window is not defined".

It appears these cached methods are only used in two places: [src/plugins/logger.ts](https://github.com/logdna/logdna-browser/blob/2f42857457fa8be92fdc8583379b1bb3f9f7331c/src/plugins/logger.ts#L24) and [src/capture.ts](https://github.com/logdna/logdna-browser/blob/2f42857457fa8be92fdc8583379b1bb3f9f7331c/src/capture.ts#L80).

Contributor guide

Open the contributing guide

Research direction

Start in src/utils.ts at the cached console methods, then inspect their two reported uses in src/plugins/logger.ts and src/capture.ts. Verify the behavior in a JavaScript worker where window is undefined; done means the worker no longer fails while those logging and capture uses remain functional.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.