feat: Add numerous repository implementations, cubits, and core utilities across various features, and update dependencies.

This commit is contained in:
mso7nueh
2026-02-02 14:24:17 +03:00
parent ac5504a514
commit 278f4d7e10
45 changed files with 602 additions and 292 deletions

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/core/comments/models/comment_update_model.dart';
import 'package:eatvio_app/core/comments/services/comments_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class CommentsRepository {
final CommentsService service;
@@ -9,7 +10,8 @@ class CommentsRepository {
Future<void> deleteComment({required int id}) async {
try {
return service.deleteComment(id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -17,7 +19,8 @@ class CommentsRepository {
Future<void> updateComment({required int id, required String body}) async {
try {
return service.updateComment(id, CommentUpdateModel(body: body));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -6,6 +6,7 @@ import 'package:eatvio_app/core/interceptors/token_interceptor.dart';
import 'package:eatvio_app/core/prefs.dart';
import 'package:get_it/get_it.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sentry_dio/sentry_dio.dart';
/// Регистрация внешних зависимостей в системе внедрения зависимостей
class ExternalRegistrations {
@@ -28,7 +29,8 @@ class ExternalRegistrations {
receiveTimeout: AppConstants.pendingDelay,
sendTimeout: AppConstants.pendingDelay,
),
)..interceptors.addAll([TokenInterceptor(), PhoneVerifyErrorInterceptor()]),
)..interceptors.addAll([TokenInterceptor(), PhoneVerifyErrorInterceptor()])
..addSentry(),
);
}

View File

@@ -12,6 +12,7 @@ import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/token_storage.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/services.dart' show MethodChannel, PlatformException;
import 'package:sentry_flutter/sentry_flutter.dart';
class FirebaseApi {
final _firebaseMessaging = FirebaseMessaging.instance;
@@ -61,6 +62,7 @@ class FirebaseApi {
);
} catch (e, st) {
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
// Не пробрасываем ошибку дальше, так как это не критичная операция
}
}
@@ -85,6 +87,7 @@ class FirebaseApi {
);
} catch (e, st) {
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
// Не пробрасываем ошибку дальше, так как это не критичная операция
}
}
@@ -110,10 +113,12 @@ class FirebaseApi {
} on PlatformException catch (e, st) {
showErrorToast('$e $st');
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
return null;
} catch (e, st) {
showErrorToast('$e $st');
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
return null;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/core/views/service/views_service.dart';
import 'package:eatvio_app/features/feed/models/view_model.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class ViewsRepository {
final ViewsService viewsService;
@@ -9,7 +10,8 @@ class ViewsRepository {
Future<void> viewContent({required ViewModel viewModel}) async {
try {
await viewsService.viewContent(viewModel: viewModel);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -9,6 +9,7 @@ import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/websockets/ws_service.dart';
import 'package:eatvio_app/core/token_storage.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:eatvio_app/features/chat/presentation/bloc/chats_cubit/chats_cubit.dart';
class WsManager {
@@ -111,6 +112,7 @@ class WsManager {
});
_subscribe();
} catch (e, st) {
await Sentry.captureException(e, stackTrace: st);
log(e.toString(), stackTrace: st);
}
}

View File

@@ -7,6 +7,7 @@ import 'package:eatvio_app/features/auth/models/oauth_verification_confirm_respo
import 'package:eatvio_app/features/auth/models/oauth_verification_request_response.dart';
import 'package:eatvio_app/features/auth/models/token_model.dart';
import 'package:eatvio_app/features/auth/services/auth_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class AuthRepository {
final AuthService authService;
@@ -18,7 +19,8 @@ class AuthRepository {
return await authService.getTokenByCredentials(
credentials: CredentialsModel(email: email, password: password),
);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -33,7 +35,8 @@ class AuthRepository {
return await authService.signInViaSocialMedia(
body: OAuthLoginRequest(provider: provider, accessToken: accessToken, refreshToken: refreshToken, clientId: clientId),
);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -72,7 +75,8 @@ class AuthRepository {
),
))['token']!
as String;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -89,7 +93,8 @@ class AuthRepository {
return await authService.requestOAuthVerification(body: body);
}
return null;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -134,8 +139,9 @@ class AuthRepository {
'AuthRepository: Sending OAuth verification confirm request: provider=$provider, verificationType=$verificationType, code=$code, email=$email, phone=$phone',
);
return await authService.confirmOAuthVerification(body: request);
} catch (e) {
} catch (e, s) {
log('AuthRepository: Error in confirmOAuthVerification: $e');
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,4 +1,5 @@
import 'package:eatvio_app/features/auth/services/reset_password_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class ResetPasswordRepository {
final ResetPasswordService resetPasswordService;
@@ -20,7 +21,8 @@ class ResetPasswordRepository {
} else {
return false;
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -46,7 +48,8 @@ class ResetPasswordRepository {
} else {
return false;
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -11,6 +11,7 @@ import 'package:eatvio_app/core/env_config.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart' as http;
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:vk_id/vk_id.dart';
import 'package:webview_flutter/webview_flutter.dart';
@@ -41,7 +42,8 @@ class SocialAuthFacade {
return null;
}
return await _parseVKAuthResult(redirectParams: redirectParams, controller: controller, codeVerifier: codeVerifier, clientId: clientIdStr);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return null;
}
}
@@ -157,8 +159,9 @@ class SocialAuthFacade {
birthDate: yandexProfileData.birthday,
clientId: clientId,
);
} catch (e) {
} catch (e, s) {
log(e.toString());
await Sentry.captureException(e, stackTrace: s);
}
return null;
}
@@ -205,7 +208,8 @@ class SocialAuthFacade {
if (code == null || deviceId == null) return null;
return await _parseVKAuthResult(redirectParams: redirectParams, controller: controller, codeVerifier: codeVerifier, clientId: clientIdStr);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return null;
}
}

View File

