RequestTracker class Null safety

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. [...]
read-only, inherited
id String
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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, dynamic> requestHeaders) Future<RequestTracker>
Sets a dictionary representing the keys and values from the client request's headers. [...]
setResponseHeaders(Map<String, 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, String>>
Generates headers used to correlate requests with business transactions. [...]