-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathAppServiceProvider.php
More file actions
64 lines (55 loc) · 1.83 KB
/
AppServiceProvider.php
File metadata and controls
64 lines (55 loc) · 1.83 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace App\Providers;
use App\Support\GitHub;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Sentry\State\Scope;
use function Sentry\captureException;
use function Sentry\configureScope;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
$this->registerSharedViewVariables();
$this->sendFailingJobsToSentry();
}
private function registerSharedViewVariables(): void
{
View::share('electronGitHubVersion', app()->environment('production')
? GitHub::electron()->latestVersion()
: 'dev'
);
View::share('discordLink', 'https://discord.gg/X62tWNStZK');
View::share('bskyLink', 'https://bsky.app/profile/nativephp.bsky.social');
View::share('openCollectiveLink', 'https://opencollective.com/nativephp');
View::share('githubLink', 'https://github.com/NativePHP');
}
private function sendFailingJobsToSentry(): void
{
Queue::failing(static function (JobFailed $event) {
if (app()->bound('sentry')) {
configureScope(function (Scope $scope) use ($event): void {
$scope->setContext('job', [
'connection' => $event->connectionName,
'queue' => $event->job->getQueue(),
'name' => $event->job->resolveName(),
'payload' => $event->job->payload(),
]);
});
captureException($event->exception);
}
});
}
}