onRequest method

  1. @override
Future onRequest(
  1. RequestOptions options,
  2. RequestInterceptorHandler handler
)

Called when the request is about to be sent.

Implementation

@override
Future onRequest(
  RequestOptions options,
  RequestInterceptorHandler handler,
) async {
  try {
    final metric = FirebasePerformance.instance.newHttpMetric(
      requestUrlBuilder(options),
      options.method.asHttpMethod()!,
    );
    options.extra[extraKey] = metric;
    final requestContentLength = requestContentLengthMethod(options);
    await metric.start();
    if (requestContentLength != null) {
      metric.requestPayloadSize = requestContentLength;
    }
  } catch (_) {}
  return super.onRequest(options, handler);
}