ガイド
CapacitorでFirebase Performanceを使用する方法
@capgo/capacitor-firebase-performanceを使用する
CapacitorのFirebase Performanceモニタリング用プラグイン
インストール
bun add @capgo/capacitor-firebase-performance
bunx cap sync
bunx cap sync プラグインのネイティブcodeをプロジェクトにコピーします。プラグインのアップグレード後は、再度実行してください。
インポート
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
APIの概要
| 方法 | 説明 |
|---|---|
startTrace |
トレースを開始します。 |
stopTrace |
トレースを停止します。 |
incrementMetric |
選択したトレースの指定されたメトリックに与えられた値を含めて、原子的にインクリメントします。 incrementBy value. |
setEnabled |
パフォーマンスモニタリングが有効か無効かを決定します。 |
isEnabled |
トレースのカスタム属性を指定された値に設定します。 |
putAttribute |
トレースのカスタム属性の値を取得します。 |
getAttribute |
メソッド |
getAttributes |
すべてのカスタム属性を取得します。 |
removeAttribute |
指定された名前のカスタム属性を削除します。 |
putMetric |
カスタムメトリックの値を設定します。 |
getMetric |
指定された名前のカスタムメトリックの値を取得します。 |
record |
指定された名前とオプションでトレースを記録します。 |
例
startTrace()
ページ/エリア: バグバウティープログラムページ。役割: セクションまたはページヘッダー。見られる場所: bug-bounty.astroページ。メッセージキー `bug_bounty_supabase_examples_title` (バグバウティー スーパーバース エクサンプル タイトル)。
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.startTrace({ traceName: 'trace' });
stopTrace()
トレースを開始します。
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.stopTrace({ traceName: 'trace' });
incrementMetric()
トレースを停止します。 incrementBy value.
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.incrementMetric({
traceName: 'trace',
metricName: 'metric',
});
setEnabled()
パフォーマンスモニタリングを有効または無効にします。次のアプリ起動時に適用されます。
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.setEnabled({ enabled: true });
isEnabled()
パフォーマンスモニタリングが有効か無効かを判断します。
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
const result = await FirebasePerformance.isEnabled();
console.log(result);
putAttribute()
指定された値にトレースのカスタム属性を設定します。
import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';
await FirebasePerformance.putAttribute({
traceName: 'trace',
attribute: "experiment",
value: "A",
});
上の表には、12の基本メソッドがリストされています。リスナーとバージョンヘルパー、各メソッドのフルコントラクトは、以下のリポジトリでドキュメント化されています。 GitHub リポジトリ.
フルリファレンス
@capgo/capacitor-firebase-performance
Capgo を使用して Firebase Performance を使用している場合 @Capgo/capacitor/capgo-firebase-performance Capgo プラグイン ディレクトリ Capgo プラグインディレクトリ for the product workflow in Capgo Plugin Directory, Capacitor Capgo Capgoの実装詳細については、Capacitor プラグインによって Capgo で管理されます。 プラグインの追加または更新 プラグインの追加または更新の実装詳細について Ionic Enterpriseプラグインの代替 製品ワークフローについて、Ionic Enterpriseプラグインの代替、 Capgo 本機ビルド Capgoの製品ワークフローにおけるCapgoネイティブビルドのために。