Skip to content

Commit

Permalink
Fix bugsnag source maps
Browse files Browse the repository at this point in the history
Use bugsnag-source-maps to upload map file for android
Use npx @bugsnag/react-native-cli init to install and configure BugSnag for ios map file upload
  • Loading branch information
paullinator committed Jan 15, 2024
1 parent 28bc1aa commit a41a919
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 58 deletions.
4 changes: 0 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,3 @@ if (hasProperty('storeFile')) {

// Integrate react-native-vector-icons fonts
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

bugsnag {
uploadReactNativeMappings = true
}
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.1")
classpath("com.bugsnag:bugsnag-android-gradle-plugin:7.+")
classpath("com.facebook.react:react-native-gradle-plugin")

// Edge additions:
classpath 'com.google.gms:google-services:4.3.14'
classpath "com.bugsnag:bugsnag-android-gradle-plugin:7.+"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
}
}
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- _NIODataStructures (2.40.0)
- boost (1.76.0)
- BugsnagReactNative (7.20.2):
- BugsnagReactNative (7.22.3):
- React-Core
- BVLinearGradient (2.8.3):
- React-Core
Expand Down Expand Up @@ -1253,7 +1253,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
_NIODataStructures: 3d45d8e70a1d17a15b1dc59d102c63dbc0525ffd
boost: 7dcd2de282d72e344012f7d6564d024930a6a440
BugsnagReactNative: bf6f4ebababa8536726b3014c7d3e4af8c53d488
BugsnagReactNative: d9fa0824cea1beb5ab1f12828d79a2bd1b383e60
BVLinearGradient: 880f91a7854faff2df62518f0281afb1c60d49a3
CGRPCZlib: 298dd3237ba4bd7b3eed109e7080ff3324b7d9c9
CNIOAtomics: 8edf08644e5e6fa0f021c239be9e8beb1cd9ef18
Expand Down
17 changes: 16 additions & 1 deletion ios/edge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */,
E235C05ADACE081382539298 /* [CP] Copy Pods Resources */,
6B28E05B75112FE0B6FF32C6 /* [CP-User] [RNFB] Core Configuration */,
18D5C87BF6BD4974A24F472D /* Upload source maps to Bugsnag */,
);
buildRules = (
);
Expand Down Expand Up @@ -320,7 +321,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
shellScript = "export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $TMPDIR/$(md5 -qs \"$CONFIGURATION_BUILD_DIR\")-main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
};
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -339,6 +340,20 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-edge/Pods-edge-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
18D5C87BF6BD4974A24F472D /* Upload source maps to Bugsnag */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Upload source maps to Bugsnag";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "SOURCE_MAP=\"$TMPDIR/$(md5 -qs \"$CONFIGURATION_BUILD_DIR\")-main.jsbundle.map\" ../node_modules/@bugsnag/react-native/bugsnag-react-native-xcode.sh";
};
6B28E05B75112FE0B6FF32C6 /* [CP-User] [RNFB] Core Configuration */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
17 changes: 17 additions & 0 deletions jestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ import './node_modules/react-native-gesture-handler/jestSetup.js'
import { jest } from '@jest/globals'
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock'

jest.mock('@bugsnag/react-native', () => {
return {
isStarted: () => false,
leaveBreadcrumb: () => {},
notify: () => {},
start: () => false,
getPlugin: () => {
return {
createErrorBoundary:
() =>
({ children }) =>
children
}
}
}
})

