-
-
Notifications
You must be signed in to change notification settings - Fork 220
sdk built-in screenshot feature #422
Changes from all commits
389395b
33ed6ec
49976bd
a96199a
11d87c6
4e5ecc6
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 |
|---|---|---|
|
|
@@ -141,6 +141,22 @@ envelope item, the SDK must discard items larger than the `maxAttachmentSize`. E | |
| useful because attachments could quickly eat up the users' disk space. Furthermore, Relay has a | ||
| [maximum size for attachments](https://docs.sentry.io/product/relay/options/), and we want to reduce unnecessary requests. | ||
|
|
||
| ## Screenshots | ||
|
|
||
| When the user opts-in, if technically possible, take a screenshot of the application and include as an [attachment](#attachments) to the [envelope](/sdk/envelopes/) with the event. | ||
|
|
||
| This feature only applies to SDKs with a user interface, such as Mobile and Desktop. | ||
| In some environments such as native iOS, taking a screenshot requires the UI thread and in the event of a crash, that might not be available. So inherently this feature will be a best effort solution. | ||
| It's advised to provide this feature through a single option called `attachScreenshot`. That's the preferred way but in platforms such as Flutter, a wrapping widget is required so documentation can point users to that instead of the suggested option name. | ||
|
|
||
| The feature is achieved by adding an attachment with: | ||
|
|
||
| * File name `screenshot.jpg` or `screenshot.png` | ||
|
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. should we mention that it should overwrite any existing attachment with that given name during the process of attaching the screenshot?
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. its a good point, or doing a sort of send it once and drop it, so the same attachment won't be attached to every following event
Member
Author
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 think we should just add one and if there's always one added, the front end will just pick one of them. It's an edge case I rather the SDK doesn't have custom code to look for stuff in the attachments list (it can also be added after our check though so it would anwyay be best effort)
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. so if there were 3 events before, the 4th event contains the 3 previous attachments + the new one? I'd say it's burning users' data and it's not that nice.
Member
Author
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. The SDK should add a single attachment when capturing the event. It'll not keep adding to the scope. Each capture includes a fresh screenshot. If the user had already added one manually with the same name, that's just an edge case I don't think worth spending too many cycles on. |
||
| * Image size, if possible should stay below 2 MB but quality/size could be configurable | ||
bruno-garcia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * `ContentType: image/jpg` or `ContentType: image/png` | ||
bruno-garcia marked this conversation as resolved.
Show resolved
Hide resolved
Member
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. Any particular reason why we need the
Member
Author
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. At the end we didn't rely on it at all for the preview. It's just file extension and file name. ContentType was @mitsuhiko's idea so maybe he can help us with a direction here
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. If no content type is set then sentry will try to guess it. I would generally prefer we send the content type explicitly. |
||
|
|
||
| Whenever possible, avoid adding the attachment altogether if taking the screenshot fails. Alternatively, when streaming, it's possible the envelope header was already flushed through before the attempt to take the screenshot happens. In this case, a 0 byte attachment will be included. In that case, Sentry will not show a screenshot preview. | ||
|
|
||
| ## Before-Send Hook | ||
|
|
||
| Hook called with the event (and on some platforms the hint) that allow the user to decide whether an event should be sent or not. This can also be used to further modify the event. | ||
|
|
||
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.
My suggestion.
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.
instead of checking the event level, I'd rather consider if its an errored or crashed event via exception list/mechanism, that's how it works for session, maybe we do the same? https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/SentryEvent.java#L223-L249
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.
Similar to
attachStacktraceI was hoping we'd attach the screenshot on all events.Perhaps we should consider a
shouldAttachScreenshotcallback that receives the event as an argument?If the callback is
nullwe always attach, but it gives the user a chance to configure things like: only attach on unhandled exception or other use casesThere 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 guess we have to give the user a chance to not add the screenshot (either via callback or only for more important events) since we also detect events automatically and taking SS is visible by the user (the screen kinda flashes out for a few millis)
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.
Seems reasonable to make it very clear and intentional when screenshots (in the order of megabytes) go out of the SDK to avoid excessive data consumption.
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.
Agree with this. Lets consider this a second iteration.