Skip to main content

Firebase Performance Capacitor plugin

Capacitor plugin for Firebase Performance Monitoring

Install

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

Guide

How to use Firebase Performance in Capacitor

Using @capgo/capacitor-firebase-performance

Capacitor plugin for Firebase Performance Monitoring.

Install

bun add @capgo/capacitor-firebase-performance
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';

API at a glance

Method Description
startTrace Starts a trace.
stopTrace Stops a trace.
incrementMetric Atomically increments the metric with the given name for the selected trace by the incrementBy value.
setEnabled Enables or disables performance monitoring. Will be applied with the next start of the app.
isEnabled Determines whether performance monitoring is enabled or disabled.
putAttribute Sets a custom attribute of a trace to a given value.
getAttribute Returns the value of a custom attribute of a trace.
getAttributes Gets the all the custom attributes of a trace with their values.
removeAttribute Removes a custom attribute from a trace given its name.
putMetric Sets the value of a custom metric.
getMetric Get the value of a custom metric by name.
record Records a trace given its name and options.

Examples

startTrace()

Starts a trace.

import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';

await FirebasePerformance.startTrace({ traceName: 'trace' });

stopTrace()

Stops a trace.

import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';

await FirebasePerformance.stopTrace({ traceName: 'trace' });

incrementMetric()

Atomically increments the metric with the given name for the selected trace by the incrementBy value.

import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';

await FirebasePerformance.incrementMetric({
  traceName: 'trace',
  metricName: 'metric',
});

setEnabled()

Enables or disables performance monitoring. Will be applied with the next start of the app.

import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';

await FirebasePerformance.setEnabled({ enabled: true });

isEnabled()

Determines whether performance monitoring is enabled or disabled.

import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';

const result = await FirebasePerformance.isEnabled();
console.log(result);

putAttribute()

Sets a custom attribute of a trace to a given value.

import { FirebasePerformance } from '@capgo/capacitor-firebase-performance';

await FirebasePerformance.putAttribute({
  traceName: 'trace',
  attribute: "experiment",
  value: "A",
});

The table above lists the 12 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.

Full reference

Keep going from Using @capgo/capacitor-firebase-performance

If you are using Using @capgo/capacitor-firebase-performance to plan native plugin work, connect it with Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins, Ionic Enterprise Plugin Alternatives for the product workflow in Ionic Enterprise Plugin Alternatives, and Capgo Native Builds for the product workflow in Capgo Native Builds.

FAQ

Firebase Performance plugin FAQ

How do I install the Firebase Performance plugin in a Capacitor app?

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.

Does @capgo/capacitor-firebase-performance work with React, Vue and Angular?

Yes. Firebase Performance is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-firebase-performance support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-firebase-performance free and open source?

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.

Can I update code that uses Firebase Performance without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Firebase Performance changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo