fix(detect): auto-detect Zen/Floorp via getBrowserInfo (fixes #232)#233
Open
fanxing11 wants to merge 1 commit into
Open
fix(detect): auto-detect Zen/Floorp via getBrowserInfo (fixes #232)#233fanxing11 wants to merge 1 commit into
fanxing11 wants to merge 1 commit into
Conversation
…yWatch#232) detectBrowser() only checks navigator.userAgent, which is plain Firefox for Firefox forks (Zen, Floorp, LibreWolf, Waterfox, ...) since that's how they run Firefox extensions unchanged. As a result, Zen users got a bucket named aw-watcher-web-firefox_<host>, but the aw-webui Browser view's firefox regex (firefox|librewolf|waterfox|nightly) does not match zen's window-watcher app name, so 'Top Browser Domains/URLs' came up empty even though Timeline showed the raw events. Refine the 'firefox' branch with browser.runtime.getBrowserInfo() (a Firefox-only API that forks override to report their own name) and map known forks that have a dedicated entry in aw-webui queries.ts (browser_appnames + browser_appname_regex) onto their bucket: zen, floorp. Forks without a dedicated entry stay on the firefox bucket. getBrowserInfo is absent on Chromium and on Firefox < 51, so we guard the lookup with a typeof check and a try/catch and fall back to 'firefox' on any failure.
Comment on lines
+26
to
+28
| for (const key of Object.keys(FIREFOX_FORK_BUCKETS)) { | ||
| if (name.includes(key)) return FIREFOX_FORK_BUCKETS[key] | ||
| } |
There was a problem hiding this comment.
Using
name.includes(key) for the fork lookup means any substring match triggers a bucket assignment. For example, a hypothetical fork whose getBrowserInfo returns "Zenith" or "Gozen" would silently resolve to the zen bucket. Since the bucket name is persisted via setBrowserName and short-circuits future calls, a false-positive match would stick permanently until the user manually resets it. An exact-match check (after stripping trailing words like "browser") is more defensive.
Suggested change
| for (const key of Object.keys(FIREFOX_FORK_BUCKETS)) { | |
| if (name.includes(key)) return FIREFOX_FORK_BUCKETS[key] | |
| } | |
| for (const [key, bucket] of Object.entries(FIREFOX_FORK_BUCKETS)) { | |
| // Match exactly or as the first word (e.g. "zen browser" → "zen") | |
| if (name === key || name.startsWith(key + ' ')) return bucket | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #232.
detectBrowser()only looks atnavigator.userAgent, which is plain Firefox for Firefox forks (Zen, Floorp, LibreWolf, Waterfox, …) since that's how they run Firefox extensions unchanged. As a result, Zen users end up with a bucket namedaw-watcher-web-firefox_<host>, but aw-webui's Browser view filters window events through the firefox regex(?i)(firefox|librewolf|waterfox|nightly). Zen's window-watcherappname doesn't match, so "Top Browser Domains/URLs" comes up empty even though the raw events show up in Timeline.This refines the
firefoxbranch withbrowser.runtime.getBrowserInfo()— a Firefox-only API that forks override to report their own name — and maps forks that have a dedicated entry in aw-webui'squeries.ts(browser_appnames+browser_appname_regex) onto their own bucket: currentlyzenandfloorp. Forks without a dedicated entry (librewolf, waterfox) fall through and keep the firefox bucket, which already covers them via the firefox regex.getBrowserInfois absent on Chromium and on Firefox < 51, so the lookup is guarded with atypeofcheck and a try/catch and falls back to'firefox'on anything unexpected.Notes:
storedNameshort-circuits as before, so existing installs keep their current bucket — no migration, no data loss).helpers.ts.tsc --noEmitandvite buildboth clean.