Repository navigation
feat(callbacks): [Callback Errors Optional Addon] Add opt-in strict callback mode #6173
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
base: main
Are you sure you want to change the base?
Changes from all commits
468abd9
28af8f2
d689526
fa3ca45
434e1db
8b3c3fa
aa17ea5
6d07426
8a06fde
9320f73
60d1e15
2c84527
aa15164
49f8b9c
b62c094
efb5dfb
7a471df
8845736
44ed7c6
fcbf95f
154d94e
d11680e
425a6b1
835c0d2
2a38eeb
0954682
23b58bd
0414429
a2b4847
9ef9efd
518d48a
7fd012e
4916a15
38bf38c
4d44b53
15cc695
97cd7e2
287418b
92968ab
e87fddf
5d674d6
0b922a6
dea8dbc
64c1c55
75338f5
b692e97
5b0d221
136073f
dfb67ed
92e9ef5
598c1dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ | |
| import android.graphics.Bitmap; | ||
| import android.view.View; | ||
| import io.sentry.Attachment; | ||
| import io.sentry.EventProcessor; | ||
| import io.sentry.Hint; | ||
| import io.sentry.SentryEvent; | ||
| import io.sentry.SentryLevel; | ||
|
|
@@ -18,6 +17,7 @@ | |
| import io.sentry.android.replay.util.MaskRenderer; | ||
| import io.sentry.android.replay.util.ViewsKt; | ||
| import io.sentry.android.replay.viewhierarchy.ViewHierarchyNode; | ||
| import io.sentry.internal.eventprocessor.SentryEventProcessor; | ||
| import io.sentry.protocol.SentryTransaction; | ||
| import io.sentry.util.HintUtils; | ||
| import io.sentry.util.Objects; | ||
|
|
@@ -34,7 +34,7 @@ | |
| * captured. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public final class ScreenshotEventProcessor implements EventProcessor { | ||
| public final class ScreenshotEventProcessor implements SentryEventProcessor { | ||
|
|
||
| private final @NotNull SentryAndroidOptions options; | ||
| private final @NotNull BuildInfoProvider buildInfoProvider; | ||
|
|
@@ -112,7 +112,21 @@ private boolean isMaskingEnabled() { | |
| final @Nullable SentryAndroidOptions.BeforeCaptureCallback beforeCaptureCallback = | ||
| options.getBeforeScreenshotCaptureCallback(); | ||
| if (beforeCaptureCallback != null) { | ||
| if (!beforeCaptureCallback.execute(event, hint, shouldDebounce)) { | ||
| try { | ||
| if (!beforeCaptureCallback.execute(event, hint, shouldDebounce)) { | ||
| return event; | ||
| } | ||
| } catch (Exception | Error e) { | ||
| io.sentry.util.CallbackUtils.rethrowIfStrictCallbackMode(options, e); | ||
| if (e instanceof Error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always agree with narrowing the number of swallowed errors. That being said, this would be a breaking change to consumers since we will now throw an exception that we previously did not catch. That's fine if we do this in a major, otherwise if we want to do this in a minor, we should discuss! Also, if the goal of this is to rethrow unrecoverable errors, we created |
||
| throw (Error) e; | ||
| } | ||
| options | ||
| .getLogger() | ||
| .log( | ||
| SentryLevel.ERROR, | ||
| "The beforeScreenshotCapture callback threw an exception. Skipping screenshot capture.", | ||
| e); | ||
| return event; | ||
| } | ||
| } else if (shouldDebounce) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ public boolean dispatchTouchEvent(final @Nullable MotionEvent motionEvent) { | |
| try { | ||
| handleTouchEvent(copy); | ||
| } catch (Throwable e) { | ||
| io.sentry.util.ExceptionUtils.maybeRethrow(e); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: import (here and elsewhere in the PR) |
||
| if (options != null) { | ||
| options.getLogger().log(SentryLevel.ERROR, "Error dispatching touch event", e); | ||
| } | ||
|
|
||
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.
what does this mean?
It just isn't clear since it seems to contradict the previous sentence. maybe adding "Otherwise..." would help clarify.
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 agree this entry needs a bit of polishing, it's difficult to grasp. E.g. I'd split the option into proper code snippets with language markers, so it doesn't read as a wall of text