Add e custom hook to allow to add custom data
I think it would be nice to expose an option to pass a custom function that can be used to enrich the event with custom data.
@dnlup would that be something like the previous version that could allow us to run scope.setTag in a custom error handler?
@fernandesGabriel Yes, I imagined the function could be useful to add more info, like the tags you are mentioning. The only difference with the previous version of the plugin would be that you don't need to implement a custom handler.
That would be perfect @dnlup, I just upgraded to the new version of the plugin, and just noticed that we also have the use case you mention here.
@fernandesGabriel I was thinking, wouldn't the beforeSend (the SDK one) option be enough for this use case?
Chiming in that this would be great to have as well! Either a way to expose beforeSend, or a way to expose adding custom context to errors
The workaround for now is to use beforeSend as mentioned above:
void app.register(fastifySentryPlugin, {
dsn: "...",
...,
beforeSend(event, hint) {
// Can do custom processing based on `hint.originalException`
return {
...event,
extra: {
...event.extra,
hello: "world"
},
};
},
That hello: "world" will show up under "Additional Data" in Sentry 👍
Thanks @noahsark769 for the feedback. So maybe something that allows us to use the scope api instead of manipulating the raw event should be what we are looking for.