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

[MAUI] Make it possible to programmatically decide whether to attach a screenshot or not #3353

Open
vecalion opened this issue May 7, 2024 · 2 comments

Comments

@vecalion
Copy link

vecalion commented May 7, 2024

Problem Statement

Something like BeforeCaptureCallback in the Android version (https://docs.sentry.io/platforms/android/enriching-events/screenshots/).

There are two reasons why I'm interested in this feature:

  1. Screenshots of some parts of the app may contain private information that is not supposed to be seen by the team monitoring issues in Sentry.
  2. There is no need to have screenshots for handled exceptions because in our case, they don't add any new information. However, since they are quite heavy, they generate a lot of unnecessary traffic for users.

Solution Brainstorm

No response

@jamescrosswell
Copy link
Collaborator

Hi @vecalion ,

If you don't want screenshots at all, it is possible to turn these off in the options when initialising the SDK.

Alternatively, the screenshots for an event are available (and can be altered) via the Hint parameter in the SetBeforeSend callback:

                options.AttachScreenshot = true;
                options.SetBeforeSend((@event, hint) =>
                {
                    hint.Attachments.Clear();
                    return @event;
                });

@bitsandfoxes
Copy link
Contributor

Thanks for the workarounds @jamescrosswell.
If we wanted to prevent the overhead of actually creating the screenshot and only then make a decision to discard it I think we need to add a BeforeCaptureScreenshot callback to the options and invoke it here:

public SentryEvent? Process(SentryEvent @event, SentryHint hint)
{
hint.Attachments.Add(new ScreenshotAttachment(_options));
return @event;
}

@bitsandfoxes bitsandfoxes added the Good First Issue Good for newcomers label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: No status
Development

No branches or pull requests

3 participants