update perf

This commit is contained in:
Phuoc Nguyen
2025-12-02 17:32:20 +07:00
parent 211ebdf1d8
commit fc9b5e967f
13 changed files with 254 additions and 200 deletions

View File

@@ -10,6 +10,7 @@ library;
import 'dart:developer' as developer;
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -569,10 +570,10 @@ Future<AuthInterceptor> authInterceptor(Ref ref, Dio dio) async {
@riverpod
LoggingInterceptor loggingInterceptor(Ref ref) {
// Only enable logging in debug mode
const bool isDebug = true; // TODO: Replace with kDebugMode from Flutter
const bool isDebug = kDebugMode; // TODO: Replace with kDebugMode from Flutter
return LoggingInterceptor(
enableRequestLogging: false,
enableRequestLogging: true,
enableResponseLogging: isDebug,
enableErrorLogging: isDebug,
);

View File

@@ -189,7 +189,7 @@ final class LoggingInterceptorProvider
}
String _$loggingInterceptorHash() =>
r'6afa480caa6fcd723dab769bb01601b8a37e20fd';
r'79e90e0eb78663d2645d2d7c467e01bc18a30551';
/// Provider for ErrorTransformerInterceptor

View File

@@ -13,6 +13,7 @@ import 'dart:developer' as developer;
import 'package:dio/dio.dart';
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
import 'package:dio_cache_interceptor_hive_store/dio_cache_interceptor_hive_store.dart';
import 'package:flutter/foundation.dart';
import 'package:path_provider/path_provider.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -248,13 +249,13 @@ class CustomCurlLoggerInterceptor extends Interceptor {
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
final curl = _cURLRepresentation(options);
// debugPrint(
// '╔╣ CURL Request ╠══════════════════════════════════════════════════',
// );
// debugPrint(curl);
// debugPrint(
// '╚═════════════════════════════════════════════════════════════════',
// );
debugPrint(
'╔╣ CURL Request ╠══════════════════════════════════════════════════',
);
debugPrint(curl);
debugPrint(
'╚═════════════════════════════════════════════════════════════════',
);
// Also log to dart:developer for better filtering in DevTools
developer.log(curl, name: 'DIO_CURL', time: DateTime.now());
handler.next(options);
@@ -467,7 +468,7 @@ Future<Dio> dio(Ref ref) async {
// Add interceptors in order
// 1. Custom Curl interceptor (first to log cURL commands)
// Uses debugPrint and developer.log for better visibility
..interceptors.add(CustomCurlLoggerInterceptor())
// ..interceptors.add(CustomCurlLoggerInterceptor())
// 2. Logging interceptor
..interceptors.add(ref.watch(loggingInterceptorProvider))
// 3. Auth interceptor (add tokens to requests)

View File

@@ -131,7 +131,7 @@ final class DioProvider
}
}
String _$dioHash() => r'd15bfe824d6501e5cbd56ff152de978030d97be4';
String _$dioHash() => r'f15495e99d11744c245e2be892657748aeeb8ae7';
/// Provider for DioClient