diff --git a/assets/backoffice.js b/assets/backoffice.js index 7758b59..de391c0 100644 --- a/assets/backoffice.js +++ b/assets/backoffice.js @@ -3,3 +3,35 @@ import 'bootstrap-icons/font/bootstrap-icons.min.css'; import './styles/backoffice.scss'; import './stimulus.js'; import './bootstrap.js'; +import * as Sentry from '@sentry/browser'; + +const dsn = document.querySelector('meta[name="sentry-dsn"]')?.content ?? ''; +const userEmail = document.querySelector('meta[name="user-email"]')?.content ?? ''; + +// When no real DSN is configured, route to the local Spotlight sidecar so +// nothing reaches Sentry. A syntactically valid DSN is still required for the +// SDK to initialise; the tunnel option redirects all transport to Spotlight. +const useSpotlight = !dsn; +const effectiveDsn = dsn || 'https://0@o0.ingest.sentry.io/0'; + +const feedbackIntegration = Sentry.feedbackIntegration({ + colorScheme: 'system', + showName: true, + showEmail: true, + isNameRequired: false, + isEmailRequired: false, + autoInject: false, +}); + +Sentry.init({ + dsn: effectiveDsn, + tunnel: useSpotlight ? 'http://localhost:8969/stream' : undefined, + integrations: [feedbackIntegration], +}); + +// autoInject is unreliable in Sentry v10 due to the setupOnce guard; mount manually. +feedbackIntegration.createWidget(); + +if (userEmail) { + Sentry.setUser({ email: userEmail }); +} diff --git a/compose.override.yaml b/compose.override.yaml index 2efd489..7c718e0 100644 --- a/compose.override.yaml +++ b/compose.override.yaml @@ -70,5 +70,10 @@ services: MP_SMTP_AUTH_ALLOW_INSECURE: 1 ###< symfony/mailer ### + spotlight: + image: ghcr.io/getsentry/spotlight:latest + ports: + - "8969:8969" + volumes: sass: diff --git a/config/bundles.php b/config/bundles.php index 0cf9639..bf0ee87 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -30,7 +30,7 @@ return [ TwigExtraBundle::class => ['all' => true], DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], SymfonyCastsVerifyEmailBundle::class => ['all' => true], - SentryBundle::class => ['prod' => true], + SentryBundle::class => ['dev' => true, 'prod' => true], SymfonycastsSassBundle::class => ['all' => true], StimulusBundle::class => ['all' => true], TurboBundle::class => ['all' => true], diff --git a/config/packages/sentry.yaml b/config/packages/sentry.yaml index aefb61a..234bebc 100644 --- a/config/packages/sentry.yaml +++ b/config/packages/sentry.yaml @@ -1,3 +1,10 @@ +when@dev: + sentry: + dsn: 'https://placeholder@placeholder.ingest.sentry.io/0' + options: + spotlight: true + spotlight_url: 'http://spotlight:8969/stream' + when@prod: sentry: dsn: '%env(SENTRY_DSN)%' diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index eb82507..9ce76ab 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -1,6 +1,8 @@ twig: file_name_pattern: '*.twig' form_themes: [ 'bootstrap_5_layout.html.twig' ] + globals: + sentry_dsn: '%env(SENTRY_DSN)%' when@test: twig: diff --git a/config/reference.php b/config/reference.php index 0fe774d..27b09bf 100644 --- a/config/reference.php +++ b/config/reference.php @@ -1,5 +1,7 @@ ['version' => '3.2.2'], '@hotwired/turbo' => ['version' => '8.0.23'], 'bootstrap-icons/font/bootstrap-icons.min.css' => ['version' => '1.13.1', 'type' => 'css'], + '@sentry/browser' => ['version' => '10.63.0'], + '@sentry/feedback' => ['version' => '10.63.0'], + '@sentry/core/browser' => ['version' => '10.63.0'], + '@sentry/browser-utils' => ['version' => '10.63.0'], + '@sentry/replay' => ['version' => '10.63.0'], + '@sentry/replay-canvas' => ['version' => '10.63.0'], + '@sentry/core' => ['version' => '10.63.0'], ]; diff --git a/templates/backoffice/base.html.twig b/templates/backoffice/base.html.twig index 5aeeaa2..ea75932 100644 --- a/templates/backoffice/base.html.twig +++ b/templates/backoffice/base.html.twig @@ -1,5 +1,10 @@ {% extends 'base.html.twig' %} {% block importmap %}{{ importmap('backoffice') }}{% endblock %} +{% block sentry_loader %}{% endblock %} +{% block head_extra %} + + +{% endblock %} {% block title %}Tijd voor de test | {% endblock %} {% block nav %}{{ include('backoffice/nav.html.twig') }}{% endblock %} diff --git a/templates/base.html.twig b/templates/base.html.twig index 33f4c8d..cbb04d9 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -3,14 +3,17 @@ + {% block sentry_loader %} + {% endblock %} {% block title %}Tijd voor de test{% endblock title %} {% block importmap %}{% endblock %} + {% block head_extra %}{% endblock %} {% block nav %}