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.
Related
We store our configurations on the vault and during the Github action workflow we pull this and intend to use this for the app during build time.
This is our workflow
- name: Get app configs from vault
env:
ENVIRONMENT: development
run: |
chmod +x scripts/ci/get-app-configs.sh
scripts/ci/get-app-configs.sh
echo "action_state=yellow" >> $GITHUB_ENV
- name: Set .env to process.env of github actions
uses: cardinalby/export-env-action#v1
with:
envFile: '.env'
expand: 'true'
- name: Generate APK
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
run: |
echo "${{ env.action_state }}"
echo ${{ env.FIREBASE }}
eas build --platform android --local --profile development --non-interactive
The Get app configs from vault step creates an .env file with the following contents
FIREBASE={firebase_config_string}
And then inside firebase.ts we do this.
const firebaseConfig = JSON.parse(process.env.FIREBASE as string) as FirebaseOptions;
The app works fine when testing on an emulator but when testing the actual APK on a physical device, it always crashes. And in the logcat I keep seeing this error E AndroidRuntime: com.facebook.react.common.JavascriptException: SyntaxError: JSON Parse error: Unexpected identifier "undefined", stack:.
I've already narrowed it down to the firebase.ts process.env since the app doesn't crash when the config is hard coded.
I can see the env.FIREBASE as an env variable inside the Generate APK step so it's being passed to other steps fine. And the echo also prints out the value fine.
Is it not possible to access the env variables of Github action within the code during build time? Or are there other ways to achieve this?
Kept the github workflow as it is.
Fixed by using expo-constants.
Renaming the app.json to app.config.js to be able to add the following lines:
import 'dotenv/config';
export default {
expo: {
extra: {
ENV_VAR: process.env.ENV_VAR,
},
},
};
And access the said variable from the app by
import Constants from 'expo-constants';
const ENV_VAR = Constants.manifest?.extra?.ENV_VAR
Currently I'm trying to build container serving VueJS application via Cloud Native Buildpacks.
I already have working Docker file that builds VueJS in production mode and then copy results to nginx image, but I would like to try to use CNB.
So I just have created empty VueJS project for test via vue create vue-tutorial and trying to do with CNB somehting like described there https://cli.vuejs.org/guide/deployment.html#heroku but using CNB.
Does anyone know working recipe how to do that with CNB?
P.S. Currently I'm trying to build that with
pack build spa --path . \ SIGINT(2) ↵ 17:22:41
--buildpack gcr.io/paketo-buildpacks/nodejs \
--buildpack gcr.io/paketo-buildpacks/nginx
but getting next error (and I'm not sure that I'm on right way):
===> DETECTING
ERROR: No buildpack groups passed detection.
ERROR: Please check that you are running against the correct path.
ERROR: failed to detect: no buildpacks participating
ERROR: failed to build: executing lifecycle: failed with status code: 100
UPD
My current dockerfile
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:1.19-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
We chatted about this in Slack, but I wanted to capture it here too:
pack build --buildpack heroku/nodejs --buildpack https://cnb-shim.herokuapp.com/v1/heroku-community/static yourimage
This command may do what you want. The static buildpack used in that example is not yet converted to a cloud native buildpack, but the shim may allow you to build a workable artifact. Then run your image with something like docker run -it -e PORT=5000 -p 5000:5000 yourimagename
I'm trying to achieve building an APK for each time there's a push to master.
But I'm using an 'env' file and Expo needs it to build the APK (importing it in some places in the code).
I don't wish to commit the 'env' file, and trying to avoid it.
Is there any workaround or do I have to commit the 'env' file?
Thanks!
SOLVED:
I found a solution. I kept the entire file as a Github Secret and then added a script to create the env file from the secret.
- name: Create env.js file
uses: actions/github-script#0.9.0
with:
script: |
const fs = require('fs');
if (!fs.existsSync('env.js')) {
fs.writeFileSync('env.js', process.env.ENV_FILE);
}
env:
ENV_FILE: ${{ secrets.ENV_FILE }}
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'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!