add platform type to userAgent header
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:stream_chat/src/api/retry_policy.dart';
|
||||
import 'package:stream_chat/src/event_type.dart';
|
||||
import 'package:stream_chat/src/models/attachment_file.dart';
|
||||
import 'package:stream_chat/src/models/own_user.dart';
|
||||
import 'package:stream_chat/src/platform_detector/platform_detector.dart';
|
||||
import 'package:stream_chat/version.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
@@ -888,9 +889,8 @@ class StreamChatClient {
|
||||
|
||||
String get _authType => _anonymous ? 'anonymous' : 'jwt';
|
||||
|
||||
// TODO: get the right version of the lib from the build toolchain
|
||||
String get _userAgent =>
|
||||
'stream-chat-dart-client-${PACKAGE_VERSION.split('+')[0]}';
|
||||
'stream-chat-dart-client-${Platform.name}-${PACKAGE_VERSION.split('+')[0]}';
|
||||
|
||||
Map<String, String> get _commonQueryParams => {
|
||||
'user_id': state.user?.id,
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'platform_detector_web.dart' if (dart.library.io) 'src/platform_io.dart';
|
||||
|
||||
enum PlatformType {
|
||||
Android,
|
||||
Ios,
|
||||
Web,
|
||||
MacOS,
|
||||
Windows,
|
||||
Linux,
|
||||
Fuchsia,
|
||||
}
|
||||
|
||||
abstract class Platform {
|
||||
static bool get isAndroid => currentPlatform == PlatformType.Android;
|
||||
static bool get isIos => currentPlatform == PlatformType.Ios;
|
||||
static bool get isWeb => currentPlatform == PlatformType.Web;
|
||||
static bool get isMacOS => currentPlatform == PlatformType.MacOS;
|
||||
static bool get isWindows => currentPlatform == PlatformType.Windows;
|
||||
static bool get isLinux => currentPlatform == PlatformType.Linux;
|
||||
static bool get isFuchsia => currentPlatform == PlatformType.Fuchsia;
|
||||
|
||||
static String get name {
|
||||
switch (currentPlatform) {
|
||||
case PlatformType.Android:
|
||||
return 'android';
|
||||
case PlatformType.Ios:
|
||||
return 'ios';
|
||||
case PlatformType.Web:
|
||||
return 'web';
|
||||
case PlatformType.MacOS:
|
||||
return 'macos';
|
||||
case PlatformType.Windows:
|
||||
return 'windows';
|
||||
case PlatformType.Linux:
|
||||
return 'linux';
|
||||
case PlatformType.Fuchsia:
|
||||
return 'fuchsia';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
PlatformType get type => currentPlatform;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'dart:io';
|
||||
import 'platform_detector.dart';
|
||||
|
||||
PlatformType get currentPlatform {
|
||||
if (Platform.isWindows) return PlatformType.Windows;
|
||||
if (Platform.isFuchsia) return PlatformType.Fuchsia;
|
||||
if (Platform.isMacOS) return PlatformType.MacOS;
|
||||
if (Platform.isLinux) return PlatformType.Linux;
|
||||
if (Platform.isIos) return PlatformType.Ios;
|
||||
return PlatformType.Android;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import 'platform_detector.dart';
|
||||
|
||||
PlatformType get currentPlatform => PlatformType.Web;
|
||||
Reference in New Issue
Block a user