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
Technical Analytics: Milestone 2 - Add Ability To Log Feature Flags #5240
base: develop
Are you sure you want to change the base?
Technical Analytics: Milestone 2 - Add Ability To Log Feature Flags #5240
Conversation
… persistent cache store
Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com>
…o a common constants file
…a/oppia-android into technical-analytics-milestone-1
…implify sync monitoring
…a/oppia-android into technical-analytics-milestone-1
@kkmurerwa, checking if you meant to assign this to @BenHenning. |
This is not done yet. I meant to assign M3 to you and ended up assigning M2 instead. |
Hi @kkmurerwa, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
@BenHenning this PR is now ready for another review. PTAL |
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.
Thanks @kkmurerwa! Just small things left I think--PTAL.
@@ -176,6 +176,7 @@ class ApplicationLifecycleObserver @Inject constructor( | |||
|
|||
private fun logAllFeatureFlags() { | |||
CoroutineScope(backgroundDispatcher).launch { | |||
// TODO(#5240): Replace appSessionId generation to the modified Twitter snowflake algorithm. |
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.
This should point to an issue, not a PR. Should it be pointing to #5341? Though, I think that issue also needs to be updated to explain the additional work of using the modified snowflake algorithm (per the TDD).
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.
I have modified the reference on the code and updated the issue to include the detail about the Twitter snowflake algorithm. Let me know if the issue description is detailed enough.
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.
I see the TODO was removed from code--shouldn't it stay here and point to #5341?
I also think #5341 is a bit confusing since, after this PR is merged, it will seem as if an ID is being provided. The issue should probably instead explain what needs to be changed from the solution introduced in this PR to get analytics to where we want them long-term.
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.
I have updated the issue description and reverted the deletion that removed the TODO from the codebase.
@@ -251,6 +251,44 @@ class LoggingIdentifierControllerTest { | |||
assertThat(sessionIdFlow.value).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") | |||
} | |||
|
|||
@Test | |||
fun testGetAppSessionId_initialState_returnsRandomId() { |
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.
Please add a test to verify a new app instance to demonstrate a different ID is generated, similar to this test:
Line 100 in 4f03d9a
fun testGetInstallationId_secondAppOpen_providerReturnsSameInstallationIdValue() { |
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.
I have added a test that kind of checks for this but I will need some validation on whether it does that correctly.
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.
As discussed in the meeting today, we should probably be doing something like the following to ensure correct behavior:
- Arrange
- Set fixed application random seed to value (explicitly within the test). Note this should be done in the test that doesn't verify app restart, too, for parity.
- Set up rest of test as normal
- Act
- Update the application random seed to be something different.
- Recreate the application component & reinit the test suite fields, where needed.
- Assert: assert as normal (that the ID is different than in the test which doesn't 'restart' the app).
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.
I am unable to create a test that can objectively test that the app is generating different app session IDs on restart based on how the test file is structured. I have created an issue to track this #5399. Once fixed, all tests on the file should now pass (or fail) for the correct reason.
domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt
Outdated
Show resolved
Hide resolved
domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt
Outdated
Show resolved
Hide resolved
domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt
Outdated
Show resolved
Hide resolved
domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt
Outdated
Show resolved
Hide resolved
domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt
Show resolved
Hide resolved
@BenHenning this PR should be ready for another review. PTAL |
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.
Thanks @kkmurerwa! Just a few follow-ups--PTAL.
* 1. The app is opened. | ||
* 2. The app is destroyed by the Android system. | ||
*/ | ||
fun updateAppSessionId() { |
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.
Why is this needed? It seems like we shouldn't ever need to explicitly updated the session ID since it autoinitializes upon app open.
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.
I realize that now. I will remove this.
@@ -176,6 +176,7 @@ class ApplicationLifecycleObserver @Inject constructor( | |||
|
|||
private fun logAllFeatureFlags() { | |||
CoroutineScope(backgroundDispatcher).launch { | |||
// TODO(#5240): Replace appSessionId generation to the modified Twitter snowflake algorithm. |
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.
I see the TODO was removed from code--shouldn't it stay here and point to #5341?
I also think #5341 is a bit confusing since, after this PR is merged, it will seem as if an ID is being provided. The issue should probably instead explain what needs to be changed from the solution introduced in this PR to get analytics to where we want them long-term.
@@ -251,6 +251,44 @@ class LoggingIdentifierControllerTest { | |||
assertThat(sessionIdFlow.value).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") | |||
} | |||
|
|||
@Test | |||
fun testGetAppSessionId_initialState_returnsRandomId() { |
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.
As discussed in the meeting today, we should probably be doing something like the following to ensure correct behavior:
- Arrange
- Set fixed application random seed to value (explicitly within the test). Note this should be done in the test that doesn't verify app restart, too, for parity.
- Set up rest of test as normal
- Act
- Update the application random seed to be something different.
- Recreate the application component & reinit the test suite fields, where needed.
- Assert: assert as normal (that the ID is different than in the test which doesn't 'restart' the app).
Explanation
When merged, this PR will:
FeatureFlagLogger.kt
file that aggregates and logs all feature flags.FeatureFlagLoggerTest.kt
to test the FeatureFlagLogger.ApplicationLifecycleObserver.kt
file so that it is logged when the app is in foreground.Screenshot of the FeatureFlagContext log in the Event Logs page
Essential Checklist
For UI-specific PRs only
If your PR includes UI-related changes, then: