message  Send Feedback

perf

The Firebase Performance Monitoring service interface.

This module is available for the default app only.

Example

Get the Performance Monitoring service for the default app:

const defaultAppPerf = firebase.perf();

Properties

Methods


Properties

app

app: FirebaseApp;
keyboard_return Inherited from 
FirebaseModule.app

The current FirebaseApp instance for this Firebase service.


isPerformanceCollectionEnabled

isPerformanceCollectionEnabled: boolean;

Determines whether performance monitoring is enabled or disabled.

Example

const isEnabled = firebase.perf().isPerformanceCollectionEnabled;
console.log('Performance collection enabled: ', isEnabled);

Methods

newHttpMetric

newHttpMetric(
  url: string,
  httpMethod: HttpMethod
): HttpMetric;

Creates a HttpMetric instance for collecting network performance data for a single request/response

Example

const metric = firebase.perf().newHttpMetric('https://api.com/user/1', 'GET');
await metric.start();

Parameters

  • url: string
    A valid url String, cannot be empty
  • httpMethod: HttpMethod
    One of the values GET, PUT, POST, DELETE, HEAD, PATCH, OPTIONS, TRACE, or CONNECT

newTrace

newTrace(
  identifier: string
): Trace;

Creates a Trace instance with the given identifier.

Example

const trace = firebase.perf().newTrace('user_profile');
await trace.start();

Parameters

  • identifier: string
    Name of the trace, no leading or trailing whitespace allowed, no leading underscore '_' character allowed, max length is 100.

setPerformanceCollectionEnabled

setPerformanceCollectionEnabled(
  enabled: boolean
): Promise<null>;

Enables or disables performance monitoring.

Example

// Disable performance monitoring collection
await firebase.perf().setPerformanceCollectionEnabled(false);

Parameters

  • enabled: boolean
    Should performance monitoring be enabled

startTrace

startTrace(
  identifier: string
): Promise<Trace>;

Creates a Trace instance with the given identifier and immediately starts it.

Example

const trace = await firebase.perf().startTrace('user_profile');

Parameters

  • identifier: string
    Name of the trace, no leading or trailing whitespace allowed, no leading underscore '_' character allowed, max length is 100.

React Native Market

Looking for pre-built React Native apps to kick start your next project? Check out the React Native Market by Invertase.

Your purchases help support our open-source projects such as React Native Firebase. All items are currently 50% off to celebrate the release of React Native Firebase version 6.
shopping_cartVisit React Native Market