Screenshots

Learn more about taking screenshots when an error occurs. Sentry pairs the screenshot with the original event, giving you additional insight into issues.

Sentry makes it possible to automatically take a screenshot and include it as an attachment when a user experiences an error, an exception or a crash.

This feature is only available for SDKs with a user interface, like the ones for mobile and desktop applications. It's also limited by whether taking a screenshot is possible or not. For example, in some environments, like native iOS, taking a screenshot requires the UI thread, which often isn't available in the event of a crash. Another example where a screenshot might not be available is when the event happens before the screen starts to load. So inherently, this feature is a best effort solution.

App hang events won't have a screenshot because the main thread is blocked and Sentry can't interact with UI elements in a background view.

Because screenshots may contain PII, they are an opt-in feature. You can enable screenshots as shown below:

Copied
import Sentry

SentrySDK.start { options in
  options.attachScreenshot = true
}

Requires Cocoa SDK version 8.27.0 or higher.

The beforeCaptureScreenshot also allows you to customize the behavior based on event data, so you can decide when to capture a screenshot and when not to. The callback doesn't work for crash events.

Copied
import Sentry

SentrySDK.start { options in
    options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
    options.beforeCaptureScreenshot = { event in
        // Return false to not capture a screenshot for the event.
        return false
    }
}

If one is available, you'll see a thumbnail of the screenshot when you click on a specific issue from the Issues page.

Screenshot Thumbnail

Once you've clicked on the event ID of a specific issue, you'll be able to see an overview of all the attachments as well as associated events in the "Attachments" tab.

Screenshots List Example

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").