Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Sentry for Mobile #21682

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft

Conversation

ilmotta
Copy link
Contributor

@ilmotta ilmotta commented Nov 26, 2024

Fixes: #21656

Summary

In this PR we integrate Sentry and implement a feature flagged feature (disabled by default) to force crash the app using the function mobile/status.go#IntendedPanic() provided by status-go.

PR is waiting for #21706 to be resolved for this one to be taken out of draft.

Review notes

Documentation about Sentry in status-go: https://github.com/status-im/status-go/blob/3466ac2661bb19cd0eaa27761551de3b4d31b393/internal/sentry/README.md#L60

Areas that may be impacted

Whenever a panic happens in status-go and usage data collection is enabled we will send error data to Sentry. In theory, nothing should change for the user, therefore nothing should be visibly different in the app's behavior.

Steps to test

Before following the steps below, the CI must be configured with the appropriate SENTRY_DSN_STATUS_GO value. You can also use a free tier cloud instance to do your own testing in case you want to play around with Sentry.

  1. Login with any profile.
  2. Enable usage data collection (for now, Sentry and analytics are tied to the same setting in status-go).
  3. Go to Settings > Feature flags and enable app-monitoring > intentional-crash
  4. Go to Settings > Advanced > and press on Force crash immediately

Usually you should see the error in the Sentry dashboard in a matter of seconds.

status: ready

@ilmotta ilmotta self-assigned this Nov 26, 2024
@ilmotta ilmotta requested a review from jakubgs as a code owner November 26, 2024 10:12
@ilmotta ilmotta marked this pull request as draft November 26, 2024 10:12
@status-im-auto
Copy link
Member

status-im-auto commented Nov 26, 2024

Jenkins Builds

