Skip to content

Commit 018081b

Browse files
authored
🔨 Fixes various bugs and improvements in automatic sourcemap upload scripts (#375)
1 parent c3732e6 commit 018081b

File tree

7 files changed

+38
-63
lines changed

7 files changed

+38
-63
lines changed

‎CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## master
2+
3+
* Fixes various bugs and improvements in automatic sourcemap upload scripts.
4+
15
## v8.6.1 (2019-08-26)
26

37
* Introducing our new logo and branding. Meet the new Instabug: the platform for Real-Time Contextual Insights.

‎README.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,25 +185,9 @@ If your app doesn’t already access the microphone or photo library, we recomme
185185
186186
## Uploading Source Map Files for Crash Reports
187187
188-
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.
188+
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.start('YOUR_APP_TOKEN')` in JavaScript.
189189
190-
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.
191-
192-
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.
193-
194-
```java
195-
task upload_sourcemap(type: Exec) {
196-
environment "INSTABUG_APP_TOKEN", "YOUR_APP_TOKEN"
197-
commandLine 'sh', './upload_sourcemap.sh'
198-
}
199-
```
200-
201-
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.
202-
203-
```bash
204-
export INSTABUG_APP_TOKEN="YOUR_APP_TOKEN"
205-
bash "../node_modules/instabug-reactnative/ios/upload_sourcemap.sh"
206-
```
190+
If your app token is defined as a constant, you can set an environment variable `INSTABUG_APP_TOKEN` to be used instead.
207191
208192
## Network Logging
209193

‎android/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ task upload_sourcemap(type: Exec) {
4545
commandLine 'cmd', '/c', 'echo Automatic Upload of sourcemap files is currently not available on windows, please generate the sourcemapfiles and upload them to the dashboard'
4646
project.logger.lifecycle('Automatic Upload of sourcemap files is currently not available on windows, please generate the sourcemapfiles and upload them to the dashboard')
4747
} else {
48-
environment "INSTABUG_APP_TOKEN", "YOUR_APP_TOKEN"
4948
commandLine 'sh', './upload_sourcemap.sh'
5049
}
5150
}

‎android/upload_sourcemap.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,27 @@ elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
88
. "$(brew --prefix nvm)/nvm.sh"
99
fi
1010
export NODE_BINARY=node
11-
#Generate android sourcemap
12-
react-native bundle --platform android \
13-
--entry-file index.js \
14-
--dev false \
15-
--bundle-output ./android/main.jsbundle \
16-
--sourcemap-output ./android-sourcemap.json &&
17-
zip ./android-sourcemap.zip ./android-sourcemap.json
1811

19-
if [ ${INSTABUG_APP_TOKEN} == "YOUR_APP_TOKEN" ]; then
12+
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
2013
echo "Instabug: Looking for Token..."
21-
INSTABUG_APP_TOKEN='';
22-
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
23-
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)
24-
fi
25-
26-
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
27-
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)
28-
fi
14+
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} "Instabug.start[WithToken]*([\"\'][0-9a-zA-Z]*[\"\']" ./ -m 1 | grep -o "[\"\'][0-9a-zA-Z]*[\"\']" | cut -d "\"" -f 2)
2915
fi
3016

31-
32-
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ] || [ "${INSTABUG_APP_TOKEN}" == "YOUR_APP_TOKEN" ];then
33-
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"
17+
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
18+
echo "Instabug: err: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.start Or added the environment variable INSTABUG_APP_TOKEN"
3419
exit 0
3520
else
21+
echo "Instabug: Token found" "\""${INSTABUG_APP_TOKEN}"\""
22+
echo "Instabug: Generating sourcemap files..."
23+
#Generate android sourcemap
24+
react-native bundle --platform android \
25+
--entry-file index.js \
26+
--dev false \
27+
--bundle-output ./android/main.jsbundle \
28+
--sourcemap-output ./android-sourcemap.json
3629
echo "Instabug: Uploading files..."
3730
#Upload android sourcemap
38-
curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F "symbols_file=@./android-sourcemap.json" -F "application_token=${INSTABUG_APP_TOKEN}" -F "platform=react_native" -F "os=android"
31+
curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F "symbols_file=@./android-sourcemap.json" -F "application_token=${INSTABUG_APP_TOKEN}" -F "platform=react_native" -F "os=android"
32+
rm -rf android-sourcemap.json
3933
echo
40-
fi
34+
fi

‎autolink.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
INSTABUG_UPLOAD_NAME = "Upload Sourcemap"
2929

3030
INSTABUG_UPLOAD_SCRIPT = <<-SCRIPTEND
31-
export INSTABUG_APP_TOKEN="YOUR_APP_TOKEN"
3231
bash "../node_modules/instabug-reactnative/ios/upload_sourcemap.sh"
3332
SCRIPTEND
3433

‎ios/upload_sourcemap.sh

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
1-
#!/bin/bash
2-
cd "${SRCROOT}"
1+
#!/bin/sh
2+
cd ..
3+
cd ..
34
cd ..
45
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
56
. "$HOME/.nvm/nvm.sh"
67
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
78
. "$(brew --prefix nvm)/nvm.sh"
89
fi
910
export NODE_BINARY=node
10-
#Generate ios sourcemap
11-
react-native bundle --platform ios \
12-
--entry-file index.js \
13-
--dev false \
14-
--bundle-output ./ios/main.jsbundle \
15-
--sourcemap-output ./ios-sourcemap.json &&
16-
zip ./ios-sourcemap.zip ./ios-sourcemap.json
1711

18-
if [ ${INSTABUG_APP_TOKEN} == "YOUR_APP_TOKEN" ]; then
12+
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
1913
echo "Instabug: Looking for Token..."
20-
INSTABUG_APP_TOKEN='';
21-
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
22-
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)
23-
fi
24-
25-
if [ ! "${INSTABUG_APP_TOKEN}" ]; then
26-
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)
27-
fi
14+
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} "Instabug.start[WithToken]*([\"\'][0-9a-zA-Z]*[\"\']" ./ -m 1 | grep -o "[\"\'][0-9a-zA-Z]*[\"\']" | cut -d "\"" -f 2)
2815
fi
2916

30-
31-
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ] || [ "${INSTABUG_APP_TOKEN}" == "YOUR_APP_TOKEN" ];then
32-
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"
17+
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
18+
echo "Instabug: err: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.start Or added the environment variable INSTABUG_APP_TOKEN"
3319
exit 0
3420
else
21+
echo "Instabug: Token found" "\""${INSTABUG_APP_TOKEN}"\""
22+
echo "Instabug: Generating sourcemap files..."
23+
#Generate ios sourcemap
24+
react-native bundle --platform ios \
25+
--entry-file index.js \
26+
--dev false \
27+
--bundle-output ./ios/main.jsbundle \
28+
--sourcemap-output ./ios-sourcemap.json
3529
echo "Instabug: Uploading files..."
3630
#Upload ios sourcemap
3731
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"
32+
rm -rf ios-sourcemap.json
3833
echo
3934
fi
35+

‎link.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
INSTABUG_UPLOAD_NAME = "Upload Sourcemap"
2525

2626
INSTABUG_UPLOAD_SCRIPT = <<-SCRIPTEND
27-
export INSTABUG_APP_TOKEN="YOUR_APP_TOKEN"
2827
bash "../node_modules/instabug-reactnative/ios/upload_sourcemap.sh"
2928
SCRIPTEND
3029

0 commit comments

Comments
 (0)