diff --git a/packages/alice_chopper/lib/alice_chopper_adapter.dart b/packages/alice_chopper/lib/alice_chopper_adapter.dart index 4d4be2bf..185f0088 100644 --- a/packages/alice_chopper/lib/alice_chopper_adapter.dart +++ b/packages/alice_chopper/lib/alice_chopper_adapter.dart @@ -10,6 +10,7 @@ import 'package:alice/model/alice_http_request.dart'; import 'package:alice/model/alice_http_response.dart'; import 'package:chopper/chopper.dart'; import 'package:http/http.dart' as http; +import 'package:uuid/uuid.dart'; class AliceChopperAdapter with AliceAdapter implements Interceptor { /// Creates hashcode based on request @@ -31,11 +32,15 @@ class AliceChopperAdapter with AliceAdapter implements Interceptor { FutureOr> intercept( Chain chain, ) async { - final int requestId = getRequestHashCode(applyHeader( - chain.request, - 'alice_token', - DateTime.now().microsecondsSinceEpoch.toString(), - )); + final int requestId = getRequestHashCode( + /// The alice_token header is added to the request in order to keep track + /// of the request in the AliceCore instance. + applyHeader( + chain.request, + 'alice_token', + Uuid().v4(), + ), + ); aliceCore.addCall( AliceHttpCall(requestId) diff --git a/packages/alice_chopper/pubspec.yaml b/packages/alice_chopper/pubspec.yaml index bf72a1a4..f77ec00c 100644 --- a/packages/alice_chopper/pubspec.yaml +++ b/packages/alice_chopper/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: alice: ^1.0.0-dev.4 chopper: ^8.0.0 http: ^1.2.1 + uuid: ^4.4.0 dev_dependencies: - very_good_analysis: ^5.1.0 \ No newline at end of file + very_good_analysis: ^5.1.0