@@ -5,6 +5,7 @@ import 'package:http/http.dart' as http;
55import 'package:powersync/src/abort_controller.dart' ;
66import 'package:powersync/src/exceptions.dart' ;
77import 'package:powersync/src/log_internal.dart' ;
8+ import 'package:powersync/src/user_agent/user_agent.dart' ;
89import 'package:sqlite_async/mutex.dart' ;
910
1011import 'bucket_storage.dart' ;
@@ -48,6 +49,8 @@ class StreamingSyncImplementation {
4849
4950 final Mutex syncMutex, crudMutex;
5051
52+ late final String ? userAgent;
53+
5154 StreamingSyncImplementation (
5255 {required this .adapter,
5356 required this .credentialsCallback,
@@ -65,6 +68,7 @@ class StreamingSyncImplementation {
6568 crudMutex = Mutex (identifier: "crud-$identifier " ) {
6669 _client = client;
6770 statusStream = _statusStreamController.stream;
71+ userAgent = powerSyncUserAgent ();
6872 }
6973
7074 /// Close any active streams.
@@ -195,10 +199,15 @@ class StreamingSyncImplementation {
195199 }
196200 final uri = credentials.endpointUri ('write-checkpoint2.json' );
197201
198- final response = await _client. get (uri, headers: {
202+ Map < String , String > headers = {
199203 'Content-Type' : 'application/json' ,
200204 'Authorization' : "Token ${credentials .token }"
201- });
205+ };
206+ if (userAgent != null ) {
207+ headers['User-Agent' ] = userAgent! ;
208+ }
209+
210+ final response = await _client.get (uri, headers: headers);
202211 if (response.statusCode == 401 ) {
203212 if (invalidCredentialsCallback != null ) {
204213 await invalidCredentialsCallback !();
@@ -405,6 +414,9 @@ class StreamingSyncImplementation {
405414 final request = http.Request ('POST' , uri);
406415 request.headers['Content-Type' ] = 'application/json' ;
407416 request.headers['Authorization' ] = "Token ${credentials .token }" ;
417+ if (userAgent != null ) {
418+ request.headers['User-Agent' ] = userAgent! ;
419+ }
408420 request.body = convert.jsonEncode (data);
409421
410422 http.StreamedResponse res;
0 commit comments