Skip to content

Add ravenPresend and ravenMessage events - #513

Closed
romainneutron wants to merge 1 commit into
getsentry:masterfrom
romainneutron:add-events
Closed

romainneutron wants to merge 1 commit into
getsentry:masterfrom
romainneutron:add-events

Conversation

@romainneutron

Copy link
Copy Markdown
Contributor

Hello,

As we already have ravenHandle event when handling an exception, ravenSuccess and ravenFailure events for post-submitting data, I propose to add

  • ravenMessage when capturing a message
  • ravenPresend just before sending data to Sentry server.

This improves raven flexibility for the developer as it allows him to tweak the data.

@benvinegar

Copy link
Copy Markdown
Contributor

So, we're definitely going to change the event API and get away from DOM events. I'm cool with adding these events; it's just a question of whether it makes sense for us to merge this ahead of those API changes, and wait until the API is done.

It will likely look like:

Raven.on('send', function () { ... }); // or presend/beforesend
Raven.on('exception', function () { ... });
Raven.on('message', function () { ... });
Raven.on('success', function () { ... });
Raven.on('failure', function () { ... });

And then also:

Raven.off('send'); // all send events
Raven.off('send', listener); // specific listener

Also, this will allow people to add multiple event handlers, which wasn't possible earlier.

@romainneutron

Copy link
Copy Markdown
Contributor Author

Wow, this is definitely a better API. When these changes are supposed to land in a production-ready version?

@benvinegar

Copy link
Copy Markdown
Contributor

When these changes are supposed to land in a production-ready version?

See: #521, which is targeted against a 3.0 release. We'll probably release 3.0 within a week (hopefully). After which we can re-evaluate this PR.

As an aside, if you need to use presend today, you get almost the same thing out of Raven.setDataCallback.

Re: the message event – was there a reason you wanted to bind to message events? Or were you just filling out the API for consistency?

@benvinegar

Copy link
Copy Markdown
Contributor

I've added a discussion about changing the events API: #524

@romainneutron – appreciate your thoughts there

@romainneutron

Copy link
Copy Markdown
Contributor Author

Sorry for the late reply. This sounds good. I wanted to use message event to customize message based on some pattern before sending them to Sentry.

Your proposal looks good, can't wait to test this

@romainneutron
romainneutron deleted the add-events branch March 22, 2016 13:09
pull Bot pushed a commit to TheDegenerateDev5150/sentry-javascript that referenced this pull request Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants