Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions samples/Sentry.Samples.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ protected override void OnCreate(Bundle? savedInstanceState)
// Enable Native Android SDK ANR detection
options.Native.AnrEnabled = true;

// If your app doesn't have sensitive data, you can attach screenshots automatically when a Java/native
// error is captured.
// Note: this only applies to Java-based errors; .NET managed exceptions are not currently supported.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

question: Note for iOS?

Does this Note also apply to both the iOS and Mac Catalyst samples?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Tbh, I can't remember where I copied this from (presumably some documentation for the Android SDK but I can no longer find it).

Let's just remove this line as it's potentially confusing.

To answer your question though, I think yes this would apply to both Android and iOS... it'd to do with the order in which the signal handlers fire and .NET will try to insert it's own signal handler in the queue first so that if an exception occurs in what was, originally, managed code, it gets handled by the .NET exception handler (e.g. a try..catch block). The native SDK that is capturing screenshots (per this setting) will only get activated when capturing native exceptions (i.e. if .NET's signal handler didn't already fire).

@jpnurmi does it sound like I've got that right? You've been going deep down the rabbit hole on this recently...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, with today's signal-handling order, both sentry-native and sentry-cocoa step on the .NET runtime's toes and accidentally handle certain .NET exceptions as fatal.

// https://docs.sentry.io/platforms/android/enriching-events/screenshots/
options.Native.AttachScreenshot = true;

// Currently experimental support is only available on Android
options.Native.ExperimentalOptions.SessionReplay.OnErrorSampleRate = 1.0;
options.Native.ExperimentalOptions.SessionReplay.SessionSampleRate = 1.0;
Expand Down
4 changes: 4 additions & 0 deletions samples/Sentry.Samples.Ios/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary?
// Enable Native iOS SDK App Hangs detection
options.Native.EnableAppHangTracking = true;

// If your app doesn't have sensitive data, you can get screenshots on error events automatically
// https://docs.sentry.io/platforms/apple/guides/ios/configuration/options/#attach-screenshot
options.Native.AttachScreenshot = true;

options.CacheDirectoryPath = Path.GetTempPath();

options.SetBeforeSend(evt =>
Expand Down
4 changes: 4 additions & 0 deletions samples/Sentry.Samples.MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary?
options.Dsn = EnvironmentVariables.Dsn;
#endif
options.Debug = true;

// If your app doesn't have sensitive data, you can get screenshots on error events automatically
// https://docs.sentry.io/platforms/apple/guides/mac-catalyst/configuration/options/#attach-screenshot
options.Native.AttachScreenshot = true;
});

// Try out the Sentry SDK
Expand Down
2 changes: 1 addition & 1 deletion samples/Sentry.Samples.Maui/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static MauiApp CreateMauiApp()
// If you want to see everything we can capture from MAUI, you may wish to use a larger value.
options.MaxBreadcrumbs = 1000;

// Be aware that screenshots may contain PII
// If your app doesn't have sensitive data, you can get screenshots on error events automatically
options.AttachScreenshot = true;

options.Debug = true;
Expand Down
Loading