mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-06 15:40:14 +02:00
feat: add Sentry User Feedback widget to backoffice (#178)
Install @sentry/browser via AssetMapper and initialize the feedback integration on all backoffice pages. The CDN loader script is moved to an overridable block so backoffice pages use the npm SDK without double-initialising Sentry. Sentry is initialised only when a DSN is configured (SENTRY_DSN env var). When a user is logged in their email is pre-filled in the feedback form via Sentry.setUser(); both name and email remain optional so anonymous submissions are supported by simply leaving those fields empty.
This commit is contained in:
@@ -3,3 +3,26 @@ 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 ?? '';
|
||||
|
||||
if (dsn) {
|
||||
Sentry.init({
|
||||
dsn,
|
||||
integrations: [
|
||||
Sentry.feedbackIntegration({
|
||||
colorScheme: 'system',
|
||||
showName: true,
|
||||
showEmail: true,
|
||||
isNameRequired: false,
|
||||
isEmailRequired: false,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
if (userEmail) {
|
||||
Sentry.setUser({ email: userEmail });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -34,4 +34,11 @@ return [
|
||||
'@hotwired/stimulus' => ['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'],
|
||||
];
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
{% block importmap %}{{ importmap('backoffice') }}{% endblock %}
|
||||
{% block sentry_loader %}{% endblock %}
|
||||
{% block head_extra %}
|
||||
<meta name="sentry-dsn" content="{{ sentry_dsn }}">
|
||||
<meta name="user-email" content="{{ app.user ? app.user.userIdentifier : '' }}">
|
||||
{% endblock %}
|
||||
{% block title %}Tijd voor de test | {% endblock %}
|
||||
{% block nav %}{{ include('backoffice/nav.html.twig') }}{% endblock %}
|
||||
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
{% block sentry_loader %}
|
||||
<script
|
||||
src="https://js-de.sentry-cdn.com/30cf438bc708c97e6f45c127bed9af96.min.js"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
{% endblock %}
|
||||
<title>
|
||||
{% block title %}Tijd voor de test{% endblock title %}
|
||||
</title>
|
||||
{% block importmap %}{% endblock %}
|
||||
{% block head_extra %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block nav %}
|
||||
|
||||
Reference in New Issue
Block a user