Erste Schritte
Kopiere einen Setup-Prompt mit den Installationsschritten und dem vollständigen Markdown-Guide für dieses Plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-firebase-performance`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/firebase-performance/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installieren
Abschnitt „Installation“Du kannst unser KI-gestütztes Setup nutzen, um das Plugin zu installieren. Füge die Capgo Skills mit dem folgenden Befehl deinem KI-Tool hinzu:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsNutze dann diesen Prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-performance` plugin in my project.Wenn du ein manuelles Setup bevorzugst, installiere das Plugin mit den folgenden Befehlen und befolge die plattformspezifischen Anweisungen unten:
bun add @capgo/capacitor-firebase-performancenpx cap syncImportieren
Abschnitt mit dem Titel „Import“import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';Quickstart
Abschnitt „Quick start“import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.startTrace({ traceName: 'trace' });Beispiel: stopTrace
Abschnitt mit dem Titel „Beispiel: stopTrace“import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.stopTrace({ traceName: 'trace' });Beispiel: incrementMetric
Abschnitt mit dem Titel „Beispiel: incrementMetric“import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.incrementMetric({ traceName: 'trace', metricName: 'metric',});Häufige Stolperfallen
Abschnitt „Häufige Fallstricke“- Nativer Sync: ausführen
npx cap syncnach Plugin-Upgrades. - Single Source of Truth: Vertrauen
src/definitions.tsim GitHub Repo.
API Übersicht
Abschnitt „API Übersicht“startTrace
Abschnitt „startTrace“Startet einen Trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.startTrace({ traceName: 'trace' });stopTrace
Abschnitt „stopTrace“Stoppt einen Trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.stopTrace({ traceName: 'trace' });incrementMetric
Abschnitt „incrementMetric“Erhöht die Metrik mit dem angegebenen Namen für den ausgewählten Trace atomar um den incrementBy Wert.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.incrementMetric({ traceName: 'trace', metricName: 'metric',});setEnabled
Abschnitt „setEnabled“Aktiviert oder deaktiviert das Performance-Monitoring. Wird beim nächsten App-Start angewendet.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.setEnabled({ enabled: true });isEnabled
Abschnitt mit dem Titel „isEnabled“Legt fest, ob das Performance-Monitoring aktiviert oder deaktiviert ist.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.isEnabled();console.log(result);putAttribute
Abschnitt mit dem Titel „putAttribute“Setzt ein benutzerdefiniertes Attribut eines Traces auf einen bestimmten Wert.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.putAttribute({ traceName: 'trace', attribute: "experiment", value: "A",});getAttribute
Abschnitt mit dem Titel „getAttribute“Gibt den Wert eines benutzerdefinierten Attributs eines Traces zurück.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getAttribute({ traceName: 'trace', attribute: 'attribute',});console.log(result);getAttributes
Abschnitt mit dem Titel „getAttributes“Ruft alle benutzerdefinierten Attribute eines Traces inklusive ihrer Werte ab.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getAttributes({ traceName: 'trace' });console.log(result);removeAttribute
Abschnitt „removeAttribute“Entfernt ein benutzerdefiniertes Attribut anhand seines Namens aus einem Trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.removeAttribute({ traceName: 'trace', attribute: 'attribute',});putMetric
Abschnitt „putMetric“Setzt den Wert einer benutzerdefinierten Metrik.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.putMetric({ traceName: 'trace', metricName: 'metric', num: 1,});getMetric
Abschnitt „getMetric“Get the value of a custom metric by name.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getMetric({ traceName: 'trace', metricName: 'metric',});console.log(result);record
Abschnitt „record“Zeichnet einen Trace mit Namen und Optionen auf.
Nur im Web verfügbar.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.record({ traceName: 'trace', startTime: 10, duration: 1000,});Typreferenz
Abschnitt mit dem Titel „Typreferenz“StartTraceOptions
Abschnitt mit dem Titel „StartTraceOptions“export interface StartTraceOptions { /** * Custom trace name. * * Names for custom code traces must meet the following requirements: * no leading or trailing whitespace, no leading underscore (_) character, * and max length is 100 characters. * * @since 0.1.0 */ traceName: string;}StopTraceOptions
Abschnitt mit dem Titel „StopTraceOptions“export interface StopTraceOptions { /** * Name of the trace that was set with `startTrace`. * * @since 0.1.0 */ traceName: string;}IncrementMetricOptions
Abschnitt mit dem Titel „IncrementMetricOptions“export interface IncrementMetricOptions { /** * Name of the trace that was set with `startTrace`. * * @since 0.1.0 */ traceName: string; /** * Name of the metric to be incremented. * * @since 0.1.0 */ metricName: string; /** * Amount by which the metric has to be incremented. * * @default 1 * @since 0.1.0 */ incrementBy?: number;}SetEnabledOptions
Abschnitt „SetEnabledOptions“export interface SetEnabledOptions { /** * Should performance monitoring be enabled. * * @since 0.1.0 */ enabled: boolean;}IsEnabledResult
Abschnitt „IsEnabledResult“export interface IsEnabledResult { /** * `true` if performance monitoring is enabled, otherwise `false`. * * @since 0.1.0 */ enabled: boolean;}PutAttributeOptions
Abschnitt „PutAttributeOptions“export interface PutAttributeOptions { /** * Name of the trace to set its attribute. * * @since 6.3.0 */ traceName: string; /** * Name of the attribute to set its value. * * @since 6.3.0 * @example "experiment" */ attribute: string; /** * The value to set to the attribute. * * @since 6.3.0 * @example "A" */ value: string;}GetAttributeOptions
Abschnitt „GetAttributeOptions“export interface GetAttributeOptions { /** * Name of the trace to set its attribute. * * @since 6.3.0 */ traceName: string; /** * Name of the attribute to retrieve its value. * * @since 6.3.0 */ attribute: string;}GetAttributeResult
Abschnitt „GetAttributeResult“export interface GetAttributeResult { /** * The value of the custom attribute. * * @since 6.3.0 */ value: string | null;}GetAttributesOptions
Abschnitt „GetAttributesOptions“export interface GetAttributesOptions { /** * Name of the trace to get its attributes. * * @since 6.3.0 */ traceName: string;}GetAttributesResult
Abschnitt „GetAttributesResult“export interface GetAttributesResult { /** * A map of all custom attributes of a trace with their values. * * @since 6.3.0 */ attributes: { [key: string]: string };}RemoveAttributeOptions
Abschnitt mit dem Titel „RemoveAttributeOptions“export type RemoveAttributeOptions = GetAttributeOptions;PutMetricOptions
Abschnitt mit dem Titel „PutMetricOptions“export interface PutMetricOptions { /** * Name of the trace to set its metric. * * @since 6.3.0 */ traceName: string; /** * The metric name. * * @since 6.3.0 */ metricName: string; /** * The value to set for the metric. * The given value is floored down to the nearest integer. * * @since 6.3.0 */ num: number;}Source of Truth
Abschnitt mit dem Titel „Source of Truth“Diese Seite wird aus dem Plugin generiert src/definitions.ts. Führe den Sync erneut aus, wenn sich das öffentliche API upstream ändert.
Weiter geht's nach Getting Started
Abschnitt: „Weiter geht’s mit Getting Started“Wenn du es nutzt Erste Schritte um Dashboard- und API-Operationen zu planen, verbinde es mit API Übersicht für Details zur Implementierung im API Overview, Einführung für die Implementierungsdetails in der Einleitung, API Schlüssel für die Implementierungsdetails in API Keys, Geräte für die Implementierungsdetails in Devices und Bundles für die Implementierungsdetails in Bundles.