Table of Contents
sentry Plugin
Compatible with DokuWiki
Greebo
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
This plugin will log errors and exceptions in DokuWiki's PHP backend and the JavaScript frontend to a Sentry instance. You can either use sentry.io or a self hosted instance.
Installation
Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.
Privacy Info: when you install this plugin in a live wiki, you probably need to inform your users that their personal information (username, email, IP-Address, browser info) is logged to Sentry in case of an unforeseen error. Sentry also offers some detailed setting to configure how long personal data is retained.
Changes
- Merge pull request #12 from cosmocode/memory (2020-07-02 15:23)
- Version upped (2020-07-02 15:04)
- Fix Travis CI config (2020-07-02 13:08)
- Prevent memory exhaustion in Hogfather (2020-07-02 12:59)
- Version upped (2018-06-12 23:52)
- Merge pull request #7 from cosmocode/jslogs (2018-06-12 14:46)
- reverse javascritp stack traces (2018-06-12 14:34)
- set correct file name field for chrome stacks (2018-06-12 14:34)
Configuration
Use the extension manager and configure the DSN to you sentry project. You can find it under Project → Settings → Client Keys.
It should look like this: https://<public>:<secret>@<sentryinstance>/<projectid>
.
You can configure which kind of errors should be logged via the errors
configuration setting. It defaults to what is set for PHP's error_reporting and accepts the same integer. You can use this calculator to figure out the value you want.
The env
variable allows you to easily differentiate between multiple wikis being logged into the same Sentry. This is useful when you have a local development and a live wiki for example.
Usage
Once installed and configured, it will log all unhandled errors to Sentry automatically.
You can also use it in your code for specialized logging.
PHP
To log an error use the helper plugin:
try { // some code } catch(\Exception $e) { $sentry = plugin_load('helper', 'sentry'); if($sentry) $sentry->logException($e); msg(hsc($e->getMessage()), -1); }
The helper plugin exposes some more public methods in case you need more control.
You can also use the following to log an arbitrary message and additional data. (Useful when debugging problems on a live server):
$sentry = plugin_load('helper','sentry'); if($sentry) { $sentry->logMessage('my log message', array( 'something' => $info) ); }
JavaScript
To log an error, call the SentryPlugin.logSentryException()
method.
try { // some code } catch(error) { window.SentryPlugin && SentryPlugin.logSentryException(error, {}); console.log(error) }