Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/sdk/reactNative/.backtracejsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"run": {
"process": true,
"upload": true,
"add-sources": true
},
"upload": {
"url": "https://<your-backtrace-url>:6098/post?format=sourcemap&token=<your-symbols-access-token>",
"include-sources": true
}
}
12 changes: 12 additions & 0 deletions examples/sdk/reactNative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ This example app shows features available in the @backtrace/react-native package
1. Add your universe and token to the SUBMISSION_URL in src/consts.ts
2. `npm install`. If you're on iOS, navigate to the `ios` directory and run `pod install`
3. `npm run start` and pick desired platform

#### Source maps

On Android: You can verify our example app with the source map support. In order to do that, please use the
android-sourcemap.sh script.

```bash
./android-sourcemap.sh ./optional-path-to-directory
```

The script will prepare a release APK version of your React Native application with the sourcemap and Hermes support.
The APK can be found in the ./android/app/build/outputs/apk/release/ directory.
66 changes: 66 additions & 0 deletions examples/sdk/reactNative/android-sourcemap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#/bin/bash

# This script shows how to add source map support to any react-native android application.
# By using it, you can upload source maps to Backtrace and built a release version of the app
# with hermesc support. This script uses .backtracejsrc file available in your react-native directory.
#
# Additional information: This script prepares your bundle for you. In the release build, to prevent "double" application build
# while building final apk/aab, in the build.gradle file, please use `debuggableVariants = ["release"]`. Otherwise
# Gradle and react-native will try to build the application twice and override application version with source map support.

BUILD_DIR=${1:-build}
BUNDLE_PATH="$BUILD_DIR/index.android.bundle"
SOURCE_MAP_PATH="$BUILD_DIR/index.android.js.map"

mkdir -p $BUILD_DIR
# build react-native application
npx react-native bundle \
--platform android \
--dev false \
--entry-file index.js \
--reset-cache \
--bundle-output $BUNDLE_PATH \
--sourcemap-output $SOURCE_MAP_PATH \
--minify false \
--assets-dest ./android/app/src/main/res/


# add source map identifier to final javascript bundle
npx backtrace-js process --path=$BUNDLE_PATH

HBC_OUTPUT="$BUILD_DIR/app.hbc"
HBC_MAP_OUTPUT="$HBC_OUTPUT.map"

# generate react-native executable
./node_modules/react-native/sdks/hermesc/osx-bin/hermesc \
-emit-binary \
-max-diagnostic-width=80 \
-output-source-map \
-out=$HBC_OUTPUT \
$BUNDLE_PATH

# on this stage we have source map for built application via react-native
# and source map for the final executable. Combination of both should generate
# final source map needed to process correctly reports
node ./node_modules/react-native/scripts/compose-source-maps.js \
$SOURCE_MAP_PATH \
$HBC_MAP_OUTPUT \
-o $SOURCE_MAP_PATH

# upload data to Backtrace
backtrace-js run $BUNDLE_PATH

# prepare android application
mkdir -p ./android/app/src/main/assets
# rename hbc to android.bundle file
mv $HBC_OUTPUT $BUNDLE_PATH

# prepare android application
mkdir -p ./android/app/build/generated/assets/createBundleReleaseJsAndAssets
cp $BUNDLE_PATH ./android/app/build/generated/assets/createBundleReleaseJsAndAssets/
mkdir -p ./android/app/build/intermediates/assets/release/
cp $BUNDLE_PATH ./android/app/build/intermediates/assets/release/

cd android
./gradlew assembleRelease
echo "Application build is available under path: ./android/app/build/outputs/apk/release/"
2 changes: 1 addition & 1 deletion examples/sdk/reactNative/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ react {
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
debuggableVariants = ["release"]

/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
Expand Down
5,390 changes: 3,077 additions & 2,313 deletions examples/sdk/reactNative/package-lock.json

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions packages/react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
classpath "com.android.tools.build:gradle:7.4.2"
}
}

Expand All @@ -15,9 +15,6 @@ def isNewArchitectureEnabled() {

apply plugin: "com.android.library"


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}
Expand All @@ -36,11 +33,7 @@ def supportsNamespace() {
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
if (major == 7 && minor >= 3) {
return true
}

return major >= 8
return (major == 7 && minor >= 3) || major >= 8
}

android {
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ReactNative_kotlinVersion=1.7.0
ReactNative_minSdkVersion=21
ReactNative_targetSdkVersion=31
ReactNative_compileSdkVersion=31
ReactNative_minSdkVersion=16
ReactNative_targetSdkVersion=27
ReactNative_compileSdkVersion=33
ReactNative_buildToolsVersion=29.0.3
ReactNative_ndkversion=21.4.7075529

This file was deleted.

Loading