Per iniziare
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo 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.
Puoi usare il nostro setup assistito dall'IA per installare il plugin. Aggiungi le skill Capgo al tuo strumento di IA usando il seguente comando:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsPoi usa il seguente prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-performance` plugin in my project.Se preferisci la configurazione manuale, installa il plugin eseguendo questi comandi e segui le istruzioni specifiche per piattaforma qui sotto:
bun add @capgo/capacitor-firebase-performancenpx cap syncImporta
Sezione intitolata “Import”import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';Avvio rapido
Sezione intitolata “Quick start”import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.startTrace({ traceName: 'trace' });Esempio: stopTrace
Sezione intitolata “Esempio: stopTrace”import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.stopTrace({ traceName: 'trace' });Esempio: incrementMetric
Sezione intitolata “Esempio: incrementMetric”import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.incrementMetric({ traceName: 'trace', metricName: 'metric',});Errori comuni
Sezione intitolata “Errori comuni”- Sync nativo: esegui
npx cap syncdopo gli aggiornamenti dei plugin. - Fonte di verità: fidati
src/definitions.tsnel repo GitHub.
Panoramica API
Sezione intitolata “Panoramica API”startTrace
Sezione intitolata “startTrace”Avvia una trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.startTrace({ traceName: 'trace' });stopTrace
Sezione intitolata “stopTrace”Interrompe una trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.stopTrace({ traceName: 'trace' });incrementMetric
Sezione intitolata “incrementMetric”Incrementa atomicamente la metrica con il nome specificato per la trace selezionata del incrementBy valore.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.incrementMetric({ traceName: 'trace', metricName: 'metric',});setEnabled
Sezione intitolata “setEnabled”Abilita o disabilita il monitoraggio delle performance. Verrà applicato al prossimo avvio dell'app.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.setEnabled({ enabled: true });isEnabled
Sezione intitolata “isEnabled”Determina se il monitoraggio delle performance è abilitato o disabilitato.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.isEnabled();console.log(result);putAttribute
Sezione intitolata “putAttribute”Imposta un attributo personalizzato di una trace a un valore specificato.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.putAttribute({ traceName: 'trace', attribute: "experiment", value: "A",});getAttribute
Sezione intitolata “getAttribute”Restituisce il valore di un attributo personalizzato di una trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getAttribute({ traceName: 'trace', attribute: 'attribute',});console.log(result);getAttributes
Sezione intitolata “getAttributes”Ottiene tutti gli attributi personalizzati di una trace con i relativi valori.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getAttributes({ traceName: 'trace' });console.log(result);removeAttribute
Sezione intitolata “removeAttribute”Rimuove un attributo personalizzato da una trace tramite il suo nome.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.removeAttribute({ traceName: 'trace', attribute: 'attribute',});putMetric
Sezione intitolata “putMetric”Imposta il valore di una metrica personalizzata.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.putMetric({ traceName: 'trace', metricName: 'metric', num: 1,});getMetric
Sezione intitolata “getMetric”Ottieni il valore di una metrica personalizzata per nome.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getMetric({ traceName: 'trace', metricName: 'metric',});console.log(result);Registra una trace specificando nome e opzioni.
Disponibile solo su web.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.record({ traceName: 'trace', startTime: 10, duration: 1000,});Riferimento ai tipi
Sezione: “Type Reference”StartTraceOptions
Sezione intitolata “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
Sezione intitolata “StopTraceOptions”export interface StopTraceOptions { /** * Name of the trace that was set with `startTrace`. * * @since 0.1.0 */ traceName: string;}IncrementMetricOptions
Sezione intitolata “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
Sezione intitolata “SetEnabledOptions”export interface SetEnabledOptions { /** * Should performance monitoring be enabled. * * @since 0.1.0 */ enabled: boolean;}IsEnabledResult
Sezione intitolata “IsEnabledResult”export interface IsEnabledResult { /** * `true` if performance monitoring is enabled, otherwise `false`. * * @since 0.1.0 */ enabled: boolean;}PutAttributeOptions
Sezione intitolata “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
Sezione intitolata “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
Sezione intitolata “GetAttributeResult”export interface GetAttributeResult { /** * The value of the custom attribute. * * @since 6.3.0 */ value: string | null;}GetAttributesOptions
Sezione intitolata “GetAttributesOptions”export interface GetAttributesOptions { /** * Name of the trace to get its attributes. * * @since 6.3.0 */ traceName: string;}GetAttributesResult
Sezione intitolata “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
Sezione intitolata “RemoveAttributeOptions”export type RemoveAttributeOptions = GetAttributeOptions;PutMetricOptions
Sezione intitolata “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;}Fonte di verità
Sezione intitolata “Fonte di verità”Questa pagina è generata dal src/definitions.ts. Riesegui la sync quando il API pubblico cambia upstream.
Continua da Getting Started
Sezione intitolata “Continua da Getting Started”Se stai usando Per iniziare per pianificare le operazioni della dashboard e di API, collegalo a Panoramica API per i dettagli di implementazione in Panoramica di API, Introduzione per i dettagli di implementazione in Introduzione, Chiavi API per i dettagli di implementazione delle chiavi API, Dispositivi per i dettagli di implementazione in Devices, e Bundle per il dettaglio di implementazione in Bundles.