tlConnection static method

Future<void> tlConnection({
  1. required String url,
  2. required int statusCode,
  3. String description = '',
  4. int responseSize = 0,
  5. int initTime = 0,
  6. int loadTime = 0,
  7. dynamic responseTime = 0,
})

Records network connection metrics for a specific URL.

url: The URL of the network connection. statusCode: The HTTP status code of the network response. description: Optional description of the network connection. responseSize: Optional size of the network response data, in bytes. initTime: Optional time at which the network request was initiated. loadTime: Optional time at which the network response was received. responseTime: Optional time it took to receive the network response, calculated as loadTime - initTime if not provided.

Implementation

static Future<void> tlConnection(
    {required String url,
    required int statusCode,
    String description = '',
    int responseSize = 0,
    int initTime = 0,
    int loadTime = 0,
    responseTime = 0}) async {
  if (responseTime == 0) {
    responseTime = loadTime - initTime;
  }
  try {
    await _channel.invokeMethod('connection', {
      'url': url,
      'statusCode': statusCode.toString(),
      'responseDataSize': responseSize.toString(),
      'initTime': initTime.toString(),
      'loadTime': loadTime.toString(),
      'responseTime': responseTime.toString(),
      'description': description
    });
  } on PlatformException catch (pe) {
    throw TealeafException(pe, msg: 'Unable to process connection message!');
  }
}