Remix

Altix ErrorTrack unterstützt das Sentry-Protokoll, sodass Sie das offizielle @sentry/remix-SDK verwenden. Die folgenden Code-Snippets nutzen einen Platzhalter-DSN; auf der Einrichtungsseite Ihres Projekts finden Sie die echten Werte.

  1. SDK installieren

    Fügen Sie @sentry/remix hinzu, das offizielle Sentry-SDK. Es funktioniert unverändert mit Altix ErrorTrack.

    bash

    npm install @sentry/remix --save
  2. Konfigurieren

    Initialisieren Sie das SDK so früh wie möglich in Ihrer App mit Ihrer DSN.

    app/entry.client.tsx

    import { useLocation, useMatches } from "@remix-run/react";
    import * as Sentry from "@sentry/remix";
    import { useEffect } from "react";
    
    Sentry.init({
      dsn: "https://<public-key>@errortrack.altixcode.com/<project-id>",
      integrations: [
        Sentry.browserTracingIntegration({ useEffect, useLocation, useMatches }),
        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",
    });

    instrument.server.mjs

    import * as Sentry from "@sentry/remix";
    
    Sentry.init({
      dsn: "https://<public-key>@errortrack.altixcode.com/<project-id>",
      tracesSampleRate: 1.0,
    });

    app/root.tsx

    import { captureRemixErrorBoundaryError, withSentry } from "@sentry/remix";
    import { useRouteError } from "@remix-run/react";
    
    export const ErrorBoundary = () => {
      const error = useRouteError();
      captureRemixErrorBoundaryError(error);
      return <div>Something went wrong</div>;
    };
    
    export default withSentry(App);
  3. Source Maps hochladen

    Damit Stacktraces Ihren Originalcode statt des minifizierten Codes anzeigen. Erstellen Sie unter Einstellungen → Auth-Tokens ein Auth-Token mit dem Scope project:releases und bewahren Sie es in Ihren CI-Secrets auf – niemals im Repository.

    bash

    # After your production build, in CI:
    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>
    
    npx @sentry/cli sourcemaps inject ./build
    npx @sentry/cli sourcemaps upload --release=my-app@1.0.0 ./build

    Source-Maps-Anleitung

  4. Überprüfen

    Lösen Sie absichtlich einen Fehler aus. Er erscheint innerhalb weniger Sekunden in Ihrem Issue-Stream.

    javascript

    setTimeout(() => {
      throw new Error("My first ErrorTrack error");
    }, 99);

Erstellen Sie ein Projekt, und auf der Einrichtungsseite wird automatisch Ihre echte DSN eingetragen.