-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Clarify "passing extra data" #167
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
Comments
Thanks! |
@mattrobenolt does this work in the same way for captureException? and btw, I think it would be better if in the docs you specify something like:
|
It works the same for |
I try to use it with
and I can see both errors in sentry, but only capture message has extra tag. |
@zywyz just tested it and everything works fine. Can you provide repro case that doesn't work for you? |
I found another solution which works for me, so I don't need help anymore. But according to reason why it doesn't work for me I have no idea as I can see for you it works.
and in index.html
|
@kamilogorek it works for me only if I put
If I don't put |
Can someone in May 2019 clarify how we can pass extra data via We are using,
But I do not see any extra data coming through with these events. The docs for the newest version of the library make lots of references to contexts & things like that so maybe this functionality has moved? |
@econner Sentry.withScope(scope => {
scope.setExtra('some', 'data');
Sentry.captureMessage(message);
}); |
@kamilogorek
Extra question: Should I manually call Sentry.captureException() when an exception happens? or is the code above simply a way to append these extra parameters, so that they are included when an exception happens? |
In this case, I'd use https://docs.sentry.io/platforms/javascript/#extraerrordata error.localProps = this.props;
error.localState = this.state;
Sentry.captureException(error); You should also use rather shallow serialization depth for it, as props and state can be quite large.
It depends whether you use Reacts
Correct. Every captured event has the scope it was captured in attached when it's sent to Sentry. |
Thank you for the fast reply, I apologize if this is not the correct forum for these questions. Your idea of ExtraErrorData seems to fit my case, but I am a bit confused about the actual implementation of it, as I am unsure where your error-object comes from, is it just an arbitrary object that you created in the component or is there a specific error-object needed from sentry? Also, where in the component should this be placed?
Lets assume that I don't want to use Reacts errorBoundary atm. and just want a react component to include
|
It's what If you don't use error boundries, we are not able to co-relate state or props with a given error, as there's no relationship between them and something that was captured by global
componentDidMount() {
try {
somethingThatBreaks()
} catch (e) {
e.localProps = this.props;
e.localState = this.state;
Sentry.captureException(e)
}
} or componentDidMount() {
if (someCondition()) {
const someError = new Error('something broke')
someError.localProps = this.props;
someError.localState = this.state;
Sentry.captureException(someError)
}
} or componentDidMount() {
if (someCondition()) {
const someError = new Error('something broke')
someError.localProps = this.props;
someError.localState = this.state;
throw someError;
}
} |
Aah that makes sense, thank you for the clarification! |
Hi, how do I pass extra data for default configuration (without calling |
Sentry.setExtra('key', 'value');
// or
Sentry.setExtras({ key1: 'value', key2: 'value' });
// or
Sentry.configureScope(scope => {
scope.setExtra('key', 'value');
// or
scope.setExtras({ key1: 'value', key2: 'value' });
}); |
What about data key in captureException hint object |
According to the docs,
However, I don't think this means arbitrary data. For example, you can't do this:
It would be nice if the docs were more clear on what additional data is allowed.
The text was updated successfully, but these errors were encountered: