@honeybadger-io/react-native 6.1.1 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.2.0](https://github.com/honeybadger-io/honeybadger-js/compare/@honeybadger-io/react-native@6.1.1...@honeybadger-io/react-native@6.2.0) (2023-09-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * **react-native:** new source maps generation script with support for hermes ([#1169](https://github.com/honeybadger-io/honeybadger-js/issues/1169)) ([ed10921](https://github.com/honeybadger-io/honeybadger-js/commit/ed10921806d7552f1342bda9e8691a27c0773613))
12
+
13
+
14
+
6
15
  ## [6.1.1](https://github.com/honeybadger-io/honeybadger-js/compare/@honeybadger-io/react-native@6.1.0...@honeybadger-io/react-native@6.1.1) (2023-08-07)
7
16
 
8
17
  **Note:** Version bump only for package @honeybadger-io/react-native
package/README.md CHANGED
@@ -50,7 +50,25 @@ Error reports can be [customized](https://docs.honeybadger.io/lib/javascript/gui
50
50
  Some native errors on Android may not be recorded if they cause an immediate crash of the app before the notice makes it to Honeybadger.
51
51
 
52
52
  ### Source Maps
53
- The procedure to generate and upload sourcemaps for react-native is currently [under development](https://github.com/honeybadger-io/honeybadger-js/issues/1029).
53
+ To generate and upload source maps to Honeybadger, use the following command:
54
+ ```shell
55
+ npx honeybadger-upload-sourcemaps --apiKey <your project API key> --revision <build revision>
56
+ ```
57
+
58
+ The `--apiKey` param is your Honeybadger API key for the project. The `--revision` param should match the revision param of the `Honeybadger.init` call inside your application. This is done so that reported errors are correctly matched up against the generated source maps.
59
+
60
+ As of version 0.70, React Native uses Hermes as the default JavaScript engine. The source maps tool assumes that your project uses Hermes. If you are building against an earlier version of React Native, or are explicitly not using Hermes, add the `--no-hermes` flag to the sourcemaps tool, like so:
61
+
62
+ ```shell
63
+ npx honeybadger-upload-sourcemaps --no-hermes --apiKey <your project API key> --revision <build revision>
64
+ ```
65
+
66
+ If you just want to generate the sourcemaps without uploading them to Honeybadger, you can use the `--skip-upload` flag.
67
+
68
+ ```shell
69
+ npx honeybadger-upload-sourcemaps --skip-upload --apiKey <your project API key> --revision <build revision>
70
+ ```
71
+
54
72
 
55
73
  ## Example Projects
56
74
 
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ function __generator(thisArg, body) {
84
84
  }
85
85
 
86
86
  var name = "@honeybadger-io/react-native";
87
- var version = "6.1.1";
87
+ var version = "6.2.0";
88
88
 
89
89
  var Transport = /** @class */ (function () {
90
90
  function Transport() {
@@ -283,7 +283,7 @@ var Honeybadger = /** @class */ (function (_super) {
283
283
  _this.__notifier = {
284
284
  name: '@honeybadger-io/react-native',
285
285
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/react-native',
286
- version: '6.1.1'
286
+ version: '6.2.0'
287
287
  };
288
288
  _this.__jsHandlerInitialized = false;
289
289
  _this.__nativeHandlerInitialized = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honeybadger-io/react-native",
3
- "version": "6.1.1",
3
+ "version": "6.2.0",
4
4
  "description": "Honeybadger.io for React Native.",
5
5
  "author": "Andrey Butov <andreybutov@antair.com> (https://andreybutov.com)",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "test": "jest"
13
13
  },
14
14
  "bin": {
15
- "honeybadger-generate-sourcemaps": "./honeybadger-generate-sourcemaps.sh"
15
+ "honeybadger-upload-sourcemaps": "./scripts/honeybadger-upload-sourcemaps.sh"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
@@ -48,7 +48,7 @@
48
48
  "node": ">=14"
49
49
  },
50
50
  "dependencies": {
51
- "@honeybadger-io/core": "^6.2.0"
51
+ "@honeybadger-io/core": "^6.3.0"
52
52
  },
53
- "gitHead": "9899f6ed8e9b4f4d06adb984670b657548cef306"
53
+ "gitHead": "94e663836936974474628967f5c440ffa668bc9b"
54
54
  }
@@ -0,0 +1,317 @@
1
+ #!/bin/bash
2
+
3
+ # ----------------------------------------------------------------------------
4
+ #
5
+ # Generate and upload sourcemaps to Honeybadger
6
+ #
7
+ # USAGE:
8
+ # npx honeybadger-upload-sourcemaps [--no-hermes] [--skip-upload] --apiKey <project-api-key> --revision <build-revision>
9
+ #
10
+ # Hermes is enabled by default in React Native projects as of React Native 0.70.
11
+ # This script assumes that Hermes is being used. If you are not using Hermes in
12
+ # your React Native project, use the "--no-hermes" flag.
13
+ #
14
+ # If you just need to generate the sourcemaps without uploading them to
15
+ # Honeybadger, use the --skip-upload flag.
16
+ #
17
+ # ----------------------------------------------------------------------------
18
+
19
+ USAGE="npx honeybadger-upload-sourcemaps [--no-hermes] [--skip-upload] --apiKey <project-api-key> --revision <build-revision>"
20
+
21
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
22
+ PROJECT_ROOT_DIR="$SCRIPT_DIR/../.."
23
+ NODE_MODULES="$PROJECT_ROOT_DIR/node_modules"
24
+
25
+ ANDROID_PACKAGER_BUNDLE="$PROJECT_ROOT_DIR/index.android.bundle"
26
+ ANDROID_PACKAGER_SOURCE_MAP="$PROJECT_ROOT_DIR/index.android.bundle.packager.map"
27
+ ANDROID_COMPILER_BUNDLE="$PROJECT_ROOT_DIR/index.android.bundle.hbc"
28
+ ANDROID_COMPILER_SOURCE_MAP="$PROJECT_ROOT_DIR/index.android.bundle.hbc.map"
29
+ ANDROID_FINAL_SOURCE_MAP="$PROJECT_ROOT_DIR/index.android.bundle.map"
30
+
31
+ IOS_PACKAGER_BUNDLE="$PROJECT_ROOT_DIR/main.jsbundle"
32
+ IOS_PACKAGER_SOURCE_MAP="$PROJECT_ROOT_DIR/main.jsbundle.packager.map"
33
+ IOS_COMPILER_BUNDLE="$PROJECT_ROOT_DIR/main.jsbundle.hbc"
34
+ IOS_COMPILER_SOURCE_MAP="$PROJECT_ROOT_DIR/main.jsbundle.hbc.map"
35
+ IOS_FINAL_SOURCE_MAP="$PROJECT_ROOT_DIR/main.jsbundle.map"
36
+
37
+ # This is needed for the API call to upload source maps to Honeybadger.
38
+ EMPTY_FILE="$PROJECT_ROOT_DIR/empty_file.txt"
39
+
40
+ API_KEY=""
41
+ REVISION=""
42
+ USE_HERMES=true
43
+ SKIP_UPLOAD=false
44
+
45
+ OS_BIN=""
46
+
47
+
48
+ #
49
+ # Parse the command line variables.
50
+ # We need the apiKey, and the build revision.
51
+ # We also need to determine if we should use Hermes.
52
+ #
53
+
54
+ while [[ $# -gt 0 ]]; do
55
+ case "$1" in
56
+ --no-hermes)
57
+ USE_HERMES=false
58
+ shift
59
+ ;;
60
+ --skip-upload)
61
+ SKIP_UPLOAD=true
62
+ shift
63
+ ;;
64
+ --apiKey)
65
+ shift
66
+ if [[ $# -gt 0 ]]; then
67
+ API_KEY="$1"
68
+ shift
69
+ else
70
+ echo "Error: Missing value for --apiKey"
71
+ echo $USAGE
72
+ exit 1
73
+ fi
74
+ ;;
75
+ --revision)
76
+ shift
77
+ if [[ $# -gt 0 ]]; then
78
+ REVISION="$1"
79
+ shift
80
+ else
81
+ echo "Error: Missing value for --revision"
82
+ echo $USAGE
83
+ exit 1
84
+ fi
85
+ ;;
86
+ *)
87
+ echo "Unknown option: $1"
88
+ echo $USAGE
89
+ exit 1
90
+ ;;
91
+ esac
92
+ done
93
+
94
+
95
+ #
96
+ # Make sure we have API_KEY and REVISION
97
+ #
98
+
99
+ if [[ -z "$API_KEY" ]]; then
100
+ echo "Error: apiKey is empty"
101
+ echo $USAGE
102
+ exit 1
103
+ fi
104
+
105
+
106
+ if [[ -z "$REVISION" ]]; then
107
+ echo "Error: revision is empty"
108
+ echo $USAGE
109
+ exit 1
110
+ fi
111
+
112
+
113
+ #
114
+ # Determine what the operating system is. This is needed to find the path
115
+ # to the Hermes executable.
116
+ #
117
+
118
+ if $USE_HERMES; then
119
+
120
+ case "$(uname -s)" in
121
+ Darwin)
122
+ OS_BIN="osx-bin"
123
+ ;;
124
+ Linux)
125
+ OS_BIN="linux64-bin"
126
+ ;;
127
+ CYGWIN*|MINGW32*|MSYS*)
128
+ OS_BIN="win64-bin"
129
+ ;;
130
+ *)
131
+ echo "Unsupported operating system."
132
+ exit 1
133
+ ;;
134
+ esac
135
+
136
+ fi
137
+
138
+
139
+ echo "Generating the Android source map ..."
140
+
141
+ npx react-native bundle \
142
+ --platform android \
143
+ --dev false \
144
+ --entry-file "$PROJECT_ROOT_DIR/index.js" \
145
+ --reset-cache \
146
+ --bundle-output "$ANDROID_PACKAGER_BUNDLE" \
147
+ --sourcemap-output "$ANDROID_PACKAGER_SOURCE_MAP" \
148
+ --minify false > /dev/null 2>&1
149
+
150
+
151
+ echo "Generating the iOS source map ..."
152
+
153
+ npx react-native bundle \
154
+ --platform ios \
155
+ --dev false \
156
+ --entry-file index.js \
157
+ --reset-cache \
158
+ --bundle-output "$IOS_PACKAGER_BUNDLE" \
159
+ --sourcemap-output "$IOS_PACKAGER_SOURCE_MAP" \
160
+ --minify false > /dev/null 2>&1
161
+
162
+
163
+ if $USE_HERMES; then
164
+
165
+ echo "Hermes is enabled ..."
166
+
167
+ #
168
+ # Need to find the Hermes compiler executable for Android.
169
+ #
170
+
171
+ # react native >= 0.69
172
+ HERMES_PATH_1="$NODE_MODULES/react-native/sdks/hermesc/$OS_BIN/hermesc"
173
+
174
+ # react native <= 0.68
175
+ HERMES_PATH_2="$NODE_MODULES/hermes-engine/$OS_BIN/hermesc"
176
+
177
+
178
+ if [ -f "$HERMES_PATH_1" ]; then
179
+ HERMES_EXECUTABLE="$HERMES_PATH_1"
180
+ elif [ -f "$HERMES_PATH_2" ]; then
181
+ HERMES_EXECUTABLE="$HERMES_PATH_2"
182
+ else
183
+ echo "Error: The Hermes compiler executable for Android was not found in the expected locations."
184
+ exit 1
185
+ fi
186
+
187
+
188
+ echo "Generating Hermes Android source map ..."
189
+
190
+ #
191
+ # compile the Android code to bytecode and generate the Hermes sourcemap
192
+ #
193
+
194
+ "$HERMES_EXECUTABLE" \
195
+ -O \
196
+ -emit-binary \
197
+ -output-source-map \
198
+ -out="$ANDROID_COMPILER_BUNDLE" \
199
+ "$ANDROID_PACKAGER_BUNDLE" > /dev/null 2>&1
200
+
201
+ #
202
+ # merge the two Android sourcemaps
203
+ #
204
+
205
+ node "$NODE_MODULES/react-native/scripts/compose-source-maps.js" \
206
+ "$ANDROID_PACKAGER_SOURCE_MAP" \
207
+ "$ANDROID_COMPILER_SOURCE_MAP" \
208
+ -o "$ANDROID_FINAL_SOURCE_MAP" > /dev/null 2>&1
209
+
210
+
211
+ #
212
+ # Need to find the Hermes compiler executable for iOS.
213
+ #
214
+
215
+ HERMES_EXECUTABLE="$PROJECT_ROOT_DIR/ios/Pods/hermes-engine/destroot/bin/hermesc"
216
+
217
+ if [ ! -f "$HERMES_EXECUTABLE" ]; then
218
+ echo "Error: The Hermes compiler executable for iOS was not found in the expected location: $HERMES_EXECUTABLE . Did you run pod install in the ios/ directory?"
219
+ exit 1
220
+ fi
221
+
222
+
223
+ echo "Generating Hermes iOS source map ..."
224
+
225
+ #
226
+ # Compile the iOS code to bytecode and generate the Hermes sourcemap.
227
+ #
228
+
229
+ "$HERMES_EXECUTABLE" \
230
+ -O \
231
+ -emit-binary \
232
+ -output-source-map \
233
+ -out="$IOS_COMPILER_BUNDLE" \
234
+ "$IOS_PACKAGER_BUNDLE" > /dev/null 2>&1
235
+
236
+ #
237
+ # merge the two iOS sourcemaps
238
+ #
239
+
240
+ node "$NODE_MODULES/react-native/scripts/compose-source-maps.js" \
241
+ "$IOS_PACKAGER_SOURCE_MAP" \
242
+ "$IOS_COMPILER_SOURCE_MAP" \
243
+ -o "$IOS_FINAL_SOURCE_MAP" > /dev/null 2>&1
244
+
245
+
246
+ #
247
+ # cleanup
248
+ #
249
+
250
+ rm -f \
251
+ "$ANDROID_PACKAGER_BUNDLE" \
252
+ "$ANDROID_PACKAGER_SOURCE_MAP" \
253
+ "$ANDROID_COMPILER_BUNDLE" \
254
+ "$ANDROID_COMPILER_SOURCE_MAP" \
255
+ "$IOS_PACKAGER_BUNDLE" \
256
+ "$IOS_PACKAGER_SOURCE_MAP" \
257
+ "$IOS_COMPILER_BUNDLE" \
258
+ "$IOS_COMPILER_SOURCE_MAP"
259
+
260
+ else
261
+
262
+ echo "Hermes is not enabled ..."
263
+
264
+ #
265
+ # The packager source maps are the only source maps we need.
266
+ #
267
+
268
+ mv "$ANDROID_PACKAGER_SOURCE_MAP" "$ANDROID_FINAL_SOURCE_MAP"
269
+ mv "$IOS_PACKAGER_SOURCE_MAP" "$IOS_FINAL_SOURCE_MAP"
270
+
271
+ #
272
+ # cleanup
273
+ #
274
+
275
+ rm -f "$ANDROID_PACKAGER_BUNDLE" "$IOS_PACKAGER_BUNDLE"
276
+
277
+ fi
278
+
279
+
280
+ #
281
+ # We should now have Android and iOS source maps ready for upload.
282
+ #
283
+
284
+ if $SKIP_UPLOAD; then
285
+ echo "Source maps generated."
286
+ echo " iOS: main.jsbundle.map"
287
+ echo " Android: index.android.bundle.map"
288
+ echo "Skipping upload.";
289
+ exit;
290
+ fi
291
+
292
+ echo "Source maps generated. Uploading to Honeybadger ...";
293
+
294
+ rm -f "$EMPTY_FILE"
295
+ touch "$EMPTY_FILE"
296
+
297
+ curl https://api.honeybadger.io/v1/source_maps \
298
+ -F api_key="$API_KEY" \
299
+ -F revision="$REVISION" \
300
+ -F minified_url=index.android.bundle \
301
+ -F source_map=@"$ANDROID_FINAL_SOURCE_MAP" \
302
+ -F minified_file=@"$EMPTY_FILE" > /dev/null 2>&1
303
+
304
+ curl https://api.honeybadger.io/v1/source_maps \
305
+ -F api_key="$API_KEY" \
306
+ -F revision="$REVISION" \
307
+ -F minified_url=main.jsbundle \
308
+ -F source_map=@"$IOS_FINAL_SOURCE_MAP" \
309
+ -F minified_file=@"$EMPTY_FILE" > /dev/null 2>&1
310
+
311
+ #
312
+ # Cleanup
313
+ #
314
+
315
+ rm -f "$ANDROID_FINAL_SOURCE_MAP" "$IOS_FINAL_SOURCE_MAP" "$EMPTY_FILE"
316
+
317
+ echo "Source maps uploaded to Honeybadger."
@@ -1,23 +0,0 @@
1
- #!/bin/bash
2
-
3
- # ----------------------------------------------------------------------------
4
- #
5
- # Honeybadger.io
6
- # Generate iOS and Android source maps for React Native.
7
- # The main.jsbundle files for iOS and Android are also generated.
8
- #
9
- # USAGE:
10
- # npx honeybadger-generate-sourcemaps
11
- #
12
- # ----------------------------------------------------------------------------
13
-
14
- SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
15
- PROJECT_ROOT_DIR="$SCRIPT_DIR/../../"
16
-
17
- echo "Generating source maps for iOS ..."
18
- npx react-native bundle --platform ios --entry-file "$PROJECT_ROOT_DIR/index.js" --dev false --reset-cache --bundle-output main.jsbundle-ios --assets-dest /dev/null --sourcemap-output sourcemap-ios --sourcemap-sources-root "PROJECT_ROOT_DIR" > /dev/null 2>&1
19
-
20
- echo "Generating source maps for Android ..."
21
- npx react-native bundle --platform android --entry-file "$PROJECT_ROOT_DIR/index.js" --dev false --reset-cache --bundle-output main.jsbundle-android --assets-dest /dev/null --sourcemap-output sourcemap-android --sourcemap-sources-root "PROJECT_ROOT_DIR" > /dev/null 2>&1
22
-
23
- echo "Done. Your project root directory now contains sourcemap-ios, sourcemap-android, main.jsbundle-ios, and main.jsbundle-android."