Click to see older builds (72)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ ce51060 #1 2024-11-26 10:17:49 ~4 min tests 📄log
✔️ ce51060 #1 2024-11-26 10:21:12 ~8 min android-e2e 🤖apk 📲
✔️ ce51060 #1 2024-11-26 10:21:34 ~8 min android 🤖apk 📲
✔️ ce51060 #1 2024-11-26 10:22:22 ~9 min ios 📱ipa 📲
✔️ 3fc9ea1 #2 2024-12-02 11:38:01 ~4 min tests 📄log
✔️ 3fc9ea1 #2 2024-12-02 11:41:27 ~7 min android-e2e 🤖apk 📲
✔️ 3fc9ea1 #2 2024-12-02 11:41:59 ~8 min android 🤖apk 📲
3fc9ea1 #2 2024-12-02 11:43:48 ~10 min ios 📄log
✔️ dd61539 #4 2024-12-02 22:55:19 ~4 min tests 📄log
✔️ dd61539 #4 2024-12-02 22:57:49 ~7 min ios 📱ipa 📲
✔️ dd61539 #4 2024-12-02 22:58:44 ~7 min android-e2e 🤖apk 📲
✔️ dd61539 #4 2024-12-02 22:59:25 ~8 min android 🤖apk 📲
✔️ bb16070 #6 2024-12-06 12:54:50 ~4 min tests 📄log
✔️ bb16070 #6 2024-12-06 12:57:30 ~6 min ios 📱ipa 📲
✔️ bb16070 #6 2024-12-06 12:59:37 ~9 min android-e2e 🤖apk 📲
✔️ bb16070 #6 2024-12-06 13:01:11 ~10 min android 🤖apk 📲
✔️ e342290 #8 2024-12-09 11:31:32 ~4 min tests 📄log
✔️ e342290 #8 2024-12-09 11:34:25 ~7 min ios 📱ipa 📲
✔️ e342290 #8 2024-12-09 11:35:27 ~8 min android-e2e 🤖apk 📲
✔️ e342290 #8 2024-12-09 11:37:40 ~10 min android 🤖apk 📲
✔️ 98318b5 #9 2024-12-09 14:41:14 ~6 min tests 📄log
✔️ 98318b5 #9 2024-12-09 14:43:44 ~8 min android 🤖apk 📲
✔️ 98318b5 #9 2024-12-09 14:44:13 ~9 min android-e2e 🤖apk 📲
✔️ 98318b5 #9 2024-12-09 14:44:39 ~9 min ios 📱ipa 📲
✔️ a2f986a #10 2024-12-09 14:55:20 ~6 min tests 📄log
✔️ a2f986a #10 2024-12-09 14:57:36 ~9 min ios 📱ipa 📲
✔️ a2f986a #10 2024-12-09 14:59:10 ~10 min android-e2e 🤖apk 📲
✔️ a2f986a #10 2024-12-09 14:59:53 ~11 min android 🤖apk 📲
✔️ 52cbdf2 #11 2024-12-09 16:09:28 ~5 min tests 📄log
✔️ 52cbdf2 #11 2024-12-09 16:12:14 ~8 min android-e2e 🤖apk 📲
✔️ 52cbdf2 #11 2024-12-09 16:12:17 ~8 min ios 📱ipa 📲
✔️ 52cbdf2 #11 2024-12-09 16:12:32 ~8 min android 🤖apk 📲
✔️ 1d3e0be #12 2024-12-09 17:38:57 ~4 min tests 📄log
✔️ 1d3e0be #12 2024-12-09 17:41:03 ~6 min ios 📱ipa 📲
✔️ 1d3e0be #12 2024-12-09 17:42:07 ~7 min android-e2e 🤖apk 📲
✔️ 1d3e0be #12 2024-12-09 17:42:47 ~8 min android 🤖apk 📲
3060ceb #13 2024-12-10 09:41:38 ~3 min tests 📄log
✔️ 3060ceb #13 2024-12-10 09:45:19 ~7 min ios 📱ipa 📲
✔️ 3060ceb #13 2024-12-10 09:47:21 ~9 min android-e2e 🤖apk 📲
✔️ 3060ceb #13 2024-12-10 09:47:51 ~9 min android 🤖apk 📲
✔️ ffda450 #14 2024-12-10 10:01:58 ~4 min tests 📄log
✔️ ffda450 #14 2024-12-10 10:05:47 ~8 min android-e2e 🤖apk 📲
✔️ ffda450 #14 2024-12-10 10:06:19 ~8 min android 🤖apk 📲
✔️ ffda450 #14 2024-12-10 10:08:44 ~11 min ios 📱ipa 📲
✔️ 5e1ba63 #15 2024-12-10 11:00:39 ~5 min tests 📄log
✔️ 5e1ba63 #15 2024-12-10 11:04:38 ~9 min android-e2e 🤖apk 📲
✔️ 5e1ba63 #15 2024-12-10 11:05:15 ~9 min android 🤖apk 📲
✔️ 5e1ba63 #15 2024-12-10 11:17:11 ~21 min ios 📱ipa 📲
✔️ 81c9ee2 #16 2024-12-10 18:56:00 ~4 min tests 📄log
✔️ 81c9ee2 #16 2024-12-10 18:59:05 ~7 min android 🤖apk 📲
✔️ 81c9ee2 #16 2024-12-10 19:00:34 ~8 min ios 📱ipa 📲
✔️ 81c9ee2 #16 2024-12-10 19:01:31 ~9 min android-e2e 🤖apk 📲
✔️ bf616e1 #17 2024-12-10 20:23:52 ~5 min tests 📄log
✔️ bf616e1 #17 2024-12-10 20:25:58 ~7 min ios 📱ipa 📲
✔️ bf616e1 #17 2024-12-10 20:28:04 ~9 min android-e2e 🤖apk 📲
✔️ bf616e1 #17 2024-12-10 20:28:46 ~10 min android 🤖apk 📲
✔️ 5f4710b #18 2024-12-10 20:42:06 ~4 min tests 📄log
✔️ 5f4710b #18 2024-12-10 20:43:44 ~6 min android-e2e 🤖apk 📲
✔️ 5f4710b #18 2024-12-10 20:44:09 ~6 min ios 📱ipa 📲
✔️ 5f4710b #18 2024-12-10 20:45:52 ~8 min android 🤖apk 📲
✔️ 0f334a7 #19 2024-12-10 21:02:19 ~4 min tests 📄log
✔️ 0f334a7 #19 2024-12-10 21:06:04 ~7 min ios 📱ipa 📲
✔️ 0f334a7 #19 2024-12-10 21:07:29 ~9 min android-e2e 🤖apk 📲
✔️ 0f334a7 #19 2024-12-10 21:09:17 ~11 min android 🤖apk 📲
✔️ 0c0c236 #22 2024-12-12 04:08:39 ~4 min tests 📄log
✔️ 0c0c236 #22 2024-12-12 04:11:16 ~6 min ios 📱ipa 📲
✔️ 0c0c236 #22 2024-12-12 04:12:44 ~8 min android-e2e 🤖apk 📲
✔️ 0c0c236 #22 2024-12-12 04:13:12 ~8 min android 🤖apk 📲
✔️ 7bdbc7c #23 2024-12-12 05:02:04 ~4 min tests 📄log
✔️ 7bdbc7c #23 2024-12-12 05:04:49 ~7 min android-e2e 🤖apk 📲
✔️ 7bdbc7c #23 2024-12-12 05:04:54 ~7 min ios 📱ipa 📲
✔️ 7bdbc7c #23 2024-12-12 05:06:14 ~8 min android 🤖apk 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 7f8ffcf #24 2024-12-12 05:20:47 ~5 min tests 📄log
✔️ 7f8ffcf #24 2024-12-12 05:22:18 ~6 min android-e2e 🤖apk 📲
✔️ 7f8ffcf #24 2024-12-12 05:22:46 ~7 min ios 📱ipa 📲
✔️ 7f8ffcf #24 2024-12-12 05:26:14 ~10 min android 🤖apk 📲
✔️ 6039a40 #25 2024-12-12 05:36:21 ~4 min tests 📄log
✔️ 6039a40 #25 2024-12-12 05:38:44 ~7 min ios 📱ipa 📲
✔️ 6039a40 #25 2024-12-12 05:39:02 ~7 min android 🤖apk 📲
✔️ 6039a40 #25 2024-12-12 05:39:32 ~7 min android-e2e 🤖apk 📲

