expo / sentry-expo

MIT License
202 stars 83 forks source link

postPublish not running on android expo SDK 48 #320

Closed karbone4 closed 1 year ago

karbone4 commented 1 year ago

Summary

postPublish script not running on android with expo SDK 48 → source maps are not upload to sentry

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

48

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 13.2 Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn npm: 9.3.1 - ~/.nvm/versions/node/v16.17.1/bin/npm Watchman: 2022.11.07.00 - /opt/homebrew/bin/watchman SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 14.2/14C18 - /usr/bin/xcodebuild npmPackages: expo: ^48.0.1 => 48.0.1 react: 18.2.0 => 18.2.0 react-native: 0.71.2 => 0.71.2 npmGlobalPackages: eas-cli: 3.6.0 expo-cli: 6.1.0 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

https://github.com/karbone4/sentry-expo-sample-app (empty app with expo sdk 48)

evelant commented 1 year ago

Also seeing this in my project

evelant commented 1 year ago

It looks like the Expo documentation may be out of date or the sentry-expo plugin is out of date. The expo docs on migrating from "expo build" say

With EAS Build, the Classic Update's expo publish command is not run as part of the build process. Instead, the JavaScript bundle is generated locally on EAS Build at build time and directly embedded in the app.

Since we no longer publish at build time, postPublish hooks in app.json will not be executed on the build. If you use Sentry, update the sentry-expo library to the latest version and follow the updated instructions in Using Sentry. If you have other custom postPublish hooks, you can follow the same approach used in sentry-expo to support postPublish hook type of behavior.

However the "using sentry" docs still recommend adding the postPublish hook. This make it unclear how it should be configured.

Looking into the config plugin it seems that it relies on reading the sentry details from the postPublish hook section of the config file. This could definitely cause some confusion I think because AFAIK the postPublish hook is a deprecated thing that isn't recommended for use anymore now that we have EAS. Maybe it would be better to put the sentry config details in the extras.sentry section of the config?

A few warning are also emitted during Android build

 » android: sentry-expo: Could not find react.gradle script in android/app/build.gradle. Please open a bug report at https://github.com/expo/sentry-expo.
[RUN_GRADLEW] > Task :sentry_react-native:processReleaseManifest
[RUN_GRADLEW] package="io.sentry.react" found in source AndroidManifest.xml: /Users/imagio/dev/build_temp/build_android_24_19_05/build/apps/taskhero/node_modules/@sentry/react-native/android/src/main/AndroidManifest.xml.
@sentry/react-native/android/src/main/java/io/sentry/react/RNSentryModule.java uses or overrides a deprecated API.
warn Package @sentry/react-native contains invalid configuration: "dependency.platforms.ios.sharedLibraries" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
evelant commented 1 year ago

@kbrandwijk @brentvatne I haven't been able to track it down... Since you appear to be the primary maintainers here I suspect you'll probably be able to spot the issue quickly.

It appears that sentry-expo does not work with EAS on Android with SDK 48. This will likely impact every expo-sentry user now that SDK 48 is out of beta. Is there any more information I can give you to help debug it? I haven't been able to find anything wrong with the config plugin other than outdated versions of the sentry SDKs in package.json. I suspect there has been some change either from sentry or in react-native 0.71 with android gradle that requires an update to this config plugin.

kbrandwijk commented 1 year ago

The postPublish hook is currently only used to retrieve your Sentry configuration. I'll have a look at the Android issue.

GeorgeBellTMH commented 1 year ago

Just ran into this today - any word on when it will be published? It would seem a better idea to put the variables as secrets instead of as params in the json file given that checking those values in to git may allow for read/write access on sentry (beyond just creating new issues via the dsn - authToken has at minimum org:read, project:release and project:write according to documentation) ...

garrettg123 commented 1 year ago

Experiencing this in SDK 47 as well with sentry-expo 6.0.0

sergioisidoro commented 1 year ago

According to what I was able to find in the issue https://github.com/getsentry/sentry-react-native/issues/2391 we're asked to upgrade sentry react native to >5.0.0 if we're using RN > 69.

Could updating the dependency @sentry/react-native": "4.13.0 to >5 be enough to solve this issue?

sergioisidoro commented 1 year ago

Btw, I would rename the issue description, because as @evelant mentioned:

It appears that sentry-expo does not work with EAS on Android with SDK 48

So it goes beyond postPublish not working, and it's a significant breaking change.

evelant commented 1 year ago

@sergioisidoro I force upgraded the dependencies with pnpm overrides and it does not fix the issue. EAS build still fails to integrate the sentry sdk correctly resulting in no source maps being uploaded.

evelant commented 1 year ago

I went through the code here and as far as I can tell it's setting up the sentry SDK correctly. I must have missed something or the issue is more subtle. @kbrandwijk when you have a chance could you look at this issue with eas build + sourcemaps on android?

kbrandwijk commented 1 year ago

This was fixed in sentry-expo@6.1.0.

RRaideRR commented 1 year ago

Unfortunately, I cannot get it running for Android (iOS works however). I took this sample app and updated my dependencies to match the latest Expo SDK 48 release. In addition, I'm also using the url parameter because I have my own Sentry server. The source maps are not uploaded for Android eas builds.

I can see "Upload Debug Symbols to Sentry" in my fastlane logs but not in my gradle logs.

// Update: Seems like I'm not the only one.

evelant commented 1 year ago

@kbrandwijk It appears that there's still an issue. After upgrading to 6.1.1 source maps are still not uploaded on Android.

rcugut commented 1 year ago

same problem after update: sourcemaps are not uploading for Android, but they are uploading for iOS.

erzaehlsalex commented 1 year ago

What was the reason that this was closed? I cannot find an answer here how do deal with that. :( Or is there already a solution which was not mentioned here?

dhcmega commented 12 months ago

Hi, I'm on SDK48 with "sentry-expo": "~6.2.0" (6.2.2 installed), and source maps are being uploaded. Sentry is not reporting tho, but that might be another problem.