Skip to content

Commit 8869a82

Browse files
fix(android): resolve flavor path correctly in upload sourcemaps (#1225)
* fix source map * fix: gradle sourcemap * fix: added changelog item * chore: update changelog * refactor: move flavor path to variable * refactor: make flavors backward-compatible --------- Co-authored-by: Ahmed Mahmoud <[email protected]>
1 parent 915fb73 commit 8869a82

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
- 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)).
1313
- Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)).
1414

15+
### Fixed
16+
17+
- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)).
18+
1519
## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)
1620

1721
### Added

android/sourcemaps.gradle

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,7 @@ Task createUploadSourcemapsTask(String flavor) {
3838
try {
3939
def appProject = project(':app')
4040
def appDir = appProject.projectDir
41-
def flavorPath = flavor + (flavor.empty ? '' : '/')
42-
def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}release/index.android.bundle.map"
43-
def sourceMapFile = new File(appDir, sourceMapDest)
44-
45-
if (!sourceMapFile.exists()) {
46-
throw new InvalidUserDataException("Unable to find source map file at: ${sourceMapFile.absolutePath}")
47-
}
41+
def sourceMapFile = getSourceMapFile(appDir, flavor)
4842

4943
def jsProjectDir = rootDir.parentFile
5044
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) {
8074
return provider.get()
8175
}
8276

77+
File getSourceMapFile(File appDir, String flavor) {
78+
def defaultFlavorPath = flavor.empty ? 'release' : "${flavor}Release"
79+
def defaultSourceMapDest = "build/generated/sourcemaps/react/${defaultFlavorPath}/index.android.bundle.map"
80+
def defaultSourceMapFile = new File(appDir, defaultSourceMapDest)
81+
82+
if (defaultSourceMapFile.exists()) {
83+
return defaultSourceMapFile
84+
}
85+
86+
if (flavor.empty) {
87+
throw new InvalidUserDataException("Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.")
88+
}
89+
90+
def fallbackSourceMapDest = "build/generated/sourcemaps/react/${flavor}/release/index.android.bundle.map"
91+
def fallbackSourceMapFile = new File(appDir, fallbackSourceMapDest)
92+
93+
project.logger.info "Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.\n" +
94+
"Falling back to ${fallbackSourceMapFile.absolutePath}."
95+
96+
if (!fallbackSourceMapFile.exists()) {
97+
throw new InvalidUserDataException("Unable to find source map file at: ${fallbackSourceMapFile.absolutePath} either.")
98+
}
99+
100+
return fallbackSourceMapFile
101+
}
102+
83103
boolean isUploadSourcemapsEnabled() {
84104
def envValue = System.getenv('INSTABUG_SOURCEMAPS_UPLOAD_DISABLE')?.toBoolean()
85105
def defaultValue = true

0 commit comments

Comments
 (0)