File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 77This package is a Laravel extension
88
99## Installation
10- This package requires PHP 7.4 and Laravel 5.8 or higher.
10+ This package requires PHP 5.6 and Laravel 5.0 or higher.
1111
1212```
1313composer require programic/laravel-tools
Original file line number Diff line number Diff line change 22
33namespace Programic \Tools \Middleware ;
44
5+ use Sentry \State \Scope ;
6+ use Programic \Tools \ToolsServiceProvider ;
57use Closure ;
68
79class SentryContext
810{
911 public function handle ($ request , Closure $ next )
1012 {
1113 if (app ()->bound ('sentry ' )) {
12- app ('sentry ' )->configureScope (function (\ Sentry \ State \ Scope $ scope ) {
14+ app ('sentry ' )->configureScope (function (Scope $ scope ) {
1315 if (auth ()->check ()) {
1416 $ user = auth ()->user ();
1517
1618 $ scope ->setUser ([
1719 'id ' => $ user ->id ,
1820 'email ' => $ user ->email ,
19- 'plan ' => $ user ->plan
2021 ]);
2122 }
2223
2324 $ scope
24- ->setTags ([
25- 'laravel ' => app ()->version (),
25+ ->setContext ('Laravel ' , [
26+ 'version ' => app ()->version (),
27+ 'Tools version ' => ToolsServiceProvider::VERSION ,
2628 ]);
2729
2830 });
Original file line number Diff line number Diff line change 22
33namespace Programic \Tools ;
44
5- use Illuminate \Contracts \ Http \ Kernel ;
5+ use Illuminate \Routing \ Router ;
66use Illuminate \Support \ServiceProvider ;
77use Programic \Tools \Middleware \SentryContext ;
88
99class ToolsServiceProvider extends ServiceProvider
1010{
11+ const VERSION = 1.1 ;
12+ private $ middlewareGroups = ['web ' , 'api ' ];
13+
1114 /**
1215 * Boot the service provider.
1316 *
1417 * @return void
1518 */
16- public function boot (Kernel $ kernel )
19+ public function boot (Router $ router )
1720 {
18- $ kernel ->pushMiddleware (SentryContext::class);
21+ foreach ($ this ->middlewareGroups as $ group ) {
22+ if ($ router ->hasMiddlewareGroup ($ group )) {
23+ $ router ->pushMiddlewareToGroup ($ group , SentryContext::class);
24+ }
25+ }
1926 }
2027
2128
You can’t perform that action at this time.
0 commit comments