Skip to content

Commit

Permalink
feat(.NET): Screenshots for MAUI (#9120)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes authored Feb 14, 2024
1 parent 4a60351 commit fd4673d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/platforms/dotnet/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ This parameter controls whether integrations should capture HTTP request bodies.

</ConfigKey>

<ConfigKey name="attach-screenshot" supported={["dotnet.xamarin"]}>
<ConfigKey name="attach-screenshot" supported={["dotnet.xamarin", "dotnet.maui"]}>

Takes a screenshot of the application when an error happens and includes it as an attachment.
Learn more about enriching events with screenshots in our <PlatformLink to="/enriching-events/screenshots/">Screenshots documentation</PlatformLink>.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "Screenshots"
description: "Learn more about taking screenshots when an error occurs. Sentry pairs the screenshot with the original event, giving you additional insight into issues."
---

If a user experiences an error, an exception or a crash, Sentry gives you the option to capture a screenshot and include it as an <PlatformLink to="/enriching-events/attachments/">attachment</PlatformLink>.

This feature is only available for SDKs with a user interface, such as the ones for mobile and desktop applications. In some environments like native iOS, taking a screenshot requires the UI thread and in the event of a crash, that might not be available. 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.

## Enabling Screenshots

Because screenshots may contain <PlatformLink to="/data-management/sensitive-data/">PII</PlatformLink>, they are an opt-in feature. You can enable screenshots as shown below:

<PlatformContent includePath="enriching-events/attach-screenshots" />

Capturing a screenshot is a synchronous operation supported on both iOS and Android. For iOS, a UI thread is required.

## Viewing Screenshots

If one is available, you'll see a thumbnail of the screenshot if you click on a specific issue from the [**Issues**](https://demo.sentry.io/issues/) page:

![Screenshot Thumbnail](/platforms/dotnet/guides/xamarin/enriching-events/screenshots/screenshot-thumbnail.png)

Once you've clicked on the event ID of specific issue, you'll also be able to view screenshots from the "Attachments" tab where you'll be able to see attachments, as well as associated events.

![Screenshots List Example](/platforms/dotnet/guides/xamarin/enriching-events/screenshots/screenshot-list-example.png)


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<SignInNote />

```csharp
var builder = MauiApp.CreateBuilder()
.UseMauiApp<App>()
.UseSentry(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.AttachScreenshot = true;
})
```

0 comments on commit fd4673d

Please sign in to comment.