From e12bcd120a2d1fbdf56d754838f7a5c14cd8e7d3 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Fri, 31 May 2024 14:29:35 +0300 Subject: [PATCH 1/6] fix source map --- android/sourcemaps.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/sourcemaps.gradle b/android/sourcemaps.gradle index 37875e070..145a84078 100644 --- a/android/sourcemaps.gradle +++ b/android/sourcemaps.gradle @@ -38,8 +38,8 @@ Task createUploadSourcemapsTask(String flavor) { try { def appProject = project(':app') def appDir = appProject.projectDir - def flavorPath = flavor + (flavor.empty ? '' : '/') - def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}release/index.android.bundle.map" + def flavorPath = flavor + (flavor.empty ? '/' : '') + def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}${(flavor.empty ? 'release' : 'Release')}/index.android.bundle.map" def sourceMapFile = new File(appDir, sourceMapDest) if (!sourceMapFile.exists()) { From 3eee10280c47247093180c6af217672f7aeb7f56 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Fri, 31 May 2024 20:15:39 +0300 Subject: [PATCH 2/6] fix: gradle sourcemap --- android/sourcemaps.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/sourcemaps.gradle b/android/sourcemaps.gradle index 145a84078..d874962b5 100644 --- a/android/sourcemaps.gradle +++ b/android/sourcemaps.gradle @@ -38,7 +38,7 @@ Task createUploadSourcemapsTask(String flavor) { try { def appProject = project(':app') def appDir = appProject.projectDir - def flavorPath = flavor + (flavor.empty ? '/' : '') + def flavorPath = flavor def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}${(flavor.empty ? 'release' : 'Release')}/index.android.bundle.map" def sourceMapFile = new File(appDir, sourceMapDest) From 4ad2d1de580c1954780cb9ddc7c3533bbbd5a81a Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 11 Sep 2024 15:21:40 +0300 Subject: [PATCH 3/6] fix: added changelog item --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b050ce8c4..af1513181 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ - Drop non-error objects reported as crashes since they don't have a stack trace ([#1279](https://github.com/Instabug/Instabug-React-Native/pull/1279)). - Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)). +### Fixed + +- Fix Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)). + ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) ### Added From 69ebc525437989173bcb71ad31746ef217afdc02 Mon Sep 17 00:00:00 2001 From: Ahmed Mahmoud Date: Mon, 23 Sep 2024 11:58:22 +0300 Subject: [PATCH 4/6] chore: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af1513181..b514e63da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ ### Fixed -- Fix Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)). +- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)). ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) From ac21746c4c85ec2351a6eae84ec7d1348985032d Mon Sep 17 00:00:00 2001 From: Ahmed Mahmoud Date: Mon, 23 Sep 2024 12:02:09 +0300 Subject: [PATCH 5/6] refactor: move flavor path to variable --- android/sourcemaps.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/sourcemaps.gradle b/android/sourcemaps.gradle index d874962b5..215835030 100644 --- a/android/sourcemaps.gradle +++ b/android/sourcemaps.gradle @@ -38,8 +38,8 @@ Task createUploadSourcemapsTask(String flavor) { try { def appProject = project(':app') def appDir = appProject.projectDir - def flavorPath = flavor - def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}${(flavor.empty ? 'release' : 'Release')}/index.android.bundle.map" + def flavorPath = flavor.empty ? 'release' : "${flavor}Release" + def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}/index.android.bundle.map" def sourceMapFile = new File(appDir, sourceMapDest) if (!sourceMapFile.exists()) { From 098016ffd711bb9cf91badde3693674bd3d4f0e5 Mon Sep 17 00:00:00 2001 From: Ahmed Mahmoud Date: Mon, 23 Sep 2024 15:17:54 +0300 Subject: [PATCH 6/6] refactor: make flavors backward-compatible --- android/sourcemaps.gradle | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/android/sourcemaps.gradle b/android/sourcemaps.gradle index 215835030..68004228a 100644 --- a/android/sourcemaps.gradle +++ b/android/sourcemaps.gradle @@ -38,13 +38,7 @@ Task createUploadSourcemapsTask(String flavor) { try { def appProject = project(':app') def appDir = appProject.projectDir - def flavorPath = flavor.empty ? 'release' : "${flavor}Release" - def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}/index.android.bundle.map" - def sourceMapFile = new File(appDir, sourceMapDest) - - if (!sourceMapFile.exists()) { - throw new InvalidUserDataException("Unable to find source map file at: ${sourceMapFile.absolutePath}") - } + def sourceMapFile = getSourceMapFile(appDir, flavor) def jsProjectDir = rootDir.parentFile def instabugDir = new File(['node', '-p', 'require.resolve("instabug-reactnative/package.json")'].execute(null, rootDir).text.trim()).getParentFile() @@ -80,6 +74,32 @@ Task createUploadSourcemapsTask(String flavor) { return provider.get() } +File getSourceMapFile(File appDir, String flavor) { + def defaultFlavorPath = flavor.empty ? 'release' : "${flavor}Release" + def defaultSourceMapDest = "build/generated/sourcemaps/react/${defaultFlavorPath}/index.android.bundle.map" + def defaultSourceMapFile = new File(appDir, defaultSourceMapDest) + + if (defaultSourceMapFile.exists()) { + return defaultSourceMapFile + } + + if (flavor.empty) { + throw new InvalidUserDataException("Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.") + } + + def fallbackSourceMapDest = "build/generated/sourcemaps/react/${flavor}/release/index.android.bundle.map" + def fallbackSourceMapFile = new File(appDir, fallbackSourceMapDest) + + project.logger.info "Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.\n" + + "Falling back to ${fallbackSourceMapFile.absolutePath}." + + if (!fallbackSourceMapFile.exists()) { + throw new InvalidUserDataException("Unable to find source map file at: ${fallbackSourceMapFile.absolutePath} either.") + } + + return fallbackSourceMapFile +} + boolean isUploadSourcemapsEnabled() { def envValue = System.getenv('INSTABUG_SOURCEMAPS_UPLOAD_DISABLE')?.toBoolean() def defaultValue = true