React Native Firebase
    Preparing search index...

    Metric used to collect data for network requests/responses. A new instance must be used for every request/response.

    Index

    Constructors

    Methods

    • Returns the value of an attribute. Returns null if it does not exist.

      const attribute = metric.getAttribute('user_role');
      

      Parameters

      • attribute: string

        Name of the attribute to fetch the value of

      Returns string | null

    • Returns an object of all the currently added attributes.

      const attributes = metric.getAttributes();

      attributes.forEach(($) => {
      console.log($);
      });

      Returns { [key: string]: string }

    • Sets a String value for the specified attribute. Updates the value of the attribute if it already exists. The maximum number of attributes that can be added is 5.

      metric.putAttribute('user_role', 'admin');
      

      Parameters

      • attribute: string

        Name of the attribute. Max length is 40 chars.

      • value: string

        Value of the attribute. Max length is 100 chars.

      Returns void

    • Removes an already added attribute. Does nothing if attribute does not exist.

      metric.removeAttribute('user_role');
      

      Parameters

      • attribute: string

        Name of the attribute to be removed.

      Returns void

    • Sets the httpResponse code of the request.

      const response = await fetch(url);
      metric.setHttpResponseCode(response.status);

      This is required for every request, if you do not provide this your metric will not be captured.

      Parameters

      • code: number | null

        Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively.

      Returns void

    • Sets the size of the request payload.

      const response = await fetch(url);
      metric.setRequestPayloadSize(response.headers.get('Content-Type'));

      Parameters

      • bytes: number | null

        Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively.

      Returns void

    • Content type of the response e.g. text/html or application/json.

      const response = await fetch(url);
      metric.setResponsePayloadSize(response.headers.get('Content-Type'));

      Parameters

      • contentType: string | null

        Valid string of MIME type. Set to null to remove. Invalid usage will be logged natively.

      Returns void

    • Sets the size of the response payload.

      const response = await fetch(url);
      metric.setResponsePayloadSize(response.headers.get('Content-Length'));

      Parameters

      • bytes: number | null

        Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively.

      Returns void

    • Marks the start time of the request. Does nothing if already started.

      const metric = firebase.perf().newHttpMetric('https://api.com/login', 'POST');
      await metric.start();

      Returns Promise<null>

    • Marks the end time of the response and queues the network request metric on the device for transmission. Does nothing if already stopped.

      const metric = firebase.perf().newHttpMetric('https://api.com/login', 'POST');
      await metric.start();
      metric.putAttribute('user_role', 'admin');
      await metric.stop();

      Returns Promise<null>