From 80a992a583aaaa0c1fa79850ea4a0422cc217c32 Mon Sep 17 00:00:00 2001 From: gcch Date: Mon, 23 Jun 2025 21:28:33 +0200 Subject: [PATCH] ref: refactorise la configuration du SDK Sentry --- cspell.json | 2 +- docs/TODO.md | 1 - .../haiku-atelier-2024/src/scripts/gaffe.ts | 21 ++++++++++++++----- .../src/scripts/lib/types/sentry.d.ts | 9 -------- 4 files changed, 17 insertions(+), 16 deletions(-) delete mode 100755 web/app/themes/haiku-atelier-2024/src/scripts/lib/types/sentry.d.ts diff --git a/cspell.json b/cspell.json index 62e53f98..6dcc082f 100644 --- a/cspell.json +++ b/cspell.json @@ -1 +1 @@ -{ "dictionaries": ["fr-fr", "en-gb"], "words": ["oxlint", "Vali", "mobily", "valibot"] } +{ "dictionaries": ["fr-fr", "en-gb"], "words": ["oxlint", "Vali", "mobily", "valibot", "GLITCHTIP"] } diff --git a/docs/TODO.md b/docs/TODO.md index 358979d8..a4a6bbef 100755 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -19,7 +19,6 @@ - MÉTHODES DE LIVRAISON - [ ] Proposer la livraison à domicile en Belgique et en France pour le coût unique de 8 euros, quel que soit le montant de la commande - PAGE PRODUIT - - Corriger la grille des détails pour les Produits Simples. - PIED DE PAGE - Réduire la hauteur. - TOUTES LES PAGES diff --git a/web/app/themes/haiku-atelier-2024/src/scripts/gaffe.ts b/web/app/themes/haiku-atelier-2024/src/scripts/gaffe.ts index c8d414bc..8fd22491 100755 --- a/web/app/themes/haiku-atelier-2024/src/scripts/gaffe.ts +++ b/web/app/themes/haiku-atelier-2024/src/scripts/gaffe.ts @@ -7,9 +7,9 @@ import type { Transport, TransportMakeRequestResponse, TransportRequest } from " import { pipe } from "@mobily/ts-belt"; import { breadcrumbsIntegration, + browserApiErrorsIntegration, BrowserClient, captureConsoleIntegration, - createTransport, dedupeIntegration, defaultStackParser, functionToStringIntegration, @@ -19,13 +19,12 @@ import { httpContextIntegration, linkedErrorsIntegration, } from "@sentry/browser"; - -import type { BrowserTransportOptions } from "./lib/types/sentry"; +import { createTransport } from "@sentry/core"; import { ENTETE_GLITCHTIP_RATE_LIMITS, ENTETE_GLITCHTIP_RETRY_AFTER } from "./constantes/api"; /* Créé la fonction génératrice de la requête auprès de GlitchTip */ -const creeTransportFetch = (options: BrowserTransportOptions): Transport => { +const creeTransportFetch = (options): Transport => { const creeRequete = async (requete: TransportRequest): Promise => { const optionsRequete: RequestInit = { body: requete.body, @@ -56,13 +55,25 @@ const client = new BrowserClient({ dsn: import.meta.env.VITE_GLITCHTIP_NSD, environment: import.meta.env.VITE_MODE, integrations: [ + // Wraps native browser APIs to capture breadcrumbs. breadcrumbsIntegration(), + // Wraps native time and events APIs in `try/catch` blocks to handle async exceptions + browserApiErrorsIntegration(), + // Captures all Console API calls via `captureException` or `captureMessage`. captureConsoleIntegration({ levels: ["warn", "error"] }), + // Deduplicate certain events to avoid receiving duplicate errors. dedupeIntegration(), + // Allows the SDK to provide original functions and method names, even when those functions or methods are wrapped by our error or breadcrumb handlers. functionToStringIntegration(), + // Attaches global handlers to capture uncaught exceptions and unhandled rejections. globalHandlersIntegration(), - httpClientIntegration(), + // Captures errors on failed requests from Fetch and XHR and attaches request and response information. + httpClientIntegration({ + failedRequestStatusCodes: [[400, 599]], + }), + // Attaches HTTP request information, such as URL, user-agent, referrer, and other headers to the event. httpContextIntegration(), + // Allows you to configure linked errors. linkedErrorsIntegration(), ], sendDefaultPii: true, diff --git a/web/app/themes/haiku-atelier-2024/src/scripts/lib/types/sentry.d.ts b/web/app/themes/haiku-atelier-2024/src/scripts/lib/types/sentry.d.ts deleted file mode 100755 index c66e78e9..00000000 --- a/web/app/themes/haiku-atelier-2024/src/scripts/lib/types/sentry.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { BaseTransportOptions } from "@sentry/types"; - -/* Recréé une Interface non exposé par Sentry */ -export interface BrowserTransportOptions extends BaseTransportOptions { - /** Fetch API init parameters. Used by the FetchTransport */ - fetchOptions?: RequestInit; - /** Custom headers for the transport. Used by the XHRTransport and FetchTransport */ - headers?: Record; -}