Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Conversation

@bruno-garcia
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Aug 31, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sentry/develop/7UU9SLzvChtrqDCgMYDxU9eWJFj4
✅ Preview: https://develop-git-sdk-screenshot-built-in-feature.sentry.dev

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.
It's advised to provide this feature through a single option called `attachScreenshot`. That's a 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Furthermore, if `attachScreenshot` is enabled, the SDK should attach screenshots to events with levels higher or equal to error, to avoid attaching screenshots to debug/info events (the same could be configurable).

My suggestion.

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to attachStacktrace I was hoping we'd attach the screenshot on all events.
Perhaps we should consider a shouldAttachScreenshot callback that receives the event as an argument?
If the callback is null we always attach, but it gives the user a chance to configure things like: only attach on unhandled exception or other use cases

Copy link
Contributor

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)

Copy link
Contributor

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.

Copy link
Member Author

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.


The feature is achieved by adding an attachment with:

* File name `screenshot.jpg` or `screenshot.png`
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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)

Copy link
Contributor

@marandaneto marandaneto Sep 9, 2021

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Seems that clarification around when to send (always/once, all events/only errors or crashes, ...) and how to avoid excessive data consumption are still WIP?

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.
It's advised to provide this feature through a single option called `attachScreenshot`. That's a 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.

Copy link
Contributor

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.


## Screenshots

When the user opts-in, if technically possible, take a screenshot of the application and include as an [attachments](#attachments) to the [envelope](/sdk/envelopes/) with the event.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When the user opts-in, if technically possible, take a screenshot of the application and include as an [attachments](#attachments) to the [envelope](/sdk/envelopes/) with the event.
When the user opts-in, if technically possible, take a screenshot of the application and include it as an [attachments](#attachments) to the [envelope](/sdk/envelopes/) with the event.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to add a note on PII.

Co-authored-by: Rodolfo Carvalho <[email protected]>
Co-authored-by: Abhijeet Prasad <[email protected]>
Co-authored-by: Rodolfo Carvalho <[email protected]>

* File name `screenshot.jpg` or `screenshot.png`
* Image size, if possible should stay below 2 MB but quality/size could be configurable
* `ContentType: image/jpg` or `ContentType: image/png`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason why we need the ContentType? Does relay/the sentry product treat this differently>

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

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

@bruno-garcia bruno-garcia merged commit 2cf5e65 into master Mar 11, 2022
@bruno-garcia bruno-garcia deleted the sdk/screenshot-built-in-feature branch March 11, 2022 00:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants