onResponse method
Called when the response is about to be resolved.
Implementation
@override
void onResponse(
Response<dynamic> response, ResponseInterceptorHandler handler) {
assert(() {
final parentId =
response.requestOptions.extra['_trinity_event_id'] as String?;
TrinityEventBus.instance.emit(CausalEvent(
parentId: parentId,
type: CausalEventType.networkEvent,
description:
'HTTP ${response.statusCode} ${response.requestOptions.method} '
'${response.requestOptions.uri.path}',
metadata: {
'method': response.requestOptions.method,
'url': response.requestOptions.uri.toString(),
'path': response.requestOptions.uri.path,
'phase': 'response',
'status_code': response.statusCode ?? 0,
'content_length':
response.headers.value('content-length') ?? 'unknown',
},
));
return true;
}());
handler.next(response);
}