-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(dotnet): document .NET native options for Android and Apple #16664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jamescrosswell
wants to merge
13
commits into
master
Choose a base branch
from
native-options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+545
−7
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c1e3ba1
chore: Added symlink to AGENTS.md for copilot
jamescrosswell ffc8919
docs(dotnet): document .NET native options for Android and Apple
jamescrosswell 5996c26
Apply suggestions from code review
jamescrosswell 02fc6f5
review feedback
jamescrosswell 2c4b8f9
Fix broken link
jamescrosswell 37a69d4
Fix link
jamescrosswell b23c70a
Tweaked link to apple native options from the guide
jamescrosswell 3f10c0c
Fixed links on MAUI guide
jamescrosswell 2d7962b
Apply suggestions from code review
jamescrosswell d5ad458
Fix link in Android guide
jamescrosswell 39d8a45
Fix anchor
jamescrosswell dbb5bc3
Merge branch 'master' into native-options
jamescrosswell 016ab65
Merge branch 'master' into native-options
jamescrosswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
283 changes: 283 additions & 0 deletions
283
docs/platforms/dotnet/guides/android/configuration/native-options.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,283 @@ | ||
| --- | ||
| title: Android Native Options | ||
| description: "Configure the embedded Sentry Android SDK when using .NET for Android." | ||
| sidebar_order: 10 | ||
| --- | ||
|
|
||
| When you use the .NET for Android integration, Sentry embeds the [Sentry Android SDK](/platforms/android/) to provide native crash reporting and other Android-specific features. The `options.Native` property exposes configuration for this embedded SDK. | ||
|
|
||
| ```csharp | ||
| SentrySdk.Init(options => | ||
| { | ||
| options.Dsn = "___PUBLIC_DSN___"; | ||
|
|
||
| // Native Android SDK options: | ||
| options.Native.AnrEnabled = true; | ||
| options.Native.EnableNdk = true; | ||
| }); | ||
| ``` | ||
|
|
||
| These options are also available in [MAUI](/platforms/dotnet/guides/maui/) when targeting Android. | ||
|
|
||
| ## Application Not Responding (ANR) | ||
|
|
||
| <SdkOption name="Native.AnrEnabled" type="bool" defaultValue="true"> | ||
|
|
||
| Enables detection of [Application Not Responding (ANR)](/platforms/android/configuration/app-not-respond/) events where the main thread is blocked for too long. Enabled by default. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.AnrReportInDebug" type="bool" defaultValue="false"> | ||
|
|
||
| Whether ANR events are reported in debug builds. Disabled by default to avoid noise during development. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.AnrTimeoutInterval" type="TimeSpan" defaultValue="TimeSpan.FromSeconds(5)"> | ||
|
|
||
| How long the main thread must be unresponsive before an ANR event is captured. Default is 5 seconds. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Breadcrumbs | ||
|
|
||
| The Android SDK automatically captures breadcrumbs for various system events. Each category can be enabled or disabled independently. | ||
|
|
||
| <SdkOption name="Native.EnableActivityLifecycleBreadcrumbs" type="bool" defaultValue="true"> | ||
|
|
||
| Adds breadcrumbs for `Activity` lifecycle events (created, started, resumed, paused, stopped, destroyed). | ||
|
|
||
| See [Automatic Breadcrumbs](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableAppComponentBreadcrumbs" type="bool" defaultValue="true"> | ||
|
|
||
| Adds breadcrumbs for `App` component events. | ||
|
|
||
| See [Automatic Breadcrumbs](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableAppLifecycleBreadcrumbs" type="bool" defaultValue="true"> | ||
|
|
||
| Adds breadcrumbs for `App` lifecycle events (foregrounded, backgrounded). | ||
|
|
||
| See [Automatic Breadcrumbs](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableNetworkEventBreadcrumbs" type="bool" defaultValue="true"> | ||
|
|
||
| Adds breadcrumbs when network connectivity changes. | ||
|
|
||
| See [Automatic Breadcrumbs](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableSystemEventBreadcrumbs" type="bool" defaultValue="true"> | ||
|
|
||
| Adds breadcrumbs for system events such as battery state changes, low memory warnings, and timezone changes. | ||
|
|
||
| See [Automatic Breadcrumbs](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableUserInteractionBreadcrumbs" type="bool" defaultValue="true"> | ||
|
|
||
| Adds breadcrumbs when the user interacts with UI elements (taps, swipes, etc.). | ||
|
|
||
| See [Automatic Breadcrumbs](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Performance | ||
|
|
||
| <SdkOption name="Native.EnableAutoActivityLifecycleTracing" type="bool" defaultValue="true"> | ||
|
|
||
| Automatically creates transactions for `Activity` lifecycle events. Requires `TracesSampleRate` or `TracesSampler` to be configured. | ||
|
|
||
| See [Activity Instrumentation](/platforms/android/performance/instrumentation/automatic-instrumentation/#activity-instrumentation). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableActivityLifecycleTracingAutoFinish" type="bool" defaultValue="true"> | ||
|
|
||
| Whether transactions created for Activity lifecycle events finish automatically when the Activity is fully drawn. Requires `EnableAutoActivityLifecycleTracing` to be enabled. | ||
|
|
||
| See [Activity Instrumentation](/platforms/android/performance/instrumentation/automatic-instrumentation/#activity-instrumentation). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableUserInteractionTracing" type="bool" defaultValue="false"> | ||
|
|
||
| Automatically creates traces for user interaction events (button clicks, etc.). Disabled by default. | ||
|
|
||
| See [User Interaction Instrumentation](/platforms/android/performance/instrumentation/automatic-instrumentation/#user-interaction-instrumentation). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableTracing" type="bool" defaultValue="false"> | ||
|
|
||
| Enables tracing features on the embedded Android SDK. When disabled, the .NET SDK still handles traces for managed code, but the native Android SDK will not create its own traces. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.ProfilesSampleRate" type="double?" defaultValue="null"> | ||
|
|
||
| Profiling sample rate for the native Android SDK, between `0.0` and `1.0`. Disabled when `null`. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Enriching Events | ||
|
|
||
| <SdkOption name="Native.AttachScreenshot" type="bool" defaultValue="false"> | ||
|
|
||
| Automatically attaches a screenshot when the native Android SDK captures a Java-based error or exception. | ||
|
|
||
| <Alert level="info"> | ||
|
|
||
| This feature is provided by the embedded Sentry Android SDK and only works for Java-based exceptions. For .NET managed code screenshots, see See [Screenshots](/platforms/android/enriching-events/screenshots/). | ||
|
|
||
| </Alert> | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.AttachThreads" type="bool" defaultValue="false"> | ||
|
|
||
| Automatically attaches information about all threads to all logged events. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableRootCheck" type="bool" defaultValue="true"> | ||
|
|
||
| Checks whether the device has been rooted and includes this in event context. Disable if your app store flags this check as harmful. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Android NDK | ||
|
|
||
| <SdkOption name="Native.EnableNdk" type="bool" defaultValue="true"> | ||
|
|
||
| Enables the [Android NDK integration](/platforms/android/configuration/using-ndk/) for native C/C++ crash reporting. Disable only if you don't need native crash reports and want to reduce overhead. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Networking | ||
|
|
||
| <SdkOption name="Native.ConnectionTimeout" type="TimeSpan" defaultValue="TimeSpan.FromSeconds(5)"> | ||
|
|
||
| Connection timeout on the HTTP connection used by the Java SDK when sending events to Sentry. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.ReadTimeout" type="TimeSpan" defaultValue="TimeSpan.FromSeconds(5)"> | ||
|
|
||
| Read timeout on the HTTP connection used by the Java SDK when sending events to Sentry. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Error Handling | ||
|
|
||
| <SdkOption name="Native.EnableShutdownHook" type="bool" defaultValue="true"> | ||
|
|
||
| Enables a hook that flushes events when the main Java thread shuts down, ensuring events are sent before the process exits. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableUncaughtExceptionHandler" type="bool" defaultValue="true"> | ||
|
|
||
| Enables the handler that attaches to Java's `Thread.UncaughtExceptionHandler` to capture unhandled Java exceptions. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.PrintUncaughtStackTrace" type="bool" defaultValue="false"> | ||
|
|
||
| When enabled, prints uncaught Java error stack traces to _stderr_ in addition to sending them to Sentry. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.EnableBeforeSend" type="bool" defaultValue="false"> | ||
|
|
||
| When enabled, the `BeforeSend` callback configured on `SentryOptions` will also be invoked for events that originate from the embedded Android SDK. | ||
|
|
||
| <Alert level="warning"> | ||
|
|
||
| This is an experimental feature. The .NET and Android SDKs don't implement identical features, so some optional event properties may be lost when round-tripping between the two SDKs. | ||
|
|
||
| </Alert> | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Stack Traces | ||
|
|
||
| Use these methods to control which Java packages are considered "in-app" in stack traces. Note that these use Java package names, not .NET namespaces. | ||
|
|
||
| <SdkOption name="Native.AddInAppExclude(prefix)" type="method"> | ||
|
|
||
| Excludes frames matching the given Java package prefix from being flagged as "in-app" in stack traces. | ||
|
|
||
| ```csharp | ||
| options.Native.AddInAppExclude("java.util."); | ||
| options.Native.AddInAppExclude("org.apache.logging.log4j."); | ||
| ``` | ||
|
|
||
| See [In-App Exclude](/platforms/java/configuration/options/#inAppExcludes). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.AddInAppInclude(prefix)" type="method"> | ||
|
|
||
| Includes frames matching the given Java package prefix as "in-app" in stack traces. | ||
|
|
||
| ```csharp | ||
| options.Native.AddInAppInclude("io.sentry.samples."); | ||
| ``` | ||
|
|
||
| See [In-App Include](/platforms/java/configuration/options/#inAppIncludes). | ||
|
|
||
| </SdkOption> | ||
|
|
||
| ## Session Replay | ||
|
|
||
| Session Replay for Android is currently experimental and must be opted into. | ||
|
|
||
| <SdkOption name="Native.ExperimentalOptions.SessionReplay.SessionSampleRate" type="double?" defaultValue="null"> | ||
|
|
||
| Sample rate for all sessions, between `0.0` and `1.0`. Set to `0.0` or leave as `null` to disable session replay for regular sessions. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.ExperimentalOptions.SessionReplay.OnErrorSampleRate" type="double?" defaultValue="null"> | ||
|
|
||
| Sample rate for buffered replays that are triggered when an error occurs. The SDK keeps the previous minute of activity and continues until the session ends when an error is sampled. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.ExperimentalOptions.SessionReplay.MaskAllText" type="bool" defaultValue="true"> | ||
|
|
||
| Masks all text content in session replay recordings to protect user privacy. Enabled by default. | ||
|
|
||
| </SdkOption> | ||
|
|
||
| <SdkOption name="Native.ExperimentalOptions.SessionReplay.MaskAllImages" type="bool" defaultValue="true"> | ||
|
|
||
| Masks all images in session replay recordings to protect user privacy. Enabled by default. | ||
|
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. issue: mention "best effort" Wording here is important. We need to mention "best effort" when it comes to automatic masking. |
||
|
|
||
| </SdkOption> | ||
|
|
||
| For finer-grained control of masking, you can mask or unmask entire classes of `VisualElement`: | ||
|
|
||
| ```csharp | ||
| // Unmask all Buttons (override the default mask-all behaviour) | ||
| options.Native.ExperimentalOptions.SessionReplay.UnmaskControlsOfType<Button>(); | ||
|
|
||
| // Or mask a specific control type that isn't masked by default | ||
| options.Native.ExperimentalOptions.SessionReplay.MaskControlsOfType<MyCustomView>(); | ||
| ``` | ||
|
|
||
| <Alert level="warning"> | ||
|
|
||
| In apps with complex UIs containing hundreds of visual controls on a single page, type-based masking may cause performance issues. In such cases, consider applying the `sentry:SessionReplay.Mask` XML attribute to individual controls instead. | ||
|
|
||
| </Alert> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
issue: mention "best effort"
Wording here is important. We need to mention "best effort" when it comes to automatic masking.