Skip to content
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

Removed IUserFactory in favor of ISentryUserFactory #2840

Merged
merged 7 commits into from
Nov 17, 2023
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- Obsolete `AssemblyExtensions` removed, this shouldn't have been public in the past and has no replacement. ([#2856](https://github.com/getsentry/sentry-dotnet/pull/2856))
- Obsolete `SentryDatabaseLogging.UseBreadcrumbs()` removed, it is called automatically and has no replacement. ([#2856](https://github.com/getsentry/sentry-dotnet/pull/2856))
- Obsolete `Scope.GetSpan()` removed, use `Span` property instead. ([#2856](https://github.com/getsentry/sentry-dotnet/pull/2856))
- Obsolete `IUserFactory` removed, use `ISentryUserFactory` instead. ([#2856](https://github.com/getsentry/sentry-dotnet/pull/2856))
- Obsolete `IUserFactory` removed, use `ISentryUserFactory` instead. ([#2856](https://github.com/getsentry/sentry-dotnet/pull/2856), [#2840](https://github.com/getsentry/sentry-dotnet/pull/2840))

#### Changed APIs

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.AspNetCore/DefaultUserFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Sentry.AspNetCore;

internal class DefaultUserFactory : IUserFactory, ISentryUserFactory
internal class DefaultUserFactory : ISentryUserFactory
{
private readonly IHttpContextAccessor? _httpContextAccessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public static ISentryBuilder AddSentry(this IServiceCollection services)
services.AddSingleton<ISentryEventExceptionProcessor, AspNetCoreExceptionProcessor>();

services.AddHttpContextAccessor();
services.TryAddSingleton<IUserFactory, DefaultUserFactory>();
services.TryAddSingleton<ISentryUserFactory, DefaultUserFactory>();

services
Expand Down
16 changes: 0 additions & 16 deletions src/Sentry.AspNetCore/IUserFactory.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Sentry.AspNetCore/ScopeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static void Populate(this Scope scope, HttpContext context, SentryAspNetC

if (options.SendDefaultPii && !scope.HasUser())
{
var userFactory = context.RequestServices.GetService<IUserFactory>();
var user = userFactory?.Create(context);
var userFactory = context.RequestServices.GetService<ISentryUserFactory>();
var user = userFactory?.Create();

if (user != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void AddSentry_DefaultRequestPayloadExtractor_LastRegistration()
public void AddSentry_DefaultUserFactory_Registered()
{
_ = _sut.AddSentry();
_sut.Received().Add(Arg.Is<ServiceDescriptor>(d => d.ServiceType == typeof(IUserFactory)
_sut.Received().Add(Arg.Is<ServiceDescriptor>(d => d.ServiceType == typeof(ISentryUserFactory)
&& d.ImplementationType == typeof(DefaultUserFactory)));
}
#pragma warning restore CS0618
Expand Down