reportNetworkRequest static method

void reportNetworkRequest(
  1. Future<CxNetworkRequestSampling?> sampling,
  2. Map<String, dynamic> context
)

Reports a network request once its start-time sampling answer is in, without holding up the caller. The answer is echoed so native records the request in the session it started in.

Implementation

static void reportNetworkRequest(
    Future<CxNetworkRequestSampling?> sampling, Map<String, dynamic> context) {
  sampling
      .then((answer) => CxFlutterPlugin.setNetworkRequestContext({
            ...context,
            ...?answer?.toReportFields(),
          }))
      .catchError((Object e) {
    debugPrint('[Coralogix] setNetworkRequestContext failed: $e');
    return null;
  });
}