Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

- 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
Expand Down
34 changes: 27 additions & 7 deletions android/sourcemaps.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ 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 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()
Expand Down Expand Up @@ -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
Expand Down