Repository navigation
fix: infer browser source for browser runtime context - #1384
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was successfully deployed
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.
Summary
Envelopes from browser SDKs whose events carry
contexts.runtime.name = "browser"are now classified asbrowserinstead ofserverwhen no browser User-Agent is available. This corrects the source label shown in the human, logfmt, markdown, and JSON formatters and in the log stream.Root Cause
inferSourceFromEventinpackages/spotlight/src/server/formatters/human/utils.tstreated any non-emptyevent.contexts.runtime.nameas a deterministic server signal and returned"server"immediately. Browser SDKs emitcontexts.runtime.name = "browser", so such events were misclassified before the later SDK-name fallback could classify them as"browser". The user-agent signal masks this in the common case because a real browser request carries a browser User-Agent, but the sidecar can receive envelopes with no User-Agent (proxying, server-side forwarding, or privacy tooling that strips it), which exposed the wrong classification.Issue #757 in this repository is a separate, older tab-count reactivity problem and is not addressed here.
Solution
One line in
inferSourceFromEvent: keep the runtime-context server heuristic, but exclude the literal"browser"runtime name. This is the narrowest change that preserves all existing server detection (for examplenode,CPython, orruby) while letting browser SDK events reach the existing browser SDK-name fallback.A regression test was added at
packages/spotlight/src/server/formatters/human/__tests__/utils.test.tswith two cases: a browser runtime context must inferbrowser, and a non-browser runtime context must still inferserver.Test Plan
Validation ran in Docker with image
node:22-bookworm. Because a fullpnpm install --frozen-lockfilewas prohibitively slow in this environment, an isolated harness was used:vitest@4.1.12,chalk@5.6.2, and@biomejs/biome@1.9.4were installed withnpm i --legacy-peer-deps, and the exact repository source files were copied into the harness. The repository's ownbiome.jsonwas passed via--config-path.Commands and real results:
npx vitest run src/packages/spotlight/src/server/formatters/human/__tests__/utils.test.ts(with fix): 1 test file passed, 2 tests passed.utils.tswithgit -C /repo show HEAD:packages/spotlight/src/server/formatters/human/utils.ts: 1 test file failed, 1 test failed and 1 passed, withAssertionError: expected 'server' to be 'browser'.npx biome check --config-path=/repo/biome.json <the two changed files>(LF-normalized copies, matching CI checkout):Checked 2 files in 53ms. No fixes applied.Zero errors.git diff --check: exit 0.Not run locally: full
pnpm install, fullpnpm test, andpnpm build. These are deferred to GitHub Actions CI.