-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPlugin.php
52 lines (41 loc) · 1.4 KB
/
Plugin.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
49
50
51
52
<?php namespace OFFLINE\Sentry;
use Event;
use Illuminate\Support\Facades\App;
use OFFLINE\Sentry\Classes\Context;
use Sentry\State\Hub;
use Sentry\State\Scope;
use System\Classes\PluginBase;
use System\Classes\UpdateManager;
class Plugin extends PluginBase
{
use Context;
public function register()
{
Event::listen('exception.report', function (\Throwable $e) {
if (!$this->app->bound('sentry')) {
return;
}
$config = config('sentry');
if (!array_get($config, 'environment')) {
$config['environment'] = App::environment();
}
/** @var Hub $sentry */
$sentry = $this->app->get('sentry');
$sentry->configureScope(function (Scope $scope) {
if ($user = $this->getBackendUser()) {
$scope->setUser($user);
}
if ($frontendUser = $this->getFrontendUser()) {
$scope->setExtra('RainLab.User', $frontendUser);
}
try {
$octoberVersion = UpdateManager::instance()->getCurrentVersion();
} catch (\Throwable $e) {
$octoberVersion = 'unknown';
}
$scope->setExtra('october_version', $octoberVersion);
});
$sentry->captureException($e);
});
}
}