@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch from ce51060 to 3fc9ea1 Compare December 2, 2024 11:33
@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch 2 times, most recently from 4d06118 to dd61539 Compare December 2, 2024 22:50
@ilmotta ilmotta marked this pull request as ready for review December 2, 2024 22:50
@ilmotta ilmotta changed the title [DRAFT] Configure Sentry for Mobile [DO NOT MERGE] Configure Sentry for Mobile Dec 2, 2024
@ilmotta ilmotta marked this pull request as draft December 3, 2024 00:58
@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch from dd61539 to 86d99cd Compare December 6, 2024 12:47
@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 6, 2024

@siddarthkay @markoburcul this PR should be ready now to be used for testing the full integration with Sentry. In theory, the only thing needed is to set the value of SENTRY_DSN_STATUS_GO in Jenkins and things should work.

  1. I cherry-picked the infra code from ci: enable sentry for releases #21766
  2. I temporarily enabled the Advanced Settings option to allow devs and QAs to force crash the app to see errors in Sentry.
  3. I think we don't need to add vars SENTRY_CONTEXT_NAME or SENTRY_CONTEXT_VERSION to shadow-cljs.edn because we only need to do that when we need to pass env vars via the Clojure runtime, but since these vars are used directly by status-go build process they shouldn't be needed. I can be wrong here :)

Edit: after this PR is tested successfully I will remove the cherry-picked commit and disable the option to force crash from any build.

@siddarthkay
Copy link
Contributor

@ilmotta : regarding point 3, ah yeah we don't need that in @markoburcul 's commit we pass those vars to status-go which is where it matters.

@markoburcul
Copy link

@ilmotta did you test this with the changes from my PR?

@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 9, 2024

@ilmotta did you test this with the changes from my PR?

Sure I did, I cherry picked the single commit from https://github.com/status-im/status-mobile/pull/21766/commits. Local dev builds work, I just tested again https://sentry.infra.status.im/organizations/sentry/issues/142/?project=7&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=14d&stream_index=0

One problem for sure is that running make release-android is not passing through the value of SENTRY_DSN_STATUS_GO to the Clojure compiler.

I pushed a commit just now updating scripts/build-android.sh to add SENTRY_DSN_STATUS_GO to SECRETS_ENV_VARS.

@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 9, 2024

From the screenshot below, we see Sentry DSN is not set in the latest PR build.

@markoburcul
Copy link

From the screenshot below, we see Sentry DSN is not set in the latest PR build.

Sentry DSN will be set only on release builds. Can you run manual pipeline with BUILD_TYPE=release from your branch?

@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 9, 2024

Sentry DSN will be set only on release builds. Can you run manual pipeline with BUILD_TYPE=release from your branch?

Makes sense for now 👍🏼 Hopefully not too far in the future away we can set-up a Sentry project to work with non-release builds, because that can be quite helpful as well.

@markoburcul the manual job is failing https://ci.infra.status.im/job/status-mobile/job/manual/. I ran it twice with the correct parameters https://ci.infra.status.im/job/status-mobile/job/manual/340/parameters/, but could you take a look please? The iOS step is failing, then we can't get the up-to-date artifact to test.

@markoburcul
Copy link

@markoburcul the manual job is failing https://ci.infra.status.im/job/status-mobile/job/manual/. I ran it twice with the correct parameters https://ci.infra.status.im/job/status-mobile/job/manual/340/parameters/, but could you take a look please? The iOS step is failing, then we can't get the up-to-date artifact to test.

As @siddarthkay said: update VERSION file to 2.32.PRNUMBER since you are getting the error:

