I'm trying to setup Bugsnag on my react native 0.59.1, but I am not able to properly upload source maps.
The bugsnag-react-native plugin is properly installed and linked and I see errors in my bugsnag dashboard, the only problem is to properly use the source maps.
What I tried
In one of my javascript files, I added a simple fake error:
Bugsnag.notify(new Error('Error'))
The, following the official documentation I generated the bundle file and the source maps:
react-native bundle \
--dev false \
--platform android \
--entry-file index.js \
--bundle-output android-release.bundle \
--sourcemap-output android-sourcemaps.map
I uploaded them to bugsnag:
curl https://upload.bugsnag.com/react-native-source-map \
-F apiKey="XXXXX" \
-F appVersion="10.0.2" \
-F appVersionCode="100004" \
-F dev=false \
-F platform=android \
-F sourceMap=#android-sourcemaps.map \
-F bundle=#android-release.bundle \
-F projectRoot=`pwd`
In my bugsnag settings I can see the source maps with the proper versions:
But in the error report I get:
Note: I checked and the versions of the source maps are the same of the version in the event App tab.
I honestly don't know what to try anymore, do you have some ideas?
I'd advise you raise this directly with us at Bugsnag via the Support link on the dashboard so we can look at the details of the errors on your account and advise on why the source maps aren't being applied.
Looking at that screenshot though I suspect the issue may be that you're using RAM bundles in which case you'd need to use the react-native ram-bundle command in place of react-native bundle:
https://docs.bugsnag.com/platforms/react-native/react-native/showing-full-stacktraces/#generating-source-maps
Thanks!
Related
What I want to do is automating build number & app version of ios app based on git-tag. Previous native ios project, I automate build number of app using this script :
## Refer to https://www.mokacoding.com/blog/automatic-xcode-versioning-with-git/
git=$(sh /etc/profile; which git)
number_of_commits=$("$git" rev-list HEAD --count)
git_release_version=$("$git" describe --tags --always --abbrev=0)
target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH"
dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist"
for plist in "$target_plist" "$dsym_plist"; do
echo "plist :: $plist"
if [ -f "$plist" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $number_of_commits" "$plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${git_release_version#*v}" "$plist"
fi
done
but, in react native app, not working!
While debuging, I found that target_plist & dsym_plist is not exist.
How do I make it work on React Native App?
I've asked this question in the swagger github repository but the community doesn't look very responsive, so I'm going to try here.
Following the README I'm running this commands to generate a PHP client (but it could be any other language):
git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate
\
-i http://petstore.swagger.io/v2/swagger.json \
-l php \
-o /var/tmp/php_api_client
and I get the following error:
Error: Unable to access jarfile modules/swagger-codegen-cli/target/swagger-codegen-cli.jar
Does anybody have the same error? I'm trying to figure out if it's just me. Maybe I'm missing something.
As of today (1/10/19) it only works with Java version 7 or 8. I had to downgrade from version 10 to make it work.
I can't seem to figure this out. Can someone please help me troubleshoot this? I'm using CodePush to upload my app and I want Sentry to handle my errors since the appcenter diagnostics are not very good.
I have this in a root component of my app...
if (process.env.NODE_ENV === 'production') {
Sentry.config('****',{
deactivateStacktraceMerging: false
}).install();
codePush.getUpdateMetadata().then((update) => {
if (update) {
Sentry.setVersion(update.appVersion + '-codepush:' + update.label);
}
});
}
And I have a deploy package script that will deploy to codepush and also run the sentry commands found in their docs
appcenter codepush release-react -a account/project --output-dir ./build && export SENTRY_PROPERTIES=./ios/sentry.properties && sentry-cli react-native appcenter account/project ios ./build/codePush
Everytime I get an error caught or one that I've captured I lack actual information on what file threw the error and I see the There was 1 error encountered while processing this event at the top which says Source code was not found for app:///main.jsbundle when I expand it.
I feel that this has to be something with sentry not properly connecting to codepush to get my source maps?
Finally got the sourcemap to work for both iOS and Android with AppCenter codepush after some trial and failure (since the Sentry doc is misleading), following these steps in bash script:
MY_APP_NAME="e.g. Sentry account/project"
MY_BUNDLE_ID="e.g. com.company.superapp"
MY_APP_ENV="e.g. development, staging or production"
NATIVE_VERSION="e.g. 1.2.3"
PLATFORM="e.g. ios or android"
# Build and release to appcenter
appcenter codepush release-react \
-a "$MY_APP_NAME" \
-d "$MY_APP_ENV" \
-m -t "$NATIVE_VERSION" \
--sourcemap-output \
--output-dir "./build/$PLATFORM"
export SENTRY_PROPERTIES="./$PLATFORM/sentry.properties"
# Get label and name of latest release
LABEL=$(appcenter codepush deployment history $MY_APP_ENV -a $MY_APP_NAME --output json | jq '.[-1][0]' -r)
RELEASE_NAME="$MY_BUNDLE_ID#$NATIVE_VERSION+codepush:$LABEL"
# Upload sourcemap
sentry-cli react-native appcenter \
"$MY_APP_NAME" "$PLATFORM" "./build/$PLATFORM/CodePush" \
--deployment "$MY_APP_ENV" \
--release-name "$RELEASE_NAME" \
--dist "$LABEL"
And doing this initialization in app.ts (or similar):
Sentry.init({...});
codePush.getUpdateMetadata().then(update => {
if (update) {
if (MY_APP_ENV === 'production')) {
Sentry.setRelease(
`${MY_BUNDLE_ID}#${update.appVersion}+codepush:${update.label}`,
);
} else {
Sentry.setRelease(
`${MY_BUNDLE_ID}.${MY_APP_ENV}#${update.appVersion}+codepush:${update.label}`,
);
}
Sentry.setDist(update.label);
}
});
Environment:
appcenter version: 2.7.3
#sentry/react-native: 2.5.1
You need to call Sentry.init with release and dist options and pass the same values as flags when you upload your sourcemaps via the CLI.
As per the Sentry Docs
If you want to use Sentry together with CodePush you will have to pass release and dist to Sentry.init. Our suggestion is to store them in an app.json, or you can just use the package.json. These values need to be unique to each version of your codebase and match the version on the source maps exactly, or they might not be symbolicated.
For example:
Sentry.init({
dsn: YOUR_DSN,
release: '1.0',
dist: 'v1',
});
And then when you want to upload your source maps:
export SENTRY_PROPERTIES=./ios/sentry.properties
sentry-cli react-native appcenter \
account/project \
ios ./build/codePush \
--release-name "1.0" \
--dist "v1"
Your release and dist can be arbitrary strings, but Sentry recommends the following format:
${BUNDLE_ID}#${APP_VERSION}+codepush:${DIST}
I've had the same issue - everything gets uploaded to Sentry and attached into a Release, but Issues show this warning.
Issue for me was that bundle ID was different in the app and in Sentry Release, syncing this solved the issue.
When creating a react-native app with react-native init MyApp the Android and iOS package names are automatically set to com.myapp.
Changing the Android package name (especially if you need something longer like com.organisation.propject.app) later in the development is pretty fiddly and I was wondering if there was a way to set the package name when setting up a project with react-native init?
Note: it's working only in RN 0.37 and maybe one or two versions up, in 0.40+ this feature was removed.
You need to specify a --package option:
$ react-native init MyApp --package=com.organization.project.app
The below worked for me. Substitute your own app name for "Foo App" and your own package name for org.newpackage.app.
NEW_APP_NAME="Foo App"
NEW_PACKAGE_NAME=org.newpackage.app
OLD_PACKAGE_NAME=org.reactjs.native.example
npx react-native init rndemo && \
cd rndemo && \
npx react-native-rename "${NEW_APP_NAME}" -b ${NEW_PACKAGE_NAME} && \
rm -rf ios/Pods && \
pod install --project-directory=./iOS && \
grep -rl ${OLD_PACKAGE_NAME} * | \
xargs sed -i '.bak' "s/${OLD_PACKAGE_NAME}/${NEW_PACKAGE_NAME}/g"
I've created a gist that does this, prompting interactively for the app name and package name. The gist is a tiny bit more sophisticated, in that (in the above example) it would initially create the app fooapp instead of rndemo.
Explanation:
Create a react-native app. It's called rndemo temporarily; we need to know what it's going to be called so we can change to it.
Run react-native-rename to rename the new project to whatever you specified; this lets us replace the package name too.
Remove the installed cocoa pods and reinstall them (so they'll pick up the new folder locations etc).
Search for the default package name org.reactjs.native.example and replace it with your new package name. Currently this will only find ios/FooApp.xcodeproj/project.pbxproj. The old project.pbxproj file will be saved with a '.bak' extension. This step would probably be better done with find . -name project.pbxproj -exec ..... but this was good enough for my needs.
I have tried to get source maps working with react native and sentry but I keep getting this type of output with no meaningful line numbers:
i#file:///var/containers/Bundle/Application/G4535-H056800I/AppName.app/main.jsbundle:
[Filtered]#file:///var/containers/Bundle/Application/G4535-H056800I/AppName.app/main.jsbundle:
[Filtered]#file:///var/containers/Bundle/Application/G4535-H056800I/AppName.app/main.jsbundle:59:1255
[native code]
I did the following to create and upload the source maps for my release:
1. Create map/bundle artifacts
curl http://127.0.0.1:8081/index.ios.map -o index.ios.map
curl http://127.0.0.1:8081/index.ios.bundle -o index.ios.bundle
2. Edit last link in index.ios.bundle to point to map
WAS: `//# sourceMappingURL=/index.ios.map`
NOW: `//# sourceMappingURL=index.ios.map`
3. Create Release on Sentry
curl https://app.getsentry.com/api/0/projects/appname/releases/ -u "username": -X POST -d '{"version": "version_num"}' -H 'Content-Type: application/json'
4. POST artifacts to Sentry release
curl https://app.getsentry.com/api/0/projects/appname/releases/version_num/files/ -u "username": -X POST -F file=#index.ios.bundle
curl https://app.getsentry.com/api/0/projects/appname/releases/version_num/files/ -u "username": -X POST -F file=#index.ios.map
Have I missed something? Been playing around with this for some time and can't get it to work. Any help would be much appreciated! Thanks