Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 9 additions & 4 deletions docs/platforms/dotnet/guides/android/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ On .NET for Android, you also get:
- [Capture Application Not Responding (ANR) errors](/platforms/android/configuration/app-not-respond/) when the app is unresponsive
- Automatically [attach screenshots to Java exceptions](/platforms/android/enriching-events/screenshots/)
- Automatic breadcrumbs for Activity lifecycle, App lifecycle, System and Network events and User Interactions
- Automatic [Activity lifecycle tracing](/platforms/android/tracing/instrumentation/automatic-instrumentation/#activity-instrumentation) and [User Interaction tracing](/platforms/android/tracing/instrumentation/automatic-instrumentation/#user-interaction-instrumentation)
- Opt-in automatic [Activity lifecycle tracing](/platforms/android/tracing/instrumentation/automatic-instrumentation/#activity-instrumentation) and [User Interaction tracing](/platforms/android/tracing/instrumentation/automatic-instrumentation/#user-interaction-instrumentation) through the embedded Android SDK. See <PlatformLink to="/configuration/native-options/#Native.EnableTracing">`Native.EnableTracing`</PlatformLink>.
- Device Root checking
- Native crash reporting for Android, leveraging our [Android NDK](/platforms/android/configuration/using-ndk/)
- Automatic session tracking and [release health](/product/releases/)
Expand All @@ -46,7 +46,12 @@ The snippet also turns on:

Don't need a feature? Remove its options from the snippet.

```csharp
```csharp {filename:MainActivity.cs}
using Android.App;
using Android.OS;
using Sentry;
using Sentry.Android;

[Activity(Label = "@string/app_name", MainLauncher = true)]
public class MainActivity : Activity
{
Expand All @@ -66,7 +71,7 @@ public class MainActivity : Activity
#endif

// Android specific .NET features are under the Android properties:
options.Android.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only
options.Android.LogCatIntegration = LogCatIntegrationType.Errors; // Attach logcat logs to handled and unhandled errors; default is None.
options.Android.LogCatMaxLines = 1000; // Defaults to 1000

// Native Android SDK options are available via options.Native
Expand Down Expand Up @@ -163,7 +168,7 @@ Let's test your setup and confirm that data reaches your Sentry project.

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Next Steps

Expand Down
65 changes: 53 additions & 12 deletions docs/platforms/dotnet/guides/apple/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,35 @@ Install-Package Sentry -Version {{@inject packages.version('sentry.dotnet') }}

**Error Monitoring** starts working as soon as you call `SentrySdk.Init()`. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-).

This guide also enables **Tracing**, **Profiling**, and **Session Replay** (experimental).
This guide also enables **Tracing**. The iOS and Mac Catalyst setup enables **Profiling**, and the iOS setup enables experimental **Session Replay**.

On .NET for iOS, macOS, and Mac Catalyst, you also get:
On all three platforms, you get the features of the main [.NET SDK](/platforms/dotnet/) for your managed code. On iOS and Mac Catalyst, the embedded [Cocoa SDK](/platforms/apple/) also provides:

- All the features of our main [.NET SDK](/platforms/dotnet/), for your managed code
- Native crash reporting for Apple platforms, leveraging our [Cocoa SDK](/platforms/apple/) including:
- Native crash reporting, including:
- Automatically [attach screenshots to Native exceptions](/platforms/apple/guides/ios/configuration/options/#attachScreenshot)
- Detect [App Hangs](/platforms/apple/configuration/app-hangs/)
- [Automatic performance tracing](/platforms/apple/tracing/)
- Opt-in [automatic performance tracing](/platforms/apple/tracing/). See <PlatformLink to="/configuration/native-options/#Native.EnableTracing">`Native.EnableTracing`</PlatformLink>.
- [Automatic breadcrumbs](/platforms/apple/enriching-events/breadcrumbs/#automatic-breadcrumbs)
- [Swizzling](/platforms/apple/configuration/swizzling/)
- Automatic session tracking and [release health](/product/releases/)

In your `AppDelegate.cs` file, call `SentrySdk.Init` in the `FinishedLaunching` event and include any options you would like to set. The `Dsn` is the only required parameter.
### iOS and Mac Catalyst

In your `AppDelegate.cs` file, call `SentrySdk.Init` in `FinishedLaunching`. Keep your existing window and application setup after the Sentry initialization. The `Dsn` is the only required setting.

The snippet also turns on:

- Tracing: via <PlatformLink to="/configuration/options/#TracesSampleRate">`TracesSampleRate`</PlatformLink>
- Profiling: via <PlatformLink to="/profiling/">`ProfilesSampleRate`</PlatformLink>. On iOS and Mac Catalyst, the SDK adds the native profiling integration automatically, so you don't need the `Sentry.Profiling` package.
- Session Replay: via <PlatformLink to="/configuration/native-options/#session-replay">`Native.ExperimentalOptions.SessionReplay`</PlatformLink>
- Session Replay on iOS: via <PlatformLink to="/configuration/native-options/#session-replay">`Native.ExperimentalOptions.SessionReplay`</PlatformLink>

Don't need a feature? Remove its options from the snippet.

```csharp
```csharp {filename:AppDelegate.cs}
using Foundation;
using Sentry;
using UIKit;

[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
Expand Down Expand Up @@ -75,9 +80,11 @@ public class AppDelegate : UIApplicationDelegate
// https://docs.sentry.io/platforms/apple/guides/ios/configuration/options/#attachScreenshot
options.Native.AttachScreenshot = true;

// Session Replay is currently available via the ExperimentalOptions
#if IOS
// Session Replay is available on iOS via ExperimentalOptions.
options.Native.ExperimentalOptions.SessionReplay.OnErrorSampleRate = 1.0;
options.Native.ExperimentalOptions.SessionReplay.SessionSampleRate = 1.0;
#endif

options.SetBeforeSend(evt =>
{
Expand All @@ -103,11 +110,43 @@ public class AppDelegate : UIApplicationDelegate

For a full list of native options, see <PlatformLink to="/configuration/native-options/">Apple Native Options</PlatformLink>.

### macOS

For an AppKit application targeting `net*-macos`, initialize Sentry in `NSApplicationDelegate.DidFinishLaunching`. This target doesn't include the Cocoa integration's `options.Native` or `OnCrashedLastRun` APIs.

```csharp {filename:AppDelegate.cs}
using AppKit;
using Foundation;
using Sentry;

[Register("AppDelegate")]
public class AppDelegate : NSApplicationDelegate
{
public override void DidFinishLaunching(NSNotification notification)
{
SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.SendDefaultPii = true;
options.IsGlobalModeEnabled = true;
options.TracesSampleRate = 1.0;
#if DEBUG
options.Debug = true;
#endif
});

// Keep the rest of your application startup here.
}
}
```

For custom transactions, see [Verify Your Setup](#verify-your-setup). The Cocoa profiling and replay configuration above doesn't apply to this target.

### Options

The .NET for iOS, macOS, and Mac Catalyst integration is part of [Sentry](/platforms/dotnet/). Please refer to the documentation for that package for information about platform agnostic options.

For configuration of the embedded Sentry Cocoa SDK, see <PlatformLink to="/configuration/native-options/">Apple Native Options</PlatformLink>.
For configuration of the embedded Sentry Cocoa SDK on iOS and Mac Catalyst, see <PlatformLink to="/configuration/native-options/">Apple Native Options</PlatformLink>.

## Send Logs

Expand Down Expand Up @@ -141,9 +180,11 @@ Let's test your setup and confirm that data reaches your Sentry project.

<PlatformContent includePath="getting-started-verify" />

<PlatformContent includePath="getting-started-verify-tracing" />

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Next Steps

Expand All @@ -152,4 +193,4 @@ At this point, you should have integrated Sentry into your .NET for iOS, macOS,
- Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup
- Learn how to [manually capture errors](/platforms/dotnet/usage/)
- Explore [Tracing](/platforms/dotnet/tracing/)
- Configure the embedded Cocoa SDK with <PlatformLink to="/configuration/native-options/">Apple Native Options</PlatformLink>
- On iOS and Mac Catalyst, configure the embedded Cocoa SDK with <PlatformLink to="/configuration/native-options/">Apple Native Options</PlatformLink>
15 changes: 7 additions & 8 deletions docs/platforms/dotnet/guides/aspnet/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ The snippet also turns on:

Don't need a feature? Remove its options from the snippet.

```csharp
```csharp {filename:Global.asax.cs}
using System;
using System.Web;
using Sentry;
using Sentry.AspNet;
using Sentry.EntityFramework; // If you also installed Sentry.EntityFramework
using Sentry.Extensibility;

public class MvcApplication : HttpApplication
{
private IDisposable _sentry;
private static IDisposable _sentry;

protected void Application_Start()
{
Expand All @@ -64,8 +63,6 @@ public class MvcApplication : HttpApplication
// We recommend reducing this value in production.
options.TracesSampleRate = 1.0;

// If you also installed the Sentry.EntityFramework package
options.AddEntityFramework();
options.AddAspNet();
});
}
Expand All @@ -90,6 +87,8 @@ public class MvcApplication : HttpApplication
}
```

If you also use Entity Framework 6, install `Sentry.EntityFramework` and add `options.AddEntityFramework()` to the same initialization callback. See the [Entity Framework guide](/platforms/dotnet/guides/entityframework/) for setup details.

### Capturing the affected user

When opting-in to [SendDefaultPii](#senddefaultpii), the SDK will automatically read the user from the request by inspecting `HttpContext.User`. Default claim values like `NameIdentifier` for the _Id_ will be used.
Expand All @@ -104,7 +103,7 @@ options.SendDefaultPii = true;

### SendDefaultPii

Although this setting is part of the [Sentry](/platforms/dotnet/) package, in the context of ASP.NET Core, it means reporting the user by reading the frameworks `HttpContext.User`. The strategy to create the `SentryUser` can be customized.
Although this setting is part of the [Sentry](/platforms/dotnet/) package, in ASP.NET it also enables reporting the user from `HttpContext.User`.

### IncludeRequestPayload

Expand Down Expand Up @@ -151,7 +150,7 @@ Let's test your setup and confirm that data reaches your Sentry project.

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Troubleshooting

Expand Down
9 changes: 5 additions & 4 deletions docs/platforms/dotnet/guides/aspnetcore/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dotnet add package Sentry.AspNetCore -v {{@inject packages.version('sentry.dotne
```

```shell {tabTitle:Paket CLI}
paket add Sentry --version {{@inject packages.version('sentry.dotnet.aspnetcore') }}
paket add Sentry.AspNetCore --version {{@inject packages.version('sentry.dotnet.aspnetcore') }}
```

This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/). This means that besides the ASP.NET Core related features, through this package you'll also get access to all the framework's logging integration and also the features available in the main [Sentry](/platforms/dotnet/) SDK.
Expand All @@ -29,9 +29,9 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens

This guide also enables **Tracing**.

The simplest way to initialize Sentry in ASP.NET Core is by using the `UseSentry` extension method from the `Sentry.AspNetCore` package in conjunction with the [framework configuration system](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0).
The simplest way to initialize Sentry in ASP.NET Core is by using the `UseSentry` extension method from the `Sentry.AspNetCore` package in conjunction with the [framework configuration system](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/).

Call `UseSentry` with your DSN and the options you want. The SDK provides this as extension methods to support ASP.NET Core `2.X`, `3.X`, and `5.X` and later.
`Sentry.AspNetCore` 6.x requires .NET 8 or later. Call `UseSentry` with your DSN and the options you want. For .NET 6 or 7, use `Sentry.AspNetCore` 4.x.

The snippet also turns on:

Expand Down Expand Up @@ -82,6 +82,7 @@ public static IWebHost BuildWebHost(string[] args) =>
// We recommend reducing this value in production.
options.TracesSampleRate = 1.0;
})
.Build();
```

### Additional configuration
Expand Down Expand Up @@ -330,7 +331,7 @@ Let's test your setup and confirm that data reaches your Sentry project.

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Samples

Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/dotnet/guides/aws-lambda/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Let's test your setup and confirm that data reaches your Sentry project.

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Samples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Let's test your setup and confirm that data reaches your Sentry project.

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Samples

Expand Down
34 changes: 23 additions & 11 deletions docs/platforms/dotnet/guides/blazor-server/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,30 @@ However, on .NET 10 and later, Blazor emits OpenTelemetry activities for circuit

#### Install OpenTelemetry

See <PlatformLink to="/tracing/instrumentation/opentelemetry/">OpenTelemetry Support</PlatformLink> for installation and setup instructions.
Install the OTLP exporter and OpenTelemetry instrumentation:

```shell {tabTitle:.NET Core CLI}
dotnet add package Sentry.OpenTelemetry.Exporter -v {{@inject packages.version('sentry.dotnet') }}
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
```

```powershell {tabTitle:Package Manager}
Install-Package Sentry.OpenTelemetry.Exporter -Version {{@inject packages.version('sentry.dotnet') }}
Install-Package OpenTelemetry.Extensions.Hosting
Install-Package OpenTelemetry.Instrumentation.AspNetCore
```

See <PlatformLink to="/tracing/instrumentation/opentelemetry-otlp/">OpenTelemetry (OTLP)</PlatformLink> for sampling and trace propagation.

#### Configure OpenTelemetry

Wire up Sentry as an OpenTelemetry exporter, subscribe to the Blazor activity sources, and register helper services for circuit and breadcrumb tracking:
Copy the [helper services](#circuit-lifecycle-tracking-services) into your application and add a `using` directive for their namespace. Then configure the OTLP exporter, subscribe to the Blazor activity sources, and register the helpers:

```csharp {filename:Program.cs}
using Microsoft.AspNetCore.Components.Server.Circuits;
using OpenTelemetry.Trace;
using Sentry.OpenTelemetry;
using Sentry;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -95,18 +109,14 @@ builder.Services.AddOpenTelemetry()
tracing.AddSource("Microsoft.AspNetCore.Components");
tracing.AddSource("Microsoft.AspNetCore.Components.Server.Circuits");
tracing.AddAspNetCoreInstrumentation();
// Export traces to Sentry
tracing.AddSentry();
tracing.SetSampler(new ParentBasedSampler(new TraceIdRatioBasedSampler(0.1)));
tracing.AddSentryOtlpExporter("___PUBLIC_DSN___");
});

builder.WebHost.UseSentry(options =>
{
options.Dsn = "___PUBLIC_DSN___";
options.UseOpenTelemetry();
// Enables Tracing.
// Set to 1.0 to capture 100% of spans for tracing.
// We recommend reducing this value in production.
options.TracesSampleRate = 0.1;
options.UseOtlp();
// Rewrites /_blazor SignalR transaction names to the actual Blazor route
options.AddEventProcessor(new BlazorEventProcessor());
});
Expand All @@ -128,6 +138,8 @@ app.MapFallbackToPage("/_Host");
app.Run();
```

OpenTelemetry handles sampling in this configuration. Don't also set `TracesSampleRate` on the Sentry options.

#### Circuit Lifecycle Tracking Services

The `BlazorSentryIntegration`, `SentryCircuitHandler`, and `BlazorEventProcessor` services shown above are not part of the Sentry integration. You can copy them from the [Blazor Server sample](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Blazor.Server/Services) into your application if they prove useful for your use case.
Expand Down Expand Up @@ -174,7 +186,7 @@ Let's test your setup and confirm that data reaches your Sentry project.

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Samples

Expand Down
11 changes: 6 additions & 5 deletions docs/platforms/dotnet/guides/blazor-webassembly/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ builder.UseSentry(options =>
// Enables Tracing.
// Set to 1.0 to capture 100% of spans for tracing.
// We recommend reducing this value in production.
options.TracesSampleRate = 0.1;
options.TracesSampleRate = 1.0;
});

// Captures logError and higher as events
builder.Logging.AddSentry(o => o.InitializeSdk = false);

await builder.Build().RunAsync();
```

`UseSentry` also registers the logging integration. Don't call `builder.Logging.AddSentry` separately.

## Send Logs

Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization.
Expand Down Expand Up @@ -108,9 +107,11 @@ Let's test your setup and confirm that data reaches your Sentry project.

<PlatformContent includePath="getting-started-verify" />

<PlatformContent includePath="getting-started-verify-tracing" />

### View Captured Data in Sentry

Open your Sentry project to view the captured event.
<PlatformContent includePath="getting-started-verify-data" />

## Samples

Expand Down
Loading
Loading