From 36eedc53253722e87b1db34e50e0dc4b98567921 Mon Sep 17 00:00:00 2001 From: louiszawadzki Date: Fri, 14 Apr 2023 17:04:15 +0200 Subject: [PATCH] Revert "Merge pull request #423 from DataDog/louiszawadzki/do-not-upload-js-bundle-by-default" This reverts commit 92ca31c1770dfa7e3cd6f92404f9dc3570b86ebe, reversing changes made to a5bd3d24cf2b052c3f9ed41aa5d5cb694c2b14f4. --- docs/crash_reporting.md | 2 +- packages/core/datadog-sourcemaps.gradle | 55 +++---------------------- 2 files changed, 7 insertions(+), 50 deletions(-) diff --git a/docs/crash_reporting.md b/docs/crash_reporting.md index ab302f9b8..dec8b57fd 100644 --- a/docs/crash_reporting.md +++ b/docs/crash_reporting.md @@ -80,7 +80,7 @@ project.ext.datadog = [ ### On iOS using the `datadog-ci react-native xcode` command -Options for the `datadog-ci react-native xcode` command are available on the [command documentation page][12]. +Available options for the `datadog-ci react-native xcode` command are available on the [command documentation page][12]. ## Test your implementation of crash reporting diff --git a/packages/core/datadog-sourcemaps.gradle b/packages/core/datadog-sourcemaps.gradle index f2f3a6cd1..6c538001b 100644 --- a/packages/core/datadog-sourcemaps.gradle +++ b/packages/core/datadog-sourcemaps.gradle @@ -56,8 +56,8 @@ afterEvaluate { group = "datadog" description = "Uploads sourcemaps to Datadog." - def execCommand = { jsBundleFile, shouldUploadBundleFile -> - def command = [ + def execCommand = { jsBundleFile -> + return [ "yarn", "datadog-ci", "react-native", @@ -66,6 +66,8 @@ afterEvaluate { "android", "--service", serviceName, + "--bundle", + jsBundleFile.absolutePath, "--sourcemap", jsOutputSourceMapFile.absolutePath, "--release-version", @@ -73,18 +75,11 @@ afterEvaluate { "--build-version", buildVersion ] - if (shouldUploadBundleFile) { - command.add("--bundle") - command.add(jsBundleFile.absolutePath) - } - return command } doFirst { - def shouldUploadBundleFile = getShouldUploadBundleFile(reactRoot) - def jsBundleFile = reactConfig.bundleFileResolver() - if (jsBundleFile == null && shouldUploadBundleFile) { + if (jsBundleFile == null) { throw new GradleException("JS bundle file doesn't exist, aborting upload.") } @@ -92,7 +87,7 @@ afterEvaluate { throw new GradleException("JS sourcemap file doesn't exist, aborting upload.") } - runShellCommand(execCommand(jsBundleFile, shouldUploadBundleFile), reactRoot) + runShellCommand(execCommand(jsBundleFile), reactRoot) } } @@ -184,7 +179,6 @@ private def runShellCommand( result.rethrowFailure() } else { logger.lifecycle(outputStream.toString("UTF-8")) - return outputStream.toString("UTF-8") } } catch (Exception e) { def errorStreamContent = errorStream.toString("UTF-8") @@ -195,43 +189,6 @@ private def runShellCommand( } } -private def getShouldUploadBundleFile(File reactRoot) { - // Provide a way to override bundle upload - if (project.hasProperty("datadog")) { - if (project.datadog.containsKey("shouldUploadBundle")) { - return project.datadog.shouldUploadBundle - } - } - - def datadogCiVersionCommand = [ - "yarn", - "--silent", - "datadog-ci", - "version" - ] - try { - def versionAsString = runShellCommand(datadogCiVersionCommand, reactRoot) // outputs: v2.5.1 - // We remove the leading "v" in the version number output - List version = versionAsString.replace("v", "").tokenize('.').collect { it.toInteger() } - - // First datadog-ci version allowing not uploading the bundle is 2.6.0 - return !isVersionEqualOrAbove(version, [2, 6, 0]) - } catch (Exception e) { - - return true - } -} - -private static isVersionEqualOrAbove(List version, List targetVersion) { - if (version[0] != targetVersion[0]) { - return version[0] > targetVersion[0] - } - if (version [1] != targetVersion[1]) { - return version[1] > targetVersion[1] - } - return version[2] >= targetVersion[2] -} - private def getServiceName(variant) { if (project.hasProperty("datadog")) { if (project.datadog.serviceName) {