Sentry-react-native: Disable sourcemaps file upload for debug builds

Created on 21 Dec 2018  路  9Comments  路  Source: getsentry/sentry-react-native

Is there a way to disable uploading sourcemaps for android and iOS debug builds?

I can add add if [ "${CONFIGURATION}" = "Release" ]; then ... check for ios run script but I don't understand why does that even run in debug scheme

Most helpful comment

A shorter version:

gradle.projectsEvaluated {
    def tasksToSkip = project.tasks.matching {
        it.name.contains("SentryUpload") &&
        it.name.contains("Debug")
    }
    tasksToSkip.all { enabled = false }
}

All 9 comments

/* Disable Sentry tasks for test environments / flavors. */
gradle.projectsEvaluated {
    // Grab all build types and product flavors
    def buildTypes = android.buildTypes.collect { type -> type.name }
    def productFlavors = android.productFlavors.collect { flavor -> flavor.name }

    // When no product flavors defined, use empty
    if (!productFlavors) productFlavors.add("")

    productFlavors.each { flavor ->
        buildTypes.each { buildt ->
            def isEnabled = !isTestEnvironment(flavor.toString())
            /* disable sentry tasks for test environments */
            [
                    "bundle${flavor.capitalize()}${buildt.capitalize()}JsAndAssets${flavor}-${buildt}SentryUpload",
                    "bundle${flavor.capitalize()}${buildt.capitalize()}JsAndAssets${flavor}-${buildt}SentryUploadCleanUp",
            ].each { name ->
                def task = tasks.findByPath(name)
                if (null != task) {
                    task.enabled = isEnabled
                    task.group = "sentry.io"
                }
            }
        }
    }
}

/** Is flavor variation recognized as test environment. */
static isTestEnvironment(variantName) {
    return variantName.startsWith("appium")
}

A shorter version:

gradle.projectsEvaluated {
    def tasksToSkip = project.tasks.matching {
        it.name.contains("SentryUpload") &&
        it.name.contains("Debug")
    }
    tasksToSkip.all { enabled = false }
}

A shorter version:

gradle.projectsEvaluated {
    def tasksToSkip = project.tasks.matching {
        it.name.contains("SentryUpload") &&
        it.name.contains("Debug")
    }
    tasksToSkip.all { enabled = false }
}

So I should directly modify ./node_modules/react-native-sentry/sentry.gradle? Is there a way to do this in my main build.gradle or app/build.gradle?

@jussirantala you can place this code into app/build.gradle

@jussirantala you can place this code into app/build.gradle

I added it at the end of the file but nothing changed

Since version 0.42.0 sourcemap files are not uploaded by default on Android.

https://github.com/getsentry/react-native-sentry/blob/master/CHANGELOG.md#0420

Edit: This is PR that fixed this: https://github.com/getsentry/react-native-sentry/pull/546

cool, thanks @OleksandrKucherenko

Any idea how to also prevent uploading to sentry just from running UnitTests? Every prod release it uploads twice. first for the job running the unit tests and then secondly for the actual app bundle job.

Was this page helpful?
0 / 5 - 0 ratings