#Using BeforeSend to filter out Screenshots for certain Views in MAUI and Xamarin Forms SDKs

13 messages · Page 1 of 1 (latest)

velvet haven
#

Is it possible to exclude certain views from Screenshot attachment when using the MAUI and Xamarin Forms SDKs?

glass ridge
#

there is a SetBeforeScreenshotCapture option for MAUI that has not been release yet:
https://github.com/getsentry/sentry-dotnet/issues/3353
https://github.com/getsentry/sentry-dotnet/pull/3661

GitHub

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 ...

GitHub

Relevant to #3353, I added a option to have a callback just before attaching a screenshot.
Note
I didn't had a closing keyword to this PR, as I don't believe that change alone fixes...

#

there isnt the plan to add the option to xamarin forms just yet, you can try to use the workaround as in the issue above

velvet haven
#

I was just reading the workaround. Can we see what type the View is from the hint argument?

glass ridge
#

you can inspect the event object

velvet haven
#

Cool, Thanks

glass ridge
#

im not super familiar with MAUI to give a more precise code example

velvet haven
#

That's fine

glass ridge
#

basically the event object in beforeSend is the event you see in your Sentry project

karmic cobalt
novel niche
#

as Bruno mentioned it won't be available until the next release, but the way you'll be able to use it is by adding an option: ``` options.SetBeforeScreenshotCapture((@event, hint) =>
{

                // Return true to capture or false to prevent the capture
                return true;
            }); ``` you'll be able to programmatically choose to take a screenshot of not by returning `true` or `false`. I submitted a PR for the documentation so hopefully you'll have the doc for the feature on its release
karmic cobalt