-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update Sentry sdk to v2.0 #11302
Update Sentry sdk to v2.0 #11302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code for this looks good (I left one minor comment)
But I'm hitting a couple of issues that are concerning:
I'm not seeing any events coming in Sentry when I build and run the app in release mode, even if I override the shouldEnableCrashLogging
callback. It seems to work fine in development mode on-device though if I do the same. Are you seeing the same issue?
Does this configuration support multi-dex? I noted that the config suggestion from the docs wasn't present here – will that matter?
Let me know, and thanks!!
@@ -33,7 +41,7 @@ class CrashLoggingUtils { | |||
} | |||
|
|||
@JvmStatic fun stopCrashLogging() { | |||
Sentry.clearContext() | |||
Sentry.clearBreadcrumbs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need to clear the breadcrumbs if we're closing down Sentry – in the older version clearing out the context would tear down Sentry completely so that we could re-init it later.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good question 😄.
Just a bit of context. When I was looking for an alternative to .clearContext()
I couldn't find any equivalent method in the v2.0 Sentry sdk.
Then, I checked what that method was doing inside to see if I could find an equivalent logic. By doing so I bumped into the v1.X implementation, which internally is calling this method contextManager.clear()
:
# v1.X
public synchronized void clear() {
setLastEventId(null);
clearBreadcrumbs();
clearUser();
clearTags();
clearExtra();
}
Since my thought was to preserve the behavior, I tried to see if the v2.0 sdk contained methods to clear those values, but the only one I could find is clearBreadcrumbs()
.
However, I'm having second thoughts since you well pointed out that clearContext()
would tear down Sentry completely.
🤔 I would say that just calling clearBreadcrumbs()
doesn't add any value. So I think we can remove that line of code (L44).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great!
@jkmassel Answering your other questions here :)
I am going to run the release build and have a look.
I missed that bit in the docs, not sure how. Anyway, We definitely use multidex in the project, but we haven't set up any rules for the release yet using: |
Sorry for my late response, regarding events coming in Sentry when building the release. Yes, I do see the log messages from Sentry when running the release build:
What's the configuration on your side? Did you update the Also, the crashes go through and I can see them in the Sentry web console. |
It's working now! I think it might've been something to do with our production credentials system – I re-applied them and was able to get it consistently working. Sorry about that!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works! Merging.
Title: Update Sentry SDK to v2.0 Release Candidate
Issue: Making progress the against Encrypting Logs Issue #10698
Description:
We want to be able to link Sentry events (unhandled or caught exceptions) to future Encrypted logs we are gonna submit to Wordpress API.
This PR allows us to attach additional information to any Sentry event before it gets sent to Sentry server.
Why not using Sentry v1.X? Because there is a race condition when sending the event for caught exceptions. If we try to attach additional data or tags or anything before the event is sent, it seems the logic is not waiting for the info to be attached and sends the event anyway without it.
Why V2.0? With Sentry v2.0, we gain the ability to update the event with the future UUID we are going to generate in the next PR. E.g.
Testing instructions:
Enable CrashLogging momentarily for your
Debug
build by doing the followingBuild the project, deploy the app nd check out the logcat to see if the following messages are displayed:
If there are no other errors, then it should be fine.
If we attach info to events, how is it gonna look like? Let's see a dummy
Logs
id sent as Additional DataPR submission checklist:
RELEASE-NOTES.txt
if necessary.