Skip to content

Commit

Permalink
💎Bump version to 8.2.4
Browse files Browse the repository at this point in the history
Exposes environment variable to be set in android and ios for the APP TOKEN
Renames the token inside the script to INSTABUG_APP_TOKEN
  • Loading branch information
salmamali authored Apr 17, 2019
1 parent 231dcdd commit 48f00cd
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 28 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,29 @@ If your app doesn’t already access the microphone or photo library, we recomme
**The permission alert for accessing the microphone/photo library will NOT appear unless users attempt to attach a voice note/photo while using Instabug.**
## Auto Uploading Source Map Files
For your app crashes to show up with a fully symbolicated stack trace, we will automatically generate the source map files and upload them to your dashboard on release build. To do so, we rely on your app token being explicitly added to `Instabug.startWithToken('YOUR_APP_TOKEN')` in JavaScript.
If your app token is defined as a constant or you have different tokens for both iOS and Android apps, set the token as shown below.
1. In Android, go to the `build.gradle` file of the library and you will find below code, replace `YOUR_APP_TOKEN` with your app token from the dashboard.
```java
task upload_sourcemap(type: Exec) {
environment "INSTABUG_APP_TOKEN", "YOUR_APP_TOKEN"
commandLine 'sh', './upload_sourcemap.sh'
}
```
2. In iOS, go to the build phases of the project, you will find a build phase called `Upload Sourcemap`. Expand it you will find below lines of code, replace `YOUR_APP_TOKEN` with your token from the dashboard.
```bash
export INSTABUG_APP_TOKEN="YOUR_APP_TOKEN"
bash "../node_modules/instabug-reactnative/ios/upload_sourcemap.sh"
```
## Documentation
For more details about the supported APIs and how to use them, check our [**Documentation**](https://docs.instabug.com/docs/react-native-overview).
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
}

task upload_sourcemap(type: Exec) {
environment "INSTABUG_APP_TOKEN", "YOUR_APP_TOKEN"
commandLine 'sh', './upload_sourcemap.sh'
}

Expand Down
36 changes: 22 additions & 14 deletions android/upload_sourcemap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
cd ..
cd ..
cd ..
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi
export NODE_BINARY=node
#Generate android sourcemap
react-native bundle --platform android \
--entry-file index.js \
Expand All @@ -10,22 +16,24 @@ react-native bundle --platform android \
--sourcemap-output ./android-sourcemap.json &&
zip ./android-sourcemap.zip ./android-sourcemap.json

echo "Instabug: Looking for Token..."
if [ ! "${APP_TOKEN}" ]; then
APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} 'Instabug.startWithToken(\"[0-9a-zA-Z]*\"' ./ -m 1 | grep -o '\"[0-9a-zA-Z]*\"' | cut -d "\"" -f 2)
fi
if [ ${INSTABUG_APP_TOKEN} == "YOUR_APP_TOKEN" ]; then
echo "Instabug: Looking for Token..."
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} 'Instabug.startWithToken(\"[0-9a-zA-Z]*\"' ./ -m 1 | grep -o '\"[0-9a-zA-Z]*\"' | cut -d "\"" -f 2)
fi

if [ ! "${APP_TOKEN}" ]; then
APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} "Instabug.startWithToken(\'[0-9a-zA-Z]*\'" ./ -m 1 | grep -o "\'[0-9a-zA-Z]*\'" | cut -d "\"" -f 2)
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} "Instabug.startWithToken(\'[0-9a-zA-Z]*\'" ./ -m 1 | grep -o "\'[0-9a-zA-Z]*\'" | cut -d "\"" -f 2)
fi
fi

if [ ! "${APP_TOKEN}" ] || [ -z "${APP_TOKEN}" ];then
echo "Instabug: err: APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.startWithToken"
exit 0
else
echo "Instabug: Uploading files..."
#Upload android sourcemap
curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F "symbols_file=@./android-sourcemap.json" -F "application_token=${APP_TOKEN}" -F "platform=react_native" -F "os=android"

echo
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ] || [ "${INSTABUG_APP_TOKEN}" == "YOUR_APP_TOKEN" ];then
echo "Instabug: err: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.startWithToken Or added it to the environment variable in the gradle"
exit 0
else
echo "Instabug: Uploading files..."
#Upload ios sourcemap
curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F "symbols_file=@./ios-sourcemap.json" -F "application_token=${INSTABUG_APP_TOKEN}" -F "platform=react_native" -F "os=ios"
echo
fi
29 changes: 16 additions & 13 deletions ios/upload_sourcemap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@ react-native bundle --platform ios \
--sourcemap-output ./ios-sourcemap.json &&
zip ./ios-sourcemap.zip ./ios-sourcemap.json

echo "Instabug: Looking for Token..."
if [ ! "${APP_TOKEN}" ]; then
APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} 'Instabug.startWithToken(\"[0-9a-zA-Z]*\"' ./ -m 1 | grep -o '\"[0-9a-zA-Z]*\"' | cut -d "\"" -f 2)
fi
if [ ${INSTABUG_APP_TOKEN} == "YOUR_APP_TOKEN" ]; then
echo "Instabug: Looking for Token..."
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} 'Instabug.startWithToken(\"[0-9a-zA-Z]*\"' ./ -m 1 | grep -o '\"[0-9a-zA-Z]*\"' | cut -d "\"" -f 2)
fi

if [ ! "${APP_TOKEN}" ]; then
APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} "Instabug.startWithToken(\'[0-9a-zA-Z]*\'" ./ -m 1 | grep -o "\'[0-9a-zA-Z]*\'" | cut -d "\"" -f 2)
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} "Instabug.startWithToken(\'[0-9a-zA-Z]*\'" ./ -m 1 | grep -o "\'[0-9a-zA-Z]*\'" | cut -d "\"" -f 2)
fi
fi

if [ ! "${APP_TOKEN}" ] || [ -z "${APP_TOKEN}" ];then
echo "Instabug: err: APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.startWithToken"
exit 0

if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ] || [ "${INSTABUG_APP_TOKEN}" == "YOUR_APP_TOKEN" ];then
echo "Instabug: err: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.startWithToken Or added it to the environment variable in the gradle"
exit 0
else
echo "Instabug: Uploading files..."
#Upload ios sourcemap
curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F "symbols_file=@./ios-sourcemap.json" -F "application_token=${APP_TOKEN}" -F "platform=react_native" -F "os=ios"
echo
echo "Instabug: Uploading files..."
#Upload ios sourcemap
curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F "symbols_file=@./ios-sourcemap.json" -F "application_token=${INSTABUG_APP_TOKEN}" -F "platform=react_native" -F "os=ios"
echo
fi
1 change: 1 addition & 0 deletions link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
INSTABUG_UPLOAD_NAME = "Upload Sourcemap"

INSTABUG_UPLOAD_SCRIPT = <<-SCRIPTEND
export INSTABUG_APP_TOKEN="YOUR_APP_TOKEN"
bash "../node_modules/instabug-reactnative/ios/upload_sourcemap.sh"
SCRIPTEND

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instabug-reactnative",
"version": "8.2.3",
"version": "8.2.4",
"description": "React Native plugin for integrating the Instabug SDK",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 48f00cd

Please sign in to comment.