bugsnag / bugsnag-wordpress

BugSnag error monitoring for WordPress sites
http://wordpress.org/plugins/bugsnag/
GNU General Public License v2.0
20 stars 15 forks source link

Added post-construction hook #19

Closed benallfree closed 5 years ago

benallfree commented 7 years ago

I added the bugsnag_constructed hook because custom notifiers do not work in Bugsnag tests due to the way testBugsnag() constructs and fires a notification directly instead of using $bugsnagWordpress.

Example usage:


add_action('bugsnag_constructed', function($bs) {
  $bs->setBeforeNotifyFunction(function ($error) {
      $id = get_current_user_id();
      if(!$id) return;
      $user_info = get_userdata($id);
      $error->setUser([
        'id' => $id,
        'username' => $user_info->user_login,
        'email' => $user_info->user_email,
        'first_name'=>$user_info->user_firstname,
        'last_name'=>$user_info->user_lastname,
      ]);
  });
});
Cawllec commented 6 years ago

Hi @benallfree, it's been a while but I'm looking into this and will update this PR ASAP.

tomlongridge commented 5 years ago

Hi @benallfree - blowing the dust off some PR's for an upcoming release. I don't quite follow the usecase for this - why can you not just add your beforeSendCallback directly in your code? Is it run before Bugsnag is initialised?

benallfree commented 5 years ago

Sorry I don't remember the reason for this after 2 years :/

tomlongridge commented 5 years ago

Sorry it's been a while! Closing for now, until such time as need arises.