Add BugSnag error monitoring to your WordPress applications.
New to BugSnag? Create an account
Looking for performance monitoring? See our performance guide
Open the Add New
page inside the Plugins
section of your WordPress admin dashboard, search for BugSnag and click Install Now
.
Download and unzip the latest bugsnag.zip.
Upload the bugsnag
folder using ftp or scp to the wp-content/plugins
folder of your WordPress site.
Click Activate Plugin
to activate the plugin.
Click Configure
and enter your BugSnag API Key from your BugSnag Dashboard.
You can find your API key in Project Settings from your BugSnag dashboard.
At this point, BugSnag should be installed and configured, and any unhandled exceptions will be automatically detected and should appear in your BugSnag dashboard.
If you want to see error messages on the page, BugSnag exception handlers can be disabled by setting the BUGSNAG_SET_EXCEPTION_HANDLERS
constant to false
. Exceptions will still be reported to BugSnag, but will have less context and so it is not recommended to be set on production environments.
Reporting handled exceptions can be accomplished as follows:
try {
// Some potentially crashy code
} catch (Exception $e) {
$bugsnagWordpress->notifyException($e);
}
When reporting handled exceptions, it’s often helpful to send us custom diagnostic data or to adjust the severity of particular errors. For more information, see reporting handled errors.
BugSnag will automatically capture the following data for every exception:
It is often helpful to send us additional application-specific diagnostic data. This can be accomplished as follows:
$bugsnagWordpress->setBeforeNotifyFunction(function ($error) {
$error->setMetaData([
'account' => [
'name' => 'Acme Co.',
'paying_customer' => true,
]
]);
});
For more information, see the customizing error reports reference.
In order to correlate errors with customer reports, or to see a list of users who experienced each error, it is helpful to capture and display user information on your BugSnag dashboard.
You can set this information as follows:
$bugsnagWordpress->setUser([
'id' => '123456',
'name' => 'Leeroy Jenkins',
'email' => 'leeeeroy@jenkins.com',
]);
You can also set this on the error object from the callback function from v2.9 and upwards:
$bugsnagWordpress->setBeforeNotifyFunction(function ($error) {
$error->setUser([
'id' => '123456',
'name' => 'Leeroy Jenkins',
'email' => 'leeeeroy@jenkins.com',
]);
});
For more information, see configuration options.
By sending your source revision or application version to us when you deploy a new version of your app, you’ll be able to see which deploy each error was introduced in, or seen in.
See our Build API guide for more details.
bugsnag-wordpress
and bugsnag-php
, the open-source libraries powering BugSnag for Wordpress, on GitHub