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

No way to set UserId / UserEmail in AspNetCoreHttpContext when using AirbrakeMiddleware #137

Open
ja6lee opened this issue Jun 23, 2021 · 0 comments

Comments

@ja6lee
Copy link

ja6lee commented Jun 23, 2021

  • Sharpbrake version: Client: 5.1, Http.Middleware 3.1
  • .NET platform version: 3.1.301
  • Framework name & its version: AspNetCore.App 3.1.5

Airbrake config

var config = new AirbrakeConfig
{
    ProjectId = Environment.GetEnvironmentVariable("AIRBRAKE_PROJECT_ID"),
    ProjectKey = Environment.GetEnvironmentVariable("AIRBRAKE_PROJECT_KEY"),
    Environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"),
    Blocklist = new List<string> { "password" },
    IgnoreEnvironments = new List<string> { "Development", "Local" }
};

Description

We are looking to set UserId and UserEmail in AspNetCoreHttpContext or be able to override AspNetCoreHttpContext when using AirbrakeMiddleware.

We are using https://github.com/airbrake/sharpbrake#aspnet-core-middleware in our Startup we have:

var notifier = new AirbrakeNotifier(config);
notifier.AddFilter(notice =>
{
    // some ignoring of specific exceptions
});     

app.UseAirbrake(notifier);

When checking the notice in the filter block, notice.HttpContext is a AspNetCoreHttpContext which is expected, since it is created here:

notifier.SetHttpContext(notice, new AspNetCoreHttpContext(context));

However AspNetCoreHttpContext doesn't set the UserId or UserEmail and doesn't give access to the underlying HttpContext where we would be able to access them (eg. something like context.User.FindFirst("userId")).

Would it be possible to expose the underlying HttpContext or the User associated with it in AspNetCoreHttpContext or provide a way to set these / customize these? Or am I missing a way to do this that already exists? (I tried searching the repo / googling, but didn't find much).

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant