Skip to content

Conversation

@TheFreal
Copy link
Collaborator

Recording major events to local storage to provide ride statistics at a later point

QA checklist

  • Read state (state & power state)
  • Read primary battery SOC
  • Read primary battery cycles
  • Read secondary battery SOC
  • Read secondary battery cycles
  • Read seat closed
  • Read handlebar
  • Read AUX SOC
  • Read CBB SOC
  • Read CBB charging state
  • Update ping
  • SOCs are cached (after app restart)
  • Commands can be sent (locking & hibernation)

Copilot AI review requested due to automatic review settings December 10, 2025 16:42
Copy link
Contributor

Copilot AI left a 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 StatisticsHelper singleton 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 SavedScooter to 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.

}
}

void clearEventLogs() async {
Copy link

Copilot AI Dec 10, 2025

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 {
Suggested change
void clearEventLogs() async {
Future<void> clearEventLogs() async {

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +71
// logs.removeWhere((log) =>
// log.eventType != EventType.lock &&
// log.eventType != EventType.unlock &&
// log.eventType != EventType.wakeUp &&
// log.eventType != EventType.hibernate);
Copy link

Copilot AI Dec 10, 2025

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.

Suggested change
// logs.removeWhere((log) =>
// log.eventType != EventType.lock &&
// log.eventType != EventType.unlock &&
// log.eventType != EventType.wakeUp &&
// log.eventType != EventType.hibernate);

Copilot uses AI. Check for mistakes.
@TheFreal TheFreal merged commit 14aed9a into main Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants