Invertase
Invertase

Notice: This documentation is currently a work in progress for the upcoming v6 release and some content may be missing or incomplete. If you're not interested in testing out the alpha version of v6 then please click here to be taken to the v5 documentation.

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

app

app: FirebaseApp;

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
    A valid url String, cannot be empty
  • 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
    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
    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
    Name of the trace, no leading or trailing whitespace allowed, no leading underscore '_' character allowed, max length is 100.