Skip to content

Commit

Permalink
Removed IUserFactory in favor of ISentryUserFactory (#2840)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes authored Nov 17, 2023
1 parent 69806bc commit 749c9a7
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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

0 comments on commit 749c9a7

Please sign in to comment.