@@ -46,15 +46,21 @@ class SentryServiceProvider extends AbstractServiceProvider
4646
4747 public function register ()
4848 {
49+ $ this ->container ->singleton ('sentry.release ' , function () {
50+ return Application::VERSION ;
51+ });
52+
4953 $ this ->container ->singleton (HubInterface::class, function ($ container ) {
5054 /** @var SettingsRepositoryInterface $settings */
5155 $ settings = $ container ->make (SettingsRepositoryInterface::class);
5256 /** @var UrlGenerator $url */
5357 $ url = $ container ->make (UrlGenerator::class);
5458 $ dsn = $ settings ->get ('fof-sentry.dsn_backend ' );
59+ /** @var string $release */
60+ $ release = $ container ->make ('sentry.release ' );
5561 $ environment = empty ($ settings ->get ('fof-sentry.environment ' )) ? str_replace (['https:// ' , 'http:// ' ], '' , $ url ->to ('forum ' )->base ()) : $ settings ->get ('fof-sentry.environment ' );
5662 $ performanceMonitoring = (int ) $ settings ->get ('fof-sentry.monitor_performance ' );
57- $ profilesSampleRate = (int ) $ settings ->get ('fof-sentry.profile_rate ' , 0 );
63+ $ profilesSampleRate = (int ) $ settings ->get ('fof-sentry.profile_rate ' );
5864
5965 if (empty ($ dsn )) {
6066 $ dsn = $ settings ->get ('fof-sentry.dsn ' );
@@ -72,7 +78,7 @@ public function register()
7278 'traces_sample_rate ' => $ tracesSampleRate ,
7379 'profiles_sample_rate ' => $ profilesSampleRate ,
7480 'environment ' => $ environment ,
75- 'release ' => Application:: VERSION ,
81+ 'release ' => $ release ,
7682 ]);
7783
7884 return SentrySdk::getCurrentHub ();
@@ -94,8 +100,8 @@ public function register()
94100 $ hub = $ this ->container ->make (HubInterface::class);
95101
96102 $ hub ->configureScope (function (Scope $ scope ) use ($ config ) {
97- $ scope ->setTag ('offline ' , Arr::get ($ config , 'offline ' , false ));
98- $ scope ->setTag ('debug ' , Arr::get ($ config , 'debug ' , true ));
103+ $ scope ->setTag ('offline ' , $ this -> booleanToString ( Arr::get ($ config , 'offline ' , false ) ));
104+ $ scope ->setTag ('debug ' , $ this -> booleanToString ( Arr::get ($ config , 'debug ' , true ) ));
99105 $ scope ->setTag ('flarum ' , Application::VERSION );
100106
101107 if ($ this ->container ->bound ('sentry.stack ' )) {
@@ -209,4 +215,12 @@ public function __destruct()
209215 $ transaction ->finish ();
210216 }
211217 }
218+
219+ /**
220+ * A simple helper to convert a boolean to a string.
221+ */
222+ public function booleanToString (bool $ value ): string
223+ {
224+ return $ value ? 'true ' : 'false ' ;
225+ }
212226}
0 commit comments