From 2149bf5dd71710df5ebdae1ba49653b12e0acf49 Mon Sep 17 00:00:00 2001 From: IanM Date: Wed, 26 Mar 2025 12:28:20 +0000 Subject: [PATCH] feat: allow setting custom release version, standardize defaults --- extend.php | 10 +++++++++- src/Content/SentryJavaScript.php | 6 +++--- src/Formatters/SentryFormatter.php | 5 +++-- src/Reporters/SentryReporter.php | 2 +- src/SentryServiceProvider.php | 22 ++++++++++++++++++---- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/extend.php b/extend.php index afba205..d494116 100644 --- a/extend.php +++ b/extend.php @@ -62,5 +62,13 @@ }), (new Flarum\Settings()) - ->default('fof-sentry.monitor_performance', 0), + ->default('fof-sentry.monitor_performance', 0) + ->default('fof-sentry.send_emails_with_sentry_reports', false) + ->default('fof-sentry.user_feedback', false) + ->default('fof-sentry.javascript.console', false) + ->default('fof-sentry.javascript.trace_sample_rate', 0) + ->default('fof-sentry.javascript.replays_session_sample_rate', 0) + ->default('fof-sentry.javascript.replays_error_sample_rate', 0) + ->default('fof-sentry.profile_rate', 0) + ->default('fof-sentry.javascript', true), ]; diff --git a/src/Content/SentryJavaScript.php b/src/Content/SentryJavaScript.php index 0c518f5..200b70a 100644 --- a/src/Content/SentryJavaScript.php +++ b/src/Content/SentryJavaScript.php @@ -48,9 +48,9 @@ public function __invoke(Document $document) $shouldScrubEmailsFromUserData = !((bool) (int) $this->settings->get('fof-sentry.send_emails_with_sentry_reports')); - $tracesSampleRate = (int) $this->settings->get('fof-sentry.javascript.trace_sample_rate', 0); - $replaysSessionSampleRate = (int) $this->settings->get('fof-sentry.javascript.replays_session_sample_rate', 0); - $replaysErrorSampleRate = (int) $this->settings->get('fof-sentry.javascript.replays_error_sample_rate', 0); + $tracesSampleRate = (int) $this->settings->get('fof-sentry.javascript.trace_sample_rate'); + $replaysSessionSampleRate = (int) $this->settings->get('fof-sentry.javascript.replays_session_sample_rate'); + $replaysErrorSampleRate = (int) $this->settings->get('fof-sentry.javascript.replays_error_sample_rate'); $tracesSampleRate = max(0, min(100, $tracesSampleRate)) / 100; $replaysSessionSampleRate = max(0, min(100, $replaysSessionSampleRate)) / 100; diff --git a/src/Formatters/SentryFormatter.php b/src/Formatters/SentryFormatter.php index a515a82..7136f76 100644 --- a/src/Formatters/SentryFormatter.php +++ b/src/Formatters/SentryFormatter.php @@ -14,6 +14,7 @@ use Flarum\Foundation\ErrorHandling\HandledError; use Flarum\Foundation\ErrorHandling\HttpFormatter; use Flarum\Foundation\ErrorHandling\ViewFormatter; +use Flarum\Http\RequestUtil; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\View\Factory as ViewFactory; use Psr\Http\Message\ResponseInterface as Response; @@ -58,7 +59,7 @@ public function format(HandledError $error, Request $request): Response } $dsn = $settings->get('fof-sentry.dsn'); - $user = resolve('sentry.request')->getAttribute('actor'); + $user = RequestUtil::getActor(resolve('sentry.request')); $locale = $this->translator->getLocale(); $eventId = $sentry->getLastEventId(); $userData = ($user != null && $user->id != 0) ? @@ -72,7 +73,7 @@ public function format(HandledError $error, Request $request): Response $body->seek($body->getSize()); $body->write(" - +