Zum Hauptinhalt springen

AppSignal einrichten

Um AppSignal für Front-end-JavaScript zu konfigurieren, empfehlen wir, eine appsignal.js-Datei mit der AppSignal-Konfiguration im Stamm- oder src-Verzeichnis Ihres Projekts zu erstellen. Binden Sie die Konfigurationsdatei dann im Anwendungscode ein (per require oder import), bevor andere Pakete eingebunden werden. Im folgenden Beispiel befindet sich eine appsignal.js-Datei im Stammverzeichnis des Anwendungsverzeichnisses. In Zeile 8 haben wir die Konfigurationsoption namespace hinzugefügt.
// For ES Module via npm/yarn, or with import maps
import Appsignal from "@appsignal/javascript";
// For CommonJS module via npm/yarn
const Appsignal = require("@appsignal/javascript").default;
// With the JSPM.dev CDN
import Appsignal from "https://jspm.dev/@appsignal/javascript";

const appsignal = new Appsignal({
  key: "<YOUR FRONTEND API KEY>",
});

module.exports = { appsignal };

Konfiguration anpassen

Sie können die Fehlerberichterstattung Ihrer Anwendung mit den Front-end-Konfigurationsoptionen anpassen. Hier ein Beispiel, wie die Option namespace angepasst wird.
 const appsignal = new Appsignal({
   key: "<YOUR FRONTEND API KEY>",
+  namespace: "frontend", // Configure the AppSignal namespace for front-end errors in this app
 });

Die AppSignal-Konfiguration einbinden

Sobald Sie mit der Konfiguration Ihrer Anwendung fertig sind, binden Sie die appsignal.js-Datei ganz oben in der Hauptdatei Ihrer Anwendung ein, wie im folgenden Beispiel:
// Place this at the top
// Import the file created in the previous step
const { appsignal } = require("./appsignal"); // Update to the location used in the previous step

// Place your app code below this
Nachdem Ihre Anwendung die AppSignal-JavaScript-Bibliothek geladen hat, folgen Sie unbedingt allen Schritten der Installationsanleitung, fügen Sie Integrationen und Plugins hinzu und passen Sie Ihre Konfiguration an.