-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
48 lines (41 loc) · 1.33 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
@include_once __DIR__ . '/vendor/autoload.php';
use function Sentry\init;
use function Sentry\captureException;
use function Sentry\configureScope;
use Sentry\State\Scope;
Kirby::plugin("thathoff/sentry", [
'config' => [
'dsn' => null,
'environment' => 'production',
'addUserContext' => true,
],
'hooks' => [
'system.exception' => function ($exception) {
$dsn = option('thathoff.sentry.dsn');
// when no dsn is configured we do nothing
if (!$dsn) {
return;
}
// init and configure sentry
init([
'dsn' => $dsn,
'environment' => option('thathoff.sentry.environment', 'production'),
]);
// attach user context if enabled
if (
option('thathoff.sentry.addUserContext', true) &&
$user = kirby()->user()
) {
configureScope(function (Scope $scope) use ($user) {
$scope->setUser([
'email' => (string)$user->email(),
'username' => (string)$user->name(),
]);
});
}
// capture exception and send to sentry
captureException($exception);
}
],
]);