rualark
January 31, 2020, 11:21pm
1
It would be convenient to collect additional information and add it to the reported event when exception occurs. I found a solution here: https://github.com/getsentry/sentry-javascript/issues/2219
I tried to add this code to beforeSend:
beforeSend(event, hint) {
event.tags = event.tags || {};
event.tags['stateUrl'] = getStateUrl();
return event;
}
But tag does not show in “Tags” tab of the event. How should I do that?
Hi! Is this a difficult question or noone needs this?
From looking at your code I can’t tell why the tag was not added.
If that function is assigned to the beforeSend
call back, it should add the value.
Did you walk through with a debugger to make sure it’s invoked?
rualark
February 4, 2020, 10:25pm
4
Thanks for your answer! Yes, I added console.log to see that event.tags[‘stateUrl’] was successfully changed:
Sentry.init({
dsn: ‘https://…’,
beforeSend(event, hint) {
event.tags = event.tags || {};
event.tags[‘stateUrl’] = getStateUrl();
console.log(event.tags[‘stateUrl’]);
return event;
}
});
Error is reported, but there is no custom tag on Tags tab. Maybe I am looking in the wrong place?
https://sentry.io/share/issue/4eaf7fdaaf35499e9f5f1558935782cf/
rualark
February 15, 2020, 10:21pm
5
Hi! I found out that maximum length of tag is 200, but I am trying to pass state of my application, which is 300-1000 long if base64 encoded.
So I tried to try to pass information through breadcrumbs. I tried two ways: logging to console and addBreadcrumb, but none of them appears in resulting breadcrumbs. What is the correct way to pass state in event?
Sentry.init({
dsn: 'https://xxx@sentry.io/xxx',
beforeSend(event, hint) {
Sentry.addBreadcrumb({
category: 'state',
message: urlNoParams() + '?state=' + state2url(),
level: Sentry.Severity.Info
});
console.error('State url:', urlNoParams() + '?state=' + state2url());
return event;
}
});