-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Raven.setExtraContext and Raven.setTagsContext. #219
Conversation
API and semantics (merge rather than overwrite) based on raven-ruby. |
How would you handle the case of unsetting these? Lemme double check out Python handles this since that's our canonical reference. |
Seems to behave the same way: https://github.com/getsentry/raven-python/blob/683acffedc322f3f6ede606490d0e03e9a3a0b74/raven/base.py#L427 |
Are you trying to model this after Also, if so, I think I'd prefer to keep naming inline and go with either |
Or hmm, it doesn't, it completely overrides the extra/tags, instead of adding onto them. That's different from how the Ruby version behaves. |
Aha! Yeah, we definitely always merge in python and would prefer to model anything in raven-js after python. |
All right, I'll change that then. Annoying how the Ruby version don't adhere to that then :/ I don't mind the renaming, but shouldn't we rename/alias |
To be fair, we can also rename |
welp |
Yeah, let's do that, rename and leave an alias that I'll deprecate in the future. |
All right, changes coming up in a minute, currently trying to whip up a backbone plugin :) |
Changes made. |
Awesome! Thanks. 👍 |
Add Raven.setExtraContext and Raven.setTagsContext.
You should ping the Ruby guys their API is nonconforming by the way ;) |
The Ruby APIs match the Python APIs which conform to my made up spec. If anything, the JS API is nonconforming :) |
@dcramer Name-wise, yes, but check the source! In the Ruby implementation, new tags are merged with existing tags; in the Python implementation, new tags overwrite existing tags! |
Can we add setUser back as well? I wasn't paying much attention to this, but this is actually a pretty big caveat especially if its going to pop up in a minor version release. |
Ah hrm, maybe this is just a documentation issue on our end then. Doh |
K addressed in getsentry/sentry@be71a58 We'll want to minor version bump to get the new things first-class I imagine Thanks! |
This is really something to consider for the canonical Python API, but do we want to be able to not override, but add to the extra attributes? I'm setting some generic extra attribute at Raven setup: Raven.config(dsn, {
extra: {
request_id: "<%= request.headers["X-Request-ID"] %>"
}
}).install(); And then later, depending on the exact place Raven is included, I'm setting some more extra attributes that aren't necessarily (known to be) available at config-time: Raven.setExtraContext(
{
accommodation_id: "<%= current_accommodation.id %>",
accommodation_host: "<%= current_accommodation.host %>"
}
); Right now, the last call overrides the first, meaning If we don't want to make this the default, how about adding an extra |
I dont have a strong opinion here. I think two best solutions are:
There are likely rare situations where you could have multiple middleware (or similar) and want to set context at different levels, and have that merged in, but I'm not sure if it's worthwhile to cater to that situation. |
It's probably rare in the larger scheme of things, but because of the sort-of layered way our app is built, I would really appreciate a merge option. I also use this feature with the Ruby version, and I'd imagine it'd be useful with Python web frameworks as well. |
Resolves #213.