Astro
Altix ErrorTrack supporta il protocollo Sentry, quindi puoi utilizzare l'SDK ufficiale di @sentry/astro. I frammenti di codice qui sotto mostrano un DSN di esempio; la pagina di configurazione del tuo progetto li mostrerà con quello reale.
Installa l'SDK
Aggiungi
@sentry/astro, l'SDK ufficiale di Sentry. Funziona senza modifiche con Altix ErrorTrack.bash
npx astro add @sentry/astroConfiguralo
Inizializza l'SDK il prima possibile nella tua app, inserendo il tuo DSN.
astro.config.mjs
import { defineConfig } from "astro/config"; import sentry from "@sentry/astro"; export default defineConfig({ integrations: [sentry()], });sentry.client.config.js
import * as Sentry from "@sentry/astro"; Sentry.init({ dsn: "https://<public-key>@errortrack.altixcode.com/<project-id>", integrations: [ Sentry.browserTracingIntegration(), Sentry.replayIntegration(), ], tracesSampleRate: 1.0, replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, // Optional: send events through your own server to get past ad blockers (see /docs/tunnel) // tunnel: "/monitoring", });sentry.server.config.js
import * as Sentry from "@sentry/astro"; Sentry.init({ dsn: "https://<public-key>@errortrack.altixcode.com/<project-id>", tracesSampleRate: 1.0, });Carica le source map
In questo modo gli stack trace mostrano il tuo codice originale invece di quello minificato. Crea un token di autenticazione con ambito
project:releasesin Impostazioni → Token di autenticazione e salvalo nei secret della tua CI, mai nel repository.bash
# Set in the build environment; the SDK's build plugin uploads source maps with them. export SENTRY_URL=https://errortrack.altixcode.com export SENTRY_ORG=<org-slug> export SENTRY_PROJECT=<project-slug> export SENTRY_AUTH_TOKEN=<an auth token from Settings → Auth Tokens>Verifica
Genera un errore di proposito. Apparirà nel tuo elenco delle segnalazioni entro pochi secondi.
html
<button onclick="throw new Error('My first ErrorTrack error')">Break the world</button>
Crea un progetto e la pagina di configurazione genererà automaticamente il tuo DSN reale.