DockTHOR integrates WordPress with the THOR monitoring platform and automatically reports PHP errors and uncaught exceptions.
The plugin is designed to work silently in the background and has no admin interface. After installation you only need to configure your THOR project credentials.
This plugin is intended for developers and teams who want to monitor errors occurring in WordPress installations.
Installation
/wp-content/plugins/dockthor directory, or install the plugin through the WordPress plugins screen.wp-config.php.Example configuration:
php
define( 'DOCK_THOR_TOKEN', 'YOUR_THOR_TOKEN' );
define( 'DOCK_THOR_PRIVATE_KEY', 'YOUR_PRIVATE_KEY' );
Once configured, the plugin will automatically begin reporting PHP errors.
Configuration
Add the following constants to your wp-config.php file.
phpphp
define( 'DOCK_THOR_TOKEN', 'YOUR_THOR_TOKEN' );
`<h3>Private Key</h3>
define( ‘DOCK_THOR_PRIVATE_KEY’, ‘YOUR_PRIVATE_KEY’ );
`
“`php
define( ‘DOCK_THOR_ERROR_TYPES’, E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_USER_DEPRECATED );
Define which PHP errors should be captured.<h3>Send Default PII (optional)</h3>php
If enabled, additional context such as the logged-in user and IP address will be attached to the event.
define( ‘DOCK_THOR_SEND_DEFAULT_PII’, true );
<h3>Site Version (optional)</h3>php
Define the version of your website. This can help track which version of the site generated an error.
define( ‘DOCK_THOR_VERSION’, ‘v1.0.0’ );
<h3>Environment (optional)</h3>php
Define the current environment.
define( ‘DOCK_THOR_ENV’, ‘production’ );
`
Filters
DockTHOR provides several filters that allow developers to customize behavior.
Allows extending the user context sent to THOR.
Example:
php
add_filter( 'dock_thor_user_context', function ( array $user ) {
return array_merge( $user, ['custom_meta' => 'value'] );
});
Note: These values may be exposed publicly when used in JavaScript trackers.
Allows overriding the THOR token.
Example:
php
add_filter( 'dock_thor_token', function ( $token ) {
return 'xxxxxxxxxxxxxxxxxxxx';
});
Using the DOCK_THOR_TOKEN constant is recommended instead.
Allows modifying the THOR scope before events are sent.
Example:
php
add_filter( 'dock_thor_scope', function ( \Dock\Thor\State\Scope $scope ) {
$scope->setTag('custom-tag', 'value');
return $scope;
});
Allows customizing THOR SDK options.
Example:
php
add_filter( 'dock_thor_options', function ( \Dock\Thor\Options $options ) {
$options->setSampleRate(0.9);
return $options;
});
Advanced Usage
Some plugins generate large amounts of PHP notices. You can filter them out:
php
define( 'DOCK_THOR_ERROR_TYPES', E_ALL & ~E_NOTICE );
If you want to report handled exceptions:
php
try {
myMethodThatCanThrowAnException();
} catch ( \Exception $e ) {
if ( function_exists( 'dock_thor_safe' ) ) {
dock_thor_safe( function ( \Dock\Thor\State\HubInterface $client ) use ( $e ) {
$client->captureException( $e );
});
}
wp_die( 'An error occurred.' );
}
Frequently Asked Questions
No. DockTHOR works automatically after configuration in wp-config.php.
The plugin is designed to have minimal performance impact. Error events are sent asynchronously when possible.
Yes. You can configure the error types captured using the DOCK_THOR_ERROR_TYPES constant.