RequestTracker class

Class used to track network requests.

try {
   final tracker = await RequestTracker.create(url);

   // optional: add server correlation headers
   final headers = await RequestTracker.getServerCorrelationHeaders();

   // use your custom request() implementation
   final response = await request(url, headers);

   await tracker.setRequestHeaders(response.request.headers);
   await tracker.setResponseHeaders(response.headers);
   await tracker.setResponseStatusCode(response.statusCode);
   await tracker.setUserDataBool("secureCheck", false);
 } catch (error) {
   await tracker.setError(error.toString());
 } finally {
   await tracker.reportDone();
 }

Properties

hashCode int
The hash code for this object.
no setterinherited
id String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reportDone() Future<RequestTracker>
Stops tracking an HTTP request.
setError(String message, [String? stackTrace]) → dynamic
Sets an error message describing the failure to receive a response, if such a failure occurred.
setRequestHeaders(Map<String, List<String>> requestHeaders) Future<RequestTracker>
Sets a dictionary representing the keys and values from the client request's headers.
setResponseHeaders(Map<String, List<String>> responseHeaders) Future<RequestTracker>
Sets a dictionary representing the keys and values from the server response's headers.
setResponseStatusCode(int statusCode) Future<RequestTracker>
Returns the statusCode of the response, if one was received.
setUserData(String key, String value) Future<void>
Sets a key-value pair identifier that will be included with this tracker. This identifier can be used to add String types.
setUserDataBool(String key, bool value) Future<void>
Sets a key-value pair identifier that will be included with this tracker. This identifier can be used to add the bool types.
setUserDataDateTime(String key, DateTime value) Future<void>
Sets a key-value pair identifier that will be included with this tracker. This identifier can be used to add the DateTime types.
setUserDataDouble(String key, double value) Future<void>
Sets a key-value pair identifier that will be included with this tracker. This identifier can be used to add the double types.
setUserDataInt(String key, int value) Future<void>
Sets a key-value pair identifier that will be included with this tracker. This identifier can be used to add the int types.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

create(String url) Future<RequestTracker>
Creates a RequestTracker to be configured for manually tracking an HTTP request to track it manually, with a non-null url and after having called Instrumentation.start.
getServerCorrelationHeaders() Future<Map<String, List<String>>>
Generates headers used to correlate requests with business transactions.