refactor: centralize Firebase logging in HTTP interceptor#159
refactor: centralize Firebase logging in HTTP interceptor#159
Conversation
Move Crashlytics breadcrumb logging from PortalService into LogInterceptor so all HTTP calls are automatically logged. FirebaseService becomes a top-level constant, removing the Riverpod provider and simplifying service constructors.
Dokploy Preview Deployment
|
PR Preview BuildsBuild Number: 514 Deploy
Android (Firebase App Distribution)iOS (TestFlight)
|
There was a problem hiding this comment.
Pull request overview
This PR centralizes Firebase Crashlytics breadcrumb logging for network traffic by emitting HTTP request/response logs from the shared Dio LogInterceptor, and removes FirebaseService as an injected dependency from services in favor of a global firebase facade.
Changes:
- Log all HTTP responses to both
dart:developerand Firebase Crashlytics viaLogInterceptor. - Replace the Riverpod
firebaseServiceProviderwith a globalconst firebaseinstance. - Simplify
PortalServiceconstruction and update affected integration tests and router creation accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/services/student_query_service_test.dart | Updates PortalService construction after removing FirebaseService injection. |
| test/services/portal_service_test.dart | Updates PortalService construction after removing FirebaseService injection. |
| test/services/i_school_plus_service_test.dart | Updates PortalService construction after removing FirebaseService injection. |
| test/services/course_service_test.dart | Updates PortalService construction after removing FirebaseService injection. |
| lib/utils/http.dart | Adds Crashlytics breadcrumb logging for HTTP responses via firebase.log(). |
| lib/services/portal_service.dart | Removes FirebaseService dependency and per-method Firebase logging. |
| lib/services/firebase_service.dart | Removes Riverpod provider and introduces global const firebase facade. |
| lib/router/app_router.dart | Updates router factory to use global firebase.analyticsObserver instead of injected FirebaseService. |
| lib/main.dart | Stops reading FirebaseService from Riverpod; uses global firebase and updates router creation call. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR SummaryThis PR refactors the network logging architecture by centralizing Firebase Crashlytics breadcrumbs into a single HTTP interceptor and streamlining the dependency injection graph. Key Changes & Fixes:
Architectural Impact: |
Summary
Instead of sprinkling
_firebase.log()calls in individual services, log all HTTP calls automatically viaLogInterceptor.dart:developerand Crashlytics — every HTTP request/response becomes a breadcrumb automaticallyconstinstead of a Riverpod provider (it's stateless — just a facade over static Firebase singletons)FirebaseServiceas a constructor dependencyswitchexpressions instead of dynamic.lengthdispatch, fixing potentialNoSuchMethodErrorforFormData/StreambodiesTrade-offs
POST https://app.ntut.edu.tw/login.do => 200 text/html 1KBinsteadTest plan
dart analyzepasses