-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Update CodePush guide for Debug IDs #11550
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4fab254
feat: Update CodePush guide for Debug IDs
krystofwoldrich c6b46e4
Update docs/platforms/react-native/sourcemaps/uploading/codepush.mdx
krystofwoldrich 1263df8
Update docs/platforms/react-native/sourcemaps/uploading/codepush.mdx
krystofwoldrich 69f6fd6
Update codepush.mdx
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 was deleted.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
docs/platforms/react-native/sourcemaps/uploading/codepush.mdx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| --- | ||
| title: CodePush | ||
| sidebar_order: 100 | ||
| description: "Upload source maps for CodePush releases." | ||
| --- | ||
|
|
||
| Sentry's React Native SDK works out of the box with CodePush. To see readable stack traces in the product, you must upload source maps to Sentry. This guide explains how to upload source maps for CodePush releases, that are created with the AppCenter CLI. | ||
|
|
||
| ## Prerequisities | ||
|
|
||
| - [Sign up for an account](https://sentry.io/signup/) | ||
| - [Set up Sentry React Native SDK](/platforms/react-native) | ||
| - [Set up Sentry Metro Plugin](/platforms/react-native/manual-setup/metro) | ||
| - The plugin ensures that Debug IDs are enabled and used to link source maps to bundles. | ||
|
|
||
| ## Wrap Your App | ||
|
|
||
| Ensure `codePush` is the outer most function because it needs access to the root component in order to swap out the bundle. | ||
|
|
||
| ```javascript | ||
| export default codePush(Sentry.wrap(App)); | ||
| ``` | ||
|
|
||
| ## Create CodePush Release | ||
|
|
||
| To ensure Sentry can symbolicate events from your CodePush releases, you need to generate and upload the necessary assets. When creating a CodePush release, include the `--sourcemap-output-dir` flag to generate source maps. This allows you to upload these files to Sentry in the next step. | ||
|
|
||
| ```bash {tabTitle:JSC} | ||
| appcenter codepush release-react \ | ||
| --app "${APP_NAME}" \ | ||
| --deployment-name "${DEPLOYMENT_NAME}" \ | ||
| --output-dir ./build \ | ||
| --sourcemap-output-dir ./build | ||
| ``` | ||
|
|
||
| ```bash {tabTitle:Hermes} | ||
| rm -rf ./build | ||
| CODEPUSH_COMMAND="appcenter codepush release-react \ | ||
| --app \"${APP_NAME}\" \ | ||
| --deployment-name \"${DEPLOYMENT_NAME}\" \ | ||
| --use-hermes \ | ||
| --output-dir ./build \ | ||
| --sourcemap-output-dir ./build" | ||
|
|
||
| DEBUG_ID=$(eval "$CODEPUSH_COMMAND" | tee /dev/tty | grep -o 'Bundle Debug ID: [0-9a-f-]*' | sed 's/Bundle Debug ID: //') | ||
|
|
||
| # Find the .map file and add the debug_id to it | ||
| MAP_FILE=$(find ./build -name "*.map" -type f) | ||
| jq -c ". + {\"debug_id\": \"${DEBUG_ID}\"}" "${MAP_FILE}" > "${MAP_FILE}.tmp" | ||
| mv "${MAP_FILE}.tmp" "${MAP_FILE}" | ||
| ``` | ||
|
|
||
| ### Notes | ||
|
|
||
| If you are using Hermes make sure `jq` is installed on your system. If it's not, you can install it using your system's package manager. For example `apt-get install jq` on Ubuntu, or `brew install jq` on macOS with Homebrew. | ||
|
|
||
| ## Upload Source Maps | ||
|
|
||
| Upload source maps for your CodePush release by setting up your environment variables and running the `react-native appcenter` command. | ||
|
|
||
| Before running the upload command, make sure to set up your environment variables. | ||
|
|
||
| ```bash {tabTitle:Environment Variables} | ||
| export SENTRY_ORG=___ORG_SLUG___ | ||
| export SENTRY_PROJECT=___PROJECT_SLUG___ | ||
| export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ | ||
| ``` | ||
|
|
||
| To upload source maps for your CodePush release, use the `react-native appcenter` command. | ||
|
|
||
| ```bash {tabTitle:Sentry CLI} | ||
| npx sentry-cli sourcemaps upload \ | ||
| --debug-id-reference \ | ||
| --strip-prefix /path/to/project/root \ | ||
| ./build | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| ### Optional Release and Dist | ||
|
|
||
| To associate the uploaded artifacts with the CodePush release, use the `--release` and `--dist` options. Make sure that events reported by the SDK have the same `release` and `dist` values. You can follow the default schema `${BUNDLE}@${VERSION}+${BUILD}` for `release` and `${BUILD}` for `dist` or set the values manually in `Sentry.init`. This is optional when uploading artifacts with Debug IDs. | ||
krystofwoldrich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Using `codePush.getUpdateMetadata` | ||
|
|
||
| Use `Sentry.setTag` to associate the CodePush Update Label with the captured events. | ||
krystofwoldrich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```javascript | ||
| codePush.getUpdateMetadata().then((update) => { | ||
| Sentry.setTag('codepush', update.label); | ||
| }); | ||
| ``` | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.