sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Add BeforeCaptureCallback - Screenshot

Open thinkocapo opened this issue 2 years ago • 6 comments

Problem Statement

https://docs.sentry.io/platforms/apple/guides/ios/enriching-events/screenshots/ does not have it.

SDK's Screenshot feature does not have the callback setBeforeScreenshotCaptureCallback

Users want to decide if they want to send the screenshot or not, based on data from the event in the callback (event,hint,debounce).

Solution Brainstorm

Add the callback function as a feature, like how Android SDK has it. https://docs.sentry.io/platforms/android/enriching-events/screenshots/

Are you willing to submit a PR?

No response

thinkocapo avatar Jul 11 '23 08:07 thinkocapo

Related to https://github.com/getsentry/team-mobile/issues/135.

philipphofmann avatar Jul 11 '23 08:07 philipphofmann

Currently, we can only pass a little context into this callback except for the captured event, which doesn't tell the user much about for which screen the SDK is capturing the screenshot. This feature will be easier to implement once we have report current screen in the app context, which is on our roadmap. Then the user knows for which screen we are capturing the screenshot, and they can better decide which ones to keep and which to throw away.

philipphofmann avatar Jul 12 '23 12:07 philipphofmann

We should follow Android implementation:

https://docs.sentry.io/platforms/android/enriching-events/viewhierarchy/#customize-view-hierarchy-capturing https://docs.sentry.io/platforms/android/enriching-events/screenshots/#customize-screenshot-capturing

brustolin avatar Nov 29 '23 13:11 brustolin

Wrt. https://github.com/getsentry/sentry-cocoa/issues/3137#issuecomment-1632415873 - we need to make sure that at the time of the callback, the screen/view info is already available in the event, otherwise this can't be used for filtering. Also, this is another data point that https://github.com/getsentry/sentry-cocoa/issues/2325 (hints support) is valuable.

kahest avatar Nov 29 '23 13:11 kahest

We are in the POC stage, evaluating sentry's SaaS solution.

A critical requirement for us is the ability to filter iOS screenshots by specific screens. Currently, this functionality is lacking, making the screenshot feature impractical for our purposes due to several sensitive screens that shouldn't be captured.

Implementing this feature would significantly enhance the value of using Sentry for us.

ananya-mallik-ps avatar Apr 25 '24 09:04 ananya-mallik-ps

Thanks for your input @ananya-mallik-ps, that's helpful. While I can't give a concrete timeline right now, we will bump priority on this

kahest avatar Apr 25 '24 11:04 kahest