A (unofficial) WordPress plugin to report PHP errors and Browser (JavaScript) errors to Sentry.
This plugin can report PHP errors and Browser (JavaScript) errors to Sentry.
It will auto detect authenticated users and add context where possible. All context/tags can be adjusted/expanded using filters.
For more information and documentation have a look at the full documentation.
It is recommended to use the plugins interface in WordPress to install this plugin.
If manual installation is required, please make sure that the plugin files are in a folder named “wp-sentry-integration” in the WordPress plugins folder, usually “wp-content/plugins”.
To start using the plugin first setup the DSN for either the PHP side or the Browser side or both.
All other configuration options are optional but it’s advised you read through them to see if any are applicable to you or are thing you’d like to configure.
You can find more information and the full documentation: here. The following are the basics.
Note: When configuring constants in your wp-config.php
do this before the That's all, stop editing! Happy publishing.
line, otherwise they won’t work!
Note: this plugin does not do anything by default and has only a admin interface to test the integration and view it’s configuration. A Sentry DSN must be configured in your wp-config.php
.
Sentry uses something called a DSN (read more) to configure the SDK.
To track PHP errors add this snippet to your wp-config.php
and replace PHP_DSN
with your actual DSN that you find inside Sentry in the project settings under “Client Keys (DSN)”:
define( 'WP_SENTRY_PHP_DSN', 'PHP_DSN' );
Note: Do not set this constant to disable the PHP tracker.
To track Browser (JavaScript) errors add this snippet to your wp-config.php
and replace JS_DSN
with your actual DSN that you find inside Sentry in the project settings under “Client Keys (DSN)”:
define( 'WP_SENTRY_BROWSER_DSN', 'JS_DSN' ); // You can _optionally_ enable or disable the JavaScript tracker in certain parts of your site with these constants: define('WP_SENTRY_BROWSER_ADMIN_ENABLED', true); // Add the JavaScript tracker to the admin area. Default: true define('WP_SENTRY_BROWSER_LOGIN_ENABLED', true); // Add the JavaScript tracker to the login page. Default: true define('WP_SENTRY_BROWSER_FRONTEND_ENABLED', true); // Add the JavaScript tracker to the front end. Default: true
Note: Do not set this constant to disable the Browser (JavaScript) tracker.
You can find more information and the full documentation: here. The above are the basics.
theme.setup
and plugins.setup
if possibleWP_SENTRY_SEND_DEFAULT_PII
is set to true
)/
in tracing transaction when parsing the matched URLThis release adds performance tracing and profiling support for the PHP SDK, this feature is disabled by default read the documentation on how to enable it.
This update bumps the minimum PHP version to 7.2.5, this used to be 7.2.0.
This is unlikely to affect you, but if you are still running PHP 7.2.0 you should upgrade to at least 7.2.5.
The change was made to allow upgrading some libraries and prevent deprecation warnings on newer PHP versions.
$options
in wp_sentry_options
filter (#183, thanks @Pluuk)WP_SENTRY_BROWSER_USE_ES5_BUNDLES
option was enabled.wp_sentry_before_send
filter to allow modifying or discarding a PHP error event before it’s sent to Sentry (#180, thanks @herewithme)wp_sentry_hook
after setting up the integrations to allow the user modifying the integrations array from the hookis_plugin_active_for_network
unconditionally which is not always availableNote: This is a breaking release for the PHP SDK, please test it well and read the migration guides if applicable before upgrading!
If you are doing anything more than just have this plugin installed and a DSN configured in your wp-config.php
, check out the upgrade docs:
PHP SDK: https://github.com/getsentry/sentry-php/blob/master/UPGRADE-4.0.md
Update PHP SDK to version 4.0.0
WP_HTTP_Proxy
class to configure the HTTP proxy, this allows you to initialize the SDK before WordPress is fully loadedWP_SENTRY_BROWSER_FRONTEND_ENABLED
, WP_SENTRY_BROWSER_ADMIN_ENABLED
and WP_SENTRY_BROWSER_LOGIN_ENABLED
constants to enable/disable the browser SDK on the frontend, admin and login pages respectively (they are enabled by default)ignoreTransactions
option of the browser SDKIf you are using an HTTP proxy in WordPress but don’t want Sentry to use it you should configure WP_PROXY_BYPASS_HOSTS
to include the Sentry domain.
WP_SENTRY_BROWSER_REPLAYS_SESSION_SAMPLE_RATE
and WP_SENTRY_BROWSER_REPLAYS_ON_ERROR_SAMPLE_RATE
options to enable browser session replaysWP_SENTRY_BROWSER_SESSION_REPLAY_OPTIONS
to configure options passed to new Replays()
when browser session replays are enabledWP_SENTRY_BROWSER_TRACING_OPTIONS
to configure options passed to new BrowserTracing()
when browser tracing is enabledignoreErrors
option of the browser SDKNote: This is a breaking release for the Browser/JavaScript SDK
Since 5.0.0 of this plugin, which bundles the Browser SDK version 7, the whitelistUrls
and blacklistUrls
are no longer working. They are renamed to allowUrls
and denyUrls
respectively, please update your code if you are using those options.
Since this version of the plugin we no longer bundle the ES5 versions of the Browser SDK by default, which means that if you still need to support older browsers (Internet Explorer 11 mainly) you need to enable the new WP_SENTRY_BROWSER_USE_ES5_BUNDLES
option by setting it to true
. Enabling the ES5 bundles will also loads an externally hosted polyfill library for the needed polyfills.
If you are still on a WP Sentry version older than version 5.0.0 don’t forget to see the Browser SDK v7 migration guide.
WP_SENTRY_BROWSER_USE_ES5_BUNDLES
flag to enable ES5 bundles + external hosted polyfill librarywhitelistUrls
and blacklistUrls
which are now called allowUrls
and denyUrls
options (thanks @dr5hn)wp_sentry_options
filter when no DSN is setNote: This is a breaking release for the Browser/JavaScript SDK, please test it well and read the migration guides if applicable before upgrading!
Note: The v7 version of the JavaScript SDK requires a self-hosted version of Sentry 20.6.0 or higher. If you are using a version of self-hosted Sentry (aka onpremise) older than 20.6.0 then you will need to upgrade.
Version 7 of the Sentry JavaScript SDK brings a variety of features and fixes including bundle size and performance improvements, brand new integrations, support for the attachments API, and key bug fixes.
This release does not change or remove any top level public API methods (captureException, captureMessage), and only requires changes to certain configuration options or custom clients/integrations/transports.
For detailed overview of all the changes, please see the v7 migration guide.
guzzlehttp/psr7
dependency (https://github.com/advisories/GHSA-q7rv-6hp3-vh96)WPINC
constant instead of hardcoded path to wp-includes
wp-config.php
with browser DSN enabledInterface 'Stringable' not found
on PHP < 8.0wp-config.php
without WP_SENTRY_VERSION
definedwp-config.php
before WordPress is loaded (see documentation) (thanks @ocean90)ClientBuilder
builder (see documentation)wp_sentry_hook
callbackWP_SENTRY_BROWSER_TRACES_SAMPLE_RATE
option to enable browser performance tracingRereleased 4.0.0 to fix issue with missing dependencies folder, see 4.0.0 changelog for changes!
Note: This is a breaking release for the PHP SDK, please test it well and read the migration guides if applicable before upgrading!
If you are doing anything more than just have this plugin installed and a DSN defined on your wp-config.php, check out the upgrade docs:
Becasue of the upgrade to the 3.x version of the PHP SDK this plugin now has the requirement that it runs on at least PHP 7.2, for older PHP versions stick to version 3.x.
activate_plugins
capability (instead of install_plugins
) to support sites that have install_plugins
disabled globallypublic/sentry-browser-<Sentry Browser version>.min.js
to public/wp-sentry-browser.min.js
, this change should have no user impact unless you manually include that fileWP_SENTRY_DSN
to WP_SENTRY_PHP_DSN
, both will be supported but the latter is preferred because of it’s more descriptive nameWP_SENTRY_PUBLIC_DSN
to WP_SENTRY_BROWSER_DSN
, both will be supported but the latter is preferred because of it’s more descriptive nameafter_setup_theme
hookWP_SENTRY_PROJECT_ROOT
optionprefixes
to get cleaner file paths on PHP stack traces\Sentry\Monolog\Handler
classCall to undefined function getallheaders()
error on PHP versions below 7.3Important: In this release we start using a process to prefix our dependencies to prevent conflicts with other WordPress plugins.
This should cause no problems, but if they do please open up a support ticket or GitHub issue with details about your environment.
Important: In this release we start using a process to prefix our dependencies to prevent conflicts with other WordPress plugins.
This should cause no problems, but if they do please open up a support ticket or GitHub issue with details about your environment.
WP_SENTRY_VERSION
is not defined and theme version returns false
.Note: This is a breaking release for both the PHP SDK and the Browser SDK, please test it well and read the migration guides if applicable before upgrading!
If you are doing anything more than just have this plugin installed and a DSN defined on your wp-config.php, check out the upgrade docs:
Becasue of the upgrade to the 2.x version of the PHP SDK this plugin now has the requirement that it runs on at least PHP 7.1, for older PHP versions stick to version 2.x.
This release might contain breaking changes if you are using the wp_sentry_public_options
filter.
wp_sentry_public_options
filter to support the Sentry Browser SDK better (#28)If you are doing custom calls to Sentry from your front-end make sure you check out the new docs and migration instructions: https://github.com/getsentry/sentry-javascript/releases/tag/4.0.0
If you are not doing anything custom to the JS side of the SDK you can safely upgrade to this version.
This version allows the usage of the new private key-less DSN introduced in Sentry 9.
error_types
option to be configured from wp-config.php
wp_sentry_options
after the after_setup_theme
action if it’s defined