add sentry

This commit is contained in:
Phuoc Nguyen
2025-12-11 13:44:26 +07:00
parent f130820131
commit e3632d4445
9 changed files with 445 additions and 126 deletions

View File

@@ -56,21 +56,10 @@ class AuthInterceptor extends Interceptor {
// Get session data from secure storage
final sid = await _secureStorage.read(key: 'frappe_sid');
final csrfToken = await _secureStorage.read(key: 'frappe_csrf_token');
final fullName = await _secureStorage.read(key: 'frappe_full_name');
final userId = await _secureStorage.read(key: 'frappe_user_id');
if (sid != null && csrfToken != null) {
// Build cookie header with all required fields
final cookieHeader = [
'sid=$sid',
'full_name=${fullName ?? "User"}',
'system_user=no',
'user_id=${userId != null ? Uri.encodeComponent(userId) : ApiConstants.frappePublicUserId}',
'user_image=',
].join('; ');
// Add Frappe session headers
options.headers['Cookie'] = cookieHeader;
// Only send sid in Cookie header - other fields are not needed
options.headers['Cookie'] = 'sid=$sid';
options.headers['X-Frappe-CSRF-Token'] = csrfToken;
}

View File

@@ -447,6 +447,7 @@ Future<CacheOptions> cacheOptions(Ref ref) async {
Future<Dio> dio(Ref ref) async {
final dio = Dio();
// Base configuration
dio
..options = BaseOptions(
@@ -466,7 +467,7 @@ Future<Dio> dio(Ref ref) async {
},
)
// Add interceptors in order
// 1. Custom Curl interceptor (first to log cURL commands)
// 1. Custom Curl interceptor (logs cURL commands)
// Uses debugPrint and developer.log for better visibility
..interceptors.add(CustomCurlLoggerInterceptor())
// 2. Logging interceptor