```
✨ feat(Sentry): Initialise Sentry pour le suivi des erreurs et performances.
Ajoute l'initialisation de Sentry avec tunnel, suivi des performances et replay.
```
This commit is contained in:
@@ -1,15 +1,29 @@
|
||||
import './admin.scss'
|
||||
import * as Turbo from "@hotwired/turbo"
|
||||
import * as Sentry from "@sentry/browser";
|
||||
import * as Turbo from "@hotwired/turbo";
|
||||
|
||||
// --- INITIALISATION SENTRY (En premier !) ---
|
||||
Sentry.init({
|
||||
dsn: "https://803814be6540031b1c37bf92ba9c0f79@sentry.esy-web.dev/24",
|
||||
tunnel: "/sentry-tunnel",
|
||||
sendDefaultPii: true,
|
||||
integrations: [
|
||||
Sentry.browserTracingIntegration(),
|
||||
Sentry.replayIntegration()
|
||||
],
|
||||
tracesSampleRate: 1.0,
|
||||
tracePropagationTargets: ["localhost", "esy-web.dev"], // Remplace par ton domaine réel
|
||||
replaysSessionSampleRate: 0.1,
|
||||
replaysOnErrorSampleRate: 1.0
|
||||
});
|
||||
|
||||
/**
|
||||
* Initialise les composants de l'interface d'administration.
|
||||
* Cette fonction est appelée à chaque chargement de page par Turbo.
|
||||
*/
|
||||
function initAdminLayout() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const overlay = document.getElementById('sidebar-overlay');
|
||||
const toggleBtn = document.getElementById('sidebar-toggle');
|
||||
|
||||
const settingsToggle = document.getElementById('settings-toggle');
|
||||
const settingsSubmenu = document.getElementById('settings-submenu');
|
||||
|
||||
@@ -30,17 +44,11 @@ function initAdminLayout() {
|
||||
if (settingsToggle && settingsSubmenu) {
|
||||
const settingsChevron = settingsToggle.querySelector('svg:last-child');
|
||||
|
||||
/**
|
||||
* Alterne l'état du dropdown avec une animation de glissement.
|
||||
* @param {boolean} show - Forcer l'ouverture ou la fermeture
|
||||
* @param {boolean} animate - Activer ou non la transition CSS
|
||||
*/
|
||||
const toggleDropdown = (show, animate = true) => {
|
||||
if (!animate) settingsSubmenu.style.transition = 'none';
|
||||
|
||||
if (show) {
|
||||
settingsSubmenu.classList.remove('hidden');
|
||||
// scrollHeight permet de calculer la hauteur réelle du contenu
|
||||
settingsSubmenu.style.maxHeight = settingsSubmenu.scrollHeight + "px";
|
||||
settingsChevron?.classList.add('rotate-180');
|
||||
localStorage.setItem('admin_settings_open', 'true');
|
||||
@@ -49,7 +57,6 @@ function initAdminLayout() {
|
||||
settingsChevron?.classList.remove('rotate-180');
|
||||
localStorage.setItem('admin_settings_open', 'false');
|
||||
|
||||
// On cache l'élément après l'animation pour l'accessibilité
|
||||
if (animate) {
|
||||
setTimeout(() => {
|
||||
if (settingsSubmenu.style.maxHeight === "0px") {
|
||||
@@ -62,30 +69,27 @@ function initAdminLayout() {
|
||||
}
|
||||
|
||||
if (!animate) {
|
||||
// Forcer un recalcul pour réactiver la transition proprement
|
||||
settingsSubmenu.offsetHeight;
|
||||
settingsSubmenu.offsetHeight; // force redraw
|
||||
settingsSubmenu.style.transition = '';
|
||||
}
|
||||
};
|
||||
|
||||
// Événement de clic
|
||||
settingsToggle.onclick = (e) => {
|
||||
e.preventDefault();
|
||||
const isClosed = settingsSubmenu.style.maxHeight === "0px" || settingsSubmenu.classList.contains('hidden');
|
||||
toggleDropdown(isClosed);
|
||||
};
|
||||
|
||||
// --- PERSISTANCE ---
|
||||
// On vérifie si on est sur une page appartenant au menu ou si l'utilisateur l'avait laissé ouvert
|
||||
// PERSISTANCE
|
||||
const isSettingsRoute = window.location.pathname.includes('/crm/administrateur') ||
|
||||
window.location.pathname.includes('/crm/logs');
|
||||
const wasOpen = localStorage.getItem('admin_settings_open') === 'true';
|
||||
|
||||
if (isSettingsRoute || wasOpen) {
|
||||
toggleDropdown(true, false); // Ouverture immédiate sans animation
|
||||
toggleDropdown(true, false);
|
||||
}
|
||||
|
||||
// --- HIGHLIGHT DU LIEN ACTIF ---
|
||||
// HIGHLIGHT
|
||||
settingsSubmenu.querySelectorAll('a').forEach(link => {
|
||||
if (window.location.pathname === link.getAttribute('href')) {
|
||||
link.classList.add('text-blue-600', 'dark:text-blue-400', 'font-semibold');
|
||||
@@ -94,7 +98,7 @@ function initAdminLayout() {
|
||||
});
|
||||
}
|
||||
|
||||
// --- 3. GESTION DES MESSAGES FLASH (Auto-suppression) ---
|
||||
// --- 3. GESTION DES MESSAGES FLASH ---
|
||||
document.querySelectorAll('.flash-message').forEach((flash) => {
|
||||
setTimeout(() => {
|
||||
flash.classList.add('opacity-0', 'translate-x-10');
|
||||
@@ -104,7 +108,6 @@ function initAdminLayout() {
|
||||
}
|
||||
|
||||
// --- CORRECTIF DATA-TURBO-CONFIRM ---
|
||||
// Turbo 7+ intercepte les clics, on réimplémente une confirmation native simple
|
||||
document.addEventListener("turbo:click", (event) => {
|
||||
const message = event.target.closest("[data-turbo-confirm]")?.getAttribute("data-turbo-confirm");
|
||||
if (message && !confirm(message)) {
|
||||
@@ -112,10 +115,8 @@ document.addEventListener("turbo:click", (event) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Exécution au chargement initial et à chaque navigation Turbo
|
||||
document.addEventListener('turbo:load', initAdminLayout);
|
||||
|
||||
// Nettoyage avant la mise en cache de Turbo (évite les bugs visuels au retour arrière)
|
||||
document.addEventListener('turbo:before-cache', () => {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const overlay = document.getElementById('sidebar-overlay');
|
||||
|
||||
Reference in New Issue
Block a user