Giter Site home page Giter Site logo

Comments (10)

genne avatar genne commented on May 22, 2024 1

The main fix for it was to make sure you don't store the instance of HttpContext.Current (since it requires things to happen in a certain order and also won't work good for multiple requests), but instead always evaluate it. Also, not sure why HttpContext was set to null in all test cases, but had to remove it since it's a getter only by now.

Static properties/variables are always a pain 😄

Btw, PR here: #134

from raven-csharp.

asbjornu avatar asbjornu commented on May 22, 2024

@mathieukempe Is this in any way improved in version 2.1 of SharpRaven?

from raven-csharp.

genne avatar genne commented on May 22, 2024

Any updates on this? I almost never get the correct user info in Sentry.

from raven-csharp.

asbjornu avatar asbjornu commented on May 22, 2024

@genne Which version are you using?

from raven-csharp.

genne avatar genne commented on May 22, 2024

2.1.0 (nuget package)

from raven-csharp.

asbjornu avatar asbjornu commented on May 22, 2024

@genne How are you capturing? Which method on ISentryClient are you using?

from raven-csharp.

genne avatar genne commented on May 22, 2024

I'm calling Capture(SentryEvent) on an instance of RavenClient.

from raven-csharp.

asbjornu avatar asbjornu commented on May 22, 2024

@genne, @mathieukempe: Would any of you care to submit a pull request with the alleged fix? I don't quite understand how it can fix this problem, but if it does, I'll happily merge it!

from raven-csharp.

genne avatar genne commented on May 22, 2024

As mentioned by @mathieukempe, the order of the two lines must be swapped, since SentryUserFactory.Create() depends on SentryRequestFactory. Though, even if you fix that you still store the current HttpContext as a static instance which will not work when you have multiple requests occurring at the same time. You either need to use ThreadStaticAttribute before each static variable, or remove them completely and handle it in a better way.

I'll try to fix a PR just to get it working.

Further, you have a test case to make sure User is initialized correctly (Constructor_WithHttpContext_UsertIsNotNull), but

  1. in SimulateHttpRequest you initialize User and Request differently from how it's actually initialized, and
  2. you don't test multiple requests occurring at the same time.

from raven-csharp.

asbjornu avatar asbjornu commented on May 22, 2024

@genne I'll be the first to admit that this part of the code is bad in every imaginable interpretation of the word. It's horrible. But I blame most of that on HttpContext.Current being static and requiring a reference to System.Web.dll. If you have ideas on how to improve this, you'd receive all the virtual ❤️ I can give and I'd be very happy. 😃 Looking forward to that PR!

from raven-csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.