TF-4268 Initialize Sentry from Linagora Ecosystem configuration
This commit is contained in:
+2
@@ -8,6 +8,7 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosyst
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem_identifier.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem_properties.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/sentry_config_linagora_ecosystem.dart';
|
||||
|
||||
class LinagoraEcosystemConverter {
|
||||
static final defaultConverter = LinagoraEcosystemConverter();
|
||||
@@ -29,6 +30,7 @@ class LinagoraEcosystemConverter {
|
||||
LinagoraEcosystemIdentifier.mobileApps: MobileAppsLinagoraEcosystemConverter.deserialize,
|
||||
LinagoraEcosystemIdentifier.paywallURL: ApiUrlLinagoraEcosystem.deserialize,
|
||||
LinagoraEcosystemIdentifier.scribePromptUrl: ApiUrlLinagoraEcosystem.deserialize,
|
||||
LinagoraEcosystemIdentifier.sentryConfig: SentryConfigLinagoraEcosystem.deserialize,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosyst
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem_identifier.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem_properties.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/mobile_apps_linagora_ecosystem.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/sentry_config_linagora_ecosystem.dart';
|
||||
|
||||
class LinagoraEcosystem with EquatableMixin {
|
||||
final Map<LinagoraEcosystemIdentifier, LinagoraEcosystemProperties?>? properties;
|
||||
@@ -48,4 +49,8 @@ extension LinagoraEcosystemExtension on LinagoraEcosystem {
|
||||
|
||||
String? get scribePromptUrl =>
|
||||
(properties?[LinagoraEcosystemIdentifier.scribePromptUrl] as ApiUrlLinagoraEcosystem?)?.value;
|
||||
|
||||
SentryConfigLinagoraEcosystem? get sentryConfigEcosystem =>
|
||||
(properties?[LinagoraEcosystemIdentifier.sentryConfig]
|
||||
as SentryConfigLinagoraEcosystem?);
|
||||
}
|
||||
+1
@@ -13,6 +13,7 @@ class LinagoraEcosystemIdentifier with EquatableMixin {
|
||||
static final linShare = LinagoraEcosystemIdentifier('LinShare');
|
||||
static final paywallURL = LinagoraEcosystemIdentifier('paywallUrlTemplate');
|
||||
static final scribePromptUrl = LinagoraEcosystemIdentifier('scribePromptUrl');
|
||||
static final sentryConfig = LinagoraEcosystemIdentifier('sentry');
|
||||
|
||||
final String value;
|
||||
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import 'package:core/utils/application_manager.dart';
|
||||
import 'package:core/utils/sentry/sentry_config.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/empty_linagora_ecosystem.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem_properties.dart';
|
||||
|
||||
part 'sentry_config_linagora_ecosystem.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
class SentryConfigLinagoraEcosystem extends LinagoraEcosystemProperties {
|
||||
@JsonKey(fromJson: _parseBool)
|
||||
final bool? enabled;
|
||||
final String? dsn;
|
||||
final String? environment;
|
||||
|
||||
SentryConfigLinagoraEcosystem({this.enabled, this.dsn, this.environment});
|
||||
|
||||
factory SentryConfigLinagoraEcosystem.fromJson(Map<String, dynamic> json) =>
|
||||
_$SentryConfigLinagoraEcosystemFromJson(json);
|
||||
|
||||
static bool? _parseBool(dynamic value) {
|
||||
if (value == null) return null;
|
||||
if (value is bool) return value;
|
||||
if (value is String) return value.toLowerCase() == 'true';
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => _$SentryConfigLinagoraEcosystemToJson(this);
|
||||
|
||||
static LinagoraEcosystemProperties? deserialize(dynamic json) {
|
||||
if (json is Map<String, dynamic>) {
|
||||
return SentryConfigLinagoraEcosystem.fromJson(json);
|
||||
} else {
|
||||
return EmptyLinagoraEcosystem();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [enabled, dsn, environment];
|
||||
}
|
||||
|
||||
extension SentryConfigLinagoraEcosystemExtension on SentryConfigLinagoraEcosystem {
|
||||
Future<SentryConfig> toSentryConfig() async {
|
||||
final appVersion = await ApplicationManager().getAppVersion();
|
||||
|
||||
return SentryConfig(
|
||||
dsn: dsn ?? '',
|
||||
environment: environment ?? '',
|
||||
release: appVersion,
|
||||
isAvailable: enabled ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/linagora_ecosystem/linagora_ecosystem.dart';
|
||||
|
||||
class GettingLinagoraEcosystem extends LoadingState {}
|
||||
|
||||
class GetLinagoraEcosystemSuccess extends Success {
|
||||
final LinagoraEcosystem linagoraEcosystem;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class GetLinagoraEcosystemInteractor {
|
||||
|
||||
Stream<Either<Failure, Success>> execute(String baseUrl) async* {
|
||||
try {
|
||||
yield Right(GettingLinagoraEcosystem());
|
||||
final linagoraEcosystem = await _linagoraEcosystemRepository.getLinagoraEcosystem(baseUrl);
|
||||
|
||||
yield Right(GetLinagoraEcosystemSuccess(linagoraEcosystem));
|
||||
|
||||
Reference in New Issue
Block a user