diff --git a/CHANGELOG.md b/CHANGELOG.md index ab9ebe68a8..78ab884027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,25 @@ ``` More information about the new setup [can be found here](https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/). +- Add `SENTRY_DISABLE_AUTO_UPLOAD` flag ([#3323](https://github.com/getsentry/sentry-react-native/pull/3323)) + + How to use in Android project? It works by default, just set `export SENTRY_DISABLE_AUTO_UPLOAD=true` in your build environment. For Sentry Android Gradle Plugin add the following to your `android/app/build.gradle`. + + ```gradle + apply from: "../../../sentry.gradle" + + sentry { + autoUploadProguardMapping = shouldSentryAutoUpload() + uploadNativeSymbols = shouldSentryAutoUpload() + } + ``` + + How to use in Xcode? Make sure you are using `scripts/sentry-xcode.sh` and `scripts/sentry-xcode-debug-files.sh` in your + build phases. And add the following to your `ios/.xcode.env.local` file. + + ```bash + export SENTRY_DISABLE_AUTO_UPLOAD=true + ``` ### Fixes diff --git a/sample-new-architecture/android/app/build.gradle b/sample-new-architecture/android/app/build.gradle index 4f753e08bb..374e689c08 100644 --- a/sample-new-architecture/android/app/build.gradle +++ b/sample-new-architecture/android/app/build.gradle @@ -2,12 +2,31 @@ apply plugin: "com.android.application" apply plugin: "com.facebook.react" apply plugin: "io.sentry.android.gradle" +project.ext.sentryCli = [ + collectModulesScript: "../../../dist/js/tools/collectModules.js", + modulesPaths: [ + "node_modules", + "../..", + ], + skipCollectModules: false, + copyDebugIdScript: "../../../scripts/copy-debugid.js", + hasSourceMapDebugIdScript: "../../../scripts/has-sourcemap-debugid.js", +] + +apply from: "../../../sentry.gradle" + sentry { + // Whether the plugin should attempt to auto-upload the mapping file to Sentry or not. + // If disabled the plugin will run a dry-run and just generate a UUID. + // The mapping file has to be uploaded manually via sentry-cli in this case. + // Default is enabled. + autoUploadProguardMapping = shouldSentryAutoUpload() + // Disables or enables the automatic configuration of Native Symbols // for Sentry. This executes sentry-cli automatically so // you don't need to do it manually. // Default is disabled. - uploadNativeSymbols = true + uploadNativeSymbols = shouldSentryAutoUpload() // Does or doesn't include the source code of native code for Sentry. // This executes sentry-cli with the --include-sources param. automatically so @@ -67,19 +86,6 @@ react { // hermesFlags = ["-O", "-output-source-map"] } -project.ext.sentryCli = [ - collectModulesScript: "../../../dist/js/tools/collectModules.js", - modulesPaths: [ - "node_modules", - "../..", - ], - skipCollectModules: false, - copyDebugIdScript: "../../../scripts/copy-debugid.js", - hasSourceMapDebugIdScript: "../../../scripts/has-sourcemap-debugid.js", -] - -apply from: "../../../sentry.gradle" - /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ diff --git a/scripts/sentry-xcode-debug-files.sh b/scripts/sentry-xcode-debug-files.sh index f2bae94741..73ab003f59 100755 --- a/scripts/sentry-xcode-debug-files.sh +++ b/scripts/sentry-xcode-debug-files.sh @@ -19,4 +19,9 @@ fi EXTRA_ARGS="$SENTRY_CLI_EXTRA_ARGS $SENTRY_CLI_DEBUG_FILES_UPLOAD_EXTRA_ARGS $INCLUDE_SOURCES_FLAG" UPLOAD_DEBUG_FILES="\"$SENTRY_CLI_EXECUTABLE\" debug-files upload $EXTRA_ARGS \"$DWARF_DSYM_FOLDER_PATH\"" -/bin/sh -c "$UPLOAD_DEBUG_FILES" + +if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then + /bin/sh -c "$UPLOAD_DEBUG_FILES" +else + echo "SENTRY_DISABLE_AUTO_UPLOAD=true, skipping debug files upload" +fi diff --git a/scripts/sentry-xcode.sh b/scripts/sentry-xcode.sh index abb5238f75..3fb0e68a6c 100755 --- a/scripts/sentry-xcode.sh +++ b/scripts/sentry-xcode.sh @@ -16,9 +16,14 @@ REACT_NATIVE_XCODE=$1 [[ "$AUTO_RELEASE" != true ]] && [[ -z "$BUNDLE_COMMAND" || "$BUNDLE_COMMAND" != "ram-bundle" ]] && NO_AUTO_RELEASE="--no-auto-release" ARGS="$NO_AUTO_RELEASE $SENTRY_CLI_EXTRA_ARGS $SENTRY_CLI_RN_XCODE_EXTRA_ARGS" -BUNDLE_REACT_NATIVE="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $ARGS \"$REACT_NATIVE_XCODE\"" +REACT_NATIVE_XCODE_WITH_SENTRY="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $ARGS \"$REACT_NATIVE_XCODE\"" -/bin/sh -c "$BUNDLE_REACT_NATIVE" +if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then + /bin/sh -c "$REACT_NATIVE_XCODE_WITH_SENTRY" +else + echo "SENTRY_DISABLE_AUTO_UPLOAD=true, skipping sourcemaps upload" + /bin/sh -c "$REACT_NATIVE_XCODE" +fi [ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_COLLECT_MODULES="../../scripts/collect-modules.sh" diff --git a/sentry.gradle b/sentry.gradle index b7fea4e3d1..6389176ebf 100644 --- a/sentry.gradle +++ b/sentry.gradle @@ -3,6 +3,10 @@ import org.apache.tools.ant.taskdefs.condition.Os import java.util.regex.Matcher import java.util.regex.Pattern +project.ext.shouldSentryAutoUpload = { -> + return System.getenv('SENTRY_DISABLE_AUTO_UPLOAD') != 'true' +} + def config = project.hasProperty("sentryCli") ? project.sentryCli : []; gradle.projectsEvaluated { @@ -97,7 +101,8 @@ gradle.projectsEvaluated { /** Upload source map file to the sentry server via CLI call. */ def cliTask = tasks.create(nameCliTask) { - description = "upload source maps to Sentry" + onlyIf { shouldSentryAutoUpload() } + description = "upload debug symbols to sentry" group = 'sentry.io' def extraArgs = []