Skip to content
This repository was archived by the owner on Sep 14, 2020. It is now read-only.

Commit ba3dfc5

Browse files
Merge pull request #306 from bugsnag/add-deobfuscation-examples
Update examples to show how to deobfuscate JS + Native stacktraces
2 parents b6c820a + af7c656 commit ba3dfc5

13 files changed

Lines changed: 591 additions & 9597 deletions

examples/plain/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ buck-out/
5151
*/fastlane/report.xml
5252
*/fastlane/Preview.html
5353
*/fastlane/screenshots
54+
55+
*.bundle
56+
*.bundle.map

examples/plain/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,45 @@ A robust example of how to make best use of the Bugsnag React Native notifier.
5252
```
5353
react-native run-android --variant=release
5454
```
55+
56+
## Deobfuscating stacktraces
57+
58+
This app provides working examples of how to deobfuscate stacktraces for JS, Android, and iOS. For further information, please consult [our React Native documentation](https://docs.bugsnag.com/platforms/react-native/showing-full-stacktraces/).
59+
60+
### JavaScript
61+
62+
You will need to upload source maps to Bugsnag in order to deobfuscate JavaScript stack traces. Example scripts for achieving this on Android/iOS in both debug and release builds can be found [here](scripts). The example scripts use [bugsnag-sourcemaps](https://github.com/bugsnag/bugsnag-sourcemaps), which is installed as a dev dependency of the project. The scripts can also be invoked in this example project using [npm run](https://docs.npmjs.com/cli/run-script.html):
63+
64+
```bash
65+
npm run upload-sourcemaps:debug:android
66+
npm run upload-sourcemaps:debug:ios
67+
npm run upload-sourcemaps:release:android
68+
npm run upload-sourcemaps:release:ios
69+
```
70+
71+
Please note that if you use Code Push, you should specify `codeBundleId` in your JS configuration, and use that as the value of `app-version` instead. See [the docs](https://docs.bugsnag.com/platforms/react-native/showing-full-stacktraces) for further detail.
72+
73+
Note: recent versions of React Native have an [issue](https://github.com/facebook/react-native/issues/6946#issuecomment-405525464) which may result in the failure to apply source maps or incorrect line numbers being mapped.
74+
75+
### Android
76+
77+
The [Bugsnag Gradle Plugin](https://docs.bugsnag.com/build-integrations/gradle/) will automatically upload all the necessary mapping files when `react-native run-android --variant=release` is invoked.
78+
79+
ProGuard mapping files can also be uploaded manually in this example project by using [npm run](https://docs.npmjs.com/cli/run-script.html):
80+
81+
```bash
82+
npm run upload-proguard:release:android
83+
```
84+
85+
### iOS
86+
87+
If Bitcode is enabled in your project, you will first need to download your dSYMs from XCode or iTunes Connect, then upload them by using our fastlane plugin or bugsnag-dsym-upload. A working example of this can be found [here](ios/upload-react-native-dsyms.sh). The example script requires the installation of [bugsnag-dsym-upload](https://github.com/bugsnag/bugsnag-dsym-upload) to work, and can be invoked using [npm run](https://docs.npmjs.com/cli/run-script.html):
88+
89+
```bash
90+
npm run upload-dsyms:release:ios
91+
```
92+
93+
94+
If you are not using Bitcode, you can use our Fastlane or Cocoapods integrations, or add a manual Build phase to upload the dSYMs.
95+
96+
Read the [iOS symbolication guide](https://docs.bugsnag.com/platforms/ios/symbolication-guide) for further details.

examples/plain/android/app/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
apply plugin: "com.android.application"
2+
apply plugin: 'com.bugsnag.android.gradle'
23

34
import com.android.build.OutputFile
45

@@ -91,7 +92,7 @@ def enableSeparateBuildPerCPUArchitecture = false
9192
/**
9293
* Run Proguard to shrink the Java bytecode in release builds.
9394
*/
94-
def enableProguardInReleaseBuilds = false
95+
def enableProguardInReleaseBuilds = true
9596

9697
android {
9798
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -158,3 +159,7 @@ task copyDownloadableDepsToLibs(type: Copy) {
158159
from configurations.compile
159160
into 'libs'
160161
}
162+
163+
bugsnag {
164+
overwrite true
165+
}

examples/plain/android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ buildscript {
1515
}
1616
dependencies {
1717
classpath 'com.android.tools.build:gradle:3.1.4'
18+
classpath 'com.bugsnag:bugsnag-android-gradle-plugin:3.6.0'
1819

1920
// NOTE: Do not place your application dependencies here; they belong
2021
// in the individual module build.gradle files
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
cd android
4+
./gradlew uploadBugsnagReleaseMapping
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
cd ios
4+
bugsnag-dsym-upload build/Build/Products/Release-iphonesimulator/

0 commit comments

Comments
 (0)