Bind privacy settings and userInfo with the TracksTracker#118
Bind privacy settings and userInfo with the TracksTracker#118AdamGrzybkowski merged 6 commits intotrunkfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR integrates privacy settings and user information with the TracksTracker by implementing a reactive data provider pattern. It introduces a TrackerSetupDataProvider interface in the analytics module that is implemented by AppTrackerSetupDataProvider in the app module to avoid direct dependencies.
- Removes direct userId setting from Tracker abstract class and implements reactive privacy/user state binding
- Creates TrackerSetupDataProvider interface and implementation to provide tracking state and user ID
- Adds comprehensive test coverage for the new data provider functionality
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
analytics/src/main/kotlin/com/gravatar/analytics/TrackerSetupDataProvider.kt |
Defines interface for providing tracker setup data |
analytics/src/main/kotlin/com/gravatar/analytics/TrackerSetupData.kt |
Data models for tracking state and user information |
analytics/src/main/kotlin/com/gravatar/analytics/Tracker.kt |
Removes abstract userId property |
analytics/src/main/kotlin/com/gravatar/analytics/tracks/TracksTracker.kt |
Implements reactive binding to privacy settings and user data |
app/src/main/java/com/gravatar/app/AppTrackerSetupDataProvider.kt |
Concrete implementation combining privacy settings and user repository |
app/src/main/java/com/gravatar/app/di/AppModule.kt |
Dependency injection setup for the data provider |
app/src/test/kotlin/com/gravatar/app/AppTrackerSetupDataProviderTest.kt |
Comprehensive test coverage for the data provider |
app/build.gradle.kts |
Adds test dependencies |
analytics/build.gradle.kts |
Adds coroutines dependency |
app/src/main/java/com/gravatar/app/analytics/AppEvent.kt |
Removes unused event class |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| avatarAltText = "John Doe's Gravatar" | ||
| pronouns = "he/him" | ||
| pronunciation = "John Doe" | ||
| verifiedAccounts = emptyList() |
There was a problem hiding this comment.
The verifiedAccounts property is set twice in this profile builder (lines 139 and 145). Remove the duplicate assignment.
| verifiedAccounts = emptyList() |
| @@ -0,0 +1,11 @@ | |||
| package com.gravatar.analytics | |||
|
|
|||
| data class TrackerSetupData( | |||
There was a problem hiding this comment.
Not sure about the name. Any ideas?
There was a problem hiding this comment.
What about TrackingContext or TrackerConfig?
There was a problem hiding this comment.
hmm not sure - do you have a strong preference for any of those?
There was a problem hiding this comment.
I like TrackingContext, but I don't have a strong opinion. Feel free to keep TrackerSetupData if you want.
| } | ||
|
|
||
| @Test | ||
| fun `emits ENABLED when analytics enabled with non-null user id`() = runTest { |
There was a problem hiding this comment.
⛏️ Nitpicking: I think the test name can lead to some confusion, as it looks like analytics will be only enabled with a non-null user ID when there is no relation between them.
| @@ -0,0 +1,11 @@ | |||
| package com.gravatar.analytics | |||
|
|
|||
| data class TrackerSetupData( | |||
There was a problem hiding this comment.
What about TrackingContext or TrackerConfig?
| private val userRepository: UserRepository, | ||
| ) : TrackerSetupDataProvider { | ||
| override fun getTrackerSetupData(): Flow<TrackerSetupData> { | ||
| val userIdFlow: Flow<String?> = userRepository.getProfile().map { it?.userId?.toString() }.distinctUntilChanged() |
There was a problem hiding this comment.
🛑 We need to use the WPCOM userName for tracks instead of the userId.
| val userIdFlow: Flow<String?> = userRepository.getProfile().map { it?.userId?.toString() }.distinctUntilChanged() | |
| val userIdFlow: Flow<String?> = userRepository.getProfile().map { it?.userLogin }.distinctUntilChanged() |
That suggestion is not enough, as we need to persist it in the DB.
d0e1b14 to
4e4291b
Compare
Description
This PR binds the PrivacySettings and the userId with the
TracksTracker.To not create a dependency on
:userComponentin the:analyticsmodule, the:analyticsmodule exposes a public interfaceTrackerSetupDataProviderthat is implemented and provided in the:appmodule.TracksTrackeruses that provider to reactively update the state.Testing Steps