-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Add Debug Ids support for JSC and Hermes bundles #3164
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a80b3c2
POC: Add preModule for debugIds
krystofwoldrich ca91181
Add debug id steps
krystofwoldrich 2467d0d
!wip
krystofwoldrich aaa789a
Fix serialized to work with the dev server
krystofwoldrich b093f67
add debug id before source map comment, fix debug id snippet
krystofwoldrich e0c46a6
Update sentry.gradle to use debug ids
krystofwoldrich 5466a4e
Merge remote-tracking branch 'origin/main' into kw-debug-id-metro-plugin
krystofwoldrich 4fa6068
Copy debug id from `debugId` and `debug_id`
krystofwoldrich 7f5514d
Add sentry metro serializer to the SDK project
krystofwoldrich 9a408fe
Merge remote-tracking branch 'origin/main' into kw-debug-id-metro-plugin
krystofwoldrich b12997f
fix yarn lock
krystofwoldrich 3bb9a53
Exclude metro plugin types from react native sdk build
krystofwoldrich ec34509
Add deterministic debug id generator
krystofwoldrich 157cd42
Add sentry bundle callback and js docs
krystofwoldrich a998824
Add backward compatible Debug ID upload to `sentry.gradle`
krystofwoldrich 0955f2d
Add new script to published package
krystofwoldrich 6efb620
Move xcode build phase script to rn sdk package
krystofwoldrich 731af02
Remove extra sentry cli args
krystofwoldrich d248b72
Use sourcemap file to enable hermesc source maps and fallback to rele…
krystofwoldrich 9fce536
Fix lint metro serializer
krystofwoldrich 1c0d3ef
Add metro serializer tests
krystofwoldrich 4335923
Fix sample debug files upload
krystofwoldrich 19f22e9
Use debug ids in e2e ios apps
krystofwoldrich f764255
Add sentry serializer to e2e tests
krystofwoldrich 02cd404
Fix metro config e2e patch
krystofwoldrich 79d9d8c
Update debug id snippet for multiple bundles in one runtime
krystofwoldrich 9add523
Remove node_modules from metro config patch
krystofwoldrich 889265e
Merge branch 'main' into kw-debug-id-metro-plugin
krystofwoldrich 6f981cc
Add changelog
krystofwoldrich daebe29
Update has sourcemap debugid script name
krystofwoldrich e68cd87
TMP: Remove no auto release to run ios e2e tests
krystofwoldrich 661e8ae
Add metro typings license
krystofwoldrich ad0a8e8
Fix review comments
krystofwoldrich c9ff331
Add virtual js output docs
krystofwoldrich 7baf4c0
Apply suggestions from code review
krystofwoldrich 6beff46
Merge branch 'main' into kw-debug-id-metro-plugin
krystofwoldrich e1c6409
Fix lint
krystofwoldrich 58bfbfd
Merge remote-tracking branch 'origin/main' into kw-debug-id-metro-plugin
krystofwoldrich f845642
Revert "TMP: Remove no auto release to run ios e2e tests"
krystofwoldrich 2826fc4
Fix e2e metro config patch
krystofwoldrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
collectCoverage: true, | ||
preset: 'react-native', | ||
setupFilesAfterEnv: ['<rootDir>/test/mockConsole.ts'], | ||
globals: { | ||
__DEV__: true, | ||
'ts-jest': { | ||
tsConfig: './tsconfig.json', | ||
diagnostics: false, | ||
}, | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js'], | ||
testPathIgnorePatterns: ['<rootDir>/test/e2e/', '<rootDir>/test/tools/', '<rootDir>/test/react-native/versions'], | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.(ts|tsx)'], | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
collectCoverage: true, | ||
preset: 'ts-jest', | ||
setupFilesAfterEnv: ['<rootDir>/test/mockConsole.ts'], | ||
globals: { | ||
__DEV__: true, | ||
}, | ||
testMatch: ['**/test/tools/**/*.ts'], | ||
transform: { | ||
'^.+\\.(ts|tsx)$': [ | ||
'ts-jest', | ||
{ | ||
tsconfig: './tsconfig.build.tools.json', | ||
diagnostics: false, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const process = require('process'); | ||
const fs = require('fs'); | ||
|
||
console.log('Copy `debugId` from packager source map to Hermes source map...'); | ||
|
||
const packagerSourceMapPath = process.argv[2]; | ||
const hermesSourceMapPath = process.argv[3]; | ||
|
||
if (!packagerSourceMapPath) { | ||
console.log('Please provide packager source map path (A path to copy `debugId` from).'); | ||
process.exit(0); | ||
} | ||
if (!hermesSourceMapPath) { | ||
console.log('Please provide Hermes source map path. ((A path to copy `debugId` to))'); | ||
process.exit(0); | ||
} | ||
if (!fs.existsSync(packagerSourceMapPath)) { | ||
console.log('Packager source map path (A path to copy `debugId` from).'); | ||
process.exit(0); | ||
} | ||
if (!fs.existsSync(hermesSourceMapPath)) { | ||
console.log('Hermes source map not found. ((A path to copy `debugId` to))'); | ||
process.exit(0); | ||
} | ||
|
||
const from = fs.readFileSync(process.argv[2], 'utf8'); | ||
const to = fs.readFileSync(process.argv[3], 'utf8'); | ||
|
||
const fromParsed = JSON.parse(from); | ||
const toParsed = JSON.parse(to); | ||
|
||
if (!fromParsed.debugId && !fromParsed.debug_id) { | ||
console.log('Packager source map does not have `debugId`.'); | ||
process.exit(0); | ||
} | ||
|
||
if (toParsed.debugId || toParsed.debug_id) { | ||
console.log('Hermes combined source map already has `debugId`.'); | ||
process.exit(0); | ||
} | ||
|
||
if (fromParsed.debugId) { | ||
toParsed.debugId = fromParsed.debugId; | ||
toParsed.debug_id = fromParsed.debugId; | ||
} else if (fromParsed.debug_id) { | ||
toParsed.debugId = fromParsed.debug_id; | ||
toParsed.debug_id = fromParsed.debug_id; | ||
} | ||
|
||
fs.writeFileSync(process.argv[3], JSON.stringify(toParsed)); | ||
|
||
console.log('Done.'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const process = require('process'); | ||
const fs = require('fs'); | ||
|
||
const sourceMapPath = process.argv[2]; | ||
|
||
if (!sourceMapPath) { | ||
console.log('Add source map path as first argument of the script.'); | ||
process.exit(1); | ||
} | ||
|
||
if (!fs.existsSync(sourceMapPath)) { | ||
console.log(`${sourceMapPath} does not exist.`); | ||
process.exit(1); | ||
} | ||
|
||
let sourceMap; | ||
try { | ||
sourceMap = JSON.parse(fs.readFileSync(sourceMapPath, 'utf8')); | ||
} catch (e) { | ||
console.log(`Sourcemap at ${sourceMapPath} was unable to be read.`, e); | ||
process.exist(1); | ||
} | ||
|
||
if (typeof sourceMap.debugId === 'string' && sourceMap.debugId.length > 0) { | ||
console.log(sourceMap.debugId); | ||
} else if (typeof sourceMap.debug_id === 'string' && sourceMap.debug_id.length > 0) { | ||
console.log(sourceMap.debug_id); | ||
} else { | ||
console.log(`${sourceMapPath} does not contain 'debugId' nor 'debug_id'.`); | ||
process.exist(1); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This is non minified version the debug id injection snippet used in the Metro plugin. | ||
var _sentryDebugIds = {}; | ||
var _sentryDebugIdIdentifier = ''; | ||
|
||
if (typeof _sentryDebugIds === 'undefined') { | ||
_sentryDebugIds = {}; | ||
} | ||
|
||
try { | ||
var stack = new Error().stack; | ||
if (stack) { | ||
_sentryDebugIds[stack] = '__SENTRY_DEBUG_ID__'; | ||
// eslint-disable-next-line no-unused-vars | ||
_sentryDebugIdIdentifier = 'sentry-dbid-__SENTRY_DEBUG_ID__'; | ||
} | ||
} catch (e) { | ||
/**/ | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
# Upload Debug Symbols to Sentry Xcode Build Phase | ||
# PWD=ios | ||
|
||
# print commands before executing them and stop on first error | ||
set -x -e | ||
|
||
# load envs if loader file exists (since rn 0.68) | ||
WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh" | ||
if [ -f "$WITH_ENVIRONMENT" ]; then | ||
. "$WITH_ENVIRONMENT" | ||
fi | ||
|
||
[ -z "$SENTRY_PROPERTIES" ] && export SENTRY_PROPERTIES=sentry.properties | ||
[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="../node_modules/@sentry/cli/bin/sentry-cli" | ||
|
||
[[ $SENTRY_INCLUDE_NATIVE_SOURCES == "true" ]] && INCLUDE_SOURCES_FLAG="--include-sources" || INCLUDE_SOURCES_FLAG="" | ||
|
||
EXTRA_ARGS="$SENTRY_CLI_EXTRA_ARGS $SENTRY_CLI_DEBUG_FILES_UPLOAD_EXTRA_ARGS $INCLUDE_SOURCES_FLAG" | ||
|
||
UPLOAD_DEBUG_FILES="\"$SENTRY_CLI_EXECUTABLE\" debug-files upload $EXTRA_ARGS \"$DWARF_DSYM_FOLDER_PATH\"" | ||
/bin/sh -c "$UPLOAD_DEBUG_FILES" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
# Sentry Bundle React Native code and images | ||
# PWD=ios | ||
|
||
# print commands before executing them and stop on first error | ||
set -x -e | ||
|
||
# WITH_ENVIRONMENT is executed by React Native | ||
|
||
[ -z "$SENTRY_PROPERTIES" ] && export SENTRY_PROPERTIES=sentry.properties | ||
[ -z "$SOURCEMAP_FILE" ] && export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map" | ||
[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="../node_modules/@sentry/cli/bin/sentry-cli" | ||
|
||
REACT_NATIVE_XCODE=$1 | ||
|
||
[[ "$AUTO_RELEASE" != true ]] && [[ -z "$BUNDLE_COMMAND" || "$BUNDLE_COMMAND" != "ram-bundle" ]] && NO_AUTO_RELEASE="--no-auto-release" | ||
ARGS="$NO_AUTO_RELEASE $SENTRY_CLI_EXTRA_ARGS $SENTRY_CLI_RN_XCODE_EXTRA_ARGS" | ||
|
||
BUNDLE_REACT_NATIVE="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $ARGS \"$REACT_NATIVE_XCODE\"" | ||
|
||
/bin/sh -c "$BUNDLE_REACT_NATIVE" | ||
|
||
[ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_COLLECT_MODULES="../../scripts/collect-modules.sh" | ||
|
||
if [ -f "$SENTRY_COLLECT_MODULES" ]; then | ||
/bin/sh "$SENTRY_COLLECT_MODULES" | ||
fi |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
should we
console.warn
orconsole.error
these? Ditto for the console logs that are below this.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.
I agree that's more correct, but I had issues reading std err output in https://github.com/getsentry/sentry-react-native/pull/3164/files#diff-01c94c11105e37de1b11a82973b605f625fff5959b0386c32fd1e42a14325208R125-R126
So that's why I kept it
console.log
. More important is that we have the log.