跳过主要内容

Firebase 性能 Capacitor插件

Capacitor插件用于Firebase性能监控

安装

bun add @capgo/capacitor-firebase-performance bunx cap sync
npm、pnpm或yarn
  • npm install @capgo/capacitor-firebase-performance
  • pnpm add @capgo/capacitor-firebase-performance
  • yarn add @capgo/capacitor-firebase-performance

指南

如何在 Capacitor 中使用 Firebase Performance

使用@capgo/capacitor-firebase-performance

Capacitor插件用于Firebase性能监控。

安装

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 增加
setEnabled 启用或禁用应用性能监控。将在下次应用启动时生效。
isEnabled 确定应用性能监控是否启用或禁用。
putAttribute 设置一个跟踪的自定义属性值。
getAttribute 获取一个跟踪的自定义属性值。
getAttributes 获取一个跟踪的所有自定义属性及其值。
removeAttribute 从跟踪中删除一个自定义属性。
putMetric 设置一个自定义指标的值。
getMetric 通过名称获取一个自定义指标的值。
record 通过名称和选项记录一个跟踪。

Examples

startTrace()

开始一个跟踪。

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 增加指标的值。

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 个核心方法。监听器和版本辅助函数,以及每个方法的完整契约,均在 __CAPGO_KEEP_0__ 仓库中文档化。 GitHub 仓库.

文档

继续使用@capgo/capacitor-firebase-performance

如果您正在使用 使用 @capgo/capacitor-firebase-performance 为了规划原生插件工作,连接它与 Capgo 插件目录 在 Capgo 插件目录中,了解产品工作流程 Capacitor 插件由 Capgo 在 Capacitor 插件由 Capgo 中了解实现细节 添加或更新插件 在添加或更新插件中了解实现细节 Ionic 企业插件替代品 了解 Ionic 企业插件替代品中的产品工作流程 Capgo 原生构建 为Capgo Native Builds 的产品工作流程。

FAQ

常见问题解答 (FAQ) (Capgo Builder / native cloud build product page. Role: Section subtitle or tagline. Seen in: page native-build.astro. Message key `native_build_builder_faq_eyebrow` (Native Build Builder FAQ Eyebrow). | Page/area: Capgo solutions marketing page. Role: Section or page heading. Seen in: page solutions/cordova-to-capacitor.astro. Message key `solutions_cordova_to_capacitor_faq_title` (Solutions Cordova To Capacitor FAQ Title).) | Firebase Performance 插件 FAQ

如何在Capacitor应用中安装 Firebase Performance 插件?

Run "bun add @capgo/capacitor-firebase-performance" (or "npm install @capgo/capacitor-firebase-performance"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-firebase-performance" in your app code.

是否支持 @capgo/capacitor-firebase-performance 与 React、Vue 和 Angular 一起使用?

是的。 Firebase Performance 是一个 Capacitor 包,因此它与任何在 Capacitor 内部运行的 Web 框架一起工作,包括 Ionic、React、Vue、Angular、Svelte 和普通 JavaScript。

哪个 Capacitor 版本支持 @capgo/capacitor-firebase-performance?

Capgo 插件遵循 Capacitor 的主要版本:使用与 Capacitor 主要版本匹配的插件主要版本(例如插件 v8 与 Capacitor 8)。在 GitHub README 中的兼容性表格中列出了维护的版本。

是否支持 @capgo/capacitor-firebase-performance 免费和开源?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-firebase/tree/main/packages/performance and the package is free to install from npm. Bug reports and pull requests are welcome.

是否可以在不经过 App Store 审核的情况下更新使用 Firebase Performance 的 code?

安装或升级插件会更改原生 code,因此需要一个新的商店构建。之后,使用插件的 JavaScript、HTML 和 CSS 更改可以立即通过 Capgo 实时更新发布。

在应用程序审查等待之前,通过 Firebase Performance 发布应用程序

一旦插件在您的商店构建中,Capgo 实时更新将推送您的 JavaScript、HTML 和 CSS 更改到用户中几分钟内。

开始使用 Capgo