@@ -1,6 +1,7 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/barcode/models/barcode_product_model.dart';
import 'package:eatvio_app/features/barcode/services/barcode_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class BarcodeRepository {
final BarcodeService barcodeService;
@@ -28,14 +29,16 @@ class BarcodeRepository {
}
throw Exception('Unexpected status code: ${response.statusCode}');
} on DioException catch (e) {
} on DioException catch (e, s) {
if (e.response?.statusCode == 202) {
// Если получен статус 202, значит запущена задача обработки
final taskStatus = BarcodeTaskStatusModel.fromJson(e.response!.data as Map<String, dynamic>);
return BarcodeResult.processing(taskStatus.taskId ?? '');
}
await Sentry.captureException(e, stackTrace: s);
rethrow;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -52,7 +55,8 @@ class BarcodeRepository {
} else {
return BarcodeTaskStatus.processing();
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -8,6 +8,7 @@ import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
import 'package:eatvio_app/features/blog_post_create/services/blog_post_service.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class BlogPostRepository {
final BlogPostService blogPostService;
@@ -29,9 +30,14 @@ class BlogPostRepository {
if (image != null) 'image': await MultipartFile.fromFile((await ImageCompressUtility.compressFile(File(image.path))).path, filename: image.name),
});
return await blogPostService.createBlogPost(
formData: formData,
);
try {
return await blogPostService.createBlogPost(
formData: formData,
);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<XFile?> downloadImage(String imageUrl) async {
@@ -54,8 +60,9 @@ class BlogPostRepository {
log('Ошибка загрузки изображения: ${response.statusCode}');
return null;
}
} catch (e) {
} catch (e, s) {
log('Произошла ошибка: $e');
await Sentry.captureException(e, stackTrace: s);
return null;
}
}
@@ -79,11 +86,23 @@ class BlogPostRepository {
: null,
});
return await blogPostService.updateBlogPost(
id: id,
formData: formData,
);
try {
return await blogPostService.updateBlogPost(
id: id,
formData: formData,
);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> deleteBlogPost(int id) async => await blogPostService.deleteBlogPost(id: id);
Future<void> deleteBlogPost(int id) async {
try {
await blogPostService.deleteBlogPost(id: id);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
import 'package:eatvio_app/features/calendar/services/calendar_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class CalendarRepository {
final CalendarService calendarService;
@@ -9,7 +10,8 @@ class CalendarRepository {
Future<List<CalendarModel>> getCalendar() async {
try {
return await calendarService.getCalendar();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/cancel_plan_bottom_sheet/models/cancelation_model.dart';
import 'package:eatvio_app/features/cancel_plan_bottom_sheet/service/cancel_plan_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class CancelPlanRepository {
final CancelPlanService cancelService;
@@ -10,7 +11,8 @@ class CancelPlanRepository {
}) async {
try {
await cancelService.cancelChosenPlan(id: id, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -12,6 +12,7 @@ import 'package:eatvio_app/features/chat/models/plan_complain_model.dart';
import 'package:eatvio_app/features/chat/services/chat_service.dart';
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
import 'package:http_parser/http_parser.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class ChatRepository {
final ChatService chatService;
@@ -60,6 +61,7 @@ class ChatRepository {
);
} catch (e, st) {
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
rethrow;
}
}
@@ -69,6 +71,7 @@ class ChatRepository {
return (await chatService.getChatRoom(uuid: uuid));
} catch (e, st) {
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
rethrow;
}
}
@@ -76,7 +79,8 @@ class ChatRepository {
Future<ChatRoomPaginationModel> getChatRooms({String? query, int page = 1}) async {
try {
return (await chatService.getChatRooms(query: query, page: page));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -84,7 +88,8 @@ class ChatRepository {
Future<ChatMessagesModel> getChatMessages(String id, int page) async {
try {
return (await chatService.getChatMessages(id: id, page: page));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -92,7 +97,8 @@ class ChatRepository {
Future<ChatRoomModel> getChatRoomIdByUserSlug({required String slug}) async {
try {
return (await chatService.getChatRoomIdByUserSlug(user: slug));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -100,7 +106,8 @@ class ChatRepository {
Future<void> markMessagesAsRead(String id, List<int> messageIds) async {
try {
await chatService.markMessagesAsRead(id: id, body: {'messages_ids': messageIds});
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -110,7 +117,8 @@ class ChatRepository {
}) async {
try {
await chatService.cancelChosenPlan(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -118,7 +126,8 @@ class ChatRepository {
Future<void> choseStartPlanDate({required int id, required Map<String, String> date}) async {
try {
await chatService.choseStartPlanDate(id: id, date: date);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -128,7 +137,8 @@ class ChatRepository {
}) async {
try {
return await chatService.getPaymentLink(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -138,7 +148,8 @@ class ChatRepository {
}) async {
try {
return await chatService.getChosenPlan(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -148,7 +159,8 @@ class ChatRepository {
}) async {
try {
await chatService.finishChosenPlan(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -159,7 +171,8 @@ class ChatRepository {
}) async {
try {
await chatService.complainAboutConsultation(id: id, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -172,7 +185,8 @@ class ChatRepository {
} else {
return response.data['id'];
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return 'error';
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/complaining/models/complain_model.dart';
import 'package:eatvio_app/features/complaining/services/complaining_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class ComplainingRepository {
final ComplainingService service;
@@ -12,7 +13,8 @@ class ComplainingRepository {
}) async {
try {
await service.sendPlanComplain(slug: slug, category: category, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -24,7 +26,8 @@ class ComplainingRepository {
}) async {
try {
await service.sendRecipeComplain(slug: slug, category: category, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -36,7 +39,8 @@ class ComplainingRepository {
}) async {
try {
await service.sendBlogPostsComplain(id: id, category: category, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -48,7 +52,8 @@ class ComplainingRepository {
}) async {
try {
await service.sendProfileComplain(slug: slug, category: category, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -60,7 +65,8 @@ class ComplainingRepository {
}) async {
try {
await service.sendDietComplain(id: id, category: category, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -72,7 +78,8 @@ class ComplainingRepository {
}) async {
try {
await service.sendCommentComplain(id: id, category: category, body: body);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -5,6 +5,7 @@ import 'package:eatvio_app/features/consultant/become_consultant/models/consulta
import 'package:eatvio_app/features/consultant/become_consultant/models/consultation_request_model.dart';
import 'package:eatvio_app/features/consultant/become_consultant/services/consultant_service.dart';
import 'package:http_parser/http_parser.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class ConsultantRepository {
final ConsultantService consultantService;
@@ -18,7 +19,8 @@ class ConsultantRepository {
} else {
return await consultantService.consultantRegistration(consultantModel: consultant);
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -26,7 +28,8 @@ class ConsultantRepository {
Future<ConsultationRequestModel> getConsultantRequestStatus(String slug) async {
try {
return await consultantService.getConsultantRequestStatus(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -34,7 +37,8 @@ class ConsultantRepository {
Future<ConsultationRequestModel> getMyRequestStatus(String slug) async {
try {
return await consultantService.getMyRequestStatus(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -42,7 +46,8 @@ class ConsultantRepository {
Future<List<ConsultantCertPhotoModel>> getConsultantCertPhotos() async {
try {
return await consultantService.getConsultantCertPhotos();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -62,7 +67,8 @@ class ConsultantRepository {
}
return await consultantService.storeConsultantCertPhotos(photos: multipartFiles);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -70,7 +76,8 @@ class ConsultantRepository {
Future<void> hideConsultantCertPhoto(int id) async {
try {
await consultantService.hideConsultantCertPhoto(payload: {'cert_photo_id': id});
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -78,7 +85,8 @@ class ConsultantRepository {
Future<void> unHideConsultantCertPhoto(int id) async {
try {
await consultantService.unHideConsultantCertPhoto(payload: {'cert_photo_id': id});
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,6 +1,7 @@
import 'package:eatvio_app/features/consultant_rating/models/rating_model.dart';
import 'package:eatvio_app/features/consultant_rating/models/statistics_model.dart';
import 'package:eatvio_app/features/consultant_rating/services/consultant_rating_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class ConsultantRatingRepository {
final ConsultantRatingService service;
@@ -10,7 +11,8 @@ class ConsultantRatingRepository {
Future<StatisticsModel> getConsultantStatistics({String? date}) async {
try {
return await service.getConsultantStatistics(date: date);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -19,7 +21,8 @@ class ConsultantRatingRepository {
try {
final data = (await service.getScoreLogs(date: date)).data;
return data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,6 +1,7 @@
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:eatvio_app/features/finances_and_consultations_archive/models/consultant_finance_model.dart';
import 'package:eatvio_app/features/finances_and_consultations_archive/models/statistic_model.dart';
import 'package:eatvio_app/features/finances_and_consultations_archive/models/user_purchases_model.dart';
@@ -13,7 +14,8 @@ class ConsultationsRepository {
try {
final consultations = await consultationService.getConsultations();
return consultations.data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -32,7 +34,8 @@ class ConsultationsRepository {
dateComparison: dateComparison,
);
return model.data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -40,7 +43,8 @@ class ConsultationsRepository {
Future<StatisticModel> getStatistic() async {
try {
return await consultationService.getStatistics();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -48,7 +52,8 @@ class ConsultationsRepository {
Future<List<ConsultantFinanceModel>> getConsultantFinances(String? date, FiltersComparisonEnum? dateComparison) async {
try {
return await consultationService.getConsultantFinances(date, dateComparison);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -56,7 +61,8 @@ class ConsultationsRepository {
Future<List<UserPurchasesModel>> getUserPurchases(String? date, FiltersComparisonEnum? dateComparison) async {
try {
return await consultationService.getUserPurchases(date, dateComparison);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,7 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'dart:developer';
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/app_initializer.dart';
import 'package:eatvio_app/core/const.dart';
@@ -16,6 +15,7 @@ import 'package:eatvio_app/features/profile/repositories/profile_repository.dart
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:http/http.dart' as http;
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:path_provider/path_provider.dart';
class CreateDietCubit extends Cubit<CreateDietState> {
@@ -332,10 +332,11 @@ class CreateDietCubit extends Cubit<CreateDietState> {
emit(state.copyWith(published: dietState != DietState.draft, drafted: dietState == DietState.draft));
return null;
} on DioException catch (e, stackTrace) {
log(e.toString(), stackTrace: stackTrace);
} catch (e, st) {
await Sentry.captureException(e, stackTrace: st);
log(e.toString(), stackTrace: st);
emit(state.copyWith(isDietPublishing: false));
}
emit(state.copyWith(isDietPublishing: false));
return 'error';
}
@@ -361,6 +362,7 @@ class CreateDietCubit extends Cubit<CreateDietState> {
);
return null;
} catch (e, st) {
await Sentry.captureException(e, stackTrace: st);
log(e.toString(), stackTrace: st);
return 'error';
}

View File

@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/create_diet/services/create_diet_service.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class CreateDietRepository {
final CreateDietService createDietService;
@@ -18,7 +19,7 @@ class CreateDietRepository {
required String details,
required File image,
required List<List<List<DailySchedule>>> dailySchedule,
}) {
}) async {
final dietMap = <String, dynamic>{};
for (final (dayIndex, day) in dailySchedule.indexed) {
for (final (mealIndex, meal) in day.indexed) {
@@ -49,13 +50,18 @@ class CreateDietRepository {
});
final formData = FormData.fromMap(dietMap);
switch (state) {
case DietState.active:
return createDietService.createPublishedDiet(formData: formData);
case DietState.draft:
return createDietService.createDraftedDiet(formData: formData);
case DietState.personal:
return createDietService.createPersonalDiet(formData: formData);
try {
switch (state) {
case DietState.active:
return await createDietService.createPublishedDiet(formData: formData);
case DietState.draft:
return await createDietService.createDraftedDiet(formData: formData);
case DietState.personal:
return await createDietService.createPersonalDiet(formData: formData);
}
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -77,7 +83,8 @@ class CreateDietRepository {
);
});
return dailySchedule;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -94,7 +101,7 @@ class CreateDietRepository {
String? details,
File? image,
List<List<List<DailySchedule>>>? dailySchedule,
}) {
}) async {
final dietMap = <String, dynamic>{};
if (dailySchedule != null) {
for (final (dayIndex, day) in dailySchedule.indexed) {
@@ -142,13 +149,18 @@ class CreateDietRepository {
}
final formData = FormData.fromMap(dietMap);
switch (state) {
case DietState.active:
return createDietService.updatePublished(diet: dietId, formData: formData);
case DietState.draft:
return createDietService.updateDrafted(diet: dietId, formData: formData);
case DietState.personal:
return createDietService.updatePersonal(diet: dietId, formData: formData);
try {
switch (state) {
case DietState.active:
return await createDietService.updatePublished(diet: dietId, formData: formData);
case DietState.draft:
return await createDietService.updateDrafted(diet: dietId, formData: formData);
case DietState.personal:
return await createDietService.updatePersonal(diet: dietId, formData: formData);
}
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
}

View File

@@ -1,5 +1,6 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/create_plan/services/create_plan_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class CreatePlanRepository {
final CreatePlanService createPlanService;
@@ -9,7 +10,13 @@ class CreatePlanRepository {
Future<void> createPlan({
required Map<String, dynamic> model,
}) async {
final formData = FormData.fromMap(model);
return await createPlanService.createPlan(formData: formData);
}
try {
final formData = FormData.fromMap(model);
return await createPlanService.createPlan(formData: formData);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
}

View File

@@ -11,6 +11,7 @@ import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart';
@@ -165,6 +166,7 @@ class CreateRecipeCubit extends Cubit<CreateRecipeState> {
await recipeRepository.publishRecipe(model, update, slug);
return true;
} catch (e, st) {
await Sentry.captureException(e, stackTrace: st);
log(e.toString(), stackTrace: st);
return false;
}
@@ -329,7 +331,8 @@ class CreateRecipeCubit extends Cubit<CreateRecipeState> {
try {
await recipeRepository.deleteRecipe(slug);
return true;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return false;
}
}

View File

@@ -6,6 +6,7 @@ import 'package:eatvio_app/features/create_recipe/models/recipe_model.dart';
import 'package:eatvio_app/features/create_recipe/models/recipe_tag_model.dart';
import 'package:eatvio_app/features/create_recipe/models/step.dart';
import 'package:eatvio_app/features/create_recipe/services/recipe_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:eatvio_app/features/create_recipe/models/product.dart';
class RecipeRepository {
@@ -16,7 +17,8 @@ class RecipeRepository {
Future<Map<String, List<Product>>> inputProduct(String name) async {
try {
return await recipeService.getInputProduct(name);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -75,7 +77,8 @@ class RecipeRepository {
} else {
await recipeService.publishRecipe(formData: formData);
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -83,7 +86,8 @@ class RecipeRepository {
Future<RecipeModel> getRecipe(String recipeID) async {
try {
return await recipeService.getRecipe(recipeID);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -91,7 +95,8 @@ class RecipeRepository {
Future<List<RecipeTag>> getRecipesTags() async {
try {
return (await recipeService.getTags()).data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -99,7 +104,8 @@ class RecipeRepository {
Future<void> deleteRecipe(String slug) async {
try {
return await recipeService.deleteRecipe(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -9,6 +9,7 @@ import 'package:eatvio_app/features/diary/models/nutrition_model.dart';
import 'package:eatvio_app/features/diary/models/product_moderation_model.dart';
import 'package:eatvio_app/features/diary/services/diary_service.dart';
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class DiaryRepository {
final DiaryService diaryService;
@@ -69,67 +70,83 @@ class DiaryRepository {
return updatedDiaryDay;
}
return diaryDay;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<List<DiaryDayModel>> getDiaryIndexByDate(String date) async {
return (await diaryService.getDiaryIndexByDate(date: date));
try {
return (await diaryService.getDiaryIndexByDate(date: date));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<DiaryDayModel> getDiaryDay(int diaryId) async {
// Align with getDiaryByDate: enrich portions with glossary nutritional info
final diaryWrapper = await diaryService.getDiaryDay(diary: diaryId);
final DiaryDayModel diaryDay = diaryWrapper.diary;
Set<int> ids = {};
for (var meal in diaryDay.meals) {
for (var portion in meal.portions) {
if (portion.productNutritionalValueId != null) {
ids.add(portion.productNutritionalValueId!);
try {
// Align with getDiaryByDate: enrich portions with glossary nutritional info
final diaryWrapper = await diaryService.getDiaryDay(diary: diaryId);
final DiaryDayModel diaryDay = diaryWrapper.diary;
Set<int> ids = {};
for (var meal in diaryDay.meals) {
for (var portion in meal.portions) {
if (portion.productNutritionalValueId != null) {
ids.add(portion.productNutritionalValueId!);
}
}
}
}
if (ids.isNotEmpty) {
final glossary = await getGlossariesIndex(ids: ids.toList());
final List<MealModel> updatedMeals = List.from(diaryDay.meals);
for (var mealIndex = 0; mealIndex < updatedMeals.length; mealIndex++) {
final meal = updatedMeals[mealIndex];
final updatedPortions = meal.portions.map((portion) {
if (portion.productNutritionalValueId != null) {
try {
final glossaryItem = glossary.glossariesList.firstWhere((g) => g.id == portion.productNutritionalValueId);
return portion.copyWith(
productCaloriesInfo: ProductCaloriesInfoModel(
id: glossaryItem.id,
productName: glossaryItem.name,
calories: glossaryItem.energyOn100Gr,
proteins: glossaryItem.proteinsOn100Gr,
fats: glossaryItem.fatsOn100Gr,
carbohydrates: glossaryItem.carbohydratesOn100Gr,
energyOnPortion: glossaryItem.energyOnPortion,
proteinsOnPortion: glossaryItem.proteinsOnPortion,
fatsOnPortion: glossaryItem.fatsOnPortion,
carbohydratesOnPortion: glossaryItem.carbohydratesOnPortion,
),
);
} catch (e) {
return portion;
if (ids.isNotEmpty) {
final glossary = await getGlossariesIndex(ids: ids.toList());
final List<MealModel> updatedMeals = List.from(diaryDay.meals);
for (var mealIndex = 0; mealIndex < updatedMeals.length; mealIndex++) {
final meal = updatedMeals[mealIndex];
final updatedPortions = meal.portions.map((portion) {
if (portion.productNutritionalValueId != null) {
try {
final glossaryItem = glossary.glossariesList.firstWhere((g) => g.id == portion.productNutritionalValueId);
return portion.copyWith(
productCaloriesInfo: ProductCaloriesInfoModel(
id: glossaryItem.id,
productName: glossaryItem.name,
calories: glossaryItem.energyOn100Gr,
proteins: glossaryItem.proteinsOn100Gr,
fats: glossaryItem.fatsOn100Gr,
carbohydrates: glossaryItem.carbohydratesOn100Gr,
energyOnPortion: glossaryItem.energyOnPortion,
proteinsOnPortion: glossaryItem.proteinsOnPortion,
fatsOnPortion: glossaryItem.fatsOnPortion,
carbohydratesOnPortion: glossaryItem.carbohydratesOnPortion,
),
);
} catch (e) {
return portion;
}
}
}
return portion;
}).toList();
return portion;
}).toList();
updatedMeals[mealIndex] = meal.copyWith(portions: updatedPortions);
updatedMeals[mealIndex] = meal.copyWith(portions: updatedPortions);
}
final updatedDiaryDay = diaryDay.copyWith(meals: updatedMeals);
return updatedDiaryDay;
}
final updatedDiaryDay = diaryDay.copyWith(meals: updatedMeals);
return updatedDiaryDay;
return diaryDay;
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
return diaryDay;
}
Future<NutritionDataModel> getNutritionData(int index) async {
return await diaryService.getNutrition(diary: index);
try {
return await diaryService.getNutrition(diary: index);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> addPortionToMeal({
@@ -140,14 +157,19 @@ class DiaryRepository {
required int quantity,
int? productNutritionalValueId,
}) async {
return await diaryService.addProductToMeal(
diary: diaryId,
typeNo: mealId,
productName: productName,
portion: portion,
quantity: quantity,
productNutritionalValueId: productNutritionalValueId,
);
try {
return await diaryService.addProductToMeal(
diary: diaryId,
typeNo: mealId,
productName: productName,
portion: portion,
quantity: quantity,
productNutritionalValueId: productNutritionalValueId,
);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> updateProductInMeal({
@@ -160,26 +182,51 @@ class DiaryRepository {
int? productNutritionalValueId,
required PortionState portionState,
}) async {
Map<String, Object?> data = ProductInMeal(productName: productName, portion: portion, quantity: quantity).toJson();
if (productNutritionalValueId != null) data['product_nutritional_value_id'] = productNutritionalValueId;
data['state'] = portionState.name;
return await diaryService.updateProductInMeal(diary: diaryId, typeNo: mealId, portionModel: portionId, productInMeal: data);
try {
Map<String, Object?> data = ProductInMeal(productName: productName, portion: portion, quantity: quantity).toJson();
if (productNutritionalValueId != null) data['product_nutritional_value_id'] = productNutritionalValueId;
data['state'] = portionState.name;
return await diaryService.updateProductInMeal(diary: diaryId, typeNo: mealId, portionModel: portionId, productInMeal: data);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> markEaten({required int diaryId, required int mealId, required int portionId}) async {
return await diaryService.markEaten(diary: diaryId, typeNo: mealId, portionModel: portionId);
try {
return await diaryService.markEaten(diary: diaryId, typeNo: mealId, portionModel: portionId);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> unmarkEaten({required int diaryId, required int mealId, required int portionId}) async {
return await diaryService.unmarkEaten(diary: diaryId, typeNo: mealId, portionModel: portionId);
try {
return await diaryService.unmarkEaten(diary: diaryId, typeNo: mealId, portionModel: portionId);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> restore({required int diaryId, required int mealId, required int portionId}) async {
return await diaryService.restore(diary: diaryId, typeNo: mealId, portionModel: portionId);
try {
return await diaryService.restore(diary: diaryId, typeNo: mealId, portionModel: portionId);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> deleteProductFromMeal({required int diaryId, required int mealId, required int portionId}) async {
return await diaryService.deleteProductFromMeal(diary: diaryId, typeNo: mealId, portionModel: portionId);
try {
return await diaryService.deleteProductFromMeal(diary: diaryId, typeNo: mealId, portionModel: portionId);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> uploadPhotos({required int diaryId, required int mealId, required List<File> files}) async {
@@ -187,7 +234,8 @@ class DiaryRepository {
for (int i = 0; i < files.length; i++) {
await diaryService.uploadPhotoOfMeal(diary: diaryId, typeNo: mealId, photo: files[i]);
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -195,16 +243,22 @@ class DiaryRepository {
Future<void> deletePhoto({required int diaryId, required int mealId, required DiaryPhotoModel photo}) async {
try {
await diaryService.deletePhotoOfMeal(diaryId: diaryId, typeNo: mealId, userAttachment: photo.id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> finishDiaryDay({required int diaryId, required String wakeUp, required String retire, String? comment}) async {
return await diaryService.finishDiaryDay(
diary: diaryId,
finishDiaryDayModel: FinishDiaryDayModel(wakeUp: wakeUp, retire: retire, comment: comment),
);
try {
return await diaryService.finishDiaryDay(
diary: diaryId,
finishDiaryDayModel: FinishDiaryDayModel(wakeUp: wakeUp, retire: retire, comment: comment),
);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<GlossaryModerationModel> sendProductToModeration({
@@ -214,15 +268,21 @@ class DiaryRepository {
required double fats,
required double carbohydrates,
}) async {
return await diaryService.sendProductToModeration(
data: ProductModerationModel(name: name, energy: energy, proteins: proteins, fats: fats, carbohydrates: carbohydrates).toJson(),
);
try {
return await diaryService.sendProductToModeration(
data: ProductModerationModel(name: name, energy: energy, proteins: proteins, fats: fats, carbohydrates: carbohydrates).toJson(),
);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> fillSatiety({required int diaryId, required int mealId, required int satiety}) async {
try {
return await diaryService.fillSatiety(diary: diaryId, typeNo: mealId, satiety: satiety);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -230,7 +290,8 @@ class DiaryRepository {
Future<void> fillMood({required int diaryId, required int mealId, required int mood}) async {
try {
return await diaryService.fillMood(diary: diaryId, typeNo: mealId, mood: mood);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -238,7 +299,8 @@ class DiaryRepository {
Future<void> fillTime({required int diaryId, required int mealId, required String time}) async {
try {
return await diaryService.fillTime(diary: diaryId, typeNo: mealId, time: time);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -246,7 +308,8 @@ class DiaryRepository {
Future<void> fillWakeup({required int diaryId, required String time}) async {
try {
return await diaryService.fillWakeup(diary: diaryId, wakeUp: time);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -254,7 +317,8 @@ class DiaryRepository {
Future<void> fillRetire({required int diaryId, required String time}) async {
try {
return await diaryService.fillRetire(diary: diaryId, retire: time);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -263,7 +327,8 @@ class DiaryRepository {
try {
await diaryService.commentUserDay(id: diaryId, body: commentModel);
_diaryForceFetchController.add('force');
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -271,7 +336,8 @@ class DiaryRepository {
Future<ConsultantReviewModel> getDiaryComments({required int planId, required int diaryId}) async {
try {
return await diaryService.getDiaryComments(planId: planId, diaryId: diaryId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -279,7 +345,8 @@ class DiaryRepository {
Future<void> viewCommentOfDiaryDayByConsultant({required int diaryId}) async {
try {
await diaryService.viewCommentOfDiaryDayByConsultant(diaryId: diaryId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -293,7 +360,8 @@ class DiaryRepository {
}
try {
return await diaryService.getGlossariesIndex(filters: filters);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -302,7 +370,8 @@ class DiaryRepository {
try {
final diaryDay = await diaryService.getDiaryDayV2(day: day);
return setCPFCToDiary(diaryDay);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -311,7 +380,8 @@ class DiaryRepository {
try {
await diaryService.createDay(body: CreateDayModel(day: day));
await getDiaryByDate(day);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -4,6 +4,7 @@ import 'package:eatvio_app/features/diets/models/diet_likes_model.dart';
import 'package:eatvio_app/features/diets/services/diet_service.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:equatable/equatable.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class DietRepository {
DietRepository({required this.dietsService});
@@ -19,7 +20,8 @@ class DietRepository {
Future<DietLikesModel> likeDiet(int id) async {
try {
return await dietsService.likeDiet(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -28,7 +30,8 @@ class DietRepository {
try {
final diet = await dietsService.getDiet(id: id);
return diet;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -37,7 +40,8 @@ class DietRepository {
try {
final diet = await dietsService.getDietBySlug(slug: slug);
return diet;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -45,7 +49,8 @@ class DietRepository {
Future<Diet> addToFavorite(int id) async {
try {
return await dietsService.addToFavorite(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -53,7 +58,8 @@ class DietRepository {
Future<Diet> removeFromFavorite(int id) async {
try {
return await dietsService.removeFromFavorite(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -61,7 +67,8 @@ class DietRepository {
Future<void> startDiet(int id, String date) async {
try {
return await dietsService.startDiet(id: id, body: {'date': date});
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -69,7 +76,8 @@ class DietRepository {
Future<void> cancelDiet(int id) async{
try {
return await dietsService.cancelDiet(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -7,6 +7,7 @@ import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/features/feed/models/view_model.dart';
import 'package:eatvio_app/features/feed/services/feed_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class FeedRepository {
final FeedService feedService;
@@ -16,7 +17,8 @@ class FeedRepository {
Future<FeedBlogPostSettingsModel> getFeedBlogPosts({String? query, int page = 1}) async {
try {
return (await feedService.getBlogPostList(page: page, query: query));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -24,7 +26,8 @@ class FeedRepository {
Future<FeedBlogPostModel> getBlogPost({required int id}) async {
try {
return await feedService.getBlogPost(postId: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -32,7 +35,8 @@ class FeedRepository {
Future<List<Recipe>> getRecipes({String? query, List<int>? tags, int page = 1}) async {
try {
return (await feedService.getRecipes(query: query, tags: tags, page: page)).recipesList;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -40,7 +44,8 @@ class FeedRepository {
Future<DietsPagination> getDiets({int page = 1, String? query, String? types, int? duration, String? sorting}) async {
try {
return (await feedService.getDiets(page: page, query: query, types: types, duration: duration, sorting: sorting));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -48,7 +53,8 @@ class FeedRepository {
Future<PlanPaginationModel> getPlans({int page = 1, String? query, String? types, int? duration, int? minPrice, int? maxPrice}) async {
try {
return (await feedService.getPlans(page: page, query: query, types: types, duration: duration, minPrice: minPrice, maxPrice: maxPrice));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -56,7 +62,8 @@ class FeedRepository {
Future<CommentModel> getBlogPostComments({required String id}) async {
try {
return (await feedService.getBlogPostComments(id: id));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -64,7 +71,8 @@ class FeedRepository {
Future<void> sendBlogPostComment({required String id, required String commentText, int? parentCommentId}) async {
try {
await feedService.sendBlogPostComment(id: id, body: commentText, parentCommentId: parentCommentId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -72,7 +80,8 @@ class FeedRepository {
Future<CommentModel> getDietsComments({required String id}) async {
try {
return (await feedService.getDietsComments(id: id));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -80,7 +89,8 @@ class FeedRepository {
Future<void> sendDietsComment({required String id, required String commentText, int? parentCommentId}) async {
try {
await feedService.sendDietsComment(id: id, body: commentText, parentCommentId: parentCommentId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -88,7 +98,8 @@ class FeedRepository {
Future<CommentModel> getRecipesComments({required String id}) async {
try {
return (await feedService.getRecipesComments(id: id));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -96,7 +107,8 @@ class FeedRepository {
Future<void> sendRecipesComment({required String id, required String commentText, int? parentCommentId}) async {
try {
await feedService.sendRecipesComment(id: id, body: commentText, parentCommentId: parentCommentId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -104,7 +116,8 @@ class FeedRepository {
Future<CommentModel> getPlansComments({required String slug}) async {
try {
return (await feedService.getPlansComments(slug: slug));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -112,7 +125,8 @@ class FeedRepository {
Future<void> sendPlansComment({required String slug, required String commentText, int? parentCommentId}) async {
try {
await feedService.sendPlansComment(slug: slug, body: commentText, parentCommentId: parentCommentId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -120,7 +134,8 @@ class FeedRepository {
Future<void> likeBlogPost({required int id}) async {
try {
await feedService.likeBlogPost(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -128,7 +143,8 @@ class FeedRepository {
Future<void> unlikedBlogPost({required int id}) async {
try {
await feedService.unlikedBlogPost(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -136,7 +152,8 @@ class FeedRepository {
Future<List<FeedConsultantModel>> getConsultants([String? name]) async {
try {
return (await feedService.getConsultants(name: name)).data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -144,7 +161,8 @@ class FeedRepository {
Future<void> viewPost(int id) async {
try {
return (await feedService.viewPost(id: id));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -152,7 +170,8 @@ class FeedRepository {
Future<void> viewRecipe(String slug) async {
try {
return (await feedService.viewRecipe(slug: slug));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -160,7 +179,8 @@ class FeedRepository {
Future<void> viewDiet(int id) async {
try {
return (await feedService.viewDiet(id: id));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -168,7 +188,8 @@ class FeedRepository {
Future<void> viewPlan(String slug) async {
try {
return (await feedService.viewPlan(slug: slug));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -176,7 +197,8 @@ class FeedRepository {
Future<void> viewContent({required ViewModel viewModel}) async {
try {
await feedService.viewContent(viewModel: viewModel);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/services/glossary_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class GlossaryRepository {
final GlossaryService glossaryService;
@@ -11,7 +12,8 @@ class GlossaryRepository {
Future<List<GlossaryModel>> getGlossaryListByQuery(String query) async {
try {
return (await glossaryService.getGlossaryByQuery(query: query)).glossariesList;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/app_config.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/token_storage.dart';
@@ -142,6 +143,8 @@ class MenuScreen extends StatelessWidget {
onPressed: () async {
try {
await sl<Dio>().post('${sl<AppConfig>().baseUrl}/api/profile/logout');
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} finally {
await sl<WsManager>().clear();
await TokenStorage.removeTokenInStorage();

View File

@@ -1,7 +1,7 @@
import 'dart:developer';
import 'package:eatvio_app/features/menu/services/blocked_users_service.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class BlockedUsersRepository {
final BlockedUserService blockedUserService;
@@ -15,6 +15,7 @@ class BlockedUsersRepository {
return (await blockedUserService.getBlockedUsers()).profilesList;
} catch (e, st) {
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
rethrow;
}
}
@@ -28,6 +29,7 @@ class BlockedUsersRepository {
);
} catch (e, st) {
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
rethrow;
}
}
@@ -41,6 +43,7 @@ class BlockedUsersRepository {
);
} catch (e, st) {
log(e.toString(), stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
rethrow;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/menu/models/notification_settings_model.dart';
import 'package:eatvio_app/features/menu/services/notification_settings_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class NotificationSettingsRepository {
final NotificationSettingsService _notificationSettingsService;
@@ -7,10 +8,20 @@ class NotificationSettingsRepository {
NotificationSettingsRepository(this._notificationSettingsService);
Future<NotificationSettingsModel> getNotificationSettings() async {
return await _notificationSettingsService.getNotificationSettings();
try {
return await _notificationSettingsService.getNotificationSettings();
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<NotificationSettingsModel> updateNotificationSettings(Map<String, dynamic> data) async {
return await _notificationSettingsService.updateNotificationSettings(data: data);
try {
return await _notificationSettingsService.updateNotificationSettings(data: data);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/my_diets/services/my_diets_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class MyDietsRepository {
final MyDietsService myDietsService;
@@ -9,7 +10,8 @@ class MyDietsRepository {
Future<void> deleteDiet(int dietId) async {
try {
await myDietsService.deleteDiet(dietId: dietId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -31,7 +33,8 @@ class MyDietsRepository {
sorting: sorting,
state: state,
));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,6 +1,7 @@
import 'package:eatvio_app/features/my_finance/models/card_model.dart';
import 'package:eatvio_app/features/my_finance/models/payment_url_model.dart';
import 'package:eatvio_app/features/my_finance/services/cards_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class CardsRepository {
final CardsService cardsService;
@@ -8,7 +9,8 @@ class CardsRepository {
Future<PaymentUrlModel> addCard() async {
try {
return await cardsService.addCard();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -16,7 +18,8 @@ class CardsRepository {
Future<List<CardModel>> getCards() async {
try {
return await cardsService.getCards();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -24,7 +27,8 @@ class CardsRepository {
Future<void> markAsDefault({required int id}) async {
try {
await cardsService.markAsDefault(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -32,7 +36,8 @@ class CardsRepository {
Future<void> deleteCard({required int id}) async {
try {
await cardsService.deleteCard(id: id);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -40,7 +45,8 @@ class CardsRepository {
Future<void> collectCharge({required int chosenPlaId}) async {
try {
await cardsService.collectCharge(chosenPlanId: chosenPlaId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -2,6 +2,7 @@ import 'dart:developer';
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/features/my_plans/services/my_plans_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class MyPlansRepository {
final MyPlansService myPlansService;
@@ -11,7 +12,8 @@ class MyPlansRepository {
Future<void> deletePlan(String slug) async {
try {
await myPlansService.deletePlan(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -21,11 +23,17 @@ class MyPlansRepository {
return (await myPlansService.getPlans(page: page, query: query, types: types, duration: duration, minPrice: minPrice, maxPrice: maxPrice));
} catch (e, st) {
log(e.toString(), error: e, stackTrace: st);
await Sentry.captureException(e, stackTrace: st);
rethrow;
}
}
Future<void> unpublish(String slug) async {
return await myPlansService.unpublish(slug: slug);
try {
return await myPlansService.unpublish(slug: slug);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
}

View File

@@ -1,15 +1,17 @@
import 'dart:developer';
import 'package:eatvio_app/features/notifications/service/notifications_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class NotificationsRepository {
final NotificationsService notificationsService;
NotificationsRepository({required this.notificationsService});
Future<Map<String, dynamic>?> getNotifications({required int page}) {
Future<Map<String, dynamic>?> getNotifications({required int page}) async {
try {
return notificationsService.getNotifications(page: page);
} catch (e) {
return await notificationsService.getNotifications(page: page);
} catch (e, s) {
log(e.toString());
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -17,7 +19,8 @@ class NotificationsRepository {
Future<void> markNotificationsAsRead() async {
try {
await notificationsService.markNotificationsAsRead();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
import 'package:eatvio_app/features/personal_diet_suggestion/services/personal_diet_suggestion_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class PersonalDietSuggestionRepository {
final PersonalDietSuggestionService personalDietSuggestionService;
@@ -9,23 +10,26 @@ class PersonalDietSuggestionRepository {
Future<List<ConsultationModel>> getConsultationWithPersonalDiets() async{
try {
return (await personalDietSuggestionService.getConsultationWithPersonalDiets()).data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> attachPersonalDiet({required int consultationId, required int dietId}) {
Future<void> attachPersonalDiet({required int consultationId, required int dietId}) async {
try {
return personalDietSuggestionService.attachPersonalDiet(consultationId: consultationId, dietId: dietId);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> reattachPersonalDiet({required int consultationId, required int dietId}) {
Future<void> reattachPersonalDiet({required int consultationId, required int dietId}) async {
try {
return personalDietSuggestionService.reattachPersonalDiet(consultationId: consultationId, dietId: dietId);
} catch (e) {
return await personalDietSuggestionService.reattachPersonalDiet(consultationId: consultationId, dietId: dietId);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -3,6 +3,7 @@ import 'package:eatvio_app/features/diets/repositories/diet_repository.dart';
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
import 'package:eatvio_app/features/plans/services/plan_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class PlanRepository {
final PlanService planService;
@@ -19,7 +20,8 @@ class PlanRepository {
Future<PlanModel> getPlan(String slug) async {
try {
return planService.getPlan(slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -27,7 +29,8 @@ class PlanRepository {
Future<void> likePlan(String slug) async {
try {
await planService.likePlan(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -35,7 +38,8 @@ class PlanRepository {
Future<void> addToFavorite(String slug) async {
try {
await planService.addToFavorite(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -43,7 +47,8 @@ class PlanRepository {
Future<void> removeFromFavorite(String slug) async {
try {
await planService.removeFromFavorite(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -51,7 +56,8 @@ class PlanRepository {
Future<ChosenPlanModel> chosePlan(String slug, Map<String, dynamic> option ) async {
try {
return await planService.chosePlan(slug: slug, option: option);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/features/plans/services/plans_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class PlansRepository {
final PlansService plansService;
@@ -10,7 +11,8 @@ class PlansRepository {
try {
final plans = (await plansService.getPlansBySlug(author: slug)).data;
return plans.where((plan) => plan.state == 'active').toList();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -9,6 +9,7 @@ import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/models/sub_model.dart';
import 'package:eatvio_app/features/profile/models/weight_model.dart';
import 'package:eatvio_app/features/profile/services/profile_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class ProfileRepository {
final ProfileService profileService;
@@ -18,7 +19,8 @@ class ProfileRepository {
Future<ProfileModel> getProfileBySlug(String slug) async {
try {
return await profileService.getProfileBySlug(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -26,7 +28,8 @@ class ProfileRepository {
Future<ProfileDetailsModel> getProfileDetailsBySlug(String slug) async {
try {
return await profileService.getProfileDetailsBySlug(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -34,7 +37,8 @@ class ProfileRepository {
Future<ProfileModel> getMyProfile() async {
try {
return await profileService.getMyProfile();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -42,7 +46,8 @@ class ProfileRepository {
Future<ProfileDetailsModel> getMyProfileDetails() async {
try {
return await profileService.getMyProfileDetails();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -54,7 +59,8 @@ class ProfileRepository {
waistCircumference: waistCircumference,
hipCircumference: hipCircumference,
));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -62,7 +68,8 @@ class ProfileRepository {
Future<void> addWeight({required double weight}) async {
try {
return (await profileService.addWeight(weight: weight));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -70,7 +77,8 @@ class ProfileRepository {
Future<List<FeedBlogPostModel>> getBlogPostsByAuthorSlug({required String slug}) async {
try {
return (await profileService.getBlogPostByAuthorSlug(slug: slug));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -82,7 +90,8 @@ class ProfileRepository {
} else {
return (await profileService.getWeight(period: period));
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -94,7 +103,8 @@ class ProfileRepository {
} else {
return (await profileService.getCircumferences(period: period));
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -102,7 +112,8 @@ class ProfileRepository {
Future<List<SubModel>> getSubscribersBySlug(String slug, [String? query]) async {
try {
return (await profileService.getSubscribers(slug: slug, query: query)).data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -110,7 +121,8 @@ class ProfileRepository {
Future<List<SubModel>> getSubscriptionsBySlug(String slug, [String? query]) async {
try {
return (await profileService.getSubscriptions(slug: slug, query: query)).data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -118,7 +130,8 @@ class ProfileRepository {
Future<void> subscribe(String slug) async {
try {
return await profileService.subscribe(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -126,7 +139,8 @@ class ProfileRepository {
Future<void> unsubscribe(String slug) async {
try {
return await profileService.unsubscribe(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -134,7 +148,8 @@ class ProfileRepository {
Future<void> uploadPhoto(File file) async {
try {
return await profileService.uploadPhoto(photo: file);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -142,7 +157,8 @@ class ProfileRepository {
Future<void> deletePhoto() async {
try {
return await profileService.deletePhoto();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -150,26 +166,42 @@ class ProfileRepository {
Future<List<ChosenDietModel>> getChosenDiets() async {
try {
return (await profileService.getChosenDiets()).diets;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<String> getPassKey({required String routeName, Map<String, dynamic>? routeParams}) async {
return (await profileService.getPassKey(
json: PassKeyParams(routeName: routeName, routeParams: routeParams),
)).data['key_is']!;
try {
return (await profileService.getPassKey(
json: PassKeyParams(routeName: routeName, routeParams: routeParams),
)).data['key_is']!;
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<String> getMyPhone() async {
return (jsonDecode(await profileService.getMyPhone())['phone']);
try {
return (jsonDecode(await profileService.getMyPhone())['phone']);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
Future<void> sendEmailCode({String? newEmail}) async {
if (newEmail != null) {
return await profileService.sendEmailCode(data: {'new_email': newEmail});
} else {
return await profileService.sendEmailCode();
try {
if (newEmail != null) {
return await profileService.sendEmailCode(data: {'new_email': newEmail});
} else {
return await profileService.sendEmailCode();
}
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -177,7 +209,8 @@ class ProfileRepository {
try {
await profileService.tryVerifyEmailByCode(code: "{\"code\": \"$code\"}");
return true;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return false;
}
}
@@ -185,7 +218,8 @@ class ProfileRepository {
Future<void> deleteAccount() async {
try {
await profileService.deleteAccount();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:eatvio_app/features/diets/repositories/diet_repository.dart';
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/features/recipe/services/about_recipe_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class AboutRecipeRepository {
final AboutRecipeService recipeService;
@@ -18,7 +19,8 @@ class AboutRecipeRepository {
Future<Recipe> getRecipe(String recipeID) async {
try {
return await recipeService.getRecipe(recipeID);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -26,7 +28,8 @@ class AboutRecipeRepository {
Future<void> likeRecipe(String slug) async {
try {
await recipeService.likeRecipe(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -34,7 +37,8 @@ class AboutRecipeRepository {
Future<void> addToFavorite(String slug) async {
try {
await recipeService.addToFavorite(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -42,7 +46,8 @@ class AboutRecipeRepository {
Future<void> removeFromFavorite(String slug) async {
try {
await recipeService.removeFromFavorite(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -50,7 +55,8 @@ class AboutRecipeRepository {
Future<void> deleteRecipe(String slug) async {
try {
await recipeService.deleteRecipe(slug: slug);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/recipe/models/my_recipe_model.dart';
import 'package:eatvio_app/features/recipe/services/my_recipes_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class MyRecipesRepository {
final MyRecipesService myRecipesService;
@@ -9,7 +10,8 @@ class MyRecipesRepository {
Future<List<MyRecipeModel>> getMyRecipes() async {
try {
return (await myRecipesService.getMyRecipes()).data;
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -4,6 +4,7 @@ import 'package:eatvio_app/features/registration/models/user_registration_model.
import 'package:eatvio_app/features/registration/models/location_model.dart';
import 'package:eatvio_app/features/registration/services/registration_service.dart';
import 'package:eatvio_app/core/env_config.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class RegistrationRepository {
final RegistrationService registrationService;
@@ -37,7 +38,7 @@ class RegistrationRepository {
throw 'Ошибка регистрации: $response';
}
}
} on DioException catch (e) {
} on DioException catch (e, s) {
if (e.response != null && e.response?.statusCode == 422) {
final data = e.response?.data;
String errorMsg = '';
@@ -62,6 +63,10 @@ class RegistrationRepository {
throw 'Ошибка регистрации: $data';
}
}
await Sentry.captureException(e, stackTrace: s);
rethrow;
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -69,7 +74,8 @@ class RegistrationRepository {
Future<LocationModel> getLocationsListByQuery(String query) async {
try {
return (await registrationService.getLocationsByAddress(query: query));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -77,7 +83,8 @@ class RegistrationRepository {
Future<LocationModel> getLocationsListByCoordinates(String latitude, String longitude) async {
try {
return (await registrationService.getLocationsByCoordinate(latitude: latitude, longitude: longitude));
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -90,7 +97,8 @@ class RegistrationRepository {
} else {
return false;
}
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return false;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/features/registration_v2/models/registration_model.dart';
import 'package:eatvio_app/features/registration_v2/services/registration_service_v2.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class RegistrationRepositoryV2 {
final RegistrationServiceV2 registrationService;
@@ -9,7 +10,8 @@ class RegistrationRepositoryV2 {
try {
final response = await registrationService.register(model: registrationModel.toJson());
return response['token'];
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -3,6 +3,7 @@ import 'package:eatvio_app/features/settings/models/oauth_account_model.dart';
import 'package:eatvio_app/features/settings/models/oauth_attach_request.dart';
import 'package:eatvio_app/features/settings/models/profile_settings_model.dart';
import 'package:eatvio_app/features/settings/services/settings_service.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class SettingsRepository {
final SettingsService settingsService;
@@ -12,7 +13,8 @@ class SettingsRepository {
Future<ProfileSettingsModel> getProfileSettings() async {
try {
return await settingsService.getProfileSettings();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -20,7 +22,8 @@ class SettingsRepository {
Future<ProfileSettingsModel> updateProfileSettings({required ProfileSettingsModel profileSettingsModel}) async {
try {
return await settingsService.updateProfileSettings(data: profileSettingsModel.toJson());
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -28,7 +31,8 @@ class SettingsRepository {
Future<ProfileDetailsModel> updateProfileDetails({required ProfileDetailsModel profileDetailsModel}) async {
try {
return await settingsService.updateProfileDetails(data: profileDetailsModel.toJson());
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -36,7 +40,8 @@ class SettingsRepository {
Future<OAuthAccountsResponseModel> getOAuthAccounts() async {
try {
return await settingsService.getOAuthAccounts();
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -44,7 +49,8 @@ class SettingsRepository {
Future<void> linkOAuthAccount({required OAuthAttachRequest request}) async {
try {
return await settingsService.linkOAuthAccount(request);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}
@@ -52,7 +58,8 @@ class SettingsRepository {
Future<void> unlinkOAuthAccount({required String provider}) async {
try {
return await settingsService.unlinkOAuthAccount(provider);
} catch (e) {
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
}

View File

@@ -84,6 +84,7 @@ dependencies:
gpassword: ^1.0.0
webview_flutter_platform_interface: ^2.14.0
intl_utils: ^2.8.13
sentry_dio: ^9.10.0
dev_dependencies:
build_runner: ^2.10.4

Binary file not shown.

File diff suppressed because one or more lines are too long