From 0be024a850724d4e6eeb98deb1d3daf79b804e04 Mon Sep 17 00:00:00 2001 From: Julius Noack Date: Tue, 10 Mar 2026 16:46:56 +0100 Subject: [PATCH 1/3] feat: add support for allow and deny urls for storefront tracking --- src/DependencyInjection/Configuration.php | 6 ++++++ src/DependencyInjection/FroshSentryExtension.php | 2 ++ src/Resources/views/storefront/sentry.html.twig | 14 ++++++++++++++ src/Subscriber/StorefrontPageSubscriber.php | 4 ++++ 4 files changed, 26 insertions(+) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 7663127..f102b4f 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -23,6 +23,12 @@ public function getConfigTreeBuilder(): TreeBuilder ->addDefaultsIfNotSet() ->children() ->booleanNode('enabled')->defaultFalse()->end() + ->arrayNode('allowUrls') + ->scalarPrototype()->end() + ->end() + ->arrayNode('denyUrls') + ->scalarPrototype()->end() + ->end() ->arrayNode('replay_recording') ->addDefaultsIfNotSet() ->children() diff --git a/src/DependencyInjection/FroshSentryExtension.php b/src/DependencyInjection/FroshSentryExtension.php index 3bf53a3..0146c15 100644 --- a/src/DependencyInjection/FroshSentryExtension.php +++ b/src/DependencyInjection/FroshSentryExtension.php @@ -52,6 +52,8 @@ private function registerStorefrontConfiguration(array $config, ContainerBuilder $config['replay_recording']['sample_rate'] ?? 0.1, $config['tracing']['enabled'] ?? false, $config['tracing']['sample_rate'] ?? 0.1, + $config['allowUrls'] ?? [], + $config['denyUrls'] ?? [], ]) ->addTag('kernel.event_subscriber'); } diff --git a/src/Resources/views/storefront/sentry.html.twig b/src/Resources/views/storefront/sentry.html.twig index b54b8b8..b2fea3f 100644 --- a/src/Resources/views/storefront/sentry.html.twig +++ b/src/Resources/views/storefront/sentry.html.twig @@ -6,6 +6,20 @@ dsn: '{{ sentry.dsn }}', release: '{{ sentry.release }}', environment: '{{ sentry.environment }}', + {% if sentry.allowUrls -%} + allowUrls: [ + {% for url in sentry.allowUrls -%} + {{ url|raw }}, + {% endfor -%} + ], + {% endif -%} + {% if sentry.denyUrls -%} + denyUrls: [ + {% for url in sentry.denyUrls -%} + {{ url|raw }}, + {% endfor -%} + ], + {% endif -%} integrations: [ {% if sentry.tracing.enabled -%} Sentry.browserTracingIntegration({ diff --git a/src/Subscriber/StorefrontPageSubscriber.php b/src/Subscriber/StorefrontPageSubscriber.php index c45bf40..2e884db 100644 --- a/src/Subscriber/StorefrontPageSubscriber.php +++ b/src/Subscriber/StorefrontPageSubscriber.php @@ -17,6 +17,8 @@ public function __construct( private readonly float $replayRecordingSampleRate, private readonly bool $tracingEnabled, private readonly float $tracingSampleRate, + private readonly array $allowUrls, + private readonly array $denyUrls, ) {} public static function getSubscribedEvents(): array @@ -53,6 +55,8 @@ public function onRender(StorefrontRenderEvent $event): void 'enabled' => $this->tracingEnabled, 'sample_rate' => $this->tracingSampleRate, ], + 'allowUrls' => $this->allowUrls, + 'denyUrls' => $this->denyUrls, 'release' => $this->sentryOptions->getRelease(), 'environment' => $this->sentryOptions->getEnvironment(), ]); From 4f712d286d407dad8bb4607b9d3a3eda678afc70 Mon Sep 17 00:00:00 2001 From: Julius Noack Date: Tue, 10 Mar 2026 16:49:29 +0100 Subject: [PATCH 2/3] feat: add example to readme for deny/allow urls --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 531b40a..ff81c42 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,14 @@ frosh_sentry: storefront: # optional: if you want track errors occurs within the browser (javascript/cors/csp) enabled: true + # optional: if you want track errors only on specific urls/hosts + allowUrls: + - '"https://example.com"' + - /https?:\/\/((cdn|www)\.)?example\.com/ + # optional: if you want to ignore errors for specific urls/hosts + denyUrls: + - '"https://example.com"' + - /https?:\/\/((cdn|www)\.)?example\.com/ # optional: if you want record the user sessions. Please aware the GDPR. replay_recording: enabled: true From d1f1ae6c901feb2eff2ca8591c090edba01e440c Mon Sep 17 00:00:00 2001 From: Julius Noack Date: Wed, 11 Mar 2026 10:01:27 +0100 Subject: [PATCH 3/3] fix: coding styles --- src/DependencyInjection/Configuration.php | 2 +- src/DependencyInjection/FroshSentryExtension.php | 4 ++-- src/Subscriber/StorefrontPageSubscriber.php | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index f102b4f..d462928 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -6,7 +6,6 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; -use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; class Configuration implements ConfigurationInterface { @@ -16,6 +15,7 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode = $treeBuilder->getRootNode(); // @formatter:off + /** @phpstan-ignore class.notFound */ $rootNode ->children() ->booleanNode('report_scheduled_tasks')->defaultFalse()->end() diff --git a/src/DependencyInjection/FroshSentryExtension.php b/src/DependencyInjection/FroshSentryExtension.php index 0146c15..66c3bb6 100644 --- a/src/DependencyInjection/FroshSentryExtension.php +++ b/src/DependencyInjection/FroshSentryExtension.php @@ -18,7 +18,7 @@ class FroshSentryExtension extends Extension */ public function load(array $configs, ContainerBuilder $container): void { - /** @var array{report_scheduled_tasks: bool, storefront?: array{enabled: bool, javascript_sdk_version: string, replay_recording?: array{enabled: bool, sample_rate: float}, tracing?: array{enabled: bool, sample_rate: float}}} $config */ + /** @var array{report_scheduled_tasks: bool, storefront?: array{enabled: bool, javascript_sdk_version: string, allowUrls?: array{string}, denyUrls?: array{string}, replay_recording?: array{enabled: bool, sample_rate: float}, tracing?: array{enabled: bool, sample_rate: float}}} $config */ $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); $container->setParameter('frosh_sentry.report_scheduled_tasks', $config['report_scheduled_tasks']); @@ -35,7 +35,7 @@ public function getConfiguration(array $config, ContainerBuilder $container): Co } /** - * @param array{enabled?: bool, javascript_sdk_version?: string, replay_recording?: array{enabled?: bool, sample_rate?: float}, tracing?: array{enabled?: bool, sample_rate?: float}} $config + * @param array{enabled?: bool, javascript_sdk_version?: string, allowUrls?: array{string}, denyUrls?: array{string}, replay_recording?: array{enabled?: bool, sample_rate?: float}, tracing?: array{enabled?: bool, sample_rate?: float}} $config */ private function registerStorefrontConfiguration(array $config, ContainerBuilder $container): void { diff --git a/src/Subscriber/StorefrontPageSubscriber.php b/src/Subscriber/StorefrontPageSubscriber.php index 2e884db..8141af6 100644 --- a/src/Subscriber/StorefrontPageSubscriber.php +++ b/src/Subscriber/StorefrontPageSubscriber.php @@ -17,7 +17,9 @@ public function __construct( private readonly float $replayRecordingSampleRate, private readonly bool $tracingEnabled, private readonly float $tracingSampleRate, + /** @var array{string} */ private readonly array $allowUrls, + /** @var array{string} */ private readonly array $denyUrls, ) {}