Panduan Memulai
Salin prompt setup yang berisi langkah install dan panduan markdown lengkap untuk plugin ini.
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.
Anda bisa menggunakan AI-Assisted Setup kami untuk menginstal plugin ini. Tambahkan skill Capgo ke tool AI Anda dengan command berikut:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsLalu gunakan prompt berikut:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-performance` plugin in my project.Jika Anda lebih memilih Manual Setup, instal plugin dengan menjalankan perintah berikut dan ikuti petunjuk khusus platform di bawah ini:
bun add @capgo/capacitor-firebase-performancenpx cap syncimport { FirebasePerformance } from '@capgo/capacitor-firebase-performance';Mulai cepat
Bagian berjudul āMulai cepatāimport { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.startTrace({ traceName: 'trace' });Contoh: stopTrace
Bagian berjudul āContoh: stopTraceāimport { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.stopTrace({ traceName: 'trace' });Contoh: incrementMetric
Bagian berjudul āExample: incrementMetricāimport { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.incrementMetric({ traceName: 'trace', metricName: 'metric',});Kesalahan umum
Bagian berjudul āKesalahan umumā- Sinkronisasi Native: jalankan
npx cap syncsetelah upgrade plugin. - Sumber kebenaran tunggal: percayai
src/definitions.tsdi repo GitHub.
Ringkasan API
Bagian berjudul āIkhtisar APIāstartTrace
Bagian berjudul āstartTraceāMemulai sebuah trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.startTrace({ traceName: 'trace' });stopTrace
Bagian berjudul āstopTraceāMenghentikan sebuah trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.stopTrace({ traceName: 'trace' });incrementMetric
Bagian berjudul āincrementMetricāMenambah nilai metric secara atomik dengan nama yang ditentukan untuk trace yang dipilih sebesar incrementBy nilainya.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.incrementMetric({ traceName: 'trace', metricName: 'metric',});setEnabled
Bagian berjudul āsetEnabledāMengaktifkan atau menonaktifkan monitoring performa. Akan diterapkan saat aplikasi dijalankan berikutnya.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.setEnabled({ enabled: true });isEnabled
Bagian berjudul āisEnabledāMenentukan apakah monitoring performa diaktifkan atau dinonaktifkan.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.isEnabled();console.log(result);putAttribute
Bagian berjudul āputAttributeāMenetapkan atribut kustom pada trace ke nilai tertentu.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.putAttribute({ traceName: 'trace', attribute: "experiment", value: "A",});getAttribute
Bagian berjudul āgetAttributeāMengembalikan nilai dari custom attribute sebuah trace.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getAttribute({ traceName: 'trace', attribute: 'attribute',});console.log(result);getAttributes
Bagian berjudul āgetAttributesāMengambil semua custom attribute dari sebuah trace beserta nilainya.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getAttributes({ traceName: 'trace' });console.log(result);removeAttribute
Bagian berjudul āremoveAttributeāMenghapus atribut kustom dari trace berdasarkan namanya.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.removeAttribute({ traceName: 'trace', attribute: 'attribute',});putMetric
Bagian berjudul āputMetricāMengatur nilai dari metrik kustom.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.putMetric({ traceName: 'trace', metricName: 'metric', num: 1,});getMetric
Bagian berjudul āgetMetricāMengambil nilai metrik kustom berdasarkan namanya.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.getMetric({ traceName: 'trace', metricName: 'metric',});console.log(result);Merekam trace berdasarkan nama dan opsinya.
Hanya tersedia di web.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.record({ traceName: 'trace', startTime: 10, duration: 1000,});Referensi Tipe
Bagian berjudul āReferensi TipeāStartTraceOptions
Bagian berjudul ā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
Bagian berjudul āStopTraceOptionsāexport interface StopTraceOptions { /** * Name of the trace that was set with `startTrace`. * * @since 0.1.0 */ traceName: string;}IncrementMetricOptions
Bagian berjudul ā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
Bagian berjudul āSetEnabledOptionsāexport interface SetEnabledOptions { /** * Should performance monitoring be enabled. * * @since 0.1.0 */ enabled: boolean;}IsEnabledResult
Bagian berjudul āIsEnabledResultāexport interface IsEnabledResult { /** * `true` if performance monitoring is enabled, otherwise `false`. * * @since 0.1.0 */ enabled: boolean;}PutAttributeOptions
Bagian berjudul ā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
Bagian berjudul ā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
Bagian berjudul āGetAttributeResultāexport interface GetAttributeResult { /** * The value of the custom attribute. * * @since 6.3.0 */ value: string | null;}GetAttributesOptions
Bagian berjudul āGetAttributesOptionsāexport interface GetAttributesOptions { /** * Name of the trace to get its attributes. * * @since 6.3.0 */ traceName: string;}GetAttributesResult
Bagian berjudul ā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
Bagian berjudul āRemoveAttributeOptionsāexport type RemoveAttributeOptions = GetAttributeOptions;PutMetricOptions
Bagian berjudul ā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;}Sumber Kebenaran
Bagian berjudul āSumber KebenaranāHalaman ini dibuat dari plugin src/definitions.ts. Jalankan ulang sync saat API publik berubah di upstream.
Lanjutkan dari Getting Started
Bagian berjudul āLanjutkan dari Getting StartedāJika Anda menggunakan Panduan Memulai untuk merencanakan operasi dashboard dan API, hubungkan dengan Ringkasan API untuk detail implementasi di API Overview, Pendahuluan untuk detail implementasi di Introduction, Kunci API untuk detail implementasi di API Keys, Perangkat untuk detail implementasi di Devices, dan Bundle untuk detail implementasi di Bundles.