jest.mock('disklet', () => {
const originalModule = jest.requireActual('disklet')

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"uuid": "3.3.2"
},
"dependencies": {
"@bugsnag/react-native": "^7.20.2",
"@bugsnag/react-native": "^7.22.3",
"@connectedcars/react-native-slide-charts": "^1.0.5",
"@ethersproject/shims": "^5.6.0",
"@react-native-async-storage/async-storage": "^1.19.4",
Expand Down Expand Up @@ -206,7 +206,7 @@
"rn-qr-generator": "^1.3.1",
"sha.js": "^2.4.11",
"sprintf-js": "^1.1.1",
"url": "^0.11.0",
"url": "^0.11.0",
"url-parse": "^1.5.2",
"yaob": "^0.3.12",
"yavent": "^0.1.3"
Expand Down
22 changes: 18 additions & 4 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ interface BuildObj extends BuildConfigFile {
buildNum: string
bundleMapFile: string
bundlePath: string
bundleUrl: string
guiHash: string
version: string

Expand Down Expand Up @@ -159,11 +158,9 @@ function makeCommonPost(buildObj: BuildObj) {

if (buildObj.platformType === 'android') {
buildObj.bundlePath = `${buildObj.guiPlatformDir}/app/build/intermediates/assets/release/index.android.bundle`
buildObj.bundleUrl = 'index.android.bundle'
buildObj.bundleMapFile = '../android-release.bundle.map'
buildObj.bundleMapFile = `${buildObj.guiPlatformDir}/app/build/generated/sourcemaps/react/release/index.android.bundle.map`
} else if (buildObj.platformType === 'ios') {
buildObj.bundlePath = `${buildObj.guiPlatformDir}/main.jsbundle`
buildObj.bundleUrl = 'main.jsbundle'
buildObj.bundleMapFile = '../ios-release.bundle.map'
}
buildObj.productNameClean = buildObj.productName.replace(' ', '')
Expand Down Expand Up @@ -425,6 +422,23 @@ function buildCommonPost(buildObj: BuildObj) {
call(curl)
}

if (buildObj.bugsnagApiKey && buildObj.platformType === 'android' && !simBuild) {
mylog('\n\nUploading Android map files to Bugsnag')
mylog('*********************\n')
chdir(buildObj.guiDir)
call(
`yarn run bugsnag-source-maps upload-react-native \
--api-key ${buildObj.bugsnagApiKey} \
--app-version ${buildObj.version} \
--app-version-code ${buildObj.buildNum} \
--bundle ${buildObj.bundlePath} \
--platform ${buildObj.platformType} \
--project-root ${buildObj.guiPlatformDir} \
--source-map ${buildObj.bundleMapFile} \
`
)
}

if (buildObj.appCenterApiToken && buildObj.appCenterAppName && buildObj.appCenterGroupName && !simBuild) {
mylog('\n\nUploading to App Center')
mylog('***********************\n')
Expand Down
88 changes: 44 additions & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1268,45 +1268,45 @@
resolved "https://registry.yarnpkg.com/@bugsnag/cuid/-/cuid-3.0.0.tgz#2ee7642a30aee6dc86f5e7f824653741e42e5c35"
integrity sha512-LOt8aaBI+KvOQGneBtpuCz3YqzyEAehd1f3nC5yr9TIYW1+IzYKa2xWS4EiMz5pPOnRPHkyyS5t/wmSmN51Gjg==

"@bugsnag/delivery-react-native@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/delivery-react-native/-/delivery-react-native-7.19.0.tgz#06e3b2d139a206c2d0ba2bdaa918219e17f067ce"
integrity sha512-Zzl3VOwLDU4KHmf3VweyfNeJcQgL0NzbWG+OCxjCYen093Q4sxNTpWAVBCrYPRjQ2Sq3+D3+YbQg5UUrHL7kig==

"@bugsnag/plugin-console-breadcrumbs@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-console-breadcrumbs/-/plugin-console-breadcrumbs-7.19.0.tgz#89773558865f9ee4aa633408f7ab56a741e7b553"
integrity sha512-ZHqPAK0WpbvWjj2wwSV8+C8+K9TOyQsfZnRJ7lIadbeUUJORmFRnG0vUHKBvwxMP7bqCj8fOe/S0kKF3dfMMKA==

"@bugsnag/plugin-network-breadcrumbs@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-network-breadcrumbs/-/plugin-network-breadcrumbs-7.19.0.tgz#eb1cca507d6181e09e1b81a0780bfda1d1435fe2"
integrity sha512-Farc0XuUoxv10kJE65zfgZlqujR7TDu8QjwxA4YDxEE41kFM8TAw0CAK15WkQK1UTsNACiiAETZGyU279eB65Q==

"@bugsnag/plugin-react-native-client-sync@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-client-sync/-/plugin-react-native-client-sync-7.19.0.tgz#f54f44562697ab73e9529a5d6f8d5aa6d9e3b388"
integrity sha512-WyK5pZuIzqVrY0h0HimwuODCo9ty9AyDY3q1pmwjrz2y8JTT21nnwUtHybLsp5Rl2oJR4tG06QkWmazgHDkWdA==

"@bugsnag/plugin-react-native-event-sync@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-event-sync/-/plugin-react-native-event-sync-7.19.0.tgz#be12dd1ca3def5e0ca046175fd2b7506778080e2"
integrity sha512-OD73WFkDJAq8AheN2Jap+d17M1mPbEBc1Aulz9FCLs//QwlM2IOij8oarB1iF/wgK6FnIgLFEBPTZpGHuZUsyQ==

"@bugsnag/plugin-react-native-global-error-handler@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-global-error-handler/-/plugin-react-native-global-error-handler-7.19.0.tgz#cbf92d3b782bdc347b06ea2dcb9cbab2c22439df"
integrity sha512-zf+KIHqGEAs2ekAzJCTS0rM1nKrmpIfznBhn72xZJwyfYrh0wbvjZjClDEwxDZ24uNVUUHrIymzdqxpHqVb0lg==
"@bugsnag/delivery-react-native@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/delivery-react-native/-/delivery-react-native-7.22.3.tgz#7fcc324486a122101dabef085aae4c032ca97cd0"
integrity sha512-6lHcberdmzVDlMumM3Ff6A/Ycmo4nIWN28d+Q1i13HS1AYnbmry9wVRzgC/dYfad7Nk5zKwOR9yhwQz7xUaBzw==

"@bugsnag/plugin-console-breadcrumbs@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-console-breadcrumbs/-/plugin-console-breadcrumbs-7.22.3.tgz#910201ffebcd2a14df7397e2c0444f0beda2bdb4"
integrity sha512-SFfyFlvjkeQ9cJK64QLDdhNjSttpS/fbTxi4UnB1CTjj9G1spD4InUUnXDFHtSis4Dnx2GL4lWUbXXhE0cXIfw==

"@bugsnag/plugin-network-breadcrumbs@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-network-breadcrumbs/-/plugin-network-breadcrumbs-7.22.3.tgz#d1f3fffb40c7918afb70b208ccffa04653a13996"
integrity sha512-C1hpB05pvXBSI9rv9N3AxJBRJ3hY7BLIgkNRKYq+E3l8HNFipDrDGKt0i7R6nUSmolSFJkheQqr12BNmdOPosw==

"@bugsnag/plugin-react-native-client-sync@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-client-sync/-/plugin-react-native-client-sync-7.22.3.tgz#aa4945cb52239b43b16c6c4b055073bf74dd2f57"
integrity sha512-Ji5k8JRjFVyZYwGdlPRHTGbJNQI9n/rd/bqZn8697wQtl49M8WStVuLYlYoqMvjRpYaAmL7XQlNXRb/1Y8AkRQ==

"@bugsnag/plugin-react-native-event-sync@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-event-sync/-/plugin-react-native-event-sync-7.22.3.tgz#faedd1896ed5d46bdd49eb65206935946e90d774"
integrity sha512-xqvVcRjpAtOcS9e3jdW8h+SiZQwjd2yVmbKVLo2NESAbjeMVQcdTLogdUrdG92JnI5UnVWFW1bqoQqtug6shxA==

"@bugsnag/plugin-react-native-global-error-handler@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-global-error-handler/-/plugin-react-native-global-error-handler-7.22.3.tgz#316298b4993edcd4e6a35b721a69fd58348d1cde"
integrity sha512-nJwwpg3EPbTbCoi+FuxFwU4svJnqbIyHqBw1IddXiGUmI6irYnI700HYDmeFIEZXEmaX19lrOPhdhecGLhOolg==

"@bugsnag/plugin-react-native-hermes@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-hermes/-/plugin-react-native-hermes-7.19.0.tgz#d7a5d7918cc679b5ba591fda9dcf40acc18f4de4"
integrity sha512-6SGTSR6NMS2t8j02ZQ6FlA+K/nKkZqvGA+8A7WS/0M8HAShzyoMpZH10kGrU2dcCaiEtmD2T6OGBSbpF+385Dg==

"@bugsnag/plugin-react-native-session@^7.19.0":
version "7.19.0"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-session/-/plugin-react-native-session-7.19.0.tgz#52e472fdebfed06e3e6d2bcb6f3d80a07da2e2e2"
integrity sha512-PVwsUstedp9wTqJU/IKdCaMFKP2YrqHXoeBtqRTQ7FFyr0K8wsiW7nZP2jM31VS388hZWSWBlHQPA/3LZ49tNQ==
"@bugsnag/plugin-react-native-session@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-session/-/plugin-react-native-session-7.22.3.tgz#1a60fcc70660243a88b79c7ee8314b9d79548ca1"
integrity sha512-lreErWPZgjnoiGHD282+a9tCsFN4D34XEjbYLRnLRLjlugJeuTnkvDAYTFtmYpMDyEg/WBhWMaNqAdpJPj/nkQ==

"@bugsnag/plugin-react-native-unhandled-rejection@^7.19.0":
version "7.19.0"
Expand All @@ -1318,21 +1318,21 @@
resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react/-/plugin-react-7.19.0.tgz#3f86c6ed2745cd60a4099d0e14ca46f2b9cf501f"
integrity sha512-owC4QXYJWGllMoOPcH5P7sbDIDuFLMCbjGAU6FwH5mBMObSQo+1ViSKImlTJQUFXATM8ySISTBVt7w3C6FFHng==

"@bugsnag/react-native@^7.20.2":
version "7.20.2"
resolved "https://registry.yarnpkg.com/@bugsnag/react-native/-/react-native-7.20.2.tgz#f2df1cf98bb0605ba011a21960a687f378247526"
integrity sha512-pvzFZA/7PzChLgrSsynZFl/lBOcY+X76sLbniJz7S3Lcrdc5+NY5fP+AVoZH9mqNaob6OSiALubUVLpPeirivg==
"@bugsnag/react-native@^7.22.3":
version "7.22.3"
resolved "https://registry.yarnpkg.com/@bugsnag/react-native/-/react-native-7.22.3.tgz#d37cb17a23cb2adad61fe2d40f8accded3cb2b96"
integrity sha512-a6bo3Lny3RzunyUmQvhVScQjyDsaxr0DiDQQx10osu/+ysUF+Z9eMOYkUJIHq2r5ZQ2IGuG91Nql51zjjlmWlw==
dependencies:
"@bugsnag/core" "^7.19.0"
"@bugsnag/delivery-react-native" "^7.19.0"
"@bugsnag/plugin-console-breadcrumbs" "^7.19.0"
"@bugsnag/plugin-network-breadcrumbs" "^7.19.0"
"@bugsnag/delivery-react-native" "^7.22.3"
"@bugsnag/plugin-console-breadcrumbs" "^7.22.3"
"@bugsnag/plugin-network-breadcrumbs" "^7.22.3"
"@bugsnag/plugin-react" "^7.19.0"
"@bugsnag/plugin-react-native-client-sync" "^7.19.0"
"@bugsnag/plugin-react-native-event-sync" "^7.19.0"
"@bugsnag/plugin-react-native-global-error-handler" "^7.19.0"
"@bugsnag/plugin-react-native-client-sync" "^7.22.3"
"@bugsnag/plugin-react-native-event-sync" "^7.22.3"
"@bugsnag/plugin-react-native-global-error-handler" "^7.22.3"
"@bugsnag/plugin-react-native-hermes" "^7.19.0"
"@bugsnag/plugin-react-native-session" "^7.19.0"
"@bugsnag/plugin-react-native-session" "^7.22.3"
"@bugsnag/plugin-react-native-unhandled-rejection" "^7.19.0"
iserror "^0.0.2"

Expand Down

0 comments on commit a41a919

Please sign in to comment.