[2024-12-09T13:00:19.749Z]  [Application Loader Error Output]: ERROR: [ContentDelivery.Uploader] Asset validation failed (90478) Invalid Version. The build with the version “2.31.0” can’t be imported because a later version has been closed for new build submissions. Choose a different version number. (ID: 18438730-87e6-4a68-af5b-f0e2423be47d)

@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch 2 times, most recently from 98318b5 to a2f986a Compare December 9, 2024 14:48
@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 9, 2024

@markoburcul the SENTRY_DSN_STATUS_GO var is still not being injected correctly.

The manual release build in Jenkins was successful this time https://ci.infra.status.im/job/status-mobile/job/manual/342/. Thanks for the help

After trying out the manual release APK generated from Jenkins, you can see in the screenshots below that the Sentry DSN isn't set and that the app is using the expected commit hash used by the Jenkins build.

@markoburcul
Copy link

After trying out the manual release APK generated from Jenkins, you can see in the screenshots below that the Sentry DSN isn't set and that the app is using the expected commit hash used by the Jenkins build.

I've updated my PR, I think it should work now..

@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch from a2f986a to 52cbdf2 Compare December 9, 2024 16:03
@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 9, 2024

After trying out the manual release APK generated from Jenkins, you can see in the screenshots below that the Sentry DSN isn't set and that the app is using the expected commit hash used by the Jenkins build.

I've updated my PR, I think it should work now..

@markoburcul no luck yet. I cherry picked commit b62ae9e, but the env var is still not available.

@igor-sirotin
Copy link
Contributor

Makes sense for now 👍🏼 Hopefully not too far in the future away we can set-up a Sentry project to work with non-release builds, because that can be quite helpful as well.

@ilmotta Actually it was the intention to keep it only for release builds for now.
But let's discuss it after the release, we can extend it on easily, all parameters are already in place 👌

shadow-cljs.edn Outdated Show resolved Hide resolved
@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch 3 times, most recently from bf616e1 to 5f4710b Compare December 10, 2024 20:36
@ilmotta ilmotta changed the title [DO NOT MERGE] Configure Sentry for Mobile Configure Sentry for Mobile Dec 10, 2024
@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch from 5f4710b to 0f334a7 Compare December 10, 2024 20:57
@ilmotta ilmotta marked this pull request as ready for review December 10, 2024 20:57
@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 10, 2024

PR is ready to be reviewed again @siddarthkay @markoburcul. I removed all temporary workarounds I did to be able to test release builds from the CI, meaning the Sentry option to force crash the app is NOT available in release builds. I think it's better if we close PR #21766 and merge only this one because this one I tested the actual integration with Sentry.

Example from an error reported now to Sentry from a release built from the CI:


@churik do you want this PR to go through QA? I ask this because I already tested this PR with a release builds from https://ci.infra.status.im/job/status-mobile/job/manual/ and with the feature flag enabled so that the crash button was accessible. After pressing on the crash button Sentry receives the error event as expected. I also tested that when the user disables analytics tracking we are not sending errors to Sentry.

@ilmotta ilmotta requested a review from a team December 10, 2024 21:15
@igor-sirotin
Copy link
Contributor

igor-sirotin commented Dec 11, 2024

@ilmotta @siddarthkay looks like environment and release are missing 🤔

image
  1. environment should be there, if SENTRY_PRODUCTION=1 is defined during status-go build.
  2. release is a weird missing one, it should have been auto-embedded during build. So nothing new should have been defined for it to work. Perhaps something is wrong with the build stage and now status-go doesn't have correct version.Version.
    https://github.com/status-im/status-go/blob/233f2f9a2afaf81e459f0025e390a6e58964ea5c/internal/sentry/sentry.go#L50

@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch 2 times, most recently from 0c0c236 to 7bdbc7c Compare December 12, 2024 04:57
@ilmotta ilmotta force-pushed the ilmotta/add-sentry-support branch from 7f8ffcf to 6039a40 Compare December 12, 2024 05:31
@churik
Copy link
Member

churik commented Dec 12, 2024

If I understand correctly, the iOS builds that appeared in TestFlight were intended for testing these changes.

However, by mistake, several QAs installed that build during release testing, and both noted that messaging was slowed down in this build compared to the release version.

So, please hold off on pushing this. Let’s not include it in 2.32.

cc @ilmotta @igor-sirotin

@ilmotta
Copy link
Contributor Author

ilmotta commented Dec 12, 2024

Heads up, based on conversations with @churik and @igor-sirotin, although this PR shouldn't affect the app's behavior in any way, we believe it's better to integrate Sentry in a follow-up release, e.g. 2.32.1.

@ilmotta ilmotta marked this pull request as draft December 12, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: CONTRIBUTOR
Status: No status
Development

Successfully merging this pull request may close these issues.

Configure status-go to use Sentry
7 participants