diff --git a/README.md b/README.md index 7d6350450..e705c77af 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,22 @@ The RUM React Native SDK supports monitoring hybrid applications. The RUM React Native SDK supports [OpenTelemetry][9] and distributed traces through header generation. +### Source maps (Android) + +Uploading source maps lets Flashcat show readable stack traces for release builds. Apply the bundled Gradle script in `android/app/build.gradle`: + +```groovy +apply from: "../../node_modules/@flashcatcloud/mobile-react-native/flashcat-sourcemaps.gradle" +``` + +It adds an `uploadSourcemaps` task that runs automatically after the JS bundle task and uploads the bundle and its source map through `@flashcatcloud/flashcat-cli`, authenticated with the `FLASHCAT_API_KEY` environment variable. + +The upload never blocks the build: + +- If `FLASHCAT_API_KEY` is not set, the task is skipped and a warning is printed. +- If the upload fails (invalid key, network error, ...), a warning containing the CLI output is printed and the build continues. +- Set `FLASHCAT_SOURCEMAPS_DRY_RUN=true` (or the Gradle property `flashcatSourcemapsDryRun=true`) to run the task without uploading; this also silences the missing-key warning. + ## Troubleshooting If you encounter any issue when using the Flashcat SDK for React Native, please take a look at the [troubleshooting documentation][4], or at the [existing issues][5]. diff --git a/lerna.json b/lerna.json index fd4973a49..7e635b71e 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "npmClient": "yarn", - "version": "0.1.0", + "version": "0.1.1", "packages": [ "packages/*" ], diff --git a/packages/codepush/package.json b/packages/codepush/package.json index 67a356e11..fd5a9056f 100644 --- a/packages/codepush/package.json +++ b/packages/codepush/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-native-code-push", - "version": "0.1.0", + "version": "0.1.1", "description": "A client-side React Native module to interact with Appcenter Codepush and Datadog", "keywords": [ "datadog", @@ -39,7 +39,7 @@ "prepare": "rm -rf lib && yarn bob build" }, "devDependencies": { - "@flashcatcloud/mobile-react-native": "workspace:0.1.0", + "@flashcatcloud/mobile-react-native": "workspace:0.1.1", "@testing-library/react-native": "7.0.2", "react-native-builder-bob": "0.26.0", "react-native-code-push": "7.1.0" diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt index 05f145011..653e8dfe9 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt @@ -7,4 +7,4 @@ package com.datadog.reactnative // This is automatically updated by the update-version.sh script -internal const val SDK_VERSION = "0.1.0" +internal const val SDK_VERSION = "0.1.1" diff --git a/packages/core/flashcat-sourcemaps.gradle b/packages/core/flashcat-sourcemaps.gradle index 34cde9c92..a58259b58 100644 --- a/packages/core/flashcat-sourcemaps.gradle +++ b/packages/core/flashcat-sourcemaps.gradle @@ -66,6 +66,18 @@ afterEvaluate { group = "flashcat" description = "Uploads sourcemaps to Flashcat." + // The upload must never break the release build: skip it when no API key is + // available (the dry run mode does not need one). + onlyIf { + if (isDryRun || System.getenv("FLASHCAT_API_KEY")) { + return true + } + logger.warn("WARNING: FLASHCAT_API_KEY is not set, skipping sourcemap upload to Flashcat" + + " for variant=${targetName}. Set FLASHCAT_API_KEY to upload sourcemaps," + + " or set FLASHCAT_SOURCEMAPS_DRY_RUN=true to silence this warning.") + return false + } + def uploadSourcemap = { jsBundleFile -> return [ "${getFlashcatCliExecPath(reactConfig)}", @@ -362,6 +374,8 @@ private def runShellCommand( workingDir = workingDirectory standardOutput = outputStream errorOutput = errorStream + // A failed upload must not fail the build: report it and move on. + ignoreExitValue = true if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine("cmd", "/c", *command) } else { @@ -370,17 +384,17 @@ private def runShellCommand( } if (result.exitValue != 0) { - logger.error(errorStream.toString("UTF-8")) - result.rethrowFailure() + logger.warn("WARNING: Flashcat sourcemap upload step failed (exit code ${result.exitValue})," + + " the build continues without it. stderr=${errorStream.toString("UTF-8")}" + + " stdout=${outputStream.toString("UTF-8")}") } else { logger.lifecycle(outputStream.toString("UTF-8")) } } catch (Exception e) { def errorStreamContent = errorStream.toString("UTF-8") def standardStreamContent = outputStream.toString("UTF-8") - logger.error("Exception raised during command execution," + + logger.warn("WARNING: Flashcat sourcemap upload step failed, the build continues without it." + " stderr=${errorStreamContent}, stdout=${standardStreamContent}, exception=${e}") - throw e } } diff --git a/packages/core/ios/Sources/SdkVersion.swift b/packages/core/ios/Sources/SdkVersion.swift index eba4d33de..963a8c8e3 100644 --- a/packages/core/ios/Sources/SdkVersion.swift +++ b/packages/core/ios/Sources/SdkVersion.swift @@ -7,4 +7,4 @@ import Foundation // This is automatically updated by the update-version.sh script -let SdkVersion = "0.1.0" +let SdkVersion = "0.1.1" diff --git a/packages/core/package.json b/packages/core/package.json index d2536c849..06c4eacbc 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-native", - "version": "0.1.0", + "version": "0.1.1", "description": "A client-side React Native module to interact with Datadog", "keywords": [ "datadog", diff --git a/packages/core/src/version.ts b/packages/core/src/version.ts index 1159d4084..27a84c967 100644 --- a/packages/core/src/version.ts +++ b/packages/core/src/version.ts @@ -1,2 +1,2 @@ // generated by genversion -export const version = '0.1.0'; +export const version = '0.1.1'; diff --git a/packages/internal-testing-tools/package.json b/packages/internal-testing-tools/package.json index 63e6493ef..4abfd21b4 100644 --- a/packages/internal-testing-tools/package.json +++ b/packages/internal-testing-tools/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/react-native-internal-testing-tools", - "version": "0.1.0", + "version": "0.1.1", "description": "Internal tools for testing the Datadog React Native SDK.", "keywords": [ "datadog", diff --git a/packages/react-native-apollo-client/package.json b/packages/react-native-apollo-client/package.json index 2a0e0c85e..37a238c59 100644 --- a/packages/react-native-apollo-client/package.json +++ b/packages/react-native-apollo-client/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-native-apollo-client", - "version": "0.1.0", + "version": "0.1.1", "private": true, "description": "A client-side React Native module to interact with Apollo Client and Datadog", "keywords": [ diff --git a/packages/react-native-babel-plugin/package.json b/packages/react-native-babel-plugin/package.json index 8d06713d7..8234b70ad 100644 --- a/packages/react-native-babel-plugin/package.json +++ b/packages/react-native-babel-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-native-babel-plugin", - "version": "0.1.0", + "version": "0.1.1", "description": "A Babel plugin that enhances Datadog's React Native SDK by automatically enriching React components with contextual metadata.", "keywords": [ "babel", diff --git a/packages/react-native-navigation/package.json b/packages/react-native-navigation/package.json index 9ac0e6533..01c5fe99b 100644 --- a/packages/react-native-navigation/package.json +++ b/packages/react-native-navigation/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-native-navigation", - "version": "0.1.0", + "version": "0.1.1", "description": "A client-side React Native module to interact with Datadog", "keywords": [ "datadog", @@ -36,7 +36,7 @@ "prepare": "rm -rf lib && yarn bob build" }, "devDependencies": { - "@flashcatcloud/mobile-react-native": "^0.1.0", + "@flashcatcloud/mobile-react-native": "^0.1.1", "@testing-library/react-native": "7.0.2", "react-native-builder-bob": "0.26.0", "react-native-gesture-handler": "1.10.3", diff --git a/packages/react-native-session-replay/package.json b/packages/react-native-session-replay/package.json index 0038c6f01..02d7c84d9 100644 --- a/packages/react-native-session-replay/package.json +++ b/packages/react-native-session-replay/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-native-session-replay", - "version": "0.1.0", + "version": "0.1.1", "description": "A client-side React Native module to enable session replay with Datadog", "keywords": [ "datadog", diff --git a/packages/react-native-webview/package.json b/packages/react-native-webview/package.json index 8c53f2f13..6dae3b3a9 100644 --- a/packages/react-native-webview/package.json +++ b/packages/react-native-webview/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-native-webview", - "version": "0.1.0", + "version": "0.1.1", "description": "A client-side React Native module to interact with react-native-webview and Datadog", "keywords": [ "datadog", diff --git a/packages/react-navigation/package.json b/packages/react-navigation/package.json index 0ccd9fccc..4f72e6937 100644 --- a/packages/react-navigation/package.json +++ b/packages/react-navigation/package.json @@ -1,6 +1,6 @@ { "name": "@flashcatcloud/mobile-react-navigation", - "version": "0.1.0", + "version": "0.1.1", "description": "A client-side React Native module to interact with Datadog", "keywords": [ "datadog", @@ -36,7 +36,7 @@ "prepare": "rm -rf lib && yarn bob build" }, "devDependencies": { - "@flashcatcloud/mobile-react-native": "^0.1.0", + "@flashcatcloud/mobile-react-native": "^0.1.1", "@react-navigation/native-v5": "npm:@react-navigation/native@5.9.8", "@react-navigation/native-v6": "npm:@react-navigation/native@6.1.2", "@react-navigation/stack-v5": "npm:@react-navigation/stack@5.14.2", diff --git a/yarn.lock b/yarn.lock index e6a65ce5a..0f7e8d75f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2535,7 +2535,7 @@ __metadata: version: 0.0.0-use.local resolution: "@flashcatcloud/mobile-react-native-code-push@workspace:packages/codepush" dependencies: - "@flashcatcloud/mobile-react-native": "workspace:0.1.0" + "@flashcatcloud/mobile-react-native": "workspace:0.1.1" "@testing-library/react-native": 7.0.2 react-native-builder-bob: 0.26.0 react-native-code-push: 7.1.0 @@ -2551,7 +2551,7 @@ __metadata: version: 0.0.0-use.local resolution: "@flashcatcloud/mobile-react-native-navigation@workspace:packages/react-native-navigation" dependencies: - "@flashcatcloud/mobile-react-native": ^0.1.0 + "@flashcatcloud/mobile-react-native": ^0.1.1 "@testing-library/react-native": 7.0.2 react-native-builder-bob: 0.26.0 react-native-gesture-handler: 1.10.3 @@ -2593,7 +2593,7 @@ __metadata: languageName: unknown linkType: soft -"@flashcatcloud/mobile-react-native@^0.1.0, @flashcatcloud/mobile-react-native@workspace:0.1.0, @flashcatcloud/mobile-react-native@workspace:packages/core": +"@flashcatcloud/mobile-react-native@^0.1.1, @flashcatcloud/mobile-react-native@workspace:0.1.1, @flashcatcloud/mobile-react-native@workspace:packages/core": version: 0.0.0-use.local resolution: "@flashcatcloud/mobile-react-native@workspace:packages/core" dependencies: @@ -2610,7 +2610,7 @@ __metadata: version: 0.0.0-use.local resolution: "@flashcatcloud/mobile-react-navigation@workspace:packages/react-navigation" dependencies: - "@flashcatcloud/mobile-react-native": ^0.1.0 + "@flashcatcloud/mobile-react-native": ^0.1.1 "@react-navigation/native-v5": "npm:@react-navigation/native@5.9.8" "@react-navigation/native-v6": "npm:@react-navigation/native@6.1.2" "@react-navigation/stack-v5": "npm:@react-navigation/stack@5.14.2"