Skip to content
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

feat(js): Read debug IDs from debugId field #874

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 12.12.0
## Unreleased

**Features**:
- feat(js): Sourcemap debug IDs can now be read from the `"debugId"` field in addition to
`"debug_id"` ([#870](https://github.com/getsentry/symbolic/pull/870)).

### Various fixes & improvements
## 12.12.0

**Fixes**
- Unship "Support for DWARFv5 embedded source code extension ([#849](https://github.com/getsentry/symbolic/pull/849))".
Expand Down
42 changes: 42 additions & 0 deletions symbolic-debuginfo/src/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ pub fn discover_sourcemaps_location(contents: &str) -> Option<&str> {
}

/// Quickly reads the embedded `debug_id` key from a source map.
///
/// Both `debug_id` and `debugId` are supported as field names.
pub fn discover_sourcemap_embedded_debug_id(contents: &str) -> Option<DebugId> {
#[derive(Deserialize)]
struct DebugIdInSourceMap {
#[serde(alias = "debugId")]
debug_id: Option<DebugId>,
}

Expand All @@ -49,3 +52,42 @@ pub fn discover_debug_id(contents: &str) -> Option<DebugId> {
}
None
}

#[cfg(test)]
mod tests {
use debugid::DebugId;

use crate::js::discover_sourcemap_embedded_debug_id;

#[test]
fn test_debugid_snake_case() {
let input = r#"{
"version":3,
"sources":["coolstuff.js"],
"names":["x","alert"],
"mappings":"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM",
"debug_id":"00000000-0000-0000-0000-000000000000"
}"#;

assert_eq!(
discover_sourcemap_embedded_debug_id(input),
Some(DebugId::default())
);
}

#[test]
fn test_debugid_camel_case() {
let input = r#"{
"version":3,
"sources":["coolstuff.js"],
"names":["x","alert"],
"mappings":"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM",
"debugId":"00000000-0000-0000-0000-000000000000"
}"#;

assert_eq!(
discover_sourcemap_embedded_debug_id(input),
Some(DebugId::default())
);
}
}
Loading