Skip to content

Commit

Permalink
Merge pull request #1215 from GetStream/hotfix/package
Browse files Browse the repository at this point in the history
fix(llc): fix x-stream-client header
  • Loading branch information
imtoori authored Jun 20, 2022
2 parents bb2d008 + beb39d3 commit dbe7cee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/stream_chat/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions packages/stream_chat/lib/src/client/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 ??
Expand All @@ -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<String, Object?> additionalHeaders = {};

/// The current package version
static const packageVersion = PACKAGE_VERSION;

ChatPersistenceClient? _originalChatPersistenceClient;

/// Chat persistence client
Expand Down
4 changes: 2 additions & 2 deletions packages/stream_chat_flutter/lib/src/stream_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class StreamChatState extends State<StreamChat> {
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();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class StreamChatCoreState extends State<StreamChatCore>
@override
Widget build(BuildContext context) {
StreamChatClient.additionalHeaders = {
'X-Stream-Client': '${StreamChatClient.defaultUserAgent}-core',
'X-Stream-Client': '${StreamChatClient.defaultUserAgent}-'
'core-${StreamChatClient.packageVersion}',
};
return widget.child;
}
Expand Down

0 comments on commit dbe7cee

Please sign in to comment.