diff --git a/src/Subscriber/StorefrontPageSubscriber.php b/src/Subscriber/StorefrontPageSubscriber.php index 2852d97..2f5e1f4 100644 --- a/src/Subscriber/StorefrontPageSubscriber.php +++ b/src/Subscriber/StorefrontPageSubscriber.php @@ -25,7 +25,8 @@ public static function getSubscribedEvents(): array public function onRender(StorefrontRenderEvent $event): void { - if ($this->sentryOptions->getDsn() == null + if ($this->sentryOptions->getDsn() === null + || !$this->container->hasParameter('frosh_sentry.storefront.enabled') || !$this->container->getParameter('frosh_sentry.storefront.enabled') ) { return; @@ -36,8 +37,10 @@ public function onRender(StorefrontRenderEvent $event): void return; } - $isReplayRecordingEnabled = $this->container->getParameter('frosh_sentry.storefront.replay_recording.enabled'); - $isPerformanceTracingEnabled = $this->container->getParameter('frosh_sentry.storefront.tracing.enabled') === true; + $isReplayRecordingEnabled = $this->container->hasParameter('frosh_sentry.storefront.replay_recording.enabled') + && $this->container->getParameter('frosh_sentry.storefront.replay_recording.enabled') === true; + $isPerformanceTracingEnabled = $this->container->hasParameter('frosh_sentry.storefront.tracing.enabled') + && $this->container->getParameter('frosh_sentry.storefront.tracing.enabled') === true; if ($isReplayRecordingEnabled && $isPerformanceTracingEnabled) { $jsFile = 'bundle.tracing.replay.min.js'; @@ -52,8 +55,12 @@ public function onRender(StorefrontRenderEvent $event): void return; } - $replaySample = $this->container->getParameter('frosh_sentry.storefront.replay_recording.sample_rate'); - $tracingSample = $this->container->getParameter('frosh_sentry.storefront.tracing.sample_rate'); + $replaySample = $this->container->hasParameter('frosh_sentry.storefront.replay_recording.sample_rate') + ? $this->container->getParameter('frosh_sentry.storefront.replay_recording.sample_rate') + : 0.1; + $tracingSample = $this->container->hasParameter('frosh_sentry.storefront.tracing.sample_rate') + ? $this->container->getParameter('frosh_sentry.storefront.tracing.sample_rate') + : 0.1; $event->setParameter('sentry', [ 'dsn' => $this->sentryOptions->getDsn(),