Skip to content

Commit

Permalink
Merge branch 'main' into feat/ios-native-profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Dec 4, 2023
2 parents ba4982a + a2fa21f commit 8be4a87
Show file tree
Hide file tree
Showing 74 changed files with 1,353 additions and 857 deletions.
44 changes: 41 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,48 @@

## Unreleased

### API breaking Changes

#### Changed APIs

- Rename iOS and MacCatalyst platform specific options from `Cocoa` to `Native` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))
- Rename iOS platform specific options `EnableCocoaSdkTracing` to `EnableTracing` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))
- Rename Android platform specific options from `Android` to `Native` ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))
- Rename Android platform specific options `EnableAndroidSdkTracing` and `EnableAndroidSdkBeforeSend` to `EnableTracing` and `EnableBeforeSend` respectively ([#2940](https://github.com/getsentry/sentry-dotnet/pull/2940))

### Dependencies

- Bump Cocoa SDK from v8.17.0 to v8.17.1 ([#2936](https://github.com/getsentry/sentry-dotnet/pull/2936))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8171)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.17.0...8.17.1)

## 4.0.0-beta.3

### Fixes

- Reworked automatic breadcrumb creation for MAUI. ([#2900](https://github.com/getsentry/sentry-dotnet/pull/2900))
- The SDK no longer uses on reflection to bind to all public element events. This also fixes issues where the SDK would consume third-party events.
- Added `CreateElementEventsBreadcrumbs` to the SentryMauiOptions to allow users to opt-in automatic breadcrumb creation for `BindingContextChanged`, `ChildAdded`, `ChildRemoved` and `ParentChanged` on `Element`.
- Reduced amount of automatic breadcrumbs by limiting the amount of bindings created in `VisualElement`, `Window`, `Shell`, `Page` and `Button`.
- Fixed Sentry SDK has not been initialised when using ASP.NET Core, Serilog and OpenTelemetry ([#2911](https://github.com/getsentry/sentry-dotnet/pull/2911))

### Features

- Native crash reporting on NativeAOT published apps (Windows, Linux, macOS). ([#2887](https://github.com/getsentry/sentry-dotnet/pull/2887))
- Android: By default attaches LogCat logs to unhandled exceptions. Configurable via `SentryOptions.Android.LogCatIntegration` and `SentryOptions.Android.LogCatMaxLines`. Available when targeting `net7.0-android` or later, on API level 23 or later. ([#2926](https://github.com/getsentry/sentry-dotnet/pull/2926))

### API breaking Changes

- The method used to configure a Sentry Sink for Serilog now has an additional overload. Calling `WriteTo.Sentry()` with no arguments will no longer attempt to initialize the SDK (it has optional arguments to configure the behaviour of the Sink only). If you want to initialize Sentry at the same time you configure the Sentry Sink then you will need to use the overload of this method that accepts a DSN as the first parameter (e.g. `WriteTo.Sentry("https://d4d82fc1c2c4032a83f3a29aa3a3aff@fake-sentry.io:65535/2147483647")`). ([#2928](https://github.com/getsentry/sentry-dotnet/pull/2928))

#### Removed APIs

- SentrySinkExtensions.ConfigureSentrySerilogOptions is now internal. If you were using this method, please use one of the `SentrySinkExtensions.Sentry` extension methods instead. ([#2902](https://github.com/getsentry/sentry-dotnet/pull/2902))
- SentrySinkExtensions.ConfigureSentrySerilogOptions is now internal. If you were using this method, please use one of the `SentrySinkExtensions.Sentry` extension methods instead. ([#2902](https://github.com/getsentry/sentry-dotnet/pull/2902))

### Fixes
#### Changed APIs

- Fixed Sentry SDK has not been initialised when using ASP.NET Core, Serilog and OpenTelemetry ([#2911](https://github.com/getsentry/sentry-dotnet/pull/2911))
- `AssemblyExtensions` have been made public again. ([#2917](https://github.com/getsentry/sentry-dotnet/pull/2917))
- Rename iOS and MacCatalyst platform specific options from `iOS` to `Cocoa` ([#2929](https://github.com/getsentry/sentry-dotnet/pull/2929))

### Dependencies

Expand All @@ -27,6 +56,9 @@
- Bump Native SDK from v0.6.5 to v0.6.7 ([#2914](https://github.com/getsentry/sentry-dotnet/pull/2914))
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#067)
- [diff](https://github.com/getsentry/sentry-native/compare/0.6.5...0.6.7)
- Bump Java SDK from v6.34.0 to v7.0.0 ([#2932](https://github.com/getsentry/sentry-dotnet/pull/2932))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#700)
- [diff](https://github.com/getsentry/sentry-java/compare/6.34.0...7.0.0)

## 4.0.0-beta.2

Expand Down Expand Up @@ -189,6 +221,7 @@ There are some functional differences when publishing Native AOT:
- `StackTraceMode.Enhanced` is ignored because it's not available when publishing Native AOT. The mechanism to generate these enhanced stack traces relies heavily on reflection which isn't compatible with trimming.
- Reflection cannot be leveraged for JSON Serialization and you may need to use `SentryOptions.AddJsonSerializerContext` to supply a serialization context for types that you'd like to send to Sentry (e.g. in the `Span.Context`). ([#2732](https://github.com/getsentry/sentry-dotnet/pull/2732), [#2793](https://github.com/getsentry/sentry-dotnet/pull/2793))
- WinUI applications: when publishing Native AOT, Sentry isn't able to automatically register an unhandled exception handler because that relies on reflection. You'll need to [register the unhandled event handler manually](https://github.com/getsentry/sentry-dotnet/issues/2778) instead.
- For Azure Functions Workers, when AOT/Trimming is enabled we can't use reflection to read route data from the HttpTrigger so the route name will always be `/api/<FUNCTION_NAME>` ([#2920](https://github.com/getsentry/sentry-dotnet/pull/2920))

### Dependencies

Expand All @@ -199,6 +232,11 @@ There are some functional differences when publishing Native AOT:
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2222)
- [diff](https://github.com/getsentry/sentry-cli/compare/2.21.5...2.22.2)

## 3.41.3

### Fixes

- Fixed Sentry SDK has not been initialised when using ASP.NET Core, Serilog and OpenTelemetry ([#2918](https://github.com/getsentry/sentry-dotnet/pull/2918))

## 3.41.2

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Although the files in `/src/Sentry/Platforms/` are part of the `Sentry` project,
```xml
<!-- Platform-specific props included here -->
<Import Project="Platforms\Android\Sentry.Android.props" Condition="'$(TargetPlatformIdentifier)' == 'android'" />
<Import Project="Platforms\iOS\Sentry.iOS.props" Condition="'$(TargetPlatformIdentifier)' == 'ios' Or '$(TargetPlatformIdentifier)' == 'maccatalyst'" />
<Import Project="Platforms\Cocoa\Sentry.Cocoa.props" Condition="'$(TargetPlatformIdentifier)' == 'ios' Or '$(TargetPlatformIdentifier)' == 'maccatalyst'" />
```

These `*.props` files are used to add platform-specific files, such as references to the binding projects for each native SDK (which provide .NET wrappers around native Android or Cocoa functions).
Expand Down
11 changes: 1 addition & 10 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<Version>4.0.0-beta.2</Version>
<Version>4.0.0-beta.3</Version>
<LangVersion>12</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory).assets\Sentry.snk</AssemblyOriginatorKeyFile>
Expand All @@ -10,9 +10,6 @@
<Features>strict</Features>
<ImplicitUsings>true</ImplicitUsings>

<!-- Ignore EOL warnings... we need to support old stuff -->
<CheckEolWorkloads>false</CheckEolWorkloads>

<!-- Allow references to unsigned assemblies (like MAUI) from signed projects -->
<NoWarn>$(NoWarn);CS8002</NoWarn>
</PropertyGroup>
Expand Down Expand Up @@ -68,12 +65,6 @@
<DefineConstants Condition="'$(TargetPlatformIdentifier)' == ''">$(DefineConstants);PLATFORM_NEUTRAL</DefineConstants>
</PropertyGroup>

<!-- We're aware it's out of support but this is a library and it doesn't require nca3.1. -->
<!-- there's no reason to cause friction to a consumer that for some reason is stuck on an unsupported version. -->
<PropertyGroup>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<DefineConstants>$(DefineConstants);CI_BUILD</DefineConstants>
Expand Down
4 changes: 4 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'ios' And '$(TargetPlatformIdentifier)' != 'maccatalyst'">
<!-- Exclude our platform-specific code: -->
<Compile Remove="**\*.Cocoa.cs" />
<Compile Remove="**\Cocoa\**\*.cs" />
<!-- Maui device test projects have these too: -->
<Compile Remove="**\*.iOS.cs" />
<Compile Remove="**\iOS\**\*.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion modules/sentry-cocoa
Submodule sentry-cocoa updated 137 files
4 changes: 4 additions & 0 deletions samples/Sentry.Samples.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Sentry.Android;

namespace Sentry.Samples.Android;

[Activity(Label = "@string/app_name", MainLauncher = true)]
Expand All @@ -9,6 +11,8 @@ protected override void OnCreate(Bundle? savedInstanceState)
{
o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
o.SendDefaultPii = true; // adds the user's IP address automatically
o.Native.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only
o.Native.LogCatMaxLines = 1000; // Defaults to 1000
});

// Here's an example of adding custom scope information.
Expand Down
1 change: 0 additions & 1 deletion samples/Sentry.Samples.Maui/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ private void OnNativeCrashClicked(object sender, EventArgs e)
#endif
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Sentry.Extensions.Logging;

namespace Sentry.Azure.Functions.Worker;

/// <inheritdoc cref="BindableSentryOptions"/>
internal class BindableSentryAzureFunctionsOptions : BindableSentryLoggingOptions
{
public void ApplyTo(SentryAzureFunctionsOptions options)
{
base.ApplyTo(options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<Description>Official Azure Functions Worker SDK integration for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.</Description>
</PropertyGroup>

<PropertyGroup Condition="'$(FrameworkSupportsAot)' == 'true'">
<IsAotCompatible>true</IsAotCompatible>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Sentry.Extensions.Logging\Sentry.Extensions.Logging.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@

namespace Sentry.Azure.Functions.Worker;

#if NET8_0_OR_GREATER
internal class SentryAzureFunctionsOptionsSetup : IConfigureOptions<SentryAzureFunctionsOptions>
{
private readonly IConfiguration _config;

public SentryAzureFunctionsOptionsSetup(IConfiguration config)
{
ArgumentNullException.ThrowIfNull(config);
_config = config;
}

public void Configure(SentryAzureFunctionsOptions options)
{
ArgumentNullException.ThrowIfNull(options);

var bindable = new BindableSentryAzureFunctionsOptions();
_config.Bind(bindable);
bindable.ApplyTo(options);

// These can't be changed by the user
options.TagFilters.Add("AzureFunctions_");
}
}
#else
internal class SentryAzureFunctionsOptionsSetup : ConfigureFromConfigurationOptions<SentryAzureFunctionsOptions>
{
public SentryAzureFunctionsOptionsSetup(IConfiguration config) : base(config)
Expand All @@ -20,3 +44,4 @@ public override void Configure(SentryAzureFunctionsOptions options)
options.TagFilters.Add("AzureFunctions_");
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ public static IFunctionsWorkerApplicationBuilder UseSentry(
builder.UseMiddleware<SentryFunctionsWorkerMiddleware>();

var services = builder.Services;
var section = context.Configuration.GetSection("Sentry");
#if NET8_0_OR_GREATER
services.AddSingleton<IConfigureOptions<SentryAzureFunctionsOptions>>(_ =>
new SentryAzureFunctionsOptionsSetup(section)
);
#else
services.Configure<SentryAzureFunctionsOptions>(options =>
context.Configuration.GetSection("Sentry").Bind(options));
section.Bind(options));
#endif

if (optionsConfiguration != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Azure.Functions.Worker.Middleware;
using Sentry.Extensibility;
using Sentry.Internal;

namespace Sentry.Azure.Functions.Worker;

Expand Down Expand Up @@ -79,6 +80,7 @@ public async Task Invoke(FunctionContext context, FunctionExecutionDelegate next
}
}

[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = AotHelper.SuppressionJustification)]
private async Task<TransactionContext> StartOrContinueTraceAsync(FunctionContext context)
{
var transactionName = context.FunctionDefinition.Name;
Expand All @@ -94,7 +96,11 @@ private async Task<TransactionContext> StartOrContinueTraceAsync(FunctionContext
var httpMethod = requestData.Method.ToUpperInvariant();
var transactionNameKey = $"{context.FunctionDefinition.EntryPoint}-{httpMethod}";

if (!TransactionNameCache.TryGetValue(transactionNameKey, out transactionName))
// Note that, when Trimming is enabled, we can't use reflection to read route data from the HttpTrigger
// attribute. In that case the route name will always be /api/<FUNCTION_NAME>
// If this is ever a problem for customers, we can potentially see if there are alternate ways to get this info
// from route tables or something. We're not even sure if anyone will use this functionality for now though.
if (!AotHelper.IsNativeAot && !TransactionNameCache.TryGetValue(transactionNameKey, out transactionName))
{
// Find the HTTP Trigger attribute via reflection
var assembly = Assembly.LoadFrom(context.FunctionDefinition.PathToAssembly);
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net7.0-android</TargetFramework>
<!-- BG8605 and BG8606 happen because there's a missing androidx.lifecycle dependency, but we don't need it here. (The native Android Sentry SDK will use it if it exists.) -->
<NoWarn>$(NoWarn);BG8605;BG8606</NoWarn>
<SentryAndroidSdkVersion>6.34.0</SentryAndroidSdkVersion>
<SentryAndroidSdkVersion>7.0.0</SentryAndroidSdkVersion>
<SentryAndroidSdkDirectory>$(BaseIntermediateOutputPath)sdks\Sentry\Android\$(SentryAndroidSdkVersion)\</SentryAndroidSdkDirectory>
<Description>.NET Bindings for the Sentry Android SDK</Description>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Bindings.Cocoa/PrivateApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sentry.CocoaSdk;

// SentryScope.ApplyToEvent was made private in 8.x, but we use it in our IosEventProcessor class.
// SentryScope.ApplyToEvent was made private in 8.x, but we use it in our CocoaEventProcessor class.
// TODO: Find a better way than using the private API.
partial interface SentryScope
{
Expand Down
2 changes: 2 additions & 0 deletions src/Sentry.Maui/BindableSentryMauiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ internal class BindableSentryMauiOptions : BindableSentryLoggingOptions
public bool? IncludeTextInBreadcrumbs { get; set; }
public bool? IncludeTitleInBreadcrumbs { get; set; }
public bool? IncludeBackgroundingStateInBreadcrumbs { get; set; }
public bool? CreateElementEventsBreadcrumbs { get; set; } = false;

public void ApplyTo(SentryMauiOptions options)
{
base.ApplyTo(options);
options.IncludeTextInBreadcrumbs = IncludeTextInBreadcrumbs ?? options.IncludeTextInBreadcrumbs;
options.IncludeTitleInBreadcrumbs = IncludeTitleInBreadcrumbs ?? options.IncludeTitleInBreadcrumbs;
options.IncludeBackgroundingStateInBreadcrumbs = IncludeBackgroundingStateInBreadcrumbs?? options.IncludeBackgroundingStateInBreadcrumbs;
options.CreateElementEventsBreadcrumbs = CreateElementEventsBreadcrumbs ?? options.CreateElementEventsBreadcrumbs;
}
}
20 changes: 0 additions & 20 deletions src/Sentry.Maui/Internal/IMauiEventsBinder.cs

This file was deleted.

Loading

0 comments on commit 8be4a87

Please sign in to comment.