stayallive / wp-sentry

A (unofficial) WordPress plugin reporting PHP and JavaScript errors to Sentry.
https://wordpress.org/plugins/wp-sentry-integration/
MIT License
318 stars 48 forks source link

Documentation for manual PHP event capturing #57

Closed lkraav closed 4 years ago

lkraav commented 4 years ago

I'm staring at https://docs.sentry.io/error-reporting/capturing/?platform=php#capturing-events and as-is, it's surprisingly vague text:

Capturing Events SDKs generally also provide ways to capture entire custom event objects. This is what integrations internally use to capture bespoke events with a lot of extra data fed into. For more information about that consult the API documentation of the SDK.

Digging further, and started thinking maybe we should add some documentation in README.md on this.

For example, I'd like to add_action update_option_rewrite_rules to trigger a Sentry event, so I'd know as soon as someone is _doing_it_wrong().

lkraav commented 4 years ago

I think this might boil down to simply using trigger_error() manually, and _doing_it_wrong() directly where appropriate.

stayallive commented 4 years ago

I think you can look in this direction: https://github.com/stayallive/wp-sentry#capturing-handled-exceptions.

Except you might not have an exception so you want to capture a message: https://docs.sentry.io/error-reporting/capturing/?platform=php#capturing-messages

Trigger error would also work and that should also be captured, happy to take a look at your solution, it might be nice to add some more info to the docs if needed.

lkraav commented 4 years ago

Exceptions: require extra try/catch ceremony dance

Messages: no backtrace, I think?

trigger_error()-based approach seems like the optimal thing, at the moment.

stayallive commented 4 years ago

Jep I think trigger_error is the best and easiest.

Feel free to open up a PR if you feel this could be described better in the docs.