-
Notifications
You must be signed in to change notification settings - Fork 31
fix: Fix a bug where the incorrect src lines may have been captured. #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk-common size report |
| function: inFrame.func, | ||
| line: inFrame.line, | ||
| col: inFrame.column, | ||
| // Strip the nulls so we only ever return undefined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from tightening up the typing a bit in the vendored library.
|
@launchdarkly/js-client-sdk size report |
5840a4a to
a73f4ae
Compare
|
|
||
| element.context = element.line ? gatherContext(element.url, element.line) : null; | ||
| const srcContext = gatherContext(element.url, element.line!); | ||
| element.context = element.line ? (srcContext?.contextLines ?? null) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing of some of this stuff is pretty strange, but I am not trying to comprehensively re-work the existing typing. So keeping it basically the same for now.
a73f4ae to
0b7001c
Compare
| '}', | ||
| 'foo();', | ||
| ], | ||
| srcStart: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
srcStart is 1-based and is 1, line is 1-based and 3.
3 - 1 = 2; Now we use the offset from the start for the src line.
Index 0 == throw new Error("error on line 3");'
🤖 I have created a release *beep* *boop* --- <details><summary>browser-telemetry: 1.0.2</summary> ## [1.0.2](browser-telemetry-v1.0.1...browser-telemetry-v1.0.2) (2025-02-28) ### Bug Fixes * Fix a bug where the incorrect src lines may have been captured. ([#792](#792)) ([1f44dd5](1f44dd5)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Resolves a bug where the srcLine and before/after context would have been populated incorrectly.
We would assume the src line would be in the middle of the source context, but when a number of lines greater than the context window don't exist, it will not always be in the middle.
The fix extends TraceKit with a srcStart field that indicates the line the context window starts on. This can then be used to calculate the offset to the originating line.