bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
370 stars 121 forks source link

Sourcemap path in case of android flavor builds #473

Closed GOVINDDIXIT closed 4 years ago

GOVINDDIXIT commented 4 years ago

I have created flavor builds in the android side of the React Native app. Earlier there was no flavor builds So I was uploading the source map using CI like this

- run:
          name: Upload sourcemaps to Bugsnag
          command: |
            if [[ $BUGSNAG_KEY ]]; then
              yarn generate-source-maps-android upload \
                --api-key=$BUGSNAG_KEY \
                --app-version=$CIRCLE_BUILD_NUM \
                --minifiedFile=android/app/build/generated/assets/react/release/app.bundle \
                --source-map=android/app/build/generated/sourcemaps/react/release/app.bundle.map \
                --minified-url=app.bundle \
                --upload-sources
            fi

But now the app is divided into two flavor builds (play and foss) and Bugsnag is available only in playbuild. I am getting this error as the source map path needs to be updated.

 [error] Error uploading source maps: Error: Source map file does not exist (android/app/build/generated/sourcemaps/react/release/app.bundle.map)
    at /home/********/repo/node_modules/bugsnag-sourcemaps/lib/options.js:141:17

Can anyone help me in determining what will be the updated path of source map in case of multiple flavors in the app? Thanks in advance.

PS: I Have gone through the docs but didn't find anything related to this scenario.

mattdyoung commented 4 years ago

Hi @GOVINDDIXIT

Are you using the Hermes JS engine on Android in your React Native app? If you're not using Hermes you can just follow our standard instructions here to upload via the API without bugsnag-sourcemaps: https://docs.bugsnag.com/platforms/react-native/react-native/showing-full-stacktraces/#uploading-source-maps-to-bugsnag

If Hermes is enabled then using bugsnag-sourcemaps is currently the only upload method we support.

Where does you flavor build output the .bundle and .bundle.map files? Have you tried manually running the build and searching for the files? Is it just the path that's wrong in your upload command?

GOVINDDIXIT commented 4 years ago

Hi @mattdyoung

Thanks for the quick response. Yes, I have got the correct path by building source maps locally and the issue is now solved. If possible I would suggest adding a specific section for the android flavor builds in official docs.

After adding flavors the updated path for minified file and source map is

            --minifiedFile=android/app/build/generated/assets/react/play/release/app.bundle 
            --source-map=android/app/build/generated/sourcemaps/react/play/release/app.bundle.map 

In general

                --minifiedFile=android/app/build/generated/assets/react/{flavor_name}/release/app.bundle 
                --source-map=android/app/build/generated/sourcemaps/react/{flavor_name}/release/app.bundle.map 
mattdyoung commented 4 years ago

@GOVINDDIXIT Thanks for letting us know! We're looking into various docs improvements currently so we'll consider this clarification.