Skip to content

Conversation

JosephSanjaya
Copy link
Collaborator

@JosephSanjaya JosephSanjaya commented Aug 27, 2025

πŸ“± Description

Platform

  • Android
  • iOS
  • Games-Unity
  • DevOps (AWS)
  • Website
  • C/Golang

🎯 Type of Change

  • πŸ› Bug fix
  • ✨ New feature
  • πŸ”§ Refactoring (code change that neither fixes a bug nor adds a feature)
  • πŸ“š Documentation update
  • 🎨 UI/UX improvement
  • ⚑ Performance improvement
  • πŸ§ͺ Test addition or improvement

πŸ“‹ Changes

  • TimeProvider: A utility class for getting the current time, allowing for easier testing.
  • AnalyticsSource: An interface for logging analytics events.
  • FirebaseAnalyticsSource: An implementation of AnalyticsSource that uses Firebase Analytics.
  • SyncAnalyticsRepository: A repository to manage and persist sync-related analytics data, and log events.
    • startSync(): Records the start time of a sync.
    • stopSync(): Records the stop time of a sync and accumulates the duration if the sync is paused/resumed.
    • completeSync(): Persists the total sync duration, end timestamp, and a unique ID. It then logs a "user_did_complete_sync" event with these details and the current block height.
    • getLastSyncMetadata(): Retrieves the metadata of the last completed sync.
  • Unit tests for the new classes.
  • Integration of SyncAnalyticsRepository into SyncManager to call the respective methods at the start, stop, and completion of the sync process.
  • FakeSharedPreferences: A testing utility for mocking SharedPreferences.
  • The getFormatted() method has been removed from SyncAnalyticsRepository.SyncMetadata and its logic is now encapsulated in the SyncMetadata.Formatter.format() method.
  • This change improves the separation of concerns and makes the formatting logic more testable.
  • The HomeSettingDrawerSheet has been updated to use the new Formatter class.
  • Unit tests have been added to SyncAnalyticsRepositoryTest to verify the correctness of the SyncMetadata.Formatter.

πŸ”— Related Issues

πŸ§ͺ Tests Status

  • Tests ran successfully locally?
  • Added more tests? How many?
  • Code coverage percentage of the codebase: __%

πŸ“Έ Screenshots/Videos

Before After

🎯 Reviewers

@kcw-grunt, @josikie

@kcw-grunt
Copy link
Collaborator

πŸ‘€ @JosephSanjaya

Copy link
Collaborator

@josikie josikie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘€πŸ‘€πŸ‘€

Copy link
Collaborator

@kcw-grunt kcw-grunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very close @JosephSanjaya .

We do need to polish the layout so users can understand.

Screenshot 2025-08-28 at 14 58 36

Figma link is here:
https://www.figma.com/design/9IP5iHEq0jxxujWA9sg2n2/brainwallet-app-ui-ux?node-id=4872-2847&t=XZlj6ulgA55S8ckI-1

private const val KEY_LAST_END = "last_sync_end_timestamp"
private const val KEY_DURATION_MILLIS = "duration_millis"
private const val KEY_END_TIMESTAMP = "end_timestamp"
private const val KEY_BLOCK_HEIGHT = "block_height"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is ok note there are core Interfaces that may make it even more succinct
The BRTransaction Class (the core C-class running the low level wallet functions) might be helpful to review.
Here is a link (@JosephSanjaya ): https://github.com/gruntsoftware/core/blob/10ae536cab23f197b60a6feac042a07dc8d61ae0/BRTransaction.h#L86

Did you already review?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, currently im still on going understanding the process, i will update the PR again

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added formatter for the metadata, also change the source for getLastBlockTimestamp and getCurrentBlockHeight from BRPeer

cc @kcw-grunt

…t and in Settings row

This commit introduces analytics tracking for the sync process.

It includes:
- `TimeProvider`: A utility class for getting the current time, allowing for easier testing.
- `AnalyticsSource`: An interface for logging analytics events.
- `FirebaseAnalyticsSource`: An implementation of `AnalyticsSource` that uses Firebase Analytics.
- `SyncAnalyticsRepository`: A repository to manage and persist sync-related analytics data, and log events.
  - `startSync()`: Records the start time of a sync.
  - `stopSync()`: Records the stop time of a sync and accumulates the duration if the sync is paused/resumed.
  - `completeSync()`: Persists the total sync duration, end timestamp, and a unique ID. It then logs a "user_did_complete_sync" event with these details and the current block height.
  - `getLastSyncMetadata()`: Retrieves the metadata of the last completed sync.
- Unit tests for the new classes.
- Integration of `SyncAnalyticsRepository` into `SyncManager` to call the respective methods at the start, stop, and completion of the sync process.
- `FakeSharedPreferences`: A testing utility for mocking SharedPreferences.
@JosephSanjaya JosephSanjaya force-pushed the js/feat/#225-sync-duration-analytics branch from 51821be to 75bf864 Compare August 29, 2025 11:58
@JosephSanjaya JosephSanjaya changed the title Draft: feat(#225): Send sync duration in Firebase Analytics as a custom event and in Settings row feat(#225): Send sync duration in Firebase Analytics as a custom event and in Settings row Aug 29, 2025
This commit introduces a `Formatter` class within `SyncAnalyticsRepository.SyncMetadata` to handle the formatting of sync metadata.

The `getFormatted()` method has been removed from `SyncAnalyticsRepository.SyncMetadata` and its logic is now encapsulated in the `SyncMetadata.Formatter.format()` method.

This change improves the separation of concerns and makes the formatting logic more testable.

The `HomeSettingDrawerSheet` has been updated to use the new `Formatter` class.

Unit tests have been added to `SyncAnalyticsRepositoryTest` to verify the correctness of the `SyncMetadata.Formatter`.
@kcw-grunt kcw-grunt self-requested a review August 30, 2025 07:11
Copy link
Collaborator

@kcw-grunt kcw-grunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kcw-grunt kcw-grunt merged commit c9b1ef0 into develop Aug 30, 2025
2 checks passed
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.

3 participants