From 32eae500d39ed293561e163f914dfdd2477815b3 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 18 May 2022 17:07:53 +0530 Subject: [PATCH 01/12] doc(docs): Add sentry guide Signed-off-by: xsahil03x --- .../guides/error_reporting_with_sentry.mdx | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx diff --git a/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx new file mode 100644 index 00000000..4eb347d1 --- /dev/null +++ b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx @@ -0,0 +1,133 @@ +--- +id: error_reporting_with_sentry +sidebar_position: 15 +title: Error Reporting With Sentry +--- + +Error Reporting With Sentry + +## Introduction + +While one always tries to create apps that are free of bugs, they’re sure to crop up from time to time. Since buggy apps lead to unhappy users and customers, it’s important to understand how often your users experience bugs and where those bugs occur. That way, you can prioritize the bugs with the highest impact and work to fix them. +How can you determine how often your users experiences bugs? Whenever an error occurs, create a report containing the error that occurred and the associated stacktrace. You can then send the report to an error tracking service, such as Sentry, Fabric, or Rollbar. +The error tracking service aggregates all of the crashes your users experience and groups them together. This allows you to know how often your app fails and where the users run into trouble. + +In this guide, learn how to report errors to the [Sentry](https://sentry.io/welcome/) crash reporting service using the following steps: + +### 1. Get a DSN from Sentry +Before reporting errors to Sentry, you need a “DSN” to uniquely identify your app with the Sentry.io service. + +To get a DSN, use the following steps: + +* [Create an account with Sentry](https://sentry.io/signup/). +* Log in to the account. +* Create a new Flutter project. +* Copy the code snippet that includes the DSN. + +### 2. Import the Sentry package +Import the `sentry_flutter` package into the app. The sentry package makes it easier to send error reports to the Sentry error tracking service. + +```yaml +dependencies: + sentry_flutter: +``` + +### 3. Initialize the SDK to capture different unhandled errors automatically + +```dart +import 'package:sentry_flutter/sentry_flutter.dart'; + +Future main() async { + await SentryFlutter.init( + (options) => options.dsn = 'https://example@sentry.io/example', + appRunner: () => runApp(const MyApp()), + ); +} +``` + +Or, if you want to run your app in your own error zone runZonedGuarded: + +```dart +void main() async { + /// Captures errors reported by the Flutter framework. + FlutterError.onError = (FlutterErrorDetails details) { + if (kDebugMode) { + // In development mode, simply print to console. + FlutterError.dumpErrorToConsole(details); + } else { + // In production mode, report to the application zone to report to sentry. + Zone.current.handleUncaughtError(details.exception, details.stack!); + } + }; + + Future _reportError(dynamic error, StackTrace stackTrace) async { + // Print the exception to the console. + if (kDebugMode) { + // Print the full stacktrace in debug mode. + print(stackTrace); + return; + } else { + // Send the Exception and Stacktrace to sentry in Production mode. + await Sentry.captureException(error, stackTrace: stackTrace); + } + } + + runZonedGuarded( + () async { + await SentryFlutter.init( + (options) => options.dsn = 'https://example@sentry.io/example', + ); + runApp(const MyApp()); + }, + _reportError, + ); +} +``` + +Alternatively, you can pass the DSN to Flutter using the dart-define tag: + +```dart +--dart-define SENTRY_DSN=https://example@sentry.io/example +``` + +### 4. Integration with StreamChat applications + +Override the default `logHandlerFunction` to send errors to Sentry. + +```dart +void sampleAppLogHandler(LogRecord record) async { + if (kDebugMode) StreamChatClient.defaultLogHandler(record); + + // report errors to sentry + if (record.error != null || record.stackTrace != null) { + await Sentry.captureException( + record.error, + stackTrace: record.stackTrace, + ); + } +} + +StreamChatClient buildStreamChatClient( + String apiKey, { + Level logLevel = Level.SEVERE, +}) { + return StreamChatClient( + apiKey, + logLevel: logLevel, + logHandlerFunction: sampleAppLogHandler, // Pass the overridden logHandlerFunction + ); +} +``` + +### 5. Capture errors programmatically +Besides the automatic error reporting that Sentry generates by importing and initializing the SDK, +you can use the API to report errors to Sentry: + +```dart +await Sentry.captureException(exception, stackTrace: stackTrace); +``` + +For more information, see the [Sentry API](https://pub.dev/documentation/sentry_flutter/latest/sentry_flutter/sentry_flutter-library.html) docs on pub.dev. + +### Learn more +Extensive documentation about using the Sentry SDK can be found on [Sentry’s site](https://docs.sentry.io/platforms/flutter/). \ No newline at end of file From ef7f271a006392b4c7678f5218d39347aac89d66 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 18 May 2022 17:10:03 +0530 Subject: [PATCH 02/12] doc(repo): add complete example link Signed-off-by: xsahil03x --- docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx index 4eb347d1..33d4d221 100644 --- a/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx +++ b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx @@ -129,5 +129,8 @@ await Sentry.captureException(exception, stackTrace: stackTrace); For more information, see the [Sentry API](https://pub.dev/documentation/sentry_flutter/latest/sentry_flutter/sentry_flutter-library.html) docs on pub.dev. +### Complete example +To view a working example, see the [Stream Sample app](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). + ### Learn more Extensive documentation about using the Sentry SDK can be found on [Sentry’s site](https://docs.sentry.io/platforms/flutter/). \ No newline at end of file From b1e4e134cadc175bf9660fe9fbffd98478d1597f Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 19 May 2022 14:34:04 +0530 Subject: [PATCH 03/12] feat(llc): add support for channel.membership Signed-off-by: xsahil03x --- .../stream_chat/lib/src/client/channel.dart | 12 ++++ .../core/models/attachment_file.freezed.dart | 59 +++++-------------- .../lib/src/core/models/channel_model.dart | 10 ++++ .../lib/src/core/models/channel_model.g.dart | 4 ++ 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index f5d87404..2a9e26a0 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -171,6 +171,18 @@ class Channel { return state!.channelStateStream.map((cs) => cs.channel?.config); } + /// Relationship of the current user to this channel. + Member? get membership { + _checkInitialized(); + return state!._channelState.channel?.membership; + } + + /// Relationship of the current user to this channel as a stream. + Stream get membershipStream { + _checkInitialized(); + return state!.channelStateStream.map((cs) => cs.channel?.membership); + } + /// Channel user creator. User? get createdBy { _checkInitialized(); diff --git a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart index 94f15db4..9140ec5e 100644 --- a/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart +++ b/packages/stream_chat/lib/src/core/models/attachment_file.freezed.dart @@ -12,7 +12,7 @@ part of 'attachment_file.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); UploadState _$UploadStateFromJson(Map json) { switch (json['runtimeType']) { @@ -31,39 +31,6 @@ UploadState _$UploadStateFromJson(Map json) { } } -/// @nodoc -class _$UploadStateTearOff { - const _$UploadStateTearOff(); - - Preparing preparing() { - return const Preparing(); - } - - InProgress inProgress({required int uploaded, required int total}) { - return InProgress( - uploaded: uploaded, - total: total, - ); - } - - Success success() { - return const Success(); - } - - Failed failed({required String error}) { - return Failed( - error: error, - ); - } - - UploadState fromJson(Map json) { - return UploadState.fromJson(json); - } -} - -/// @nodoc -const $UploadState = _$UploadStateTearOff(); - /// @nodoc mixin _$UploadState { @optionalTypeArgs @@ -156,7 +123,7 @@ class __$$PreparingCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$Preparing implements Preparing { - const _$Preparing({String? $type}) : $type = $type ?? 'preparing'; + const _$Preparing({final String? $type}) : $type = $type ?? 'preparing'; factory _$Preparing.fromJson(Map json) => _$$PreparingFromJson(json); @@ -175,6 +142,7 @@ class _$Preparing implements Preparing { (other.runtimeType == runtimeType && other is _$Preparing); } + @JsonKey(ignore: true) @override int get hashCode => runtimeType.hashCode; @@ -304,7 +272,7 @@ class __$$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> @JsonSerializable() class _$InProgress implements InProgress { const _$InProgress( - {required this.uploaded, required this.total, String? $type}) + {required this.uploaded, required this.total, final String? $type}) : $type = $type ?? 'inProgress'; factory _$InProgress.fromJson(Map json) => @@ -332,6 +300,7 @@ class _$InProgress implements InProgress { const DeepCollectionEquality().equals(other.total, total)); } + @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, @@ -424,14 +393,14 @@ class _$InProgress implements InProgress { } abstract class InProgress implements UploadState { - const factory InProgress({required int uploaded, required int total}) = - _$InProgress; + const factory InProgress( + {required final int uploaded, required final int total}) = _$InProgress; factory InProgress.fromJson(Map json) = _$InProgress.fromJson; - int get uploaded; - int get total; + int get uploaded => throw _privateConstructorUsedError; + int get total => throw _privateConstructorUsedError; @JsonKey(ignore: true) _$$InProgressCopyWith<_$InProgress> get copyWith => throw _privateConstructorUsedError; @@ -456,7 +425,7 @@ class __$$SuccessCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$Success implements Success { - const _$Success({String? $type}) : $type = $type ?? 'success'; + const _$Success({final String? $type}) : $type = $type ?? 'success'; factory _$Success.fromJson(Map json) => _$$SuccessFromJson(json); @@ -475,6 +444,7 @@ class _$Success implements Success { (other.runtimeType == runtimeType && other is _$Success); } + @JsonKey(ignore: true) @override int get hashCode => runtimeType.hashCode; @@ -596,7 +566,7 @@ class __$$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$Failed implements Failed { - const _$Failed({required this.error, String? $type}) + const _$Failed({required this.error, final String? $type}) : $type = $type ?? 'failed'; factory _$Failed.fromJson(Map json) => @@ -621,6 +591,7 @@ class _$Failed implements Failed { const DeepCollectionEquality().equals(other.error, error)); } + @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(error)); @@ -711,11 +682,11 @@ class _$Failed implements Failed { } abstract class Failed implements UploadState { - const factory Failed({required String error}) = _$Failed; + const factory Failed({required final String error}) = _$Failed; factory Failed.fromJson(Map json) = _$Failed.fromJson; - String get error; + String get error => throw _privateConstructorUsedError; @JsonKey(ignore: true) _$$FailedCopyWith<_$Failed> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index c3e83435..e2f7303e 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:stream_chat/src/core/models/channel_config.dart'; +import 'package:stream_chat/src/core/models/member.dart'; import 'package:stream_chat/src/core/models/user.dart'; import 'package:stream_chat/src/core/util/serializer.dart'; @@ -25,6 +26,7 @@ class ChannelModel { this.extraData = const {}, this.team, this.cooldown = 0, + this.membership, }) : assert( (cid != null && cid.contains(':')) || (id != null && type != null), 'provide either a cid or an id and type', @@ -100,6 +102,10 @@ class ChannelModel { @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) final String? team; + /// Relationship of the current user to this channel. + @JsonKey(includeIfNull: false) + final Member? membership; + /// Known top level fields. /// Useful for [Serializer] methods. static const topLevelFields = [ @@ -117,6 +123,7 @@ class ChannelModel { 'member_count', 'team', 'cooldown', + 'membership', ]; /// Shortcut for channel name @@ -145,6 +152,7 @@ class ChannelModel { Map? extraData, String? team, int? cooldown, + Member? membership, }) => ChannelModel( id: id ?? this.id, @@ -162,6 +170,7 @@ class ChannelModel { extraData: extraData ?? this.extraData, team: team ?? this.team, cooldown: cooldown ?? this.cooldown, + membership: membership ?? this.membership, ); /// Returns a new [ChannelModel] that is a combination of this channelModel @@ -184,6 +193,7 @@ class ChannelModel { extraData: {...extraData, ...other.extraData}, team: other.team, cooldown: other.cooldown, + membership: other.membership, ); } } diff --git a/packages/stream_chat/lib/src/core/models/channel_model.g.dart b/packages/stream_chat/lib/src/core/models/channel_model.g.dart index 9bd8f062..910c3aea 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.g.dart @@ -36,6 +36,9 @@ ChannelModel _$ChannelModelFromJson(Map json) => ChannelModel( extraData: json['extra_data'] as Map? ?? const {}, team: json['team'] as String?, cooldown: json['cooldown'] as int? ?? 0, + membership: json['membership'] == null + ? null + : Member.fromJson(json['membership'] as Map), ); Map _$ChannelModelToJson(ChannelModel instance) { @@ -63,5 +66,6 @@ Map _$ChannelModelToJson(ChannelModel instance) { val['cooldown'] = instance.cooldown; val['extra_data'] = instance.extraData; writeNotNull('team', readonly(instance.team)); + writeNotNull('membership', instance.membership?.toJson()); return val; } From 15b2c1053419a6ab4d6d121aca4ce4bad0825f6b Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 19 May 2022 14:36:56 +0530 Subject: [PATCH 04/12] chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x --- packages/stream_chat/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 48c4dd4d..6ac8b580 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -7,6 +7,7 @@ - Added `PaginationParams.createdAtBeforeOrEqual` for message pagination. - Added `PaginationParams.createdAtBefore` for message pagination. - Added `PaginationParams.createdAtAround` for message pagination. +- Added support for `channel.membership` and `channel.membershipStream` in `Channel`. 🔄 Changed From 63f568bf90a7b5b558e85af66b7a00e1dc7feb4e Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 19 May 2022 14:51:28 +0530 Subject: [PATCH 05/12] refactor(llc): move membership from channel_model to channel_state Signed-off-by: xsahil03x --- packages/stream_chat/lib/src/client/channel.dart | 4 ++-- .../stream_chat/lib/src/core/models/channel_model.dart | 9 --------- .../stream_chat/lib/src/core/models/channel_model.g.dart | 4 ---- .../stream_chat/lib/src/core/models/channel_state.dart | 6 ++++++ .../stream_chat/lib/src/core/models/channel_state.g.dart | 4 ++++ 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/stream_chat/lib/src/client/channel.dart b/packages/stream_chat/lib/src/client/channel.dart index 2a9e26a0..6076a57f 100644 --- a/packages/stream_chat/lib/src/client/channel.dart +++ b/packages/stream_chat/lib/src/client/channel.dart @@ -174,13 +174,13 @@ class Channel { /// Relationship of the current user to this channel. Member? get membership { _checkInitialized(); - return state!._channelState.channel?.membership; + return state!._channelState.membership; } /// Relationship of the current user to this channel as a stream. Stream get membershipStream { _checkInitialized(); - return state!.channelStateStream.map((cs) => cs.channel?.membership); + return state!.channelStateStream.map((cs) => cs.membership); } /// Channel user creator. diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index e2f7303e..1ed95d9b 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -26,7 +26,6 @@ class ChannelModel { this.extraData = const {}, this.team, this.cooldown = 0, - this.membership, }) : assert( (cid != null && cid.contains(':')) || (id != null && type != null), 'provide either a cid or an id and type', @@ -102,10 +101,6 @@ class ChannelModel { @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) final String? team; - /// Relationship of the current user to this channel. - @JsonKey(includeIfNull: false) - final Member? membership; - /// Known top level fields. /// Useful for [Serializer] methods. static const topLevelFields = [ @@ -123,7 +118,6 @@ class ChannelModel { 'member_count', 'team', 'cooldown', - 'membership', ]; /// Shortcut for channel name @@ -152,7 +146,6 @@ class ChannelModel { Map? extraData, String? team, int? cooldown, - Member? membership, }) => ChannelModel( id: id ?? this.id, @@ -170,7 +163,6 @@ class ChannelModel { extraData: extraData ?? this.extraData, team: team ?? this.team, cooldown: cooldown ?? this.cooldown, - membership: membership ?? this.membership, ); /// Returns a new [ChannelModel] that is a combination of this channelModel @@ -193,7 +185,6 @@ class ChannelModel { extraData: {...extraData, ...other.extraData}, team: other.team, cooldown: other.cooldown, - membership: other.membership, ); } } diff --git a/packages/stream_chat/lib/src/core/models/channel_model.g.dart b/packages/stream_chat/lib/src/core/models/channel_model.g.dart index 910c3aea..9bd8f062 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.g.dart @@ -36,9 +36,6 @@ ChannelModel _$ChannelModelFromJson(Map json) => ChannelModel( extraData: json['extra_data'] as Map? ?? const {}, team: json['team'] as String?, cooldown: json['cooldown'] as int? ?? 0, - membership: json['membership'] == null - ? null - : Member.fromJson(json['membership'] as Map), ); Map _$ChannelModelToJson(ChannelModel instance) { @@ -66,6 +63,5 @@ Map _$ChannelModelToJson(ChannelModel instance) { val['cooldown'] = instance.cooldown; val['extra_data'] = instance.extraData; writeNotNull('team', readonly(instance.team)); - writeNotNull('membership', instance.membership?.toJson()); return val; } diff --git a/packages/stream_chat/lib/src/core/models/channel_state.dart b/packages/stream_chat/lib/src/core/models/channel_state.dart index 3ba3c5f8..e7e3c7b1 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.dart @@ -19,6 +19,7 @@ class ChannelState { this.watcherCount, this.watchers, this.read, + this.membership, }); /// The channel to which this state belongs @@ -42,6 +43,9 @@ class ChannelState { /// The list of channel reads final List? read; + /// + final Member? membership; + /// Create a new instance from a json static ChannelState fromJson(Map json) => _$ChannelStateFromJson(json); @@ -58,6 +62,7 @@ class ChannelState { int? watcherCount, List? watchers, List? read, + Member? membership, }) => ChannelState( channel: channel ?? this.channel, @@ -67,5 +72,6 @@ class ChannelState { watcherCount: watcherCount ?? this.watcherCount, watchers: watchers ?? this.watchers, read: read ?? this.read, + membership: membership ?? this.membership, ); } diff --git a/packages/stream_chat/lib/src/core/models/channel_state.g.dart b/packages/stream_chat/lib/src/core/models/channel_state.g.dart index afec76c4..40e11a32 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.g.dart @@ -26,6 +26,9 @@ ChannelState _$ChannelStateFromJson(Map json) => ChannelState( read: (json['read'] as List?) ?.map((e) => Read.fromJson(e as Map)) .toList(), + membership: json['membership'] == null + ? null + : Member.fromJson(json['membership'] as Map), ); Map _$ChannelStateToJson(ChannelState instance) => @@ -38,4 +41,5 @@ Map _$ChannelStateToJson(ChannelState instance) => 'watcher_count': instance.watcherCount, 'watchers': instance.watchers?.map((e) => e.toJson()).toList(), 'read': instance.read?.map((e) => e.toJson()).toList(), + 'membership': instance.membership?.toJson(), }; From dd4506a9269209807a313507ba885da8cd5547ca Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 19 May 2022 14:53:11 +0530 Subject: [PATCH 06/12] Update packages/stream_chat/lib/src/core/models/channel_model.dart --- packages/stream_chat/lib/src/core/models/channel_model.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index 1ed95d9b..c3e83435 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:stream_chat/src/core/models/channel_config.dart'; -import 'package:stream_chat/src/core/models/member.dart'; import 'package:stream_chat/src/core/models/user.dart'; import 'package:stream_chat/src/core/util/serializer.dart'; From 9ebfaf55f329e55851b5d6baacb840eea3c1e117 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 19 May 2022 14:54:05 +0530 Subject: [PATCH 07/12] Update packages/stream_chat/lib/src/core/models/channel_state.dart --- packages/stream_chat/lib/src/core/models/channel_state.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat/lib/src/core/models/channel_state.dart b/packages/stream_chat/lib/src/core/models/channel_state.dart index e7e3c7b1..65e22f38 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.dart @@ -43,7 +43,7 @@ class ChannelState { /// The list of channel reads final List? read; - /// + /// Relationship of the current user to this channel. final Member? membership; /// Create a new instance from a json From 3c0969c904f0c3d8fa3439343bbc5d54174f2ee2 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 May 2022 11:48:49 +0200 Subject: [PATCH 08/12] fix action --- .github/workflows/dart_code_metrics.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 7e3e41fd..dfbd0890 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -42,33 +42,33 @@ jobs: uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/stream_chat' + relative_path: 'packages/melos_stream_chat' folders: ${{ env.folders }} - name: "Stream Chat Flutter Core Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/stream_chat_flutter_core' + relative_path: 'packages/melos_stream_chat_flutter_core' folders: ${{ env.folders }} - name: "Stream Chat Flutter Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/stream_chat_flutter' + relative_path: 'packages/melos_stream_chat_flutter' folders: ${{ env.folders }} - name: "Stream Chat Localizations Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/stream_chat_localizations' + relative_path: 'packages/melos_stream_chat_localizations' folders: ${{ env.folders }} - name: "Stream Chat Persistence Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/stream_chat_persistence' + relative_path: 'packages/melos_stream_chat_persistence' folders: ${{ env.folders }} From e7ba4bc8ca3841ef836fce47b2a8a4d2030aa46c Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 May 2022 11:52:00 +0200 Subject: [PATCH 09/12] fix action --- .github/workflows/dart_code_metrics.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index dfbd0890..7e3e41fd 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -42,33 +42,33 @@ jobs: uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/melos_stream_chat' + relative_path: 'packages/stream_chat' folders: ${{ env.folders }} - name: "Stream Chat Flutter Core Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/melos_stream_chat_flutter_core' + relative_path: 'packages/stream_chat_flutter_core' folders: ${{ env.folders }} - name: "Stream Chat Flutter Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/melos_stream_chat_flutter' + relative_path: 'packages/stream_chat_flutter' folders: ${{ env.folders }} - name: "Stream Chat Localizations Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/melos_stream_chat_localizations' + relative_path: 'packages/stream_chat_localizations' folders: ${{ env.folders }} - name: "Stream Chat Persistence Metrics" uses: dart-code-checker/dart-code-metrics-action@v2.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - relative_path: 'packages/melos_stream_chat_persistence' + relative_path: 'packages/stream_chat_persistence' folders: ${{ env.folders }} From 789e6e781b2c8f025ad3c30d97d0c61453e90b81 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 May 2022 12:18:32 +0200 Subject: [PATCH 10/12] fix analysis --- analysis_options.yaml | 1 - .../lib/src/v4/message_input/stream_message_input.dart | 1 - 2 files changed, 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index c2c1d692..52f50e45 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -159,7 +159,6 @@ linter: - avoid_escaping_inner_quotes - unnecessary_overrides - prefer_null_aware_method_calls - - prefer_null_aware_operators - use_named_constants - use_raw_strings diff --git a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart index b99c0b8a..ef0ddffb 100644 --- a/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart +++ b/packages/stream_chat_flutter/lib/src/v4/message_input/stream_message_input.dart @@ -608,7 +608,6 @@ class StreamMessageInputState extends State widget: _buildCommandsOverlayEntry(), ), if (widget.enableEmojiSuggestionsOverlay && - // ignore: deprecated_member_use_from_same_package !widget.disableEmojiSuggestionsOverlay) OverlayOptions( visible: _focusNode.hasFocus && From 96914549903542defbedabe0a4b2de37cc8e8fb2 Mon Sep 17 00:00:00 2001 From: Gordon Hayes Date: Thu, 19 May 2022 12:53:33 +0200 Subject: [PATCH 11/12] docs: review and fixes --- .../guides/error_reporting_with_sentry.mdx | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx index 33d4d221..a192a613 100644 --- a/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx +++ b/docusaurus/docs/Flutter/guides/error_reporting_with_sentry.mdx @@ -8,31 +8,36 @@ Error Reporting With Sentry ## Introduction -While one always tries to create apps that are free of bugs, they’re sure to crop up from time to time. Since buggy apps lead to unhappy users and customers, it’s important to understand how often your users experience bugs and where those bugs occur. That way, you can prioritize the bugs with the highest impact and work to fix them. -How can you determine how often your users experiences bugs? Whenever an error occurs, create a report containing the error that occurred and the associated stacktrace. You can then send the report to an error tracking service, such as Sentry, Fabric, or Rollbar. -The error tracking service aggregates all of the crashes your users experience and groups them together. This allows you to know how often your app fails and where the users run into trouble. +While one always tries to create apps that are free of bugs, they're sure to crop up from time to time. Since buggy apps lead to unhappy users and customers, it's important to understand how often your users experience bugs and where those bugs occur. That way, you can prioritize the bugs with the highest impact and work to fix them. -In this guide, learn how to report errors to the [Sentry](https://sentry.io/welcome/) crash reporting service using the following steps: +Whenever an error occurs, create a report containing the error that occurred and the associated stack trace. You can then send the report to an error tracking service, such as [Sentry](https://sentry.io/), [Rollbar](https://rollbar.com/), or [Firebase Crashlytics](https://firebase.google.com/docs/crashlytics). -### 1. Get a DSN from Sentry -Before reporting errors to Sentry, you need a “DSN” to uniquely identify your app with the Sentry.io service. +The error tracking service aggregates all of the crashes your users experience and groups them together. This allows you to know how often your app fails and where your users run into trouble. +In this guide, learn how to report Stream Chat errors to the [Sentry](https://sentry.io/welcome/) crash reporting service using the following steps. + +### 1. Get a DSN From Sentry + +Before reporting errors to Sentry, you need a “DSN” to uniquely identify your app with the Sentry service: To get a DSN, use the following steps: -* [Create an account with Sentry](https://sentry.io/signup/). -* Log in to the account. -* Create a new Flutter project. -* Copy the code snippet that includes the DSN. +- [Create an account with Sentry](https://sentry.io/signup/). +- Log in to the account. +- Create a new Flutter project. +- Copy the code snippet that includes the DSN. ### 2. Import the Sentry package -Import the `sentry_flutter` package into the app. The sentry package makes it easier to send error reports to the Sentry error tracking service. + +Import the `sentry_flutter` package into your app. The sentry package makes it easier to send error reports to the Sentry error tracking service. ```yaml dependencies: sentry_flutter: ``` -### 3. Initialize the SDK to capture different unhandled errors automatically +### 3. Initialize the Sentry SDK + +Initialize the SDK to capture different unhandled errors automatically. ```dart import 'package:sentry_flutter/sentry_flutter.dart'; @@ -45,7 +50,7 @@ Future main() async { } ``` -Or, if you want to run your app in your own error zone runZonedGuarded: +Or, if you want to run your app in your own error zone, use `runZonedGuarded`: ```dart void main() async { @@ -55,7 +60,7 @@ void main() async { // In development mode, simply print to console. FlutterError.dumpErrorToConsole(details); } else { - // In production mode, report to the application zone to report to sentry. + // In production mode, report to the application zone to report to Sentry. Zone.current.handleUncaughtError(details.exception, details.stack!); } }; @@ -63,7 +68,7 @@ void main() async { Future _reportError(dynamic error, StackTrace stackTrace) async { // Print the exception to the console. if (kDebugMode) { - // Print the full stacktrace in debug mode. + // Print the full stack trace in debug mode. print(stackTrace); return; } else { @@ -84,13 +89,13 @@ void main() async { } ``` -Alternatively, you can pass the DSN to Flutter using the dart-define tag: +Alternatively, you can pass the DSN to Flutter using the **dart-define** tag: -```dart +```bash --dart-define SENTRY_DSN=https://example@sentry.io/example ``` -### 4. Integration with StreamChat applications +### 4. Integration With StreamChat Applications Override the default `logHandlerFunction` to send errors to Sentry. @@ -98,7 +103,7 @@ Override the default `logHandlerFunction` to send errors to Sentry. void sampleAppLogHandler(LogRecord record) async { if (kDebugMode) StreamChatClient.defaultLogHandler(record); - // report errors to sentry + // Report errors to Sentry if (record.error != null || record.stackTrace != null) { await Sentry.captureException( record.error, @@ -119,18 +124,21 @@ StreamChatClient buildStreamChatClient( } ``` -### 5. Capture errors programmatically +### 5. Capture Errors Programmatically + Besides the automatic error reporting that Sentry generates by importing and initializing the SDK, -you can use the API to report errors to Sentry: +you can use the API to manually report errors to Sentry: ```dart await Sentry.captureException(exception, stackTrace: stackTrace); ``` -For more information, see the [Sentry API](https://pub.dev/documentation/sentry_flutter/latest/sentry_flutter/sentry_flutter-library.html) docs on pub.dev. +For more information, see the [Sentry API](https://pub.dev/documentation/sentry_flutter/latest/sentry_flutter/sentry_flutter-library.html) docs on Pub. + +### Complete Example -### Complete example To view a working example, see the [Stream Sample app](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1). -### Learn more -Extensive documentation about using the Sentry SDK can be found on [Sentry’s site](https://docs.sentry.io/platforms/flutter/). \ No newline at end of file +### Learn More + +Extensive documentation about using the Sentry SDK can be found on [Sentry's site](https://docs.sentry.io/platforms/flutter/). From 434214e7354f8c88da6f55750a4b98d493f21063 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 May 2022 14:02:58 +0200 Subject: [PATCH 12/12] fix test --- packages/stream_chat/test/fixtures/channel_state_to_json.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat/test/fixtures/channel_state_to_json.json b/packages/stream_chat/test/fixtures/channel_state_to_json.json index ebb74fb6..c0c06f9e 100644 --- a/packages/stream_chat/test/fixtures/channel_state_to_json.json +++ b/packages/stream_chat/test/fixtures/channel_state_to_json.json @@ -11,6 +11,7 @@ }, "watchers": [], "read": [], + "membership": null, "messages": [ { "id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030",