Skip to content

Commit 29ea136

Browse files
Copilotshyim
andauthored
Fix ParameterNotFoundException when storefront config is omitted (#35)
* Initial plan * Add hasParameter check for frosh_sentry.storefront.enabled Co-authored-by: shyim <6224096+shyim@users.noreply.github.com> * Add hasParameter checks for all storefront configuration parameters Co-authored-by: shyim <6224096+shyim@users.noreply.github.com> * Fix code style: use strict comparison operators Co-authored-by: shyim <6224096+shyim@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: shyim <6224096+shyim@users.noreply.github.com>
1 parent ff1d552 commit 29ea136

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎src/Subscriber/StorefrontPageSubscriber.php‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public static function getSubscribedEvents(): array
2525

2626
public function onRender(StorefrontRenderEvent $event): void
2727
{
28-
if ($this->sentryOptions->getDsn() == null
28+
if ($this->sentryOptions->getDsn() === null
29+
|| !$this->container->hasParameter('frosh_sentry.storefront.enabled')
2930
|| !$this->container->getParameter('frosh_sentry.storefront.enabled')
3031
) {
3132
return;
@@ -36,8 +37,10 @@ public function onRender(StorefrontRenderEvent $event): void
3637
return;
3738
}
3839

39-
$isReplayRecordingEnabled = $this->container->getParameter('frosh_sentry.storefront.replay_recording.enabled');
40-
$isPerformanceTracingEnabled = $this->container->getParameter('frosh_sentry.storefront.tracing.enabled') === true;
40+
$isReplayRecordingEnabled = $this->container->hasParameter('frosh_sentry.storefront.replay_recording.enabled')
41+
&& $this->container->getParameter('frosh_sentry.storefront.replay_recording.enabled') === true;
42+
$isPerformanceTracingEnabled = $this->container->hasParameter('frosh_sentry.storefront.tracing.enabled')
43+
&& $this->container->getParameter('frosh_sentry.storefront.tracing.enabled') === true;
4144

4245
if ($isReplayRecordingEnabled && $isPerformanceTracingEnabled) {
4346
$jsFile = 'bundle.tracing.replay.min.js';
@@ -52,8 +55,12 @@ public function onRender(StorefrontRenderEvent $event): void
5255
return;
5356
}
5457

55-
$replaySample = $this->container->getParameter('frosh_sentry.storefront.replay_recording.sample_rate');
56-
$tracingSample = $this->container->getParameter('frosh_sentry.storefront.tracing.sample_rate');
58+
$replaySample = $this->container->hasParameter('frosh_sentry.storefront.replay_recording.sample_rate')
59+
? $this->container->getParameter('frosh_sentry.storefront.replay_recording.sample_rate')
60+
: 0.1;
61+
$tracingSample = $this->container->hasParameter('frosh_sentry.storefront.tracing.sample_rate')
62+
? $this->container->getParameter('frosh_sentry.storefront.tracing.sample_rate')
63+
: 0.1;
5764

5865
$event->setParameter('sentry', [
5966
'dsn' => $this->sentryOptions->getDsn(),

0 commit comments

Comments
 (0)