diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 7700235ff..f5cd874c4 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -4,7 +4,7 @@ - [[#1135]](https://github.com/GetStream/stream-chat-flutter/issues/1135) Persistence was not removing the hidden channels. - +- Fix `x-stream-client` header generation. ## 4.2.0 ✅ Added diff --git a/packages/stream_chat/lib/src/client/client.dart b/packages/stream_chat/lib/src/client/client.dart index 20506912a..0b31db9e6 100644 --- a/packages/stream_chat/lib/src/client/client.dart +++ b/packages/stream_chat/lib/src/client/client.dart @@ -98,7 +98,9 @@ class StreamChatClient { tokenManager: _tokenManager, handler: handleEvent, logger: detachedLogger('🔌'), - queryParameters: {'X-Stream-Client': defaultUserAgent}, + queryParameters: { + 'X-Stream-Client': '$defaultUserAgent-$packageVersion', + }, ); _retryPolicy = retryPolicy ?? @@ -124,13 +126,15 @@ class StreamChatClient { } /// Default user agent for all requests - static String defaultUserAgent = 'stream-chat-dart-client-' - '${CurrentPlatform.name}-' - '${PACKAGE_VERSION.split('+')[0]}'; + static String defaultUserAgent = + 'stream-chat-dart-client-${CurrentPlatform.name}'; /// Additional headers for all requests static Map additionalHeaders = {}; + /// The current package version + static const packageVersion = PACKAGE_VERSION; + ChatPersistenceClient? _originalChatPersistenceClient; /// Chat persistence client diff --git a/packages/stream_chat_flutter/lib/src/stream_chat.dart b/packages/stream_chat_flutter/lib/src/stream_chat.dart index 801769113..54bd71910 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat.dart @@ -109,8 +109,8 @@ class StreamChatState extends State { child: Builder( builder: (context) { StreamChatClient.additionalHeaders = { - 'X-Stream-Client': - '${StreamChatClient.defaultUserAgent}-ui', + 'X-Stream-Client': '${StreamChatClient.defaultUserAgent}-' + 'ui-${StreamChatClient.packageVersion}', }; return widget.child ?? const Offstage(); }, diff --git a/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart b/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart index 9b5f5dce3..1f790763d 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_chat_core.dart @@ -96,7 +96,8 @@ class StreamChatCoreState extends State @override Widget build(BuildContext context) { StreamChatClient.additionalHeaders = { - 'X-Stream-Client': '${StreamChatClient.defaultUserAgent}-core', + 'X-Stream-Client': '${StreamChatClient.defaultUserAgent}-' + 'core-${StreamChatClient.packageVersion}', }; return widget.child; }