-
Notifications
You must be signed in to change notification settings - Fork 10
Local statistics #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local statistics #125
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a local statistics tracking system that records major scooter events (lock, unlock, open seat, hibernate, wake up) to local storage for future analytics. The implementation adds event logging with location tracking, introduces a debug-only activity log viewer, and improves address caching to reduce redundant API calls.
Key Changes:
- Added
StatisticsHelpersingleton to manage event logging with queued writes to prevent race conditions - Created debug-only activity log screen to view and clear recorded events
- Implemented address caching in
SavedScooterto minimize Nominatim API calls
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/domain/statistics_helper.dart | New file implementing event logging system with queue-based write serialization and location capture |
| lib/stats/log_screen.dart | New debug-only screen for viewing and managing activity logs with translation support |
| lib/scooter_service.dart | Added event logging to lock, unlock, openSeat, wakeUp, and hibernate actions with EventSource tracking |
| lib/domain/saved_scooter.dart | Added lastAddress field for caching geocoded addresses |
| lib/geo_helper.dart | Modified to accept SavedScooter object and implement address caching with User-Agent header |
| lib/stats/scooter_section.dart | Updated getAddress calls to pass SavedScooter object instead of LatLng |
| lib/stats/settings_section.dart | Added navigation to activity log screen (debug mode only) |
| lib/background/bg_service.dart | Updated lock/unlock calls to track EventSource.background |
| lib/home_screen.dart | Added commented debug code for clearing event logs |
| pubspec.yaml | Added seasonal scooter images directory to assets |
| assets/i18n/*.json | Added activity log translations in English, German, and Pirate languages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/domain/statistics_helper.dart
Outdated
| } | ||
| } | ||
|
|
||
| void clearEventLogs() async { |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using void as the return type for an async function is discouraged in Dart. This can lead to unhandled exceptions and makes it impossible for callers to await the operation.
Change the return type to Future<void>:
Future<void> clearEventLogs() async {| void clearEventLogs() async { | |
| Future<void> clearEventLogs() async { |
| // logs.removeWhere((log) => | ||
| // log.eventType != EventType.lock && | ||
| // log.eventType != EventType.unlock && | ||
| // log.eventType != EventType.wakeUp && | ||
| // log.eventType != EventType.hibernate); |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] There's commented-out code for filtering logs by event type. If this code is not needed for the current release, consider removing it entirely rather than leaving it commented out. If it's intended for future use or debugging, add a comment explaining why it's kept.
| // logs.removeWhere((log) => | |
| // log.eventType != EventType.lock && | |
| // log.eventType != EventType.unlock && | |
| // log.eventType != EventType.wakeUp && | |
| // log.eventType != EventType.hibernate); |
Recording major events to local storage to provide ride statistics at a later point
QA checklist