From 3fee528e6f557ed1c7d82a349782aca82aece5de Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 18 Oct 2023 10:01:59 +0300 Subject: [PATCH 01/66] feat: Add a FeatureFlagConstants file to host feature flags --- .../platformparameter/FeatureFlagConstants.kt | 303 ++++++++++++++++++ .../PlatformParameterConstants.kt | 134 -------- 2 files changed, 303 insertions(+), 134 deletions(-) create mode 100644 utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt new file mode 100644 index 00000000000..a4de5f115d2 --- /dev/null +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -0,0 +1,303 @@ +package org.oppia.android.util.platformparameter + +import javax.inject.Qualifier + +/** + * This file contains all the constants that are associated with individual Feature Flags. + * These constants are: + * - Qualifier Annotation + * - Feature Flag Name - The name begins with Enable_ + * - Feature Flag Default Value + * - Feature Flag Status - A boolean that keeps track of whether the feature flag + * has been synced with Oppia Web or not. + */ + +/** + * Qualifier for the feature flag that controls whether the user has support for manually + * downloading topics. + */ +@Qualifier annotation class EnableDownloadsSupport + +/** Default value for feature flag corresponding to [EnableDownloadsSupport]. */ +const val ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableDownloadsSupport] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableDownloadsSupportIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableDownloadsSupportIsServerProvided]. + */ +const val FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** Qualifier for the feature flag corresponding to enabling the language selection UI. */ +@Qualifier +annotation class EnableLanguageSelectionUi + +/** Default value for the feature flag corresponding to [EnableLanguageSelectionUi]. */ +const val ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE = true + +/** + * Qualifier to keep track of the sync status of the [EnableLanguageSelectionUi] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableLanguageSelectionUiIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableLanguageSelectionUiIsServerProvided]. + */ +const val FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Qualifier for the feature flag corresponding to enabling the extra topic tabs: practice and info. + */ +@Qualifier +annotation class EnableExtraTopicTabsUi + +/** Default value for the feature flag corresponding to [EnableExtraTopicTabsUi]. */ +const val ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableExtraTopicTabsUi] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableExtraTopicTabsUiIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableExtraTopicTabsUiIsServerProvided]. + */ +const val FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Qualifier for the feature flag that controls the visibility of [ProfileAndDeviceIdActivity] + * and working of learner study related analytics logging. + */ +@Qualifier +annotation class EnableLearnerStudyAnalytics + +/** + * Name of the feature flag that controls the visibility of [ProfileAndDeviceIdActivity] + * and working of learner study related analytics logging. + */ +const val LEARNER_STUDY_ANALYTICS = "learner_study_analytics" + +/** + * Default value of the feature flag that controls the visibility of [ProfileAndDeviceIdActivity] + * and working of learner study related analytics logging. + */ +const val LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableLearnerStudyAnalytics] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableLearnerStudyAnalyticsIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableLearnerStudyAnalyticsIsServerProvided]. + */ +const val FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Qualifier for a feature flag that controls whether learners may be allowed (via an + * admin-controlled setting) to use a special in-lesson button for quickly switching between content + * languages. + * + * This is generally expected to only be used in tandem with [EnableLearnerStudyAnalytics]. + */ +@Qualifier annotation class EnableFastLanguageSwitchingInLesson + +/** The feature flag name corresponding to [EnableFastLanguageSwitchingInLesson]. */ +const val FAST_LANGUAGE_SWITCHING_IN_LESSON = "fast_language_switching_in_lesson" + +/** + * The default enabled state for the feature corresponding to [EnableFastLanguageSwitchingInLesson]. + */ +const val FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableFastLanguageSwitchingInLesson] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableFastLanguageSwitchingInLessonIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableFastLanguageSwitchingInLessonIsServerProvided]. + */ +const val FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Qualifier for a feature flag that controls whether learner study IDs should be generated and + * logged with outgoing events. + * + * This is generally expected to only be used in tandem with [EnableLearnerStudyAnalytics]. + */ +@Qualifier annotation class EnableLoggingLearnerStudyIds + +/** The feature flag name corresponding to [EnableLoggingLearnerStudyIds]. */ +const val LOGGING_LEARNER_STUDY_IDS = "logging_learner_study_ids" + +/** The default enabled state for the feature corresponding to [EnableLoggingLearnerStudyIds]. */ +const val LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableLoggingLearnerStudyIds] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableLoggingLearnerStudyIdsIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableLoggingLearnerStudyIdsIsServerProvided]. + */ +const val FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** Qualifier for the feature flag corresponding to enabling the edit accounts options. */ +@Qualifier +annotation class EnableEditAccountsOptionsUi + +/** Default value for the feature flag corresponding to [EnableEditAccountsOptionsUi]. */ +const val ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableEditAccountsOptionsUi] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableEditAccountsOptionsUiIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableEditAccountsOptionsUiIsServerProvided]. + */ +const val FLAG_ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** Qualifier for the platform parameter that controls whether to record performance metrics. */ +@Qualifier +annotation class EnablePerformanceMetricsCollection + +/** Name of the platform parameter that controls whether to record performance metrics. */ +const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "enable_performance_metrics_collection" + +/** Default value for whether to record performance metrics. */ +const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnablePerformanceMetricsCollection] and help + * determine if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnablePerformanceMetricsCollectionIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnablePerformanceMetricsCollectionIsServerProvided]. + */ +const val FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Qualifier for the platform parameter that controls whether to animate the continue button + * interaction and navigation items. This is used to disable the animation during testing because + * Espresso has known problems while testing views that contain animations. + */ +@Qualifier +annotation class EnableContinueButtonAnimation + +/** Default value for whether to enable continue button animation. */ +const val ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE = true + +/** + * Qualifier to keep track of the sync status of the [EnableContinueButtonAnimation] and help + * determine if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableContinueButtonAnimationIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableContinueButtonAnimationIsServerProvided]. + */ +const val FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** Qualifier for the feature flag corresponding to enabling the spotlight UI. */ +@Qualifier +annotation class EnableSpotlightUi + +/** Default value for the feature flag corresponding to [EnableSpotlightUi]. */ +const val ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableSpotlightUi] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableSpotlightUiIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableSpotlightUiIsServerProvided]. + */ +const val FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Qualifier for the feature flag that controls whether input interaction state is correctly + * retained across configuration changes. + */ +@Qualifier +annotation class EnableInteractionConfigChangeStateRetention + +/** + * Default value for feature flag corresponding to [EnableInteractionConfigChangeStateRetention]. + */ +const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableInteractionConfigChangeStateRetention] + * and help determine if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableInteractionConfigChangeStateRetentionIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableInteractionConfigChangeStateRetentionIsServerProvided]. + */ +const val FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Qualifier for the [EnableAppAndOsDeprecation] feature flag that controls whether to enable + * app and OS deprecation or not. + */ +@Qualifier +annotation class EnableAppAndOsDeprecation + +/** + * Default value for the feature flag corresponding to [EnableAppAndOsDeprecation]. + */ +const val ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false + +/** + * Qualifier to keep track of the sync status of the [EnableAppAndOsDeprecation] and help determine + * if the value of the feature flag is server-provided or default. + */ +@Qualifier +annotation class FlagEnableAppAndOsDeprecationIsServerProvided + +/** + * Default value for the feature flag sync status tracker corresponding to + * [FlagEnableAppAndOsDeprecationIsServerProvided]. + */ +const val FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index 8cb1e1b4297..46121ebf7d9 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -10,15 +10,6 @@ import javax.inject.Qualifier * - Platform Parameter Default Value */ -/** - * Qualifier for the platform parameter that controls whether the user has support for manually - * downloading topics. - */ -@Qualifier annotation class EnableDownloadsSupport - -/** Default value for feature flag corresponding to [EnableDownloadsSupport]. */ -const val ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE = false - /** * Name of the platform parameter that automatically updates topics when a user toggles the * switch in the [AdministratorControlsFragmentPresenter]. @@ -75,72 +66,6 @@ const val SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS = "sync_up_worker_time_period" */ const val SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE = 12 -/** Qualifier for the feature flag corresponding to enabling the language selection UI. */ -@Qualifier -annotation class EnableLanguageSelectionUi - -/** Default value for the feature flag corresponding to [EnableLanguageSelectionUi]. */ -const val ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE = true - -/** - * Qualifier for the feature flag corresponding to enabling the extra topic tabs: practice and info. - */ -@Qualifier -annotation class EnableExtraTopicTabsUi - -/** Default value for the feature flag corresponding to [EnableExtraTopicTabsUi]. */ -const val ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE = false - -/** - * Qualifier for the platform parameter that controls the visibility of [ProfileAndDeviceIdActivity] - * and working of learner study related analytics logging. - */ -@Qualifier -annotation class EnableLearnerStudyAnalytics - -/** - * Name of the platform parameter that controls the visibility of [ProfileAndDeviceIdActivity] - * and working of learner study related analytics logging. - */ -const val LEARNER_STUDY_ANALYTICS = "learner_study_analytics" - -/** - * Default value of the platform parameter that controls the visibility of [ProfileAndDeviceIdActivity] - * and working of learner study related analytics logging. - */ -const val LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE = false - -/** - * Qualifier for a feature flag that controls whether learners may be allowed (via an - * admin-controlled setting) to use a special in-lesson button for quickly switching between content - * languages. - * - * This is generally expected to only be used in tandem with [EnableLearnerStudyAnalytics]. - */ -@Qualifier annotation class EnableFastLanguageSwitchingInLesson - -/** The platform parameter name corresponding to [EnableFastLanguageSwitchingInLesson]. */ -const val FAST_LANGUAGE_SWITCHING_IN_LESSON = "fast_language_switching_in_lesson" - -/** - * The default enabled state for the feature corresponding to [EnableFastLanguageSwitchingInLesson]. - */ -const val FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE = false - -/** - * Qualifier for a feature flag that controls whether learner study IDs should be generated and - * logged with outgoing events. - * - * This is generally expected to only be used in tandem with [EnableLearnerStudyAnalytics]. - */ -@Qualifier annotation class EnableLoggingLearnerStudyIds - -/** The platform parameter name corresponding to [EnableLoggingLearnerStudyIds]. */ -const val LOGGING_LEARNER_STUDY_IDS = "logging_learner_study_ids" - -/** The default enabled state for the feature corresponding to [EnableLoggingLearnerStudyIds]. */ -const val LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE = false - /** * Qualifier for the platform parameter that controls whether to cache LaTeX rendering using Glide. */ @@ -153,34 +78,6 @@ const val CACHE_LATEX_RENDERING = "cache_latex_rendering" /** Default value for whether to cache LaTeX rendering using Glide. */ const val CACHE_LATEX_RENDERING_DEFAULT_VALUE = true -/** Qualifier for the feature flag corresponding to enabling the edit accounts options. */ -@Qualifier -annotation class EnableEditAccountsOptionsUi - -/** Default value for the feature flag corresponding to [EnableEditAccountsOptionsUi]. */ -const val ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE = false - -/** Qualifier for the platform parameter that controls whether to record performance metrics. */ -@Qualifier -annotation class EnablePerformanceMetricsCollection - -/** Name of the platform parameter that controls whether to record performance metrics. */ -const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "enable_performance_metrics_collection" - -/** Default value for whether to record performance metrics. */ -const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false - -/** - * Qualifier for the platform parameter that controls whether to animate the continue button - * interaction and navigation items. This is used to disable the animation during testing because - * Espresso has known problems while testing views that contain animations. - */ -@Qualifier -annotation class EnableContinueButtonAnimation - -/** Default value for whether to enable continue button animation. */ -const val ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE = true - /** * Qualifier for the platform parameter that controls the time interval in minutes of uploading * previously recorded performance metrics to the remote service. @@ -243,37 +140,6 @@ const val PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES const val PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL = 1440 -/** Qualifier for the feature flag corresponding to enabling the spotlight UI. */ -@Qualifier -annotation class EnableSpotlightUi - -/** Default value for the feature flag corresponding to [EnableSpotlightUi]. */ -const val ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE = false - -/** - * Qualifier for the platform parameter that controls whether input interaction state is correctly - * retained across configuration changes. - */ -@Qualifier -annotation class EnableInteractionConfigChangeStateRetention - -/** - * Default value for feature flag corresponding to [EnableInteractionConfigChangeStateRetention]. - */ -const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false - -/** - * Qualifier for the [EnableAppAndOsDeprecation] feature flag that controls whether to enable - * app and OS deprecation or not. - */ -@Qualifier -annotation class EnableAppAndOsDeprecation - -/** - * Default value for the feature flag corresponding to [EnableAppAndOsDeprecation]. - */ -const val ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false - /** * Qualifier for the platform parameter that contains the version code of the latest available * optional app update, which is used to notify the app that a soft update is available. From 9c09fbf1a81aaceef1e8aff529293147b9cc26f3 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 18 Oct 2023 12:28:58 +0300 Subject: [PATCH 02/66] feat: Add constant names for easy retrieval of the feature flags from persistent cache store --- .../platformparameter/FeatureFlagConstants.kt | 72 ++++++++++++++++--- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index a4de5f115d2..5dd54fae4ea 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -28,6 +28,10 @@ const val ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE = false @Qualifier annotation class FlagEnableDownloadsSupportIsServerProvided +/** The feature flag name corresponding to [FlagEnableDownloadsSupportIsServerProvided]. */ +const val FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED = + "flag_enable_downloads_support_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableDownloadsSupportIsServerProvided]. @@ -48,6 +52,10 @@ const val ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE = true @Qualifier annotation class FlagEnableLanguageSelectionUiIsServerProvided +/** The feature flag name corresponding to [FlagEnableLanguageSelectionUiIsServerProvided]. */ +const val FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED = + "flag_enable_language_selection_ui_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableLanguageSelectionUiIsServerProvided]. @@ -70,6 +78,10 @@ const val ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE = false @Qualifier annotation class FlagEnableExtraTopicTabsUiIsServerProvided +/** The feature flag name corresponding to [FlagEnableExtraTopicTabsUiIsServerProvided]. */ +const val FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED = + "flag_enable_extra_topic_tabs_ui_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableExtraTopicTabsUiIsServerProvided]. @@ -96,12 +108,16 @@ const val LEARNER_STUDY_ANALYTICS = "learner_study_analytics" const val LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE = false /** - * Qualifier to keep track of the sync status of the [EnableLearnerStudyAnalytics] and help determine - * if the value of the feature flag is server-provided or default. + * Qualifier to keep track of the sync status of the [EnableLearnerStudyAnalytics] and help + * determine if the value of the feature flag is server-provided or default. */ @Qualifier annotation class FlagEnableLearnerStudyAnalyticsIsServerProvided +/** The feature flag name corresponding to [FlagEnableLearnerStudyAnalyticsIsServerProvided]. */ +const val FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED = + "flag_enable_learner_study_analytics_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableLearnerStudyAnalyticsIsServerProvided]. @@ -126,12 +142,18 @@ const val FAST_LANGUAGE_SWITCHING_IN_LESSON = "fast_language_switching_in_lesson const val FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE = false /** - * Qualifier to keep track of the sync status of the [EnableFastLanguageSwitchingInLesson] and help determine - * if the value of the feature flag is server-provided or default. + * Qualifier to keep track of the sync status of the [EnableFastLanguageSwitchingInLesson] and help + * determine if the value of the feature flag is server-provided or default. */ @Qualifier annotation class FlagEnableFastLanguageSwitchingInLessonIsServerProvided +/** The feature flag name corresponding to + * [FlagEnableFastLanguageSwitchingInLessonIsServerProvided]. + */ +const val FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED = + "flag_enable_fast_language_switching_in_lesson_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableFastLanguageSwitchingInLessonIsServerProvided]. @@ -153,12 +175,16 @@ const val LOGGING_LEARNER_STUDY_IDS = "logging_learner_study_ids" const val LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE = false /** - * Qualifier to keep track of the sync status of the [EnableLoggingLearnerStudyIds] and help determine - * if the value of the feature flag is server-provided or default. + * Qualifier to keep track of the sync status of the [EnableLoggingLearnerStudyIds] and help + * determine if the value of the feature flag is server-provided or default. */ @Qualifier annotation class FlagEnableLoggingLearnerStudyIdsIsServerProvided +/** The feature flag name corresponding to [FlagEnableLoggingLearnerStudyIdsIsServerProvided]. */ +const val FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED = + "flag_enable_logging_learner_study_ids_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableLoggingLearnerStudyIdsIsServerProvided]. @@ -173,12 +199,16 @@ annotation class EnableEditAccountsOptionsUi const val ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE = false /** - * Qualifier to keep track of the sync status of the [EnableEditAccountsOptionsUi] and help determine - * if the value of the feature flag is server-provided or default. + * Qualifier to keep track of the sync status of the [EnableEditAccountsOptionsUi] and help + * determine if the value of the feature flag is server-provided or default. */ @Qualifier annotation class FlagEnableEditAccountsOptionsUiIsServerProvided +/** The feature flag name corresponding to [FlagEnableEditAccountsOptionsUiIsServerProvided]. */ +const val FLAG_ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_IS_SERVER_PROVIDED = + "flag_enable_edit_accounts_options_ui_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableEditAccountsOptionsUiIsServerProvided]. @@ -202,6 +232,11 @@ const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false @Qualifier annotation class FlagEnablePerformanceMetricsCollectionIsServerProvided +/** The feature flag name corresponding to [FlagEnablePerformanceMetricsCollectionIsServerProvided]. + */ +const val FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED = + "flag_enable_performance_metrics_collection_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnablePerformanceMetricsCollectionIsServerProvided]. @@ -226,6 +261,10 @@ const val ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE = true @Qualifier annotation class FlagEnableContinueButtonAnimationIsServerProvided +/** The feature flag name corresponding to [FlagEnableContinueButtonAnimationIsServerProvided]. */ +const val FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED = + "flag_enable_continue_button_animation_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableContinueButtonAnimationIsServerProvided]. @@ -246,6 +285,10 @@ const val ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE = false @Qualifier annotation class FlagEnableSpotlightUiIsServerProvided +/** The feature flag name corresponding to [FlagEnableSpotlightUiIsServerProvided]. */ +const val FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED = + "flag_enable_spotlight_ui_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableSpotlightUiIsServerProvided]. @@ -271,11 +314,18 @@ const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false @Qualifier annotation class FlagEnableInteractionConfigChangeStateRetentionIsServerProvided +/** The feature flag name corresponding to + * [FlagEnableInteractionConfigChangeStateRetentionIsServerProvided]. + */ +const val FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED = + "flag_enable_interaction_config_change_state_retention_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableInteractionConfigChangeStateRetentionIsServerProvided]. */ -const val FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false +const val FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE = + false /** * Qualifier for the [EnableAppAndOsDeprecation] feature flag that controls whether to enable @@ -296,6 +346,10 @@ const val ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false @Qualifier annotation class FlagEnableAppAndOsDeprecationIsServerProvided +/** The feature flag name corresponding to [FlagEnableAppAndOsDeprecationIsServerProvided]. */ +const val FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED = + "flag_enable_app_and_os_deprecation_is_server_provided" + /** * Default value for the feature flag sync status tracker corresponding to * [FlagEnableAppAndOsDeprecationIsServerProvided]. From b0d15724f39aabf04356c2d378b9d1af74983216 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 18 Oct 2023 13:03:39 +0300 Subject: [PATCH 03/66] feat: Add newly status flags to the Platform Parameter dependency modules --- .../PlatformParameterAlphaKenyaModule.kt | 165 ++++++++++++++++++ .../PlatformParameterAlphaModule.kt | 165 ++++++++++++++++++ .../PlatformParameterModule.kt | 165 ++++++++++++++++++ 3 files changed, 495 insertions(+) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 1b3293d56f5..c96261b5d8d 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -30,7 +30,40 @@ import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON +import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FlagEnableAppAndOsDeprecationIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableContinueButtonAnimationIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableDownloadsSupportIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableExtraTopicTabsUiIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableFastLanguageSwitchingInLessonIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableInteractionConfigChangeStateRetentionIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLanguageSelectionUiIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLearnerStudyAnalyticsIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLoggingLearnerStudyIdsIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnablePerformanceMetricsCollectionIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableSpotlightUiIsServerProvided import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS @@ -75,6 +108,18 @@ class PlatformParameterAlphaKenyaModule { fun provideEnableDownloadsSupport(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + @Provides + @FlagEnableDownloadsSupportIsServerProvided + fun provideFlagEnableDownloadsSupportIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( @@ -104,6 +149,18 @@ class PlatformParameterAlphaKenyaModule { ) } + @Provides + @FlagEnableLanguageSelectionUiIsServerProvided + fun provideFlagEnableLanguageSelectionUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableEditAccountsOptionsUi fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { @@ -122,6 +179,18 @@ class PlatformParameterAlphaKenyaModule { ?: PlatformParameterValue.createDefaultParameter(true) } + @Provides + @FlagEnableLearnerStudyAnalyticsIsServerProvided + fun provideFlagEnableLearnerStudyAnalyticsIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableFastLanguageSwitchingInLesson fun provideFastInLessonLanguageSwitching( @@ -132,6 +201,18 @@ class PlatformParameterAlphaKenyaModule { ?: PlatformParameterValue.createDefaultParameter(true) } + @Provides + @FlagEnableFastLanguageSwitchingInLessonIsServerProvided + fun provideFlagEnableFastLanguageSwitchingInLessonIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableLoggingLearnerStudyIds fun provideLoggingLearnerStudyIds( @@ -142,6 +223,18 @@ class PlatformParameterAlphaKenyaModule { ?: PlatformParameterValue.createDefaultParameter(true) } + @Provides + @FlagEnableLoggingLearnerStudyIdsIsServerProvided + fun provideFlagEnableLoggingLearnerStudyIdsIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @CacheLatexRendering fun provideCacheLatexRendering( @@ -163,6 +256,18 @@ class PlatformParameterAlphaKenyaModule { ) } + @Provides + @FlagEnablePerformanceMetricsCollectionIsServerProvided + fun provideFlagEnablePerformanceMetricsCollectionIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @PerformanceMetricsCollectionUploadTimeIntervalInMinutes fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( @@ -207,6 +312,18 @@ class PlatformParameterAlphaKenyaModule { ) } + @Provides + @FlagEnableExtraTopicTabsUiIsServerProvided + fun provideFlagEnableExtraTopicTabsUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableInteractionConfigChangeStateRetention fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { @@ -215,6 +332,18 @@ class PlatformParameterAlphaKenyaModule { ) } + @Provides + @FlagEnableInteractionConfigChangeStateRetentionIsServerProvided + fun provideFlagEnableInteractionConfigChangeStateRetentionIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableContinueButtonAnimation fun provideEnableContinueButtonAnimation(): PlatformParameterValue { @@ -223,6 +352,18 @@ class PlatformParameterAlphaKenyaModule { ) } + @Provides + @FlagEnableContinueButtonAnimationIsServerProvided + fun provideFlagEnableContinueButtonAnimationIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableSpotlightUi fun enableSpotlightUi(): PlatformParameterValue { @@ -231,6 +372,18 @@ class PlatformParameterAlphaKenyaModule { ) } + @Provides + @FlagEnableSpotlightUiIsServerProvided + fun provideFlagEnableSpotlightUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableAppAndOsDeprecation fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { @@ -239,6 +392,18 @@ class PlatformParameterAlphaKenyaModule { ) } + @Provides + @FlagEnableAppAndOsDeprecationIsServerProvided + fun provideFlagEnableAppAndOsDeprecationIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 8addae7b9fd..0781615bdee 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -30,7 +30,40 @@ import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollecti import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FlagEnableAppAndOsDeprecationIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableContinueButtonAnimationIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableDownloadsSupportIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableExtraTopicTabsUiIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableFastLanguageSwitchingInLessonIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableInteractionConfigChangeStateRetentionIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLanguageSelectionUiIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLearnerStudyAnalyticsIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLoggingLearnerStudyIdsIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnablePerformanceMetricsCollectionIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableSpotlightUiIsServerProvided import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS @@ -72,6 +105,18 @@ class PlatformParameterAlphaModule { fun provideEnableDownloadsSupport(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + @Provides + @FlagEnableDownloadsSupportIsServerProvided + fun provideFlagEnableDownloadsSupportIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( @@ -101,6 +146,18 @@ class PlatformParameterAlphaModule { ) } + @Provides + @FlagEnableLanguageSelectionUiIsServerProvided + fun provideFlagEnableLanguageSelectionUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableEditAccountsOptionsUi fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { @@ -118,6 +175,18 @@ class PlatformParameterAlphaModule { ?: PlatformParameterValue.createDefaultParameter(true) } + @Provides + @FlagEnableLearnerStudyAnalyticsIsServerProvided + fun provideFlagEnableLearnerStudyAnalyticsIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableFastLanguageSwitchingInLesson fun provideFastInLessonLanguageSwitching( @@ -129,6 +198,18 @@ class PlatformParameterAlphaModule { ) } + @Provides + @FlagEnableFastLanguageSwitchingInLessonIsServerProvided + fun provideFlagEnableFastLanguageSwitchingInLessonIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableLoggingLearnerStudyIds fun provideLoggingLearnerStudyIds( @@ -138,6 +219,18 @@ class PlatformParameterAlphaModule { ?: PlatformParameterValue.createDefaultParameter(LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE) } + @Provides + @FlagEnableLoggingLearnerStudyIdsIsServerProvided + fun provideFlagEnableLoggingLearnerStudyIdsIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @CacheLatexRendering fun provideCacheLatexRendering( @@ -159,6 +252,18 @@ class PlatformParameterAlphaModule { ) } + @Provides + @FlagEnablePerformanceMetricsCollectionIsServerProvided + fun provideFlagEnablePerformanceMetricsCollectionIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @PerformanceMetricsCollectionUploadTimeIntervalInMinutes fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( @@ -200,6 +305,18 @@ class PlatformParameterAlphaModule { fun provideEnableSpotlightUi(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(true) // Enable spotlights for alpha users. + @Provides + @FlagEnableSpotlightUiIsServerProvided + fun provideFlagEnableSpotlightUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableExtraTopicTabsUi fun provideEnableExtraTopicTabsUi(): PlatformParameterValue { @@ -208,6 +325,18 @@ class PlatformParameterAlphaModule { ) } + @Provides + @FlagEnableExtraTopicTabsUiIsServerProvided + fun provideFlagEnableExtraTopicTabsUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableInteractionConfigChangeStateRetention fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { @@ -216,6 +345,18 @@ class PlatformParameterAlphaModule { ) } + @Provides + @FlagEnableInteractionConfigChangeStateRetentionIsServerProvided + fun provideFlagEnableInteractionConfigChangeStateRetentionIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableContinueButtonAnimation fun provideEnableContinueButtonAnimation(): PlatformParameterValue { @@ -224,6 +365,18 @@ class PlatformParameterAlphaModule { ) } + @Provides + @FlagEnableContinueButtonAnimationIsServerProvided + fun provideFlagEnableContinueButtonAnimationIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableAppAndOsDeprecation fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { @@ -232,6 +385,18 @@ class PlatformParameterAlphaModule { ) } + @Provides + @FlagEnableAppAndOsDeprecationIsServerProvided + fun provideFlagEnableAppAndOsDeprecationIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index c2a211472fc..596987f39c2 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -31,7 +31,40 @@ import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollecti import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED +import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FlagEnableAppAndOsDeprecationIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableContinueButtonAnimationIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableDownloadsSupportIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableExtraTopicTabsUiIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableFastLanguageSwitchingInLessonIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableInteractionConfigChangeStateRetentionIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLanguageSelectionUiIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLearnerStudyAnalyticsIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableLoggingLearnerStudyIdsIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnablePerformanceMetricsCollectionIsServerProvided +import org.oppia.android.util.platformparameter.FlagEnableSpotlightUiIsServerProvided import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE @@ -74,6 +107,18 @@ class PlatformParameterModule { fun provideEnableDownloadsSupport(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + @Provides + @FlagEnableDownloadsSupportIsServerProvided + fun provideFlagEnableDownloadsSupportIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( @@ -103,6 +148,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnableLanguageSelectionUiIsServerProvided + fun provideFlagEnableLanguageSelectionUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableEditAccountsOptionsUi fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { @@ -120,6 +177,18 @@ class PlatformParameterModule { ?: PlatformParameterValue.createDefaultParameter(LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE) } + @Provides + @FlagEnableLearnerStudyAnalyticsIsServerProvided + fun provideFlagEnableLearnerStudyAnalyticsIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableFastLanguageSwitchingInLesson fun provideFastInLessonLanguageSwitching( @@ -131,6 +200,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnableFastLanguageSwitchingInLessonIsServerProvided + fun provideFlagEnableFastLanguageSwitchingInLessonIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableLoggingLearnerStudyIds fun provideLoggingLearnerStudyIds( @@ -140,6 +221,18 @@ class PlatformParameterModule { ?: PlatformParameterValue.createDefaultParameter(LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE) } + @Provides + @FlagEnableLoggingLearnerStudyIdsIsServerProvided + fun provideFlagEnableLoggingLearnerStudyIdsIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @CacheLatexRendering fun provideCacheLatexRendering( @@ -161,6 +254,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnablePerformanceMetricsCollectionIsServerProvided + fun provideFlagEnablePerformanceMetricsCollectionIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @PerformanceMetricsCollectionUploadTimeIntervalInMinutes fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( @@ -205,6 +310,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnableSpotlightUiIsServerProvided + fun provideFlagEnableSpotlightUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableExtraTopicTabsUi fun provideEnableExtraTopicTabsUi(): PlatformParameterValue { @@ -213,6 +330,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnableExtraTopicTabsUiIsServerProvided + fun provideFlagEnableExtraTopicTabsUiIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableInteractionConfigChangeStateRetention fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { @@ -221,6 +350,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnableInteractionConfigChangeStateRetentionIsServerProvided + fun provideFlagEnableInteractionConfigChangeStateRetentionIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableContinueButtonAnimation fun provideEnableContinueButtonAnimation(): PlatformParameterValue { @@ -229,6 +370,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnableContinueButtonAnimationIsServerProvided + fun provideFlagEnableContinueButtonAnimationIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @EnableAppAndOsDeprecation fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { @@ -237,6 +390,18 @@ class PlatformParameterModule { ) } + @Provides + @FlagEnableAppAndOsDeprecationIsServerProvided + fun provideFlagEnableAppAndOsDeprecationIsServerProvided( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( From 7e135308f2212ff7514dfc669341650b2ce9de91 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 20 Oct 2023 14:29:02 +0300 Subject: [PATCH 04/66] feat: Add ability to insert sync statuses to the cache store --- .../PlatformParameterModule.kt | 28 +++++++++---------- .../syncup/PlatformParameterSyncUpWorker.kt | 28 +++++++++++++++++-- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 596987f39c2..b7c83c3734c 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -185,7 +185,7 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE + FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE ) } @@ -208,8 +208,8 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) + FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) } @Provides @@ -229,8 +229,8 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) + FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) } @Provides @@ -262,8 +262,8 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) + FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) } @Provides @@ -318,8 +318,8 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) + FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) } @Provides @@ -338,8 +338,8 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) + FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) } @Provides @@ -378,7 +378,7 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE ) } @@ -398,8 +398,8 @@ class PlatformParameterModule { return platformParameterSingleton.getBooleanPlatformParameter( FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) + FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) } @Provides diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt index aaf5aad0a0d..f631909e5b5 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt @@ -111,11 +111,14 @@ class PlatformParameterSyncUpWorker private constructor( if (response != null) { val responseBody = checkNotNull(response.body()) val platformParameterList = parseNetworkResponse(responseBody) - if (platformParameterList.isEmpty()) { + + // Add boolean flags + val platformParameterListWithSyncStatusFlags = addSyncStatusFlags(platformParameterList) + if (platformParameterListWithSyncStatusFlags.isEmpty()) { throw IllegalArgumentException(EMPTY_RESPONSE_EXCEPTION_MSG) } val cachingResult = platformParameterController - .updatePlatformParameterDatabase(platformParameterList) + .updatePlatformParameterDatabase(platformParameterListWithSyncStatusFlags) .retrieveData() if (cachingResult is AsyncResult.Failure) { throw IllegalStateException(cachingResult.error) @@ -132,6 +135,27 @@ class PlatformParameterSyncUpWorker private constructor( } } + private fun addSyncStatusFlags( + platformParameterList: List + ): List { + val modifiedList = mutableListOf() + + for (param in platformParameterList) { + modifiedList.add(param) + + val syncStatusParamKey = "flag_" + param.name + "_is_server_provided" + + // Add it to the modified list + val paramSyncStatusTracker = PlatformParameter.newBuilder().setName(syncStatusParamKey) + paramSyncStatusTracker.boolean = true + paramSyncStatusTracker.build() + + modifiedList.add(paramSyncStatusTracker.build()) + } + + return modifiedList + } + /** Creates an instance of [PlatformParameterSyncUpWorker] by properly injecting dependencies. */ class Factory @Inject constructor( private val platformParameterController: PlatformParameterController, From 6c06ea5e63b19b1d3a667e57f5d86cda0474522c Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 23 Oct 2023 20:32:20 +0300 Subject: [PATCH 05/66] feat: Add ability to save flag statuses for every feature flag --- .../PlatformParameterSyncUpWorkerTest.kt | 47 +++++++++++++++++++ .../TestStringPlatformParameter.kt | 15 ++++++ 2 files changed, 62 insertions(+) diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt index ad16b301201..a6be2e71aaf 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt @@ -50,6 +50,8 @@ import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_SERVER_VALUE import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SERVER_VALUE +import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME +import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -112,6 +114,11 @@ class PlatformParameterSyncUpWorkerTest { .setBoolean(TEST_BOOLEAN_PARAM_SERVER_VALUE) .build() + private val expectedTestStringParameterFlagStatus = PlatformParameter.newBuilder() + .setName(TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME) + .setBoolean(TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE) + .build() + // Not including "expectedTestBooleanParameter" in this list to prove that a refresh took place private val mockPlatformParameterList = listOf( expectedTestStringParameter, @@ -322,6 +329,46 @@ class PlatformParameterSyncUpWorkerTest { .containsEntry(TEST_INTEGER_PARAM_NAME, defaultTestIntegerParameter) } + @Test + fun testSyncUpWorker_getFeatureFlags_addSyncStatusFlags_verifyCorrectStatusReturned() { + // Set up versionName to get correct network response from mock platform parameter service. + setUpApplicationForContext(MockPlatformParameterService.appVersionForCorrectResponse) + + // Empty the Platform Parameter Database to simulate the execution of first SyncUp Work request. + platformParameterController.updatePlatformParameterDatabase(listOf()) + + val workManager = WorkManager.getInstance(context) + + val inputData = Data.Builder().putString( + PlatformParameterSyncUpWorker.WORKER_TYPE_KEY, + PlatformParameterSyncUpWorker.PLATFORM_PARAMETER_WORKER + ).build() + + val request: OneTimeWorkRequest = OneTimeWorkRequestBuilder() + .setInputData(inputData) + .build() + + // Enqueue the Work Request to fetch and cache the Platform Parameters from Remote Service. + workManager.enqueue(request) + testCoroutineDispatchers.runCurrent() + + val workInfo = workManager.getWorkInfoById(request.id) + assertThat(workInfo.get().state).isEqualTo(WorkInfo.State.SUCCEEDED) + + // Retrieve the previously cached Platform Parameters from Cache Store. + monitorFactory.ensureDataProviderExecutes(platformParameterController.getParameterDatabase()) + + // Values retrieved from Cache store will be sent to Platform Parameter Singleton by the + // Controller in the form of a Map, therefore verify the retrieved values from that Map. + val platformParameterMap = platformParameterSingleton.getPlatformParameterMap() + assertThat(platformParameterMap) + .containsEntry(TEST_STRING_PARAM_NAME, expectedTestStringParameter) + + val platformParameterMapFlagStatus = platformParameterSingleton.getPlatformParameterMap() + assertThat(platformParameterMapFlagStatus) + .containsEntry(TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME, expectedTestStringParameterFlagStatus) + } + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) } diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt index 330623e1ba4..9af3f8e52f2 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt @@ -22,3 +22,18 @@ const val TEST_STRING_PARAM_DEFAULT_VALUE = "test_string_param_default_value" * Server value for the test string platform parameter. Only used in tests related to platform parameter. */ const val TEST_STRING_PARAM_SERVER_VALUE = "test_string_param_value" + +/** + * Name for the test string platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME = "flag_test_string_param_name_is_server_provided" + +/** + * Default value for the test string platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_DEFAULT_VALUE = false + +/** + * Server value for the test string platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE = true From 1f0fa64a3a488e7aeec0578ae3d026f6ab055813 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 23 Oct 2023 23:30:07 +0300 Subject: [PATCH 06/66] fix: Fix linting and styling checks --- scripts/assets/test_file_exemptions.textproto | 1 + .../util/platformparameter/FeatureFlagConstants.kt | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/assets/test_file_exemptions.textproto b/scripts/assets/test_file_exemptions.textproto index 699f8b9a9cd..25e29b480cc 100644 --- a/scripts/assets/test_file_exemptions.textproto +++ b/scripts/assets/test_file_exemptions.textproto @@ -880,6 +880,7 @@ exempted_file_path: "utility/src/main/java/org/oppia/android/util/parser/svg/Svg exempted_file_path: "utility/src/main/java/org/oppia/android/util/parser/svg/SvgDecoder.kt" exempted_file_path: "utility/src/main/java/org/oppia/android/util/parser/svg/SvgPictureDrawable.kt" exempted_file_path: "utility/src/main/java/org/oppia/android/util/parser/svg/TextSvgDrawableTranscoder.kt" +exempted_file_path: "utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt" exempted_file_path: "utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt" exempted_file_path: "utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt" exempted_file_path: "utility/src/main/java/org/oppia/android/util/statusbar/StatusBarColor.kt" diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 5dd54fae4ea..0550c4db2d3 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -148,7 +148,8 @@ const val FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE = false @Qualifier annotation class FlagEnableFastLanguageSwitchingInLessonIsServerProvided -/** The feature flag name corresponding to +/** + * The feature flag name corresponding to * [FlagEnableFastLanguageSwitchingInLessonIsServerProvided]. */ const val FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED = @@ -232,7 +233,8 @@ const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false @Qualifier annotation class FlagEnablePerformanceMetricsCollectionIsServerProvided -/** The feature flag name corresponding to [FlagEnablePerformanceMetricsCollectionIsServerProvided]. +/** + * The feature flag name corresponding to [FlagEnablePerformanceMetricsCollectionIsServerProvided]. */ const val FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED = "flag_enable_performance_metrics_collection_is_server_provided" @@ -314,7 +316,8 @@ const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false @Qualifier annotation class FlagEnableInteractionConfigChangeStateRetentionIsServerProvided -/** The feature flag name corresponding to +/** + * The feature flag name corresponding to * [FlagEnableInteractionConfigChangeStateRetentionIsServerProvided]. */ const val FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED = From 795e90c2a8e39ee022204f46f8e58d32ccf3d8f2 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 27 Oct 2023 00:33:59 +0300 Subject: [PATCH 07/66] fix: Fix comments made on the previous review --- .../syncup/PlatformParameterSyncUpWorker.kt | 13 +++++------- .../PlatformParameterSyncUpWorkerTest.kt | 13 +++++------- .../TestPlatformParameterModule.kt | 13 ++++++++++++ .../TestStringPlatformParameter.kt | 20 ++++++++++++------- .../platformparameter/FeatureFlagConstants.kt | 8 ++++---- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt index f631909e5b5..189b421cfc3 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt @@ -112,8 +112,7 @@ class PlatformParameterSyncUpWorker private constructor( val responseBody = checkNotNull(response.body()) val platformParameterList = parseNetworkResponse(responseBody) - // Add boolean flags - val platformParameterListWithSyncStatusFlags = addSyncStatusFlags(platformParameterList) + val platformParameterListWithSyncStatusFlags = platformParameterList.addSyncStatusFlags() if (platformParameterListWithSyncStatusFlags.isEmpty()) { throw IllegalArgumentException(EMPTY_RESPONSE_EXCEPTION_MSG) } @@ -135,18 +134,16 @@ class PlatformParameterSyncUpWorker private constructor( } } - private fun addSyncStatusFlags( - platformParameterList: List - ): List { + private fun List.addSyncStatusFlags(): List { val modifiedList = mutableListOf() - for (param in platformParameterList) { + for (param in this) { modifiedList.add(param) - val syncStatusParamKey = "flag_" + param.name + "_is_server_provided" - // Add it to the modified list val paramSyncStatusTracker = PlatformParameter.newBuilder().setName(syncStatusParamKey) + // Update the boolean status of the derived syncStatusParamKey to true. This is necessary + // since sync status flags are local only and don't have a preset value. paramSyncStatusTracker.boolean = true paramSyncStatusTracker.build() diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt index a6be2e71aaf..aca0317b11e 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt @@ -43,6 +43,7 @@ import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.network.MockPlatformParameterService import org.oppia.android.testing.network.RetrofitTestModule +import org.oppia.android.testing.platformparameter.FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_SERVER_VALUE import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_DEFAULT_VALUE @@ -50,7 +51,6 @@ import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_SERVER_VALUE import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SERVER_VALUE -import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -115,7 +115,7 @@ class PlatformParameterSyncUpWorkerTest { .build() private val expectedTestStringParameterFlagStatus = PlatformParameter.newBuilder() - .setName(TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME) + .setName(FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED) .setBoolean(TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE) .build() @@ -360,13 +360,10 @@ class PlatformParameterSyncUpWorkerTest { // Values retrieved from Cache store will be sent to Platform Parameter Singleton by the // Controller in the form of a Map, therefore verify the retrieved values from that Map. - val platformParameterMap = platformParameterSingleton.getPlatformParameterMap() - assertThat(platformParameterMap) - .containsEntry(TEST_STRING_PARAM_NAME, expectedTestStringParameter) - val platformParameterMapFlagStatus = platformParameterSingleton.getPlatformParameterMap() - assertThat(platformParameterMapFlagStatus) - .containsEntry(TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME, expectedTestStringParameterFlagStatus) + assertThat(platformParameterMapFlagStatus).containsEntry( + FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED, expectedTestStringParameterFlagStatus + ) } private fun setUpTestApplicationComponent() { diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 7ff02772a65..fe3b23d9cee 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -99,6 +99,19 @@ class TestPlatformParameterModule { ?: PlatformParameterValue.createDefaultParameter(TEST_BOOLEAN_PARAM_DEFAULT_VALUE) } + @TestStringParam + @Provides + @Singleton + fun provideFlagTestStringParam( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED + ) ?: PlatformParameterValue.createDefaultParameter( + FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED_DEFAULT_VALUE + ) + } + @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt index 9af3f8e52f2..e50a9a52a01 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt @@ -14,26 +14,32 @@ annotation class TestStringParam const val TEST_STRING_PARAM_NAME = "test_string_param_name" /** - * Default value for the test string platform parameter. Only used in tests related to platform parameter. + * Default value for the test string platform parameter. Only used in tests related to platform + * parameter. */ const val TEST_STRING_PARAM_DEFAULT_VALUE = "test_string_param_default_value" /** - * Server value for the test string platform parameter. Only used in tests related to platform parameter. + * Server value for the test string platform parameter. Only used in tests related to platform + * parameter. */ const val TEST_STRING_PARAM_SERVER_VALUE = "test_string_param_value" /** - * Name for the test string platform parameter. Only used in tests related to platform parameter. + * Feature flag sync status name for the test string platform parameter. This name helps retrieve + * the sync status of the [TestStringParam]. Only used in tests related to platform parameter. */ -const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_NAME = "flag_test_string_param_name_is_server_provided" +const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED = + "flag_test_string_param_name_is_server_provided" /** - * Default value for the test string platform parameter. Only used in tests related to platform parameter. + * Default value for the feature flag sync status tracker for the [TestStringParam]. Only used in + * tests related to platform parameter. */ -const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_DEFAULT_VALUE = false +const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED_DEFAULT_VALUE = false /** - * Server value for the test string platform parameter. Only used in tests related to platform parameter. + * Server value for the test string platform parameter. Only used in tests related to platform + * parameter. */ const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE = true diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 0550c4db2d3..b7045b20772 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -9,7 +9,7 @@ import javax.inject.Qualifier * - Feature Flag Name - The name begins with Enable_ * - Feature Flag Default Value * - Feature Flag Status - A boolean that keeps track of whether the feature flag - * has been synced with Oppia Web or not. + * has been synced with Oppia Web. */ /** @@ -216,11 +216,11 @@ const val FLAG_ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_IS_SERVER_PROVIDED = */ const val FLAG_ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false -/** Qualifier for the platform parameter that controls whether to record performance metrics. */ +/** Qualifier for the feature flag that controls whether to record performance metrics. */ @Qualifier annotation class EnablePerformanceMetricsCollection -/** Name of the platform parameter that controls whether to record performance metrics. */ +/** Name of the feature flag that controls whether to record performance metrics. */ const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "enable_performance_metrics_collection" /** Default value for whether to record performance metrics. */ @@ -246,7 +246,7 @@ const val FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED = const val FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false /** - * Qualifier for the platform parameter that controls whether to animate the continue button + * Qualifier for the feature flag that controls whether to animate the continue button * interaction and navigation items. This is used to disable the animation during testing because * Espresso has known problems while testing views that contain animations. */ From 9da1607fcefe86b949b31fb98667a6de969596de Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 29 Oct 2023 20:42:00 +0300 Subject: [PATCH 08/66] fix: Fix nit Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> --- .../syncup/PlatformParameterSyncUpWorker.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt index 189b421cfc3..cbe095c65af 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt @@ -134,20 +134,19 @@ class PlatformParameterSyncUpWorker private constructor( } } - private fun List.addSyncStatusFlags(): List { + private fun List.addSyncStatusFlags(): List { val modifiedList = mutableListOf() for (param in this) { modifiedList.add(param) val syncStatusParamKey = "flag_" + param.name + "_is_server_provided" - val paramSyncStatusTracker = PlatformParameter.newBuilder().setName(syncStatusParamKey) - // Update the boolean status of the derived syncStatusParamKey to true. This is necessary - // since sync status flags are local only and don't have a preset value. - paramSyncStatusTracker.boolean = true - paramSyncStatusTracker.build() - - modifiedList.add(paramSyncStatusTracker.build()) + val paramSyncStatusTracker = PlatformParameter.newBuilder().apply { + name =syncStatusParamKey + boolean = true // Indicates that sync status flags are up to date since they are local only + } + .build() + modifiedList.add(paramSyncStatusTracker) } return modifiedList From 4dae83c13d7f13585b877ec14ae5072542d41708 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 30 Oct 2023 11:02:49 +0300 Subject: [PATCH 09/66] fix: Fix lint issues causing build failure --- .../syncup/PlatformParameterSyncUpWorker.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt index cbe095c65af..645012e1f79 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt @@ -134,15 +134,15 @@ class PlatformParameterSyncUpWorker private constructor( } } - private fun List.addSyncStatusFlags(): List { + private fun List.addSyncStatusFlags(): List { val modifiedList = mutableListOf() for (param in this) { modifiedList.add(param) - val syncStatusParamKey = "flag_" + param.name + "_is_server_provided" + val syncStatusParamName = "flag_" + param.name + "_is_server_provided" - val paramSyncStatusTracker = PlatformParameter.newBuilder().apply { - name =syncStatusParamKey + val paramSyncStatusTracker = PlatformParameter.newBuilder().apply { + name = syncStatusParamName boolean = true // Indicates that sync status flags are up to date since they are local only } .build() From 81d968b9559ef6c13f3db94fae1672a02ee88837 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 30 Oct 2023 22:24:58 +0300 Subject: [PATCH 10/66] fix: Move test sync status flag booleans to the TestBooleanPlatformParameter file --- .../TestBooleanPlatformParameter.kt | 19 +++++++++++++++++++ .../TestStringPlatformParameter.kt | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt index de74d381739..2130e26e834 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt @@ -22,3 +22,22 @@ const val TEST_BOOLEAN_PARAM_DEFAULT_VALUE = false * Server value for the test boolean platform parameter. Only used in tests related to platform parameter. */ const val TEST_BOOLEAN_PARAM_SERVER_VALUE = true + +/** + * Feature flag sync status name for the test string platform parameter. This name helps retrieve + * the sync status of the [TestStringParam]. Only used in tests related to platform parameter. + */ +const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED = + "flag_test_string_param_name_is_server_provided" + +/** + * Default value for the feature flag sync status tracker for the [TestStringParam]. Only used in + * tests related to platform parameter. + */ +const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED_DEFAULT_VALUE = false + +/** + * Server value for the test string platform parameter. Only used in tests related to platform + * parameter. + */ +const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE = true diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt index e50a9a52a01..6c5e01c0d95 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt @@ -24,22 +24,3 @@ const val TEST_STRING_PARAM_DEFAULT_VALUE = "test_string_param_default_value" * parameter. */ const val TEST_STRING_PARAM_SERVER_VALUE = "test_string_param_value" - -/** - * Feature flag sync status name for the test string platform parameter. This name helps retrieve - * the sync status of the [TestStringParam]. Only used in tests related to platform parameter. - */ -const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED = - "flag_test_string_param_name_is_server_provided" - -/** - * Default value for the feature flag sync status tracker for the [TestStringParam]. Only used in - * tests related to platform parameter. - */ -const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - -/** - * Server value for the test string platform parameter. Only used in tests related to platform - * parameter. - */ -const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE = true From d8f14bd763cd7250972bb4c9a17ef8599ee04a04 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 1 Nov 2023 09:55:14 +0300 Subject: [PATCH 11/66] chore: Move all test constants from individual type-organized files to a common constants file --- .../testing/platformparameter/BUILD.bazel | 4 +- .../TestIntegerPlatformParameter.kt | 24 -------- ...r.kt => TestPlatformParameterConstants.kt} | 60 ++++++++++++++++--- .../TestPlatformParameterModule.kt | 1 - .../TestStringPlatformParameter.kt | 26 -------- 5 files changed, 53 insertions(+), 62 deletions(-) delete mode 100644 testing/src/main/java/org/oppia/android/testing/platformparameter/TestIntegerPlatformParameter.kt rename testing/src/main/java/org/oppia/android/testing/platformparameter/{TestBooleanPlatformParameter.kt => TestPlatformParameterConstants.kt} (51%) delete mode 100644 testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel index a724de2135e..2ef5618b8fc 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel @@ -10,9 +10,7 @@ kt_android_library( name = "test_constants", testonly = True, srcs = [ - "TestBooleanPlatformParameter.kt", - "TestIntegerPlatformParameter.kt", - "TestStringPlatformParameter.kt", + "TestPlatformParameterConstants.kt", ], visibility = [ "//:oppia_testing_visibility", diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestIntegerPlatformParameter.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestIntegerPlatformParameter.kt deleted file mode 100644 index 956d3f1d4e0..00000000000 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestIntegerPlatformParameter.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.oppia.android.testing.platformparameter - -import javax.inject.Qualifier - -/** - * Qualifier for test integer platform parameter. Only used in tests related to platform parameter. - */ -@Qualifier -annotation class TestIntegerParam - -/** - * Name for the test integer platform parameter. Only used in tests related to platform parameter. - */ -const val TEST_INTEGER_PARAM_NAME = "test_integer_param_name" - -/** - * Default value for the test integer platform parameter. Only used in tests related to platform parameter. - */ -const val TEST_INTEGER_PARAM_DEFAULT_VALUE = 0 - -/** - * Server value for the test integer platform parameter. Only used in tests related to platform parameter. - */ -const val TEST_INTEGER_PARAM_SERVER_VALUE = 1 diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt similarity index 51% rename from testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt rename to testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt index 2130e26e834..567184a9bdd 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt @@ -3,25 +3,27 @@ package org.oppia.android.testing.platformparameter import javax.inject.Qualifier /** - * Qualifier for test boolean platform parameter. Only used in tests related to platform parameter. + * Qualifier for test string platform parameter. Only used in tests related to platform parameter. */ @Qualifier -annotation class TestBooleanParam +annotation class TestStringParam /** - * Name for the test boolean platform parameter. Only used in tests related to platform parameter. + * Name for the test string platform parameter. Only used in tests related to platform parameter. */ -const val TEST_BOOLEAN_PARAM_NAME = "test_boolean_param_name" +const val TEST_STRING_PARAM_NAME = "test_string_param_name" /** - * Default value for the test boolean platform parameter. Only used in tests related to platform parameter. + * Default value for the test string platform parameter. Only used in tests related to platform + * parameter. */ -const val TEST_BOOLEAN_PARAM_DEFAULT_VALUE = false +const val TEST_STRING_PARAM_DEFAULT_VALUE = "test_string_param_default_value" /** - * Server value for the test boolean platform parameter. Only used in tests related to platform parameter. + * Server value for the test string platform parameter. Only used in tests related to platform + * parameter. */ -const val TEST_BOOLEAN_PARAM_SERVER_VALUE = true +const val TEST_STRING_PARAM_SERVER_VALUE = "test_string_param_value" /** * Feature flag sync status name for the test string platform parameter. This name helps retrieve @@ -41,3 +43,45 @@ const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED_DEFAULT_VALUE = false * parameter. */ const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE = true + +/** + * Qualifier for test boolean platform parameter. Only used in tests related to platform parameter. + */ +@Qualifier +annotation class TestBooleanParam + +/** + * Name for the test boolean platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_BOOLEAN_PARAM_NAME = "test_boolean_param_name" + +/** + * Default value for the test boolean platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_BOOLEAN_PARAM_DEFAULT_VALUE = false + +/** + * Server value for the test boolean platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_BOOLEAN_PARAM_SERVER_VALUE = true + +/** + * Qualifier for test integer platform parameter. Only used in tests related to platform parameter. + */ +@Qualifier +annotation class TestIntegerParam + +/** + * Name for the test integer platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_INTEGER_PARAM_NAME = "test_integer_param_name" + +/** + * Default value for the test integer platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_INTEGER_PARAM_DEFAULT_VALUE = 0 + +/** + * Server value for the test integer platform parameter. Only used in tests related to platform parameter. + */ +const val TEST_INTEGER_PARAM_SERVER_VALUE = 1 diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index fe3b23d9cee..2e0d35203e1 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -99,7 +99,6 @@ class TestPlatformParameterModule { ?: PlatformParameterValue.createDefaultParameter(TEST_BOOLEAN_PARAM_DEFAULT_VALUE) } - @TestStringParam @Provides @Singleton fun provideFlagTestStringParam( diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt deleted file mode 100644 index 6c5e01c0d95..00000000000 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt +++ /dev/null @@ -1,26 +0,0 @@ -package org.oppia.android.testing.platformparameter - -import javax.inject.Qualifier - -/** - * Qualifier for test string platform parameter. Only used in tests related to platform parameter. - */ -@Qualifier -annotation class TestStringParam - -/** - * Name for the test string platform parameter. Only used in tests related to platform parameter. - */ -const val TEST_STRING_PARAM_NAME = "test_string_param_name" - -/** - * Default value for the test string platform parameter. Only used in tests related to platform - * parameter. - */ -const val TEST_STRING_PARAM_DEFAULT_VALUE = "test_string_param_default_value" - -/** - * Server value for the test string platform parameter. Only used in tests related to platform - * parameter. - */ -const val TEST_STRING_PARAM_SERVER_VALUE = "test_string_param_value" From 7bcbdcf69f77837de45b48e65fdae12f6908d073 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 1 Nov 2023 13:21:31 +0300 Subject: [PATCH 12/66] fix: Fix failing text file checks --- scripts/assets/test_file_exemptions.textproto | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/assets/test_file_exemptions.textproto b/scripts/assets/test_file_exemptions.textproto index 0a4417cd30a..dac453e5d9b 100644 --- a/scripts/assets/test_file_exemptions.textproto +++ b/scripts/assets/test_file_exemptions.textproto @@ -798,10 +798,8 @@ exempted_file_path: "testing/src/main/java/org/oppia/android/testing/network/Moc exempted_file_path: "testing/src/main/java/org/oppia/android/testing/network/MockSubtopicService.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/network/MockTopicService.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/network/RetrofitTestModule.kt" -exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestBooleanPlatformParameter.kt" -exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestIntegerPlatformParameter.kt" +exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt" -exempted_file_path: "testing/src/main/java/org/oppia/android/testing/platformparameter/TestStringPlatformParameter.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/robolectric/IsOnRobolectric.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/robolectric/RobolectricModule.kt" exempted_file_path: "testing/src/main/java/org/oppia/android/testing/threading/BackgroundTestDispatcher.kt" From b49df60dd78e40fdbac0a928f8e9cf027950b658 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 7 Nov 2023 12:51:08 +0300 Subject: [PATCH 13/66] feat: Add a isSynced variable in the platform parameter variable to simplify sync monitoring --- .../PlatformParameterAlphaKenyaModule.kt | 165 -------------- .../PlatformParameterAlphaModule.kt | 165 -------------- .../PlatformParameterModule.kt | 165 -------------- .../PlatformParameterSingletonImpl.kt | 6 + .../syncup/PlatformParameterSyncUpWorker.kt | 25 +- .../domain/audio/AudioPlayerControllerTest.kt | 2 + .../PlatformParameterSyncUpWorkerTest.kt | 65 +++++- .../ProfileManagementControllerTest.kt | 2 + model/src/main/proto/platform_parameter.proto | 2 + .../TestPlatformParameterConstants.kt | 19 -- .../TestPlatformParameterModule.kt | 12 - .../platformparameter/FeatureFlagConstants.kt | 213 ------------------ .../PlatformParameterValue.kt | 9 +- 13 files changed, 77 insertions(+), 773 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index c96261b5d8d..1b3293d56f5 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -30,40 +30,7 @@ import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON -import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.FlagEnableAppAndOsDeprecationIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableContinueButtonAnimationIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableDownloadsSupportIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableExtraTopicTabsUiIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableFastLanguageSwitchingInLessonIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableInteractionConfigChangeStateRetentionIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLanguageSelectionUiIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLearnerStudyAnalyticsIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLoggingLearnerStudyIdsIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnablePerformanceMetricsCollectionIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableSpotlightUiIsServerProvided import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS @@ -108,18 +75,6 @@ class PlatformParameterAlphaKenyaModule { fun provideEnableDownloadsSupport(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) - @Provides - @FlagEnableDownloadsSupportIsServerProvided - fun provideFlagEnableDownloadsSupportIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( @@ -149,18 +104,6 @@ class PlatformParameterAlphaKenyaModule { ) } - @Provides - @FlagEnableLanguageSelectionUiIsServerProvided - fun provideFlagEnableLanguageSelectionUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableEditAccountsOptionsUi fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { @@ -179,18 +122,6 @@ class PlatformParameterAlphaKenyaModule { ?: PlatformParameterValue.createDefaultParameter(true) } - @Provides - @FlagEnableLearnerStudyAnalyticsIsServerProvided - fun provideFlagEnableLearnerStudyAnalyticsIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableFastLanguageSwitchingInLesson fun provideFastInLessonLanguageSwitching( @@ -201,18 +132,6 @@ class PlatformParameterAlphaKenyaModule { ?: PlatformParameterValue.createDefaultParameter(true) } - @Provides - @FlagEnableFastLanguageSwitchingInLessonIsServerProvided - fun provideFlagEnableFastLanguageSwitchingInLessonIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableLoggingLearnerStudyIds fun provideLoggingLearnerStudyIds( @@ -223,18 +142,6 @@ class PlatformParameterAlphaKenyaModule { ?: PlatformParameterValue.createDefaultParameter(true) } - @Provides - @FlagEnableLoggingLearnerStudyIdsIsServerProvided - fun provideFlagEnableLoggingLearnerStudyIdsIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @CacheLatexRendering fun provideCacheLatexRendering( @@ -256,18 +163,6 @@ class PlatformParameterAlphaKenyaModule { ) } - @Provides - @FlagEnablePerformanceMetricsCollectionIsServerProvided - fun provideFlagEnablePerformanceMetricsCollectionIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @PerformanceMetricsCollectionUploadTimeIntervalInMinutes fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( @@ -312,18 +207,6 @@ class PlatformParameterAlphaKenyaModule { ) } - @Provides - @FlagEnableExtraTopicTabsUiIsServerProvided - fun provideFlagEnableExtraTopicTabsUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableInteractionConfigChangeStateRetention fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { @@ -332,18 +215,6 @@ class PlatformParameterAlphaKenyaModule { ) } - @Provides - @FlagEnableInteractionConfigChangeStateRetentionIsServerProvided - fun provideFlagEnableInteractionConfigChangeStateRetentionIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableContinueButtonAnimation fun provideEnableContinueButtonAnimation(): PlatformParameterValue { @@ -352,18 +223,6 @@ class PlatformParameterAlphaKenyaModule { ) } - @Provides - @FlagEnableContinueButtonAnimationIsServerProvided - fun provideFlagEnableContinueButtonAnimationIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableSpotlightUi fun enableSpotlightUi(): PlatformParameterValue { @@ -372,18 +231,6 @@ class PlatformParameterAlphaKenyaModule { ) } - @Provides - @FlagEnableSpotlightUiIsServerProvided - fun provideFlagEnableSpotlightUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableAppAndOsDeprecation fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { @@ -392,18 +239,6 @@ class PlatformParameterAlphaKenyaModule { ) } - @Provides - @FlagEnableAppAndOsDeprecationIsServerProvided - fun provideFlagEnableAppAndOsDeprecationIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 0781615bdee..8addae7b9fd 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -30,40 +30,7 @@ import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollecti import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.FlagEnableAppAndOsDeprecationIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableContinueButtonAnimationIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableDownloadsSupportIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableExtraTopicTabsUiIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableFastLanguageSwitchingInLessonIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableInteractionConfigChangeStateRetentionIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLanguageSelectionUiIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLearnerStudyAnalyticsIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLoggingLearnerStudyIdsIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnablePerformanceMetricsCollectionIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableSpotlightUiIsServerProvided import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS @@ -105,18 +72,6 @@ class PlatformParameterAlphaModule { fun provideEnableDownloadsSupport(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) - @Provides - @FlagEnableDownloadsSupportIsServerProvided - fun provideFlagEnableDownloadsSupportIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( @@ -146,18 +101,6 @@ class PlatformParameterAlphaModule { ) } - @Provides - @FlagEnableLanguageSelectionUiIsServerProvided - fun provideFlagEnableLanguageSelectionUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableEditAccountsOptionsUi fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { @@ -175,18 +118,6 @@ class PlatformParameterAlphaModule { ?: PlatformParameterValue.createDefaultParameter(true) } - @Provides - @FlagEnableLearnerStudyAnalyticsIsServerProvided - fun provideFlagEnableLearnerStudyAnalyticsIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableFastLanguageSwitchingInLesson fun provideFastInLessonLanguageSwitching( @@ -198,18 +129,6 @@ class PlatformParameterAlphaModule { ) } - @Provides - @FlagEnableFastLanguageSwitchingInLessonIsServerProvided - fun provideFlagEnableFastLanguageSwitchingInLessonIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableLoggingLearnerStudyIds fun provideLoggingLearnerStudyIds( @@ -219,18 +138,6 @@ class PlatformParameterAlphaModule { ?: PlatformParameterValue.createDefaultParameter(LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE) } - @Provides - @FlagEnableLoggingLearnerStudyIdsIsServerProvided - fun provideFlagEnableLoggingLearnerStudyIdsIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @CacheLatexRendering fun provideCacheLatexRendering( @@ -252,18 +159,6 @@ class PlatformParameterAlphaModule { ) } - @Provides - @FlagEnablePerformanceMetricsCollectionIsServerProvided - fun provideFlagEnablePerformanceMetricsCollectionIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @PerformanceMetricsCollectionUploadTimeIntervalInMinutes fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( @@ -305,18 +200,6 @@ class PlatformParameterAlphaModule { fun provideEnableSpotlightUi(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(true) // Enable spotlights for alpha users. - @Provides - @FlagEnableSpotlightUiIsServerProvided - fun provideFlagEnableSpotlightUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableExtraTopicTabsUi fun provideEnableExtraTopicTabsUi(): PlatformParameterValue { @@ -325,18 +208,6 @@ class PlatformParameterAlphaModule { ) } - @Provides - @FlagEnableExtraTopicTabsUiIsServerProvided - fun provideFlagEnableExtraTopicTabsUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableInteractionConfigChangeStateRetention fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { @@ -345,18 +216,6 @@ class PlatformParameterAlphaModule { ) } - @Provides - @FlagEnableInteractionConfigChangeStateRetentionIsServerProvided - fun provideFlagEnableInteractionConfigChangeStateRetentionIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableContinueButtonAnimation fun provideEnableContinueButtonAnimation(): PlatformParameterValue { @@ -365,18 +224,6 @@ class PlatformParameterAlphaModule { ) } - @Provides - @FlagEnableContinueButtonAnimationIsServerProvided - fun provideFlagEnableContinueButtonAnimationIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableAppAndOsDeprecation fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { @@ -385,18 +232,6 @@ class PlatformParameterAlphaModule { ) } - @Provides - @FlagEnableAppAndOsDeprecationIsServerProvided - fun provideFlagEnableAppAndOsDeprecationIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index b7c83c3734c..c2a211472fc 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -31,40 +31,7 @@ import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollecti import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED -import org.oppia.android.util.platformparameter.FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.FlagEnableAppAndOsDeprecationIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableContinueButtonAnimationIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableDownloadsSupportIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableExtraTopicTabsUiIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableFastLanguageSwitchingInLessonIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableInteractionConfigChangeStateRetentionIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLanguageSelectionUiIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLearnerStudyAnalyticsIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableLoggingLearnerStudyIdsIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnablePerformanceMetricsCollectionIsServerProvided -import org.oppia.android.util.platformparameter.FlagEnableSpotlightUiIsServerProvided import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE @@ -107,18 +74,6 @@ class PlatformParameterModule { fun provideEnableDownloadsSupport(): PlatformParameterValue = PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) - @Provides - @FlagEnableDownloadsSupportIsServerProvided - fun provideFlagEnableDownloadsSupportIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( @@ -148,18 +103,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnableLanguageSelectionUiIsServerProvided - fun provideFlagEnableLanguageSelectionUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableEditAccountsOptionsUi fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { @@ -177,18 +120,6 @@ class PlatformParameterModule { ?: PlatformParameterValue.createDefaultParameter(LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE) } - @Provides - @FlagEnableLearnerStudyAnalyticsIsServerProvided - fun provideFlagEnableLearnerStudyAnalyticsIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableFastLanguageSwitchingInLesson fun provideFastInLessonLanguageSwitching( @@ -200,18 +131,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnableFastLanguageSwitchingInLessonIsServerProvided - fun provideFlagEnableFastLanguageSwitchingInLessonIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableLoggingLearnerStudyIds fun provideLoggingLearnerStudyIds( @@ -221,18 +140,6 @@ class PlatformParameterModule { ?: PlatformParameterValue.createDefaultParameter(LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE) } - @Provides - @FlagEnableLoggingLearnerStudyIdsIsServerProvided - fun provideFlagEnableLoggingLearnerStudyIdsIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @CacheLatexRendering fun provideCacheLatexRendering( @@ -254,18 +161,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnablePerformanceMetricsCollectionIsServerProvided - fun provideFlagEnablePerformanceMetricsCollectionIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @PerformanceMetricsCollectionUploadTimeIntervalInMinutes fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( @@ -310,18 +205,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnableSpotlightUiIsServerProvided - fun provideFlagEnableSpotlightUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableExtraTopicTabsUi fun provideEnableExtraTopicTabsUi(): PlatformParameterValue { @@ -330,18 +213,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnableExtraTopicTabsUiIsServerProvided - fun provideFlagEnableExtraTopicTabsUiIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableInteractionConfigChangeStateRetention fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { @@ -350,18 +221,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnableInteractionConfigChangeStateRetentionIsServerProvided - fun provideFlagEnableInteractionConfigChangeStateRetentionIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableContinueButtonAnimation fun provideEnableContinueButtonAnimation(): PlatformParameterValue { @@ -370,18 +229,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnableContinueButtonAnimationIsServerProvided - fun provideFlagEnableContinueButtonAnimationIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @EnableAppAndOsDeprecation fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { @@ -390,18 +237,6 @@ class PlatformParameterModule { ) } - @Provides - @FlagEnableAppAndOsDeprecationIsServerProvided - fun provideFlagEnableAppAndOsDeprecationIsServerProvided( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt index b672ad6cdf9..9d00ea77ed2 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt @@ -26,6 +26,8 @@ class PlatformParameterSingletonImpl @Inject constructor() : PlatformParameterSi return object : PlatformParameterValue { override val value: String get() = parameter.string + override val isSynced: Boolean + get() = parameter.isSynced } } @@ -38,6 +40,8 @@ class PlatformParameterSingletonImpl @Inject constructor() : PlatformParameterSi return object : PlatformParameterValue { override val value: Int get() = parameter.integer + override val isSynced: Boolean + get() = parameter.isSynced } } @@ -50,6 +54,8 @@ class PlatformParameterSingletonImpl @Inject constructor() : PlatformParameterSi return object : PlatformParameterValue { override val value: Boolean get() = parameter.boolean + override val isSynced: Boolean + get() = parameter.isSynced } } } diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt index 645012e1f79..5232d8eedba 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt @@ -81,7 +81,7 @@ class PlatformParameterSyncUpWorker private constructor( */ private fun parseNetworkResponse(response: Map): List { return response.map { - val platformParameter = PlatformParameter.newBuilder().setName(it.key) + val platformParameter = PlatformParameter.newBuilder().setName(it.key).setIsSynced(true) when (val value = it.value) { is String -> platformParameter.string = value is Int -> platformParameter.integer = value @@ -112,12 +112,11 @@ class PlatformParameterSyncUpWorker private constructor( val responseBody = checkNotNull(response.body()) val platformParameterList = parseNetworkResponse(responseBody) - val platformParameterListWithSyncStatusFlags = platformParameterList.addSyncStatusFlags() - if (platformParameterListWithSyncStatusFlags.isEmpty()) { + if (platformParameterList.isEmpty()) { throw IllegalArgumentException(EMPTY_RESPONSE_EXCEPTION_MSG) } val cachingResult = platformParameterController - .updatePlatformParameterDatabase(platformParameterListWithSyncStatusFlags) + .updatePlatformParameterDatabase(platformParameterList) .retrieveData() if (cachingResult is AsyncResult.Failure) { throw IllegalStateException(cachingResult.error) @@ -134,24 +133,6 @@ class PlatformParameterSyncUpWorker private constructor( } } - private fun List.addSyncStatusFlags(): List { - val modifiedList = mutableListOf() - - for (param in this) { - modifiedList.add(param) - val syncStatusParamName = "flag_" + param.name + "_is_server_provided" - - val paramSyncStatusTracker = PlatformParameter.newBuilder().apply { - name = syncStatusParamName - boolean = true // Indicates that sync status flags are up to date since they are local only - } - .build() - modifiedList.add(paramSyncStatusTracker) - } - - return modifiedList - } - /** Creates an instance of [PlatformParameterSyncUpWorker] by properly injecting dependencies. */ class Factory @Inject constructor( private val platformParameterController: PlatformParameterController, diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index 1730f091d1b..3d9b4bf8408 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -843,6 +843,7 @@ class AudioPlayerControllerTest { val enableFeature = enableLearnerStudyAnalytics return object : PlatformParameterValue { override val value: Boolean = enableFeature + override val isSynced: Boolean = false } } @@ -854,6 +855,7 @@ class AudioPlayerControllerTest { val enableFeature = enableLearnerStudyAnalytics return object : PlatformParameterValue { override val value: Boolean = enableFeature + override val isSynced: Boolean = false } } } diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt index aca0317b11e..6737bc6066f 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt @@ -43,7 +43,6 @@ import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.network.MockPlatformParameterService import org.oppia.android.testing.network.RetrofitTestModule -import org.oppia.android.testing.platformparameter.FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_SERVER_VALUE import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_DEFAULT_VALUE @@ -51,7 +50,6 @@ import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_INTEGER_PARAM_SERVER_VALUE import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SERVER_VALUE -import org.oppia.android.testing.platformparameter.TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule @@ -97,26 +95,25 @@ class PlatformParameterSyncUpWorkerTest { private val expectedTestStringParameter = PlatformParameter.newBuilder() .setName(TEST_STRING_PARAM_NAME) .setString(TEST_STRING_PARAM_SERVER_VALUE) + .setIsSynced(true) .build() private val expectedTestIntegerParameter = PlatformParameter.newBuilder() .setName(TEST_INTEGER_PARAM_NAME) .setInteger(TEST_INTEGER_PARAM_SERVER_VALUE) + .setIsSynced(true) .build() private val defaultTestIntegerParameter = PlatformParameter.newBuilder() .setName(TEST_INTEGER_PARAM_NAME) .setInteger(TEST_INTEGER_PARAM_DEFAULT_VALUE) + .setIsSynced(false) .build() private val expectedTestBooleanParameter = PlatformParameter.newBuilder() .setName(TEST_BOOLEAN_PARAM_NAME) .setBoolean(TEST_BOOLEAN_PARAM_SERVER_VALUE) - .build() - - private val expectedTestStringParameterFlagStatus = PlatformParameter.newBuilder() - .setName(FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED) - .setBoolean(TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE) + .setIsSynced(true) .build() // Not including "expectedTestBooleanParameter" in this list to prove that a refresh took place @@ -360,10 +357,56 @@ class PlatformParameterSyncUpWorkerTest { // Values retrieved from Cache store will be sent to Platform Parameter Singleton by the // Controller in the form of a Map, therefore verify the retrieved values from that Map. - val platformParameterMapFlagStatus = platformParameterSingleton.getPlatformParameterMap() - assertThat(platformParameterMapFlagStatus).containsEntry( - FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED, expectedTestStringParameterFlagStatus - ) + val platformParameterMap = platformParameterSingleton.getPlatformParameterMap() + + // Previous String Platform Parameter is still same in the Database. + assertThat(platformParameterMap) + .containsEntry(TEST_STRING_PARAM_NAME, expectedTestStringParameter) + + // Is synced boolean of the platform parameter is true + assertThat(platformParameterMap[TEST_STRING_PARAM_NAME]!!.isSynced).isEqualTo(true) + } + + @Test + fun testSyncUpWorker_databaseNotEmpty_getEmptyResponse_verifySyncStatusNotUpdated() { + // Set up versionName to get incorrect network response from mock platform parameter service. + setUpApplicationForContext(MockPlatformParameterService.appVersionForEmptyResponse) + + // Fill the Platform Parameter Database with mock values to simulate the execution of a SyncUp + // Work request that is not first. + platformParameterController.updatePlatformParameterDatabase(mockPlatformParameterList) + + val workManager = WorkManager.getInstance(context) + + val inputData = Data.Builder().putString( + PlatformParameterSyncUpWorker.WORKER_TYPE_KEY, + PlatformParameterSyncUpWorker.PLATFORM_PARAMETER_WORKER + ).build() + + val request: OneTimeWorkRequest = OneTimeWorkRequestBuilder() + .setInputData(inputData) + .build() + + // Enqueue the Work Request to fetch and cache the Platform Parameters from Remote Service. + workManager.enqueue(request) + testCoroutineDispatchers.runCurrent() + + val workInfo = workManager.getWorkInfoById(request.id) + assertThat(workInfo.get().state).isEqualTo(WorkInfo.State.FAILED) + + val exceptionMessage = fakeExceptionLogger.getMostRecentException().message + assertThat(exceptionMessage) + .isEqualTo(PlatformParameterSyncUpWorker.EMPTY_RESPONSE_EXCEPTION_MSG) + + // Retrieve the previously cached Platform Parameters from Cache Store. + monitorFactory.ensureDataProviderExecutes(platformParameterController.getParameterDatabase()) + + // Values retrieved from Cache store will be sent to Platform Parameter Singleton by the + // Controller in the form of a Map, therefore verify the retrieved values from that Map. + val platformParameterMap = platformParameterSingleton.getPlatformParameterMap() + + // Previous integer sync status is still the same in the database + assertThat(platformParameterMap[TEST_INTEGER_PARAM_NAME]!!.isSynced).isEqualTo(false) } private fun setUpTestApplicationComponent() { diff --git a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt index 62733f8119c..71b1798f1b1 100644 --- a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt @@ -1358,6 +1358,7 @@ class ProfileManagementControllerTest { val enableFeature = enableLearnerStudyAnalytics return object : PlatformParameterValue { override val value: Boolean = enableFeature + override val isSynced: Boolean = true } } @@ -1369,6 +1370,7 @@ class ProfileManagementControllerTest { val enableFeature = enableLearnerStudyAnalytics return object : PlatformParameterValue { override val value: Boolean = enableFeature + override val isSynced: Boolean = true } } } diff --git a/model/src/main/proto/platform_parameter.proto b/model/src/main/proto/platform_parameter.proto index 67f9fd6d772..b42ea11d909 100644 --- a/model/src/main/proto/platform_parameter.proto +++ b/model/src/main/proto/platform_parameter.proto @@ -18,6 +18,8 @@ message PlatformParameter { // Indicates a string-typed platform parameter. string string = 4; } + // Indicates that the platform parameter is synced + bool is_synced = 5; } // Format of platform parameters stored on disk. It closely resembles the JSON response in cache. diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt index 567184a9bdd..a904314f795 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt @@ -25,25 +25,6 @@ const val TEST_STRING_PARAM_DEFAULT_VALUE = "test_string_param_default_value" */ const val TEST_STRING_PARAM_SERVER_VALUE = "test_string_param_value" -/** - * Feature flag sync status name for the test string platform parameter. This name helps retrieve - * the sync status of the [TestStringParam]. Only used in tests related to platform parameter. - */ -const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED = - "flag_test_string_param_name_is_server_provided" - -/** - * Default value for the feature flag sync status tracker for the [TestStringParam]. Only used in - * tests related to platform parameter. - */ -const val FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - -/** - * Server value for the test string platform parameter. Only used in tests related to platform - * parameter. - */ -const val TEST_STRING_PARAM_SYNC_STATUS_FLAG_SERVER_VALUE = true - /** * Qualifier for test boolean platform parameter. Only used in tests related to platform parameter. */ diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 2e0d35203e1..7ff02772a65 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -99,18 +99,6 @@ class TestPlatformParameterModule { ?: PlatformParameterValue.createDefaultParameter(TEST_BOOLEAN_PARAM_DEFAULT_VALUE) } - @Provides - @Singleton - fun provideFlagTestStringParam( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED - ) ?: PlatformParameterValue.createDefaultParameter( - FLAG_TEST_STRING_PARAM_IS_SERVER_PROVIDED_DEFAULT_VALUE - ) - } - @Provides @SplashScreenWelcomeMsg fun provideSplashScreenWelcomeMsgParam( diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index b7045b20772..a785a61d836 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -21,23 +21,6 @@ import javax.inject.Qualifier /** Default value for feature flag corresponding to [EnableDownloadsSupport]. */ const val ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableDownloadsSupport] and help determine - * if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableDownloadsSupportIsServerProvided - -/** The feature flag name corresponding to [FlagEnableDownloadsSupportIsServerProvided]. */ -const val FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED = - "flag_enable_downloads_support_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableDownloadsSupportIsServerProvided]. - */ -const val FLAG_ENABLE_DOWNLOADS_SUPPORT_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** Qualifier for the feature flag corresponding to enabling the language selection UI. */ @Qualifier annotation class EnableLanguageSelectionUi @@ -45,23 +28,6 @@ annotation class EnableLanguageSelectionUi /** Default value for the feature flag corresponding to [EnableLanguageSelectionUi]. */ const val ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE = true -/** - * Qualifier to keep track of the sync status of the [EnableLanguageSelectionUi] and help determine - * if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableLanguageSelectionUiIsServerProvided - -/** The feature flag name corresponding to [FlagEnableLanguageSelectionUiIsServerProvided]. */ -const val FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED = - "flag_enable_language_selection_ui_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableLanguageSelectionUiIsServerProvided]. - */ -const val FLAG_ENABLE_LANGUAGE_SELECTION_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** * Qualifier for the feature flag corresponding to enabling the extra topic tabs: practice and info. */ @@ -71,23 +37,6 @@ annotation class EnableExtraTopicTabsUi /** Default value for the feature flag corresponding to [EnableExtraTopicTabsUi]. */ const val ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableExtraTopicTabsUi] and help determine - * if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableExtraTopicTabsUiIsServerProvided - -/** The feature flag name corresponding to [FlagEnableExtraTopicTabsUiIsServerProvided]. */ -const val FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED = - "flag_enable_extra_topic_tabs_ui_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableExtraTopicTabsUiIsServerProvided]. - */ -const val FLAG_ENABLE_EXTRA_TOPIC_TABS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** * Qualifier for the feature flag that controls the visibility of [ProfileAndDeviceIdActivity] * and working of learner study related analytics logging. @@ -107,23 +56,6 @@ const val LEARNER_STUDY_ANALYTICS = "learner_study_analytics" */ const val LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableLearnerStudyAnalytics] and help - * determine if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableLearnerStudyAnalyticsIsServerProvided - -/** The feature flag name corresponding to [FlagEnableLearnerStudyAnalyticsIsServerProvided]. */ -const val FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED = - "flag_enable_learner_study_analytics_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableLearnerStudyAnalyticsIsServerProvided]. - */ -const val FLAG_ENABLE_LEARNER_STUDY_ANALYTICS_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** * Qualifier for a feature flag that controls whether learners may be allowed (via an * admin-controlled setting) to use a special in-lesson button for quickly switching between content @@ -141,26 +73,6 @@ const val FAST_LANGUAGE_SWITCHING_IN_LESSON = "fast_language_switching_in_lesson */ const val FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableFastLanguageSwitchingInLesson] and help - * determine if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableFastLanguageSwitchingInLessonIsServerProvided - -/** - * The feature flag name corresponding to - * [FlagEnableFastLanguageSwitchingInLessonIsServerProvided]. - */ -const val FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED = - "flag_enable_fast_language_switching_in_lesson_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableFastLanguageSwitchingInLessonIsServerProvided]. - */ -const val FLAG_ENABLE_FAST_LANGUAGE_SWITCHING_IN_LESSON_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** * Qualifier for a feature flag that controls whether learner study IDs should be generated and * logged with outgoing events. @@ -175,23 +87,6 @@ const val LOGGING_LEARNER_STUDY_IDS = "logging_learner_study_ids" /** The default enabled state for the feature corresponding to [EnableLoggingLearnerStudyIds]. */ const val LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableLoggingLearnerStudyIds] and help - * determine if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableLoggingLearnerStudyIdsIsServerProvided - -/** The feature flag name corresponding to [FlagEnableLoggingLearnerStudyIdsIsServerProvided]. */ -const val FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED = - "flag_enable_logging_learner_study_ids_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableLoggingLearnerStudyIdsIsServerProvided]. - */ -const val FLAG_ENABLE_LOGGING_LEARNER_STUDY_IDS_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** Qualifier for the feature flag corresponding to enabling the edit accounts options. */ @Qualifier annotation class EnableEditAccountsOptionsUi @@ -199,23 +94,6 @@ annotation class EnableEditAccountsOptionsUi /** Default value for the feature flag corresponding to [EnableEditAccountsOptionsUi]. */ const val ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableEditAccountsOptionsUi] and help - * determine if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableEditAccountsOptionsUiIsServerProvided - -/** The feature flag name corresponding to [FlagEnableEditAccountsOptionsUiIsServerProvided]. */ -const val FLAG_ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_IS_SERVER_PROVIDED = - "flag_enable_edit_accounts_options_ui_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableEditAccountsOptionsUiIsServerProvided]. - */ -const val FLAG_ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** Qualifier for the feature flag that controls whether to record performance metrics. */ @Qualifier annotation class EnablePerformanceMetricsCollection @@ -226,25 +104,6 @@ const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "enable_performance_metrics_co /** Default value for whether to record performance metrics. */ const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnablePerformanceMetricsCollection] and help - * determine if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnablePerformanceMetricsCollectionIsServerProvided - -/** - * The feature flag name corresponding to [FlagEnablePerformanceMetricsCollectionIsServerProvided]. - */ -const val FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED = - "flag_enable_performance_metrics_collection_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnablePerformanceMetricsCollectionIsServerProvided]. - */ -const val FLAG_ENABLE_PERFORMANCE_METRICS_COLLECTION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** * Qualifier for the feature flag that controls whether to animate the continue button * interaction and navigation items. This is used to disable the animation during testing because @@ -256,23 +115,6 @@ annotation class EnableContinueButtonAnimation /** Default value for whether to enable continue button animation. */ const val ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE = true -/** - * Qualifier to keep track of the sync status of the [EnableContinueButtonAnimation] and help - * determine if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableContinueButtonAnimationIsServerProvided - -/** The feature flag name corresponding to [FlagEnableContinueButtonAnimationIsServerProvided]. */ -const val FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED = - "flag_enable_continue_button_animation_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableContinueButtonAnimationIsServerProvided]. - */ -const val FLAG_ENABLE_CONTINUE_BUTTON_ANIMATION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** Qualifier for the feature flag corresponding to enabling the spotlight UI. */ @Qualifier annotation class EnableSpotlightUi @@ -280,23 +122,6 @@ annotation class EnableSpotlightUi /** Default value for the feature flag corresponding to [EnableSpotlightUi]. */ const val ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableSpotlightUi] and help determine - * if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableSpotlightUiIsServerProvided - -/** The feature flag name corresponding to [FlagEnableSpotlightUiIsServerProvided]. */ -const val FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED = - "flag_enable_spotlight_ui_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableSpotlightUiIsServerProvided]. - */ -const val FLAG_ENABLE_SPOTLIGHT_UI_IS_SERVER_PROVIDED_DEFAULT_VALUE = false - /** * Qualifier for the feature flag that controls whether input interaction state is correctly * retained across configuration changes. @@ -309,27 +134,6 @@ annotation class EnableInteractionConfigChangeStateRetention */ const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false -/** - * Qualifier to keep track of the sync status of the [EnableInteractionConfigChangeStateRetention] - * and help determine if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableInteractionConfigChangeStateRetentionIsServerProvided - -/** - * The feature flag name corresponding to - * [FlagEnableInteractionConfigChangeStateRetentionIsServerProvided]. - */ -const val FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED = - "flag_enable_interaction_config_change_state_retention_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableInteractionConfigChangeStateRetentionIsServerProvided]. - */ -const val FLAG_ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_IS_SERVER_PROVIDED_DEFAULT_VALUE = - false - /** * Qualifier for the [EnableAppAndOsDeprecation] feature flag that controls whether to enable * app and OS deprecation or not. @@ -341,20 +145,3 @@ annotation class EnableAppAndOsDeprecation * Default value for the feature flag corresponding to [EnableAppAndOsDeprecation]. */ const val ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false - -/** - * Qualifier to keep track of the sync status of the [EnableAppAndOsDeprecation] and help determine - * if the value of the feature flag is server-provided or default. - */ -@Qualifier -annotation class FlagEnableAppAndOsDeprecationIsServerProvided - -/** The feature flag name corresponding to [FlagEnableAppAndOsDeprecationIsServerProvided]. */ -const val FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED = - "flag_enable_app_and_os_deprecation_is_server_provided" - -/** - * Default value for the feature flag sync status tracker corresponding to - * [FlagEnableAppAndOsDeprecationIsServerProvided]. - */ -const val FLAG_ENABLE_APP_AND_OS_DEPRECATION_IS_SERVER_PROVIDED_DEFAULT_VALUE = false diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt index 309574d9660..b2e3dafc6ab 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt @@ -9,16 +9,23 @@ import org.oppia.android.app.model.PlatformParameter */ interface PlatformParameterValue { val value: T + val isSynced: Boolean companion object { /** * Creates a Platform Parameter Implementation containing the default value for a particular * Platform Parameter */ - fun createDefaultParameter(defaultValue: T): PlatformParameterValue { + fun createDefaultParameter( + defaultValue: T, + defaultIsSynced: Boolean = false + ): PlatformParameterValue { return object : PlatformParameterValue { override val value: T get() = defaultValue + + override val isSynced: Boolean + get() = defaultIsSynced } } } From 7ee1fd817e0e415e93297a63c0e6d6575fecf195 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 7 Nov 2023 13:33:41 +0300 Subject: [PATCH 14/66] fix: Fix failing EventBundleCreator tests --- .../org/oppia/android/util/logging/EventBundleCreatorTest.kt | 1 + .../android/util/logging/KenyaAlphaEventBundleCreatorTest.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt index d2062e9097f..10bcfe91263 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt @@ -2416,6 +2416,7 @@ class EventBundleCreatorTest { val enableFeature = enableLoggingLearnerStudyIds return object : PlatformParameterValue { override val value: Boolean = enableFeature + override val isSynced: Boolean = false } } } diff --git a/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt b/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt index 562f16b4337..1d50bc1b42d 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt @@ -1583,6 +1583,7 @@ class KenyaAlphaEventBundleCreatorTest { val enableFeature = enableLoggingLearnerStudyIds return object : PlatformParameterValue { override val value: Boolean = enableFeature + override val isSynced: Boolean = false } } } From b9f28bad5c4247d8194a003988a1264dc13ee096 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 14 Nov 2023 12:46:26 +0300 Subject: [PATCH 15/66] feat: Make Sync status an enum --- .../analytics/ApplicationLifecycleObserver.kt | 1 + .../PlatformParameterSingletonImpl.kt | 18 ++++------ .../syncup/PlatformParameterSyncUpWorker.kt | 4 ++- .../domain/audio/AudioPlayerControllerTest.kt | 14 ++++---- .../PlatformParameterSyncUpWorkerTest.kt | 33 +++++++++---------- .../ProfileManagementControllerTest.kt | 14 ++++---- model/src/main/proto/platform_parameter.proto | 15 +++++++-- .../PlatformParameterValue.kt | 12 +++---- .../util/logging/EventBundleCreatorTest.kt | 7 ++-- .../KenyaAlphaEventBundleCreatorTest.kt | 7 ++-- 10 files changed, 61 insertions(+), 64 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index 8a4504b4372..2d62cdcd639 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -1,3 +1,4 @@ + package org.oppia.android.domain.oppialogger.analytics import android.app.Activity diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt index 9d00ea77ed2..0a72d4b6b44 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt @@ -24,10 +24,8 @@ class PlatformParameterSingletonImpl @Inject constructor() : PlatformParameterSi val parameter = platformParameterMap[platformParameterName] ?: return null if (!parameter.valueTypeCase.equals(PlatformParameter.ValueTypeCase.STRING)) return null return object : PlatformParameterValue { - override val value: String - get() = parameter.string - override val isSynced: Boolean - get() = parameter.isSynced + override val value = parameter.string + override val syncStatus = parameter.syncStatus } } @@ -38,10 +36,8 @@ class PlatformParameterSingletonImpl @Inject constructor() : PlatformParameterSi val parameter = platformParameterMap[platformParameterName] ?: return null if (!parameter.valueTypeCase.equals(PlatformParameter.ValueTypeCase.INTEGER)) return null return object : PlatformParameterValue { - override val value: Int - get() = parameter.integer - override val isSynced: Boolean - get() = parameter.isSynced + override val value = parameter.integer + override val syncStatus = parameter.syncStatus } } @@ -52,10 +48,8 @@ class PlatformParameterSingletonImpl @Inject constructor() : PlatformParameterSi val parameter = platformParameterMap[platformParameterName] ?: return null if (!parameter.valueTypeCase.equals(PlatformParameter.ValueTypeCase.BOOLEAN)) return null return object : PlatformParameterValue { - override val value: Boolean - get() = parameter.boolean - override val isSynced: Boolean - get() = parameter.isSynced + override val value = parameter.boolean + override val syncStatus = parameter.syncStatus } } } diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt index 5232d8eedba..164f7fea914 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.app.model.PlatformParameter.SyncStatus import org.oppia.android.app.utility.getVersionName import org.oppia.android.data.backends.gae.api.PlatformParameterService import org.oppia.android.domain.oppialogger.OppiaLogger @@ -81,7 +82,8 @@ class PlatformParameterSyncUpWorker private constructor( */ private fun parseNetworkResponse(response: Map): List { return response.map { - val platformParameter = PlatformParameter.newBuilder().setName(it.key).setIsSynced(true) + val platformParameter = PlatformParameter.newBuilder().setName(it.key) + .setSyncStatus(SyncStatus.SYNCED_FROM_SERVER) when (val value = it.value) { is String -> platformParameter.string = value is Int -> platformParameter.integer = value diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index 3d9b4bf8408..1854ec26330 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -841,10 +841,9 @@ class AudioPlayerControllerTest { fun provideLearnerStudyAnalytics(): PlatformParameterValue { // Snapshot the value so that it doesn't change between injection and use. val enableFeature = enableLearnerStudyAnalytics - return object : PlatformParameterValue { - override val value: Boolean = enableFeature - override val isSynced: Boolean = false - } + return PlatformParameterValue.createDefaultParameter( + defaultValue = enableFeature + ) } @Provides @@ -853,10 +852,9 @@ class AudioPlayerControllerTest { fun provideLoggingLearnerStudyIds(): PlatformParameterValue { // Snapshot the value so that it doesn't change between injection and use. val enableFeature = enableLearnerStudyAnalytics - return object : PlatformParameterValue { - override val value: Boolean = enableFeature - override val isSynced: Boolean = false - } + return PlatformParameterValue.createDefaultParameter( + defaultValue = enableFeature + ) } } diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt index 6737bc6066f..82e756c79e6 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorkerTest.kt @@ -25,6 +25,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.app.model.PlatformParameter.SyncStatus import org.oppia.android.data.backends.gae.BaseUrl import org.oppia.android.data.backends.gae.JsonPrefixNetworkInterceptor import org.oppia.android.data.backends.gae.NetworkApiKey @@ -95,25 +96,25 @@ class PlatformParameterSyncUpWorkerTest { private val expectedTestStringParameter = PlatformParameter.newBuilder() .setName(TEST_STRING_PARAM_NAME) .setString(TEST_STRING_PARAM_SERVER_VALUE) - .setIsSynced(true) + .setSyncStatus(SyncStatus.SYNCED_FROM_SERVER) .build() private val expectedTestIntegerParameter = PlatformParameter.newBuilder() .setName(TEST_INTEGER_PARAM_NAME) .setInteger(TEST_INTEGER_PARAM_SERVER_VALUE) - .setIsSynced(true) + .setSyncStatus(SyncStatus.SYNCED_FROM_SERVER) .build() private val defaultTestIntegerParameter = PlatformParameter.newBuilder() .setName(TEST_INTEGER_PARAM_NAME) .setInteger(TEST_INTEGER_PARAM_DEFAULT_VALUE) - .setIsSynced(false) + .setSyncStatus(SyncStatus.NOT_SYNCED_FROM_SERVER) .build() private val expectedTestBooleanParameter = PlatformParameter.newBuilder() .setName(TEST_BOOLEAN_PARAM_NAME) .setBoolean(TEST_BOOLEAN_PARAM_SERVER_VALUE) - .setIsSynced(true) + .setSyncStatus(SyncStatus.SYNCED_FROM_SERVER) .build() // Not including "expectedTestBooleanParameter" in this list to prove that a refresh took place @@ -349,9 +350,6 @@ class PlatformParameterSyncUpWorkerTest { workManager.enqueue(request) testCoroutineDispatchers.runCurrent() - val workInfo = workManager.getWorkInfoById(request.id) - assertThat(workInfo.get().state).isEqualTo(WorkInfo.State.SUCCEEDED) - // Retrieve the previously cached Platform Parameters from Cache Store. monitorFactory.ensureDataProviderExecutes(platformParameterController.getParameterDatabase()) @@ -363,8 +361,9 @@ class PlatformParameterSyncUpWorkerTest { assertThat(platformParameterMap) .containsEntry(TEST_STRING_PARAM_NAME, expectedTestStringParameter) - // Is synced boolean of the platform parameter is true - assertThat(platformParameterMap[TEST_STRING_PARAM_NAME]!!.isSynced).isEqualTo(true) + // SyncStatus of the platform parameter is SYNCED_FROM_SERVER + assertThat(platformParameterMap[TEST_STRING_PARAM_NAME]?.syncStatus) + .isEqualTo(SyncStatus.SYNCED_FROM_SERVER) } @Test @@ -391,13 +390,6 @@ class PlatformParameterSyncUpWorkerTest { workManager.enqueue(request) testCoroutineDispatchers.runCurrent() - val workInfo = workManager.getWorkInfoById(request.id) - assertThat(workInfo.get().state).isEqualTo(WorkInfo.State.FAILED) - - val exceptionMessage = fakeExceptionLogger.getMostRecentException().message - assertThat(exceptionMessage) - .isEqualTo(PlatformParameterSyncUpWorker.EMPTY_RESPONSE_EXCEPTION_MSG) - // Retrieve the previously cached Platform Parameters from Cache Store. monitorFactory.ensureDataProviderExecutes(platformParameterController.getParameterDatabase()) @@ -405,8 +397,13 @@ class PlatformParameterSyncUpWorkerTest { // Controller in the form of a Map, therefore verify the retrieved values from that Map. val platformParameterMap = platformParameterSingleton.getPlatformParameterMap() - // Previous integer sync status is still the same in the database - assertThat(platformParameterMap[TEST_INTEGER_PARAM_NAME]!!.isSynced).isEqualTo(false) + // Previous Integer Platform Parameter is still same in the Database. + assertThat(platformParameterMap) + .containsEntry(TEST_INTEGER_PARAM_NAME, defaultTestIntegerParameter) + + // SyncStatus of the platform parameter is still the same in the database + assertThat(platformParameterMap[TEST_INTEGER_PARAM_NAME]?.syncStatus) + .isEqualTo(SyncStatus.NOT_SYNCED_FROM_SERVER) } private fun setUpTestApplicationComponent() { diff --git a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt index 71b1798f1b1..e95142771be 100644 --- a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt @@ -1356,10 +1356,9 @@ class ProfileManagementControllerTest { fun provideLearnerStudyAnalytics(): PlatformParameterValue { // Snapshot the value so that it doesn't change between injection and use. val enableFeature = enableLearnerStudyAnalytics - return object : PlatformParameterValue { - override val value: Boolean = enableFeature - override val isSynced: Boolean = true - } + return PlatformParameterValue.createDefaultParameter( + defaultValue = enableFeature + ) } @Provides @@ -1368,10 +1367,9 @@ class ProfileManagementControllerTest { fun provideLoggingLearnerStudyIds(): PlatformParameterValue { // Snapshot the value so that it doesn't change between injection and use. val enableFeature = enableLearnerStudyAnalytics - return object : PlatformParameterValue { - override val value: Boolean = enableFeature - override val isSynced: Boolean = true - } + return PlatformParameterValue.createDefaultParameter( + defaultValue = enableFeature + ) } } diff --git a/model/src/main/proto/platform_parameter.proto b/model/src/main/proto/platform_parameter.proto index b42ea11d909..58e45f8325c 100644 --- a/model/src/main/proto/platform_parameter.proto +++ b/model/src/main/proto/platform_parameter.proto @@ -18,8 +18,19 @@ message PlatformParameter { // Indicates a string-typed platform parameter. string string = 4; } - // Indicates that the platform parameter is synced - bool is_synced = 5; + // Indicates the sync status of the platform parameter. + SyncStatus sync_status = 5; + + enum SyncStatus { + // Indicates that the sync status isn't yet known. + SYNC_STATUS_UNSPECIFIED = 0; + + // Indicates that the parameter isn't yet synced with the remote server. + NOT_SYNCED_FROM_SERVER = 1; + + // Indicates the parameter's value has been synced with the remote server. + SYNCED_FROM_SERVER = 2; + } } // Format of platform parameters stored on disk. It closely resembles the JSON response in cache. diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt index b2e3dafc6ab..51523f0134f 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt @@ -1,6 +1,7 @@ package org.oppia.android.util.platformparameter import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.app.model.PlatformParameter.SyncStatus /** * Generic interface that is used to provide platform parameter values corresponding to the @@ -9,7 +10,7 @@ import org.oppia.android.app.model.PlatformParameter */ interface PlatformParameterValue { val value: T - val isSynced: Boolean + val syncStatus: SyncStatus companion object { /** @@ -18,14 +19,11 @@ interface PlatformParameterValue { */ fun createDefaultParameter( defaultValue: T, - defaultIsSynced: Boolean = false + defaultIsSynced: SyncStatus = SyncStatus.NOT_SYNCED_FROM_SERVER ): PlatformParameterValue { return object : PlatformParameterValue { - override val value: T - get() = defaultValue - - override val isSynced: Boolean - get() = defaultIsSynced + override val value = defaultValue + override val syncStatus = defaultIsSynced } } } diff --git a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt index 10bcfe91263..db424118e1f 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt @@ -2414,10 +2414,9 @@ class EventBundleCreatorTest { fun provideLoggingLearnerStudyIds(): PlatformParameterValue { // Snapshot the value so that it doesn't change between injection and use. val enableFeature = enableLoggingLearnerStudyIds - return object : PlatformParameterValue { - override val value: Boolean = enableFeature - override val isSynced: Boolean = false - } + return PlatformParameterValue.createDefaultParameter( + defaultValue = enableFeature + ) } } diff --git a/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt b/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt index 1d50bc1b42d..3ec4c2f5169 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt @@ -1581,10 +1581,9 @@ class KenyaAlphaEventBundleCreatorTest { fun provideLoggingLearnerStudyIds(): PlatformParameterValue { // Snapshot the value so that it doesn't change between injection and use. val enableFeature = enableLoggingLearnerStudyIds - return object : PlatformParameterValue { - override val value: Boolean = enableFeature - override val isSynced: Boolean = false - } + return PlatformParameterValue.createDefaultParameter( + defaultValue = enableFeature + ) } } From 501ae406a9ef1d97fe1d75d86a83a8bec502592c Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 14 Nov 2023 23:16:35 +0300 Subject: [PATCH 16/66] feat: Add feature flag names to all flags lacking one --- .../PlatformParameterAlphaKenyaModule.kt | 55 +++++++++++++----- .../PlatformParameterAlphaModule.kt | 57 +++++++++++++----- .../PlatformParameterModule.kt | 58 ++++++++++++++----- .../platformparameter/FeatureFlagConstants.kt | 20 +++++++ 4 files changed, 146 insertions(+), 44 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 1b3293d56f5..d427ff5117f 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -4,9 +4,12 @@ import android.content.Context import dagger.Module import dagger.Provides import org.oppia.android.app.utility.getVersionCode +import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering +import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT +import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE @@ -17,6 +20,7 @@ import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEF import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation import org.oppia.android.util.platformparameter.EnableDownloadsSupport @@ -32,6 +36,7 @@ import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode +import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL @@ -58,6 +63,7 @@ import org.oppia.android.util.platformparameter.PlatformParameterSingleton import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg @@ -72,8 +78,12 @@ import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours class PlatformParameterAlphaKenyaModule { @Provides @EnableDownloadsSupport - fun provideEnableDownloadsSupport(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + fun provideEnableDownloadsSupport( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + } @Provides @SplashScreenWelcomeMsg @@ -106,8 +116,12 @@ class PlatformParameterAlphaKenyaModule { @Provides @EnableEditAccountsOptionsUi - fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableEditAccountsOptionsUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + EDIT_ACCOUNTS_OPTIONS_UI + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE ) } @@ -201,16 +215,24 @@ class PlatformParameterAlphaKenyaModule { @Provides @EnableExtraTopicTabsUi - fun provideEnableExtraTopicTabsUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableExtraTopicTabsUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + EXTRA_TOPIC_TABS_UI + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE ) } @Provides @EnableInteractionConfigChangeStateRetention - fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableInteractionConfigChangeStateRetention( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + INTERACTION_CONFIG_CHANGE_STATE_RETENTION + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE ) } @@ -225,16 +247,21 @@ class PlatformParameterAlphaKenyaModule { @Provides @EnableSpotlightUi - fun enableSpotlightUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE - ) + fun provideEnableSpotlightUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE) } @Provides @EnableAppAndOsDeprecation - fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableAppAndOsDeprecation( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + APP_AND_OS_DEPRECATION + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE ) } diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 8addae7b9fd..7aec58bc1c6 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -4,9 +4,12 @@ import android.content.Context import dagger.Module import dagger.Provides import org.oppia.android.app.utility.getVersionCode +import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering +import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT +import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE @@ -16,6 +19,7 @@ import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation import org.oppia.android.util.platformparameter.EnableDownloadsSupport @@ -32,6 +36,7 @@ import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSO import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode +import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE @@ -59,6 +64,7 @@ import org.oppia.android.util.platformparameter.PlatformParameterSingleton import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg @@ -69,8 +75,12 @@ import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours class PlatformParameterAlphaModule { @Provides @EnableDownloadsSupport - fun provideEnableDownloadsSupport(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + fun provideEnableDownloadsSupport( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + } @Provides @SplashScreenWelcomeMsg @@ -103,8 +113,12 @@ class PlatformParameterAlphaModule { @Provides @EnableEditAccountsOptionsUi - fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableEditAccountsOptionsUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + EDIT_ACCOUNTS_OPTIONS_UI + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE ) } @@ -197,21 +211,33 @@ class PlatformParameterAlphaModule { @Provides @EnableSpotlightUi - fun provideEnableSpotlightUi(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(true) // Enable spotlights for alpha users. + fun provideEnableSpotlightUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) + ?: PlatformParameterValue.createDefaultParameter(true) // Enable spotlights for alpha users. + } @Provides @EnableExtraTopicTabsUi - fun provideEnableExtraTopicTabsUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableExtraTopicTabsUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + EXTRA_TOPIC_TABS_UI + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE ) } @Provides @EnableInteractionConfigChangeStateRetention - fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableInteractionConfigChangeStateRetention( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + INTERACTION_CONFIG_CHANGE_STATE_RETENTION + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE ) } @@ -226,10 +252,13 @@ class PlatformParameterAlphaModule { @Provides @EnableAppAndOsDeprecation - fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE - ) + fun provideEnableAppAndOsDeprecation( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(APP_AND_OS_DEPRECATION) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE + ) } @Provides diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index c2a211472fc..33318858a69 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -4,9 +4,12 @@ import android.content.Context import dagger.Module import dagger.Provides import org.oppia.android.app.utility.getVersionCode +import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering +import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT +import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE @@ -17,6 +20,7 @@ import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEF import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation import org.oppia.android.util.platformparameter.EnableDownloadsSupport @@ -33,6 +37,7 @@ import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSO import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode +import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS @@ -61,6 +66,7 @@ import org.oppia.android.util.platformparameter.PlatformParameterSingleton import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG import org.oppia.android.util.platformparameter.SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg @@ -71,8 +77,12 @@ import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours class PlatformParameterModule { @Provides @EnableDownloadsSupport - fun provideEnableDownloadsSupport(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + fun provideEnableDownloadsSupport( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) + } @Provides @SplashScreenWelcomeMsg @@ -105,8 +115,12 @@ class PlatformParameterModule { @Provides @EnableEditAccountsOptionsUi - fun provideEnableEditAccountsOptionsUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableEditAccountsOptionsUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + EDIT_ACCOUNTS_OPTIONS_UI + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE ) } @@ -199,24 +213,33 @@ class PlatformParameterModule { @Provides @EnableSpotlightUi - fun provideEnableSpotlightUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE - ) + fun provideEnableSpotlightUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) + ?: PlatformParameterValue.createDefaultParameter(ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE) } @Provides @EnableExtraTopicTabsUi - fun provideEnableExtraTopicTabsUi(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableExtraTopicTabsUi( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + EXTRA_TOPIC_TABS_UI + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE ) } @Provides @EnableInteractionConfigChangeStateRetention - fun provideEnableInteractionConfigChangeStateRetention(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( + fun provideEnableInteractionConfigChangeStateRetention( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + INTERACTION_CONFIG_CHANGE_STATE_RETENTION + ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE ) } @@ -231,10 +254,13 @@ class PlatformParameterModule { @Provides @EnableAppAndOsDeprecation - fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE - ) + fun provideEnableAppAndOsDeprecation( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(APP_AND_OS_DEPRECATION) + ?: PlatformParameterValue.createDefaultParameter( + ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE + ) } @Provides diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index a785a61d836..6d5d716d730 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -18,6 +18,9 @@ import javax.inject.Qualifier */ @Qualifier annotation class EnableDownloadsSupport +/** Name of the feature flag that controls whether to enable downloads support. */ +const val DOWNLOADS_SUPPORT = "downloads_support" + /** Default value for feature flag corresponding to [EnableDownloadsSupport]. */ const val ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE = false @@ -34,6 +37,9 @@ const val ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE = true @Qualifier annotation class EnableExtraTopicTabsUi +/** Name of the feature flag that controls whether to enable the extra topics tab UI. */ +const val EXTRA_TOPIC_TABS_UI = "extra_topics_tab_ui" + /** Default value for the feature flag corresponding to [EnableExtraTopicTabsUi]. */ const val ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE = false @@ -91,6 +97,9 @@ const val LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE = false @Qualifier annotation class EnableEditAccountsOptionsUi +/** Name of the feature flag that controls whether to enable the edit account options UI. */ +const val EDIT_ACCOUNTS_OPTIONS_UI = "edit_accounts_options_ui" + /** Default value for the feature flag corresponding to [EnableEditAccountsOptionsUi]. */ const val ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE = false @@ -119,6 +128,9 @@ const val ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE = true @Qualifier annotation class EnableSpotlightUi +/** Name of the feature flag that controls whether to enable the spotlight UI. */ +const val SPOTLIGHT_UI = "spotlight_ui" + /** Default value for the feature flag corresponding to [EnableSpotlightUi]. */ const val ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE = false @@ -129,6 +141,11 @@ const val ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE = false @Qualifier annotation class EnableInteractionConfigChangeStateRetention +/** Name of the feature flag that controls whether input interaction state is correctly retained + * across configuration changes. + */ +const val INTERACTION_CONFIG_CHANGE_STATE_RETENTION = "interaction_config_change_state_retention" + /** * Default value for feature flag corresponding to [EnableInteractionConfigChangeStateRetention]. */ @@ -141,6 +158,9 @@ const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false @Qualifier annotation class EnableAppAndOsDeprecation +/** Name of the feature flag that controls whether to enable app and os deprecation. */ +const val APP_AND_OS_DEPRECATION = "app_and_os_deprecation" + /** * Default value for the feature flag corresponding to [EnableAppAndOsDeprecation]. */ From 551fd4a1e54acf0546df1ccd219ed532bb7c62e6 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 15 Nov 2023 15:22:32 +0300 Subject: [PATCH 17/66] fix: Fix failing check and linting issue --- .../oppialogger/analytics/ApplicationLifecycleObserver.kt | 1 - .../android/util/platformparameter/FeatureFlagConstants.kt | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index 2d62cdcd639..8a4504b4372 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -1,4 +1,3 @@ - package org.oppia.android.domain.oppialogger.analytics import android.app.Activity diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 6d5d716d730..0e49a39738c 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -141,7 +141,8 @@ const val ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE = false @Qualifier annotation class EnableInteractionConfigChangeStateRetention -/** Name of the feature flag that controls whether input interaction state is correctly retained +/** + * Name of the feature flag that controls whether input interaction state is correctly retained * across configuration changes. */ const val INTERACTION_CONFIG_CHANGE_STATE_RETENTION = "interaction_config_change_state_retention" From df983b9735facbf46c1e621d5431fcaa7e6dbe82 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 17 Nov 2023 09:14:07 +0300 Subject: [PATCH 18/66] chore: Remove unused feature flag --- .../util/platformparameter/FeatureFlagConstants.kt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 0e49a39738c..fdfe77ef820 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -113,17 +113,6 @@ const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "enable_performance_metrics_co /** Default value for whether to record performance metrics. */ const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false -/** - * Qualifier for the feature flag that controls whether to animate the continue button - * interaction and navigation items. This is used to disable the animation during testing because - * Espresso has known problems while testing views that contain animations. - */ -@Qualifier -annotation class EnableContinueButtonAnimation - -/** Default value for whether to enable continue button animation. */ -const val ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE = true - /** Qualifier for the feature flag corresponding to enabling the spotlight UI. */ @Qualifier annotation class EnableSpotlightUi From a5dbf3adbd6659b2feb6fc270505d3ab59086f42 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 21 Nov 2023 11:24:37 +0300 Subject: [PATCH 19/66] feat: Add ability to log feature flag statuses --- .../vieweventlogs/ViewEventLogsViewModel.kt | 1 + .../analytics/ApplicationLifecycleObserver.kt | 18 ++ .../domain/oppialogger/analytics/BUILD.bazel | 9 + .../analytics/FeatureFlagsLogger.kt | 154 ++++++++++++++++++ .../PlatformParameterAlphaKenyaModule.kt | 4 +- .../PlatformParameterAlphaModule.kt | 4 +- .../PlatformParameterModule.kt | 4 +- model/src/main/proto/oppia_logger.proto | 28 ++++ .../util/logging/EventBundleCreator.kt | 16 ++ ...entTypeToHumanReadableNameConverterImpl.kt | 1 + ...entTypeToHumanReadableNameConverterImpl.kt | 1 + .../platformparameter/FeatureFlagConstants.kt | 2 +- .../PlatformParameterValue.kt | 2 +- 13 files changed, 236 insertions(+), 8 deletions(-) create mode 100644 domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt diff --git a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt index 09362e1d90e..70edf9a2958 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt @@ -30,6 +30,7 @@ class ViewEventLogsViewModel @Inject constructor( private fun processEventLogsList(): List { return eventList.map { + println("Event Log Details: $it") EventLogItemViewModel(it, machineLocale, resourceHandler) }.reversed() } diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index 8a4504b4372..e3bea1108f5 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -38,6 +38,7 @@ class ApplicationLifecycleObserver @Inject constructor( private val profileManagementController: ProfileManagementController, private val oppiaLogger: OppiaLogger, private val performanceMetricsLogger: PerformanceMetricsLogger, + private val featureFlagsLogger: FeatureFlagsLogger, private val performanceMetricsController: PerformanceMetricsController, private val cpuPerformanceSnapshotter: CpuPerformanceSnapshotter, @LearnerAnalyticsInactivityLimitMillis private val inactivityLimitMillis: Long, @@ -83,6 +84,7 @@ class ApplicationLifecycleObserver @Inject constructor( ProcessLifecycleOwner.get().lifecycle.addObserver(this) application.registerActivityLifecycleCallbacks(this) logApplicationStartupMetrics() + logCurrentFeatureFlags() cpuPerformanceSnapshotter.initialiseSnapshotter() } @@ -165,6 +167,22 @@ class ApplicationLifecycleObserver @Inject constructor( } } + private fun logCurrentFeatureFlags() { + CoroutineScope(backgroundDispatcher).launch { + val sessionId = loggingIdentifierController.getSessionIdFlow().value + + featureFlagsLogger.logAllFeatureFlags(sessionId) + }.invokeOnCompletion { failure -> + if (failure != null) { + oppiaLogger.e( + "ActivityLifecycleObserver", + "Encountered error while trying to log app's feature flags.", + failure + ) + } + } + } + private fun getStartupLatencyMillis(initialTimestampMillis: Long): Long = oppiaClock.getCurrentTimeMs() - initialTimestampMillis diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index 6b207de01aa..61e2587045e 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -129,6 +129,7 @@ kt_android_library( ":performance_metrics_controller", "//domain/src/main/java/org/oppia/android/domain/oppialogger:logging_identifier_controller", "//domain/src/main/java/org/oppia/android/domain/oppialogger:startup_listener", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:feature_flags_logger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:performance_metrics_logger", "//domain/src/main/java/org/oppia/android/domain/profile:profile_management_controller", "//model/src/main/proto:screens_java_proto_lite", @@ -196,4 +197,12 @@ kt_android_library( visibility = ["//:oppia_api_visibility"], ) +kt_android_library( + name = "feature_flags_logger", + srcs = [ + "FeatureFlagsLogger.kt", + ], + visibility = ["//:oppia_api_visibility"], +) + dagger_rules() diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt new file mode 100644 index 00000000000..fc916b908d9 --- /dev/null +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -0,0 +1,154 @@ +package org.oppia.android.domain.oppialogger.analytics + +import org.oppia.android.app.model.EventLog +import org.oppia.android.app.model.EventLog.FeatureFlagContext +import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItem +import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION +import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT +import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI +import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI +import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation +import org.oppia.android.util.platformparameter.EnableDownloadsSupport +import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi +import org.oppia.android.util.platformparameter.EnableExtraTopicTabsUi +import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLesson +import org.oppia.android.util.platformparameter.EnableInteractionConfigChangeStateRetention +import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics +import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds +import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection +import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON +import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION +import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS +import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS +import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION +import org.oppia.android.util.platformparameter.PlatformParameterValue +import org.oppia.android.util.platformparameter.SPOTLIGHT_UI +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class FeatureFlagsLogger @Inject constructor( + private val analyticsController: AnalyticsController, + @EnableDownloadsSupport + private val enableDownloadsSupport: PlatformParameterValue, + @EnableExtraTopicTabsUi + private val enableExtraTopicTabsUi: PlatformParameterValue, + @EnableLearnerStudyAnalytics + private val enableLearnerStudyAnalytics: PlatformParameterValue, + @EnableFastLanguageSwitchingInLesson + private val enableFastLanguageSwitchingInLesson: PlatformParameterValue, + @EnableLoggingLearnerStudyIds + private val enableLoggingLearnerStudyIds: PlatformParameterValue, + @EnableEditAccountsOptionsUi + private val enableEditAccountsOptionsUi: PlatformParameterValue, + @EnablePerformanceMetricsCollection + private val enablePerformanceMetricsCollection: PlatformParameterValue, + @EnableSpotlightUi + private val enableSpotlightUi: PlatformParameterValue, + @EnableInteractionConfigChangeStateRetention + private val enableInteractionConfigChangeStateRetention: PlatformParameterValue, + @EnableAppAndOsDeprecation + private val enableAppAndOsDeprecation: PlatformParameterValue +) { + /** + * This method logs all the configured feature flags to firebase. + */ + fun logAllFeatureFlags(sessionId: String) { + analyticsController.logImportantEvent( + createFeatureFlagContext(sessionId = sessionId), + null + ) + } + + private fun compileFeatureFlagsForLogging(): List { + val listOfFlags = arrayListOf() + + val enableDownloadsSupportFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(DOWNLOADS_SUPPORT) + .setFlagEnabledState(enableDownloadsSupport.value) + .setFlagSyncStatus(enableDownloadsSupport.syncStatus) + .build() + + val enableExtraTopicTabsUiFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(EXTRA_TOPIC_TABS_UI) + .setFlagEnabledState(enableExtraTopicTabsUi.value) + .setFlagSyncStatus(enableExtraTopicTabsUi.syncStatus) + .build() + + val enableLearnerStudyAnalyticsFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(LEARNER_STUDY_ANALYTICS) + .setFlagEnabledState(enableLearnerStudyAnalytics.value) + .setFlagSyncStatus(enableLearnerStudyAnalytics.syncStatus) + .build() + + val enableFastLanguageSwitchingInLessonFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(FAST_LANGUAGE_SWITCHING_IN_LESSON) + .setFlagEnabledState(enableFastLanguageSwitchingInLesson.value) + .setFlagSyncStatus(enableFastLanguageSwitchingInLesson.syncStatus) + .build() + + val enableLoggingLearnerStudyIdsFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(LOGGING_LEARNER_STUDY_IDS) + .setFlagEnabledState(enableLoggingLearnerStudyIds.value) + .setFlagSyncStatus(enableLoggingLearnerStudyIds.syncStatus) + .build() + + val enableEditAccountsOptionsUiFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(EDIT_ACCOUNTS_OPTIONS_UI) + .setFlagEnabledState(enableEditAccountsOptionsUi.value) + .setFlagSyncStatus(enableEditAccountsOptionsUi.syncStatus) + .build() + + val enablePerformanceMetricsCollectionFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(PERFORMANCE_METRICS_COLLECTION) + .setFlagEnabledState(enablePerformanceMetricsCollection.value) + .setFlagSyncStatus(enablePerformanceMetricsCollection.syncStatus) + .build() + + val enableSpotlightUiFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(SPOTLIGHT_UI) + .setFlagEnabledState(enableSpotlightUi.value) + .setFlagSyncStatus(enableSpotlightUi.syncStatus) + .build() + + val enableInteractionConfigChangeStateRetentionFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(INTERACTION_CONFIG_CHANGE_STATE_RETENTION) + .setFlagEnabledState(enableInteractionConfigChangeStateRetention.value) + .setFlagSyncStatus(enableInteractionConfigChangeStateRetention.syncStatus) + .build() + + val enableAppAndOsDeprecationFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(APP_AND_OS_DEPRECATION) + .setFlagEnabledState(enableAppAndOsDeprecation.value) + .setFlagSyncStatus(enableAppAndOsDeprecation.syncStatus) + .build() + + listOfFlags.addAll( + listOf( + enableDownloadsSupportFlagItem, enableExtraTopicTabsUiFlagItem, + enableLearnerStudyAnalyticsFlagItem, enableFastLanguageSwitchingInLessonFlagItem, + enableLoggingLearnerStudyIdsFlagItem, enableEditAccountsOptionsUiFlagItem, + enablePerformanceMetricsCollectionFlagItem, enableSpotlightUiFlagItem, + enableInteractionConfigChangeStateRetentionFlagItem, enableAppAndOsDeprecationFlagItem + ) + ) + + return listOfFlags + } + + private fun createFeatureFlagContext(sessionId: String): EventLog.Context { + return EventLog.Context.newBuilder() + .setFeatureFlagContext( + FeatureFlagContext.newBuilder() + // TODO: Add uuid + .setUuid("My UUID") + .setSessionId(sessionId) + .addAllFeatureFlag( + compileFeatureFlagsForLogging() + ) + .build() + ) + .build() + } +} diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 376f5abf36e..9509dff7f23 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -16,7 +16,6 @@ import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_ import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI @@ -48,6 +47,7 @@ import org.oppia.android.util.platformparameter.NpsSurveyGracePeriodInDays import org.oppia.android.util.platformparameter.NpsSurveyMinimumAggregateLearningTimeInATopicInMinutes import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode +import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES @@ -169,7 +169,7 @@ class PlatformParameterAlphaKenyaModule { platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { return platformParameterSingleton.getBooleanPlatformParameter( - ENABLE_PERFORMANCE_METRICS_COLLECTION + PERFORMANCE_METRICS_COLLECTION ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE ) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 6574762dae5..2eba6e0d6e7 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -16,7 +16,6 @@ import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_ import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation @@ -49,6 +48,7 @@ import org.oppia.android.util.platformparameter.NpsSurveyGracePeriodInDays import org.oppia.android.util.platformparameter.NpsSurveyMinimumAggregateLearningTimeInATopicInMinutes import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode +import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES @@ -165,7 +165,7 @@ class PlatformParameterAlphaModule { platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { return platformParameterSingleton.getBooleanPlatformParameter( - ENABLE_PERFORMANCE_METRICS_COLLECTION + PERFORMANCE_METRICS_COLLECTION ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE ) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 4acd5804929..3287dd469d8 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -16,7 +16,6 @@ import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_ import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI @@ -51,6 +50,7 @@ import org.oppia.android.util.platformparameter.NpsSurveyGracePeriodInDays import org.oppia.android.util.platformparameter.NpsSurveyMinimumAggregateLearningTimeInATopicInMinutes import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode +import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES @@ -167,7 +167,7 @@ class PlatformParameterModule { platformParameterSingleton: PlatformParameterSingleton ): PlatformParameterValue { return platformParameterSingleton.getBooleanPlatformParameter( - ENABLE_PERFORMANCE_METRICS_COLLECTION + PERFORMANCE_METRICS_COLLECTION ) ?: PlatformParameterValue.createDefaultParameter( ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE ) diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index e2d6cc455ea..8df4b6a806f 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -5,6 +5,7 @@ package model; import "languages.proto"; import "profile.proto"; import "survey.proto"; +import "platform_parameter.proto"; option java_package = "org.oppia.android.app.model"; option java_multiple_files = true; @@ -175,6 +176,9 @@ message EventLog { // The event being logged is related to the response to the optional survey question. OptionalSurveyResponseContext optional_response = 42; + + // The event being logged contains the feature flags and their current enabled and sync state + FeatureFlagContext feature_flag_context = 43; } } @@ -368,6 +372,30 @@ message EventLog { string profile_id = 2; } + // Structure of a feature flag context. + message FeatureFlagContext { + // The unique UUID of the user. + string uuid = 1; + + // The session id for the current session. + string session_id = 2; + + // List of Feature Flag items + repeated FeatureFlagItem feature_flag = 3; + + // Structure for the feature flag log item + message FeatureFlagItem { + // The name of the feature flag or sync status flag + string flag_name = 1; + + // The enabled state of the feature flag + bool flag_enabled_state = 2; + + // The status of the feature flag or sync status flag + PlatformParameter.SyncStatus flag_sync_status = 3; + } + } + // Supported priority of events for event logging enum Priority { // The undefined priority of an event diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 100f1c86c4c..c77d2e0f545 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -17,6 +17,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.CLOSE_RE import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.DELETE_PROFILE_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.END_CARD_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.EXIT_EXPLORATION_CONTEXT +import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FINISH_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.HINT_UNLOCKED_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG @@ -91,6 +92,7 @@ import org.oppia.android.app.model.EventLog.AbandonSurveyContext as AbandonSurve import org.oppia.android.app.model.EventLog.CardContext as CardEventContext import org.oppia.android.app.model.EventLog.ConceptCardContext as ConceptCardEventContext import org.oppia.android.app.model.EventLog.ExplorationContext as ExplorationEventContext +import org.oppia.android.app.model.EventLog.FeatureFlagContext as FeatureFlagEventContext import org.oppia.android.app.model.EventLog.HintContext as HintEventContext import org.oppia.android.app.model.EventLog.LearnerDetailsContext as LearnerDetailsEventContext import org.oppia.android.app.model.EventLog.MandatorySurveyResponseContext as MandatorySurveyResponseEventContext @@ -223,6 +225,8 @@ class EventBundleCreator @Inject constructor( ABANDON_SURVEY -> AbandonSurveyContext(activityName, abandonSurvey) MANDATORY_RESPONSE -> MandatorySurveyResponseContext(activityName, mandatoryResponse) OPTIONAL_RESPONSE -> OptionalSurveyResponseContext(activityName, optionalResponse) + FEATURE_FLAG_CONTEXT -> + EventActivityContext.FeatureFlagContext(activityName, featureFlagContext) INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> SensitiveStringContext(activityName, installIdForFailedAnalyticsLog, "install_id") ACTIVITYCONTEXT_NOT_SET, null -> EmptyContext(activityName) // No context to create here. @@ -557,6 +561,18 @@ class EventBundleCreator @Inject constructor( store.putNonSensitiveValue("question_name", questionName) } } + + /** The [EventActivityContext] corresponding to [FeatureFlagEventContext]s. */ + class FeatureFlagContext( + activityName: String, + value: FeatureFlagEventContext + ) : EventActivityContext(activityName, value) { + override fun EventLog.FeatureFlagContext.storeValue(store: PropertyStore) { + store.putNonSensitiveValue("uuid", uuid) + store.putNonSensitiveValue("session_id", sessionId) + store.putNonSensitiveValue("feature_flags", featureFlagList) + } + } } /** Represents an [OppiaMetricLog] loggable metric (denoted by [LoggableMetricTypeCase]). */ diff --git a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt index 4f11a6e5f8d..05d0d9c5ce3 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt @@ -50,6 +50,7 @@ class KenyaAlphaEventTypeToHumanReadableNameConverterImpl @Inject constructor() ActivityContextCase.ABANDON_SURVEY -> "abandon_survey" ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" + ActivityContextCase.FEATURE_FLAG_CONTEXT -> "feature_flag" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> "failed_analytics_log" ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "unknown_activity_context" } diff --git a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt index 4c71ee5446e..7c52ee09ec9 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt @@ -60,6 +60,7 @@ class StandardEventTypeToHumanReadableNameConverterImpl @Inject constructor() : ActivityContextCase.ABANDON_SURVEY -> "abandon_survey" ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" + ActivityContextCase.FEATURE_FLAG_CONTEXT -> "feature_flag" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG, ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "ERROR_internal_logging_failure" } diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index fdfe77ef820..f19eb8dc8b7 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -108,7 +108,7 @@ const val ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE = false annotation class EnablePerformanceMetricsCollection /** Name of the feature flag that controls whether to record performance metrics. */ -const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "enable_performance_metrics_collection" +const val PERFORMANCE_METRICS_COLLECTION = "performance_metrics_collection" /** Default value for whether to record performance metrics. */ const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt index 51523f0134f..1f516de9d37 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterValue.kt @@ -19,7 +19,7 @@ interface PlatformParameterValue { */ fun createDefaultParameter( defaultValue: T, - defaultIsSynced: SyncStatus = SyncStatus.NOT_SYNCED_FROM_SERVER + defaultIsSynced: SyncStatus = SyncStatus.SYNC_STATUS_UNSPECIFIED ): PlatformParameterValue { return object : PlatformParameterValue { override val value = defaultValue From e93ff75818960a3618242e2b61464b9d7659af29 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 21 Nov 2023 21:05:12 +0300 Subject: [PATCH 20/66] feat: Add tests for the FeatureFlagLogger --- .../domain/oppialogger/analytics/BUILD.bazel | 31 ++++ .../analytics/FeatureFlagsLoggerTest.kt | 165 ++++++++++++++++++ .../testing/logging/EventLogSubject.kt | 49 ++++++ 3 files changed, 245 insertions(+) create mode 100644 domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index 12886f46df6..82e9532e2fc 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -289,4 +289,35 @@ oppia_android_test( ], ) +oppia_android_test( + name = "FeatureFlagsLoggerTest", + srcs = ["FeatureFlagsLoggerTest.kt"], + custom_package = "org.oppia.android.domain.oppialogger.analytics", + test_class = "org.oppia.android.domain.oppialogger.analytics.FeatureFlagsLoggerTest", + test_manifest = "//domain:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:feature_flags_logger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/survey:survey_events_logger", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", + "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", + "//testing/src/main/java/org/oppia/android/testing/logging:sync_status_test_module", + "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:androidx_test_ext_junit", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + "//utility/src/main/java/org/oppia/android/util/caching:asset_prod_module", + "//utility/src/main/java/org/oppia/android/util/locale:prod_module", + "//utility/src/main/java/org/oppia/android/util/networking:debug_module", + ], +) + dagger_rules() diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt new file mode 100644 index 00000000000..5ea6300c6eb --- /dev/null +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -0,0 +1,165 @@ +package org.oppia.android.domain.oppialogger.analytics + +import android.app.Application +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import dagger.BindsInstance +import dagger.Component +import dagger.Module +import dagger.Provides +import javax.inject.Inject +import javax.inject.Singleton +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize +import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize +import org.oppia.android.domain.oppialogger.LoggingIdentifierModule +import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule +import org.oppia.android.testing.FakeAnalyticsEventLogger +import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat +import org.oppia.android.testing.logging.SyncStatusTestModule +import org.oppia.android.testing.platformparameter.TestPlatformParameterModule +import org.oppia.android.testing.robolectric.RobolectricModule +import org.oppia.android.testing.threading.TestCoroutineDispatchers +import org.oppia.android.testing.threading.TestDispatcherModule +import org.oppia.android.testing.time.FakeOppiaClockModule +import org.oppia.android.util.caching.AssetModule +import org.oppia.android.util.data.DataProvidersInjector +import org.oppia.android.util.data.DataProvidersInjectorProvider +import org.oppia.android.util.locale.LocaleProdModule +import org.oppia.android.util.logging.EnableConsoleLog +import org.oppia.android.util.logging.EnableFileLog +import org.oppia.android.util.logging.GlobalLogLevel +import org.oppia.android.util.logging.LogLevel +import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.robolectric.annotation.Config +import org.robolectric.annotation.LooperMode + +/** Tests for [FeatureFlagsLogger]. */ +// FunctionName: test names are conventionally named with underscores. +@Suppress("FunctionName") +@RunWith(AndroidJUnit4::class) +@LooperMode(LooperMode.Mode.PAUSED) +@Config(application = FeatureFlagsLoggerTest.TestApplication::class) +class FeatureFlagsLoggerTest { + private companion object { + private const val TEST_SESSION_ID = "test_session_id" + private val INITIAL_SYNC_STATUS = PlatformParameter.SyncStatus.SYNC_STATUS_UNSPECIFIED + } + + @Inject + lateinit var featureFlagsLogger: FeatureFlagsLogger + + @Inject + lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger + + @Inject + lateinit var testCoroutineDispatchers: TestCoroutineDispatchers + + @Before + fun setup() { + setUpTestApplicationComponent() + } + + @Test + fun testLogFeatureFlags_logsFeatureFlagsWithCorrectValues() { + featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + testCoroutineDispatchers.runCurrent() + + val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() + + assertThat(eventLog).hasFeatureFlagContextThat { + hasSessionIdThat().isEqualTo(TEST_SESSION_ID) + } + assertThat(eventLog).hasFeatureFlagContextThat { + hasFeatureEnabledStateThat().isEqualTo(false) + } + assertThat(eventLog).hasFeatureFlagContextThat { + hasSyncStatusThat().isEqualTo(INITIAL_SYNC_STATUS) + } + } + + private fun setUpTestApplicationComponent() { + DaggerFeatureFlagsLoggerTest_TestApplicationComponent.builder() + .setApplication(ApplicationProvider.getApplicationContext()) + .build() + .inject(this) + } + + // TODO(#89): Move this to a common test application component. + @Module + class TestModule { + @Provides + @Singleton + fun provideContext(application: Application): Context { + return application + } + + // TODO(#59): Either isolate these to their own shared test module, or use the real logging + // module in tests to avoid needing to specify these settings for tests. + @EnableConsoleLog + @Provides + fun provideEnableConsoleLog(): Boolean = true + + @EnableFileLog + @Provides + fun provideEnableFileLog(): Boolean = false + + @GlobalLogLevel + @Provides + fun provideGlobalLogLevel(): LogLevel = LogLevel.VERBOSE + } + + @Module + class TestLogStorageModule { + @Provides + @EventLogStorageCacheSize + fun provideEventLogStorageCacheSize(): Int = 2 + + @Provides + @ExceptionLogStorageCacheSize + fun provideExceptionLogStorageCacheSize(): Int = 2 + } + + // TODO(#89): Move this to a common test application component. + @Singleton + @Component( + modules = [ + PerformanceMetricsLoggerTest.TestModule::class, TestLogReportingModule::class, RobolectricModule::class, + TestDispatcherModule::class, PerformanceMetricsLoggerTest.TestLogStorageModule::class, + NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, + TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, + LoggingIdentifierModule::class, SyncStatusTestModule::class, AssetModule::class, + ApplicationLifecycleModule::class + ] + ) + + interface TestApplicationComponent : DataProvidersInjector { + @Component.Builder + interface Builder { + @BindsInstance + fun setApplication(application: Application): Builder + fun build(): TestApplicationComponent + } + + fun inject(featureFlagLoggerTest: FeatureFlagsLoggerTest) + } + + class TestApplication : Application(), DataProvidersInjectorProvider { + private val component: TestApplicationComponent by lazy { + DaggerFeatureFlagsLoggerTest_TestApplicationComponent.builder() + .setApplication(this) + .build() + } + + fun inject(featureFlagLoggerTest: FeatureFlagsLoggerTest) { + component.inject(featureFlagLoggerTest) + } + + override fun getDataProvidersInjector(): DataProvidersInjector = component + } +} \ No newline at end of file diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index cbd7163ce19..05e231bf536 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -52,6 +52,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SUBMIT_A import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SWITCH_IN_LESSON_LANGUAGE import org.oppia.android.app.model.MarketFitAnswer import org.oppia.android.app.model.OppiaLanguage +import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.model.SurveyQuestionName import org.oppia.android.app.model.UserTypeAnswer import org.oppia.android.app.model.WrittenTranslationLanguageSelection @@ -1046,6 +1047,18 @@ class EventLogSubject private constructor( hasBeginSurveyContextThat().block() } + fun hasFeatureFlagContextThat(): FeatureFlagContextSubject { + return FeatureFlagContextSubject.assertThat( + actual.context.featureFlagContext + ) + } + + fun hasFeatureFlagContextThat( + block: FeatureFlagContextSubject.() -> Unit + ) { + hasFeatureFlagContextThat().block() + } + /** * Truth subject for verifying properties of [AppLanguageSelection]s. * @@ -1944,6 +1957,42 @@ class EventLogSubject private constructor( } } + /** + * Truth subject for verifying properties of [EventLog.SurveyContext]s. + * + * Note that this class is also a [LiteProtoSubject] so other aspects of the underlying + * [EventLog.SurveyContext] proto can be verified through inherited methods. + * + * Call [SurveyContextSubject.assertThat] to create the subject. + */ + class FeatureFlagContextSubject private constructor( + metadata: FailureMetadata, + private val actual: EventLog.FeatureFlagContext + ) : LiteProtoSubject(metadata, actual) { + /** + * Returns a [StringSubject] to test [EventLog.SurveyContext.getExplorationId]. + * + * This method never fails since the underlying property defaults to empty string if it's not + * defined in the context. + */ + fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) + + fun hasFeatureEnabledStateThat(): BooleanSubject = + assertThat(actual.getFeatureFlag(0).flagEnabledState) + + fun hasSyncStatusThat(): ComparableSubject = + assertThat(actual.getFeatureFlag(0).flagSyncStatus) + + companion object { + /** + * Returns a new [SurveyContextSubject] to verify aspects of the specified + * [EventLog.SurveyContext] value. + */ + fun assertThat(actual: EventLog.FeatureFlagContext): FeatureFlagContextSubject = + assertAbout(::FeatureFlagContextSubject).that(actual) + } + } + companion object { /** Returns a new [EventLogSubject] to verify aspects of the specified [EventLog] value. */ fun assertThat(actual: EventLog): EventLogSubject = assertAbout(::EventLogSubject).that(actual) From 8ae088cf21a704b4244b061805290957e565ec8c Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 22 Nov 2023 09:11:26 +0300 Subject: [PATCH 21/66] feat: add a feature flag test --- .../oppialogger/analytics/FeatureFlagsLoggerTest.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 5ea6300c6eb..805fed89c33 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -8,8 +8,6 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides -import javax.inject.Inject -import javax.inject.Singleton import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -38,6 +36,8 @@ import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode +import javax.inject.Inject +import javax.inject.Singleton /** Tests for [FeatureFlagsLogger]. */ // FunctionName: test names are conventionally named with underscores. @@ -129,8 +129,9 @@ class FeatureFlagsLoggerTest { @Singleton @Component( modules = [ - PerformanceMetricsLoggerTest.TestModule::class, TestLogReportingModule::class, RobolectricModule::class, - TestDispatcherModule::class, PerformanceMetricsLoggerTest.TestLogStorageModule::class, + PerformanceMetricsLoggerTest.TestModule::class, TestLogReportingModule::class, + RobolectricModule::class, TestDispatcherModule::class, + PerformanceMetricsLoggerTest.TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, AssetModule::class, @@ -162,4 +163,4 @@ class FeatureFlagsLoggerTest { override fun getDataProvidersInjector(): DataProvidersInjector = component } -} \ No newline at end of file +} From 2b7aad4e7a8922e76e4b2df9a2e0427318604572 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 22 Nov 2023 13:18:05 +0300 Subject: [PATCH 22/66] fix: Fix bazel build issues --- .../android/domain/oppialogger/analytics/BUILD.bazel | 9 ++++++++- model/src/main/proto/BUILD.bazel | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index 61e2587045e..cb03e1c0ff2 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -125,11 +125,11 @@ kt_android_library( ":application_lifecycle_listener", ":cpu_performance_snapshotter", ":dagger", + ":feature_flags_logger", ":learner_analytics_inactivity_limit_millis", ":performance_metrics_controller", "//domain/src/main/java/org/oppia/android/domain/oppialogger:logging_identifier_controller", "//domain/src/main/java/org/oppia/android/domain/oppialogger:startup_listener", - "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:feature_flags_logger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:performance_metrics_logger", "//domain/src/main/java/org/oppia/android/domain/profile:profile_management_controller", "//model/src/main/proto:screens_java_proto_lite", @@ -203,6 +203,13 @@ kt_android_library( "FeatureFlagsLogger.kt", ], visibility = ["//:oppia_api_visibility"], + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger:oppia_logger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:controller", + "//model/src/main/proto:survey_java_proto_lite", + "//third_party:javax_inject_javax_inject", + ], ) dagger_rules() diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel index a168e981191..a2f0920addb 100644 --- a/model/src/main/proto/BUILD.bazel +++ b/model/src/main/proto/BUILD.bazel @@ -49,6 +49,7 @@ oppia_proto_library( ":languages_proto", ":profile_proto", ":survey_proto", + ":platform_parameter_proto", ], ) From fd8135014445c43190e586a11cda33e8b56683b8 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 22 Nov 2023 19:49:07 +0300 Subject: [PATCH 23/66] fix: Fix failing tests --- .../analytics/FeatureFlagsLogger.kt | 23 +++++++++++++-- .../analytics/FeatureFlagsLoggerTest.kt | 5 ++-- model/src/main/proto/BUILD.bazel | 2 +- .../testing/logging/EventLogSubject.kt | 28 ++++++++++++++++--- .../util/logging/EventBundleCreator.kt | 2 +- 5 files changed, 49 insertions(+), 11 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index fc916b908d9..9e1b28684f7 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -27,6 +27,12 @@ import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import javax.inject.Inject import javax.inject.Singleton +/** + * Convenience logger for feature flags. + * + * This logger is meant to be used to log the current status of all feature flags once after the app + * has been launched. + */ @Singleton class FeatureFlagsLogger @Inject constructor( private val analyticsController: AnalyticsController, @@ -53,6 +59,8 @@ class FeatureFlagsLogger @Inject constructor( ) { /** * This method logs all the configured feature flags to firebase. + * + * @param sessionId denotes the id of the current appInForeground session */ fun logAllFeatureFlags(sessionId: String) { analyticsController.logImportantEvent( @@ -61,6 +69,12 @@ class FeatureFlagsLogger @Inject constructor( ) } + /** + * Collects all the feature flags in the app, creates a FeatureFlagItem for them and adds them to + * a list that is returned to the calling object. + * + * @return a list of [FeatureFlagItem]s + */ private fun compileFeatureFlagsForLogging(): List { val listOfFlags = arrayListOf() @@ -137,12 +151,17 @@ class FeatureFlagsLogger @Inject constructor( return listOfFlags } + /** + * Creates an [EventLog] context for the feature flags to be logged. + * + * @param sessionId denotes the session id of the current appInForeground session + * @return an [EventLog.Context] for the feature flags to be logged + */ private fun createFeatureFlagContext(sessionId: String): EventLog.Context { return EventLog.Context.newBuilder() .setFeatureFlagContext( FeatureFlagContext.newBuilder() - // TODO: Add uuid - .setUuid("My UUID") + .setUuid("") .setSessionId(sessionId) .addAllFeatureFlag( compileFeatureFlagsForLogging() diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 805fed89c33..324c991e0a7 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -129,9 +129,8 @@ class FeatureFlagsLoggerTest { @Singleton @Component( modules = [ - PerformanceMetricsLoggerTest.TestModule::class, TestLogReportingModule::class, - RobolectricModule::class, TestDispatcherModule::class, - PerformanceMetricsLoggerTest.TestLogStorageModule::class, + TestModule::class, TestLogReportingModule::class, RobolectricModule::class, + TestDispatcherModule::class, TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, LoggingIdentifierModule::class, SyncStatusTestModule::class, AssetModule::class, diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel index a2f0920addb..30e0db0de33 100644 --- a/model/src/main/proto/BUILD.bazel +++ b/model/src/main/proto/BUILD.bazel @@ -47,9 +47,9 @@ oppia_proto_library( deps = [ ":exploration_proto", ":languages_proto", + ":platform_parameter_proto", ":profile_proto", ":survey_proto", - ":platform_parameter_proto", ], ) diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 05e231bf536..25a2c424b31 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -1047,12 +1047,19 @@ class EventLogSubject private constructor( hasBeginSurveyContextThat().block() } + /** + * Verifies the [EventLog]'s context and returns a [FeatureFlagContextSubject] to test the + * corresponding context. + */ fun hasFeatureFlagContextThat(): FeatureFlagContextSubject { return FeatureFlagContextSubject.assertThat( actual.context.featureFlagContext ) } + /** + * Verifies the [EventLog]'s context and executes [block]. + */ fun hasFeatureFlagContextThat( block: FeatureFlagContextSubject.() -> Unit ) { @@ -1958,28 +1965,41 @@ class EventLogSubject private constructor( } /** - * Truth subject for verifying properties of [EventLog.SurveyContext]s. + * Truth subject for verifying properties of [EventLog.FeatureFlagContext]s. * * Note that this class is also a [LiteProtoSubject] so other aspects of the underlying - * [EventLog.SurveyContext] proto can be verified through inherited methods. + * [EventLog.FeatureFlagContext] proto can be verified through inherited methods. * - * Call [SurveyContextSubject.assertThat] to create the subject. + * Call [FeatureFlagContextSubject.assertThat] to create the subject. */ class FeatureFlagContextSubject private constructor( metadata: FailureMetadata, private val actual: EventLog.FeatureFlagContext ) : LiteProtoSubject(metadata, actual) { /** - * Returns a [StringSubject] to test [EventLog.SurveyContext.getExplorationId]. + * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.getSessionId]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. */ fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) + /** + * Returns a [BooleanSubject] to test the flagEnabledState of the [EventLog.FeatureFlagContext]. + * + * This method never fails since the underlying property defaults to empty string if it's not + * defined in the context. + */ fun hasFeatureEnabledStateThat(): BooleanSubject = assertThat(actual.getFeatureFlag(0).flagEnabledState) + /** + * Returns a [ComparableSubject] to test the flagSyncStatus of the + * [EventLog.FeatureFlagContext]. + * + * This method never fails since the underlying property defaults to empty string if it's not + * defined in the context. + */ fun hasSyncStatusThat(): ComparableSubject = assertThat(actual.getFeatureFlag(0).flagSyncStatus) diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index c77d2e0f545..5dea78ed323 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -562,7 +562,7 @@ class EventBundleCreator @Inject constructor( } } - /** The [EventActivityContext] corresponding to [FeatureFlagEventContext]s. */ + /** The [EventActivityContext] corresponding to [FeatureFlagEventContext]s. */ class FeatureFlagContext( activityName: String, value: FeatureFlagEventContext From 493d4c173a0568991fb6f010e1460c328b9f84b4 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 24 Nov 2023 16:46:44 +0300 Subject: [PATCH 24/66] fix: Fix minor linting issues --- .../app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt | 1 - .../android/util/platformparameter/FeatureFlagConstants.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt index 70edf9a2958..09362e1d90e 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt @@ -30,7 +30,6 @@ class ViewEventLogsViewModel @Inject constructor( private fun processEventLogsList(): List { return eventList.map { - println("Event Log Details: $it") EventLogItemViewModel(it, machineLocale, resourceHandler) }.reversed() } diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index f19eb8dc8b7..c3344922948 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -38,7 +38,7 @@ const val ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE = true annotation class EnableExtraTopicTabsUi /** Name of the feature flag that controls whether to enable the extra topics tab UI. */ -const val EXTRA_TOPIC_TABS_UI = "extra_topics_tab_ui" +const val EXTRA_TOPIC_TABS_UI = "extra_topic_tabs_ui" /** Default value for the feature flag corresponding to [EnableExtraTopicTabsUi]. */ const val ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE = false From 989a915ecf33f72abed59e3c1ab3979e701f6e8c Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Thu, 30 Nov 2023 10:17:23 +0300 Subject: [PATCH 25/66] feat: Fix changes suggested in the self-review --- .../analytics/FeatureFlagsLogger.kt | 20 +++++++------------ .../analytics/FeatureFlagsLoggerTest.kt | 2 +- .../testing/logging/EventLogSubject.kt | 3 ++- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 9e1b28684f7..69172d0a2bf 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -58,7 +58,7 @@ class FeatureFlagsLogger @Inject constructor( private val enableAppAndOsDeprecation: PlatformParameterValue ) { /** - * This method logs all the configured feature flags to firebase. + * This method logs the name, enabled status and sync status of all feature flags to Firebase. * * @param sessionId denotes the id of the current appInForeground session */ @@ -76,8 +76,6 @@ class FeatureFlagsLogger @Inject constructor( * @return a list of [FeatureFlagItem]s */ private fun compileFeatureFlagsForLogging(): List { - val listOfFlags = arrayListOf() - val enableDownloadsSupportFlagItem = FeatureFlagItem.newBuilder() .setFlagName(DOWNLOADS_SUPPORT) .setFlagEnabledState(enableDownloadsSupport.value) @@ -138,17 +136,13 @@ class FeatureFlagsLogger @Inject constructor( .setFlagSyncStatus(enableAppAndOsDeprecation.syncStatus) .build() - listOfFlags.addAll( - listOf( - enableDownloadsSupportFlagItem, enableExtraTopicTabsUiFlagItem, - enableLearnerStudyAnalyticsFlagItem, enableFastLanguageSwitchingInLessonFlagItem, - enableLoggingLearnerStudyIdsFlagItem, enableEditAccountsOptionsUiFlagItem, - enablePerformanceMetricsCollectionFlagItem, enableSpotlightUiFlagItem, - enableInteractionConfigChangeStateRetentionFlagItem, enableAppAndOsDeprecationFlagItem - ) + return listOf( + enableDownloadsSupportFlagItem, enableExtraTopicTabsUiFlagItem, + enableLearnerStudyAnalyticsFlagItem, enableFastLanguageSwitchingInLessonFlagItem, + enableLoggingLearnerStudyIdsFlagItem, enableEditAccountsOptionsUiFlagItem, + enablePerformanceMetricsCollectionFlagItem, enableSpotlightUiFlagItem, + enableInteractionConfigChangeStateRetentionFlagItem, enableAppAndOsDeprecationFlagItem ) - - return listOfFlags } /** diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 324c991e0a7..6e1c66e238c 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -48,7 +48,7 @@ import javax.inject.Singleton class FeatureFlagsLoggerTest { private companion object { private const val TEST_SESSION_ID = "test_session_id" - private val INITIAL_SYNC_STATUS = PlatformParameter.SyncStatus.SYNC_STATUS_UNSPECIFIED + private val INITIAL_SYNC_STATUS = PlatformParameter.SyncStatus.NOT_SYNCED_FROM_SERVER } @Inject diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 25a2c424b31..402b67655fb 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -1985,7 +1985,8 @@ class EventLogSubject private constructor( fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) /** - * Returns a [BooleanSubject] to test the flagEnabledState of the [EventLog.FeatureFlagContext]. + * Returns a [BooleanSubject] to test the flagEnabledState of the first item on the feature flag + * list in the [EventLog.FeatureFlagContext]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. From f3fe5a0134c961f362b98ea65c7ab91968bfc043 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 3 Dec 2023 07:55:24 +0300 Subject: [PATCH 26/66] fix: Make some of the suggested changes from preliminary review --- .../analytics/ApplicationLifecycleObserver.kt | 4 ++-- .../android/domain/oppialogger/analytics/BUILD.bazel | 1 - .../oppialogger/analytics/FeatureFlagsLogger.kt | 5 +++-- .../android/domain/oppialogger/analytics/BUILD.bazel | 1 - .../oppialogger/analytics/FeatureFlagsLoggerTest.kt | 2 +- model/src/main/proto/oppia_logger.proto | 12 ++++++------ .../oppia/android/testing/logging/EventLogSubject.kt | 4 ++-- .../oppia/android/util/logging/EventBundleCreator.kt | 4 ++-- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index e3bea1108f5..b337cd9ff1b 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -84,7 +84,7 @@ class ApplicationLifecycleObserver @Inject constructor( ProcessLifecycleOwner.get().lifecycle.addObserver(this) application.registerActivityLifecycleCallbacks(this) logApplicationStartupMetrics() - logCurrentFeatureFlags() + logAllFeatureFlags() cpuPerformanceSnapshotter.initialiseSnapshotter() } @@ -167,7 +167,7 @@ class ApplicationLifecycleObserver @Inject constructor( } } - private fun logCurrentFeatureFlags() { + private fun logAllFeatureFlags() { CoroutineScope(backgroundDispatcher).launch { val sessionId = loggingIdentifierController.getSessionIdFlow().value diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index cb03e1c0ff2..34c00660486 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -207,7 +207,6 @@ kt_android_library( ":dagger", "//domain/src/main/java/org/oppia/android/domain/oppialogger:oppia_logger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:controller", - "//model/src/main/proto:survey_java_proto_lite", "//third_party:javax_inject_javax_inject", ], ) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 69172d0a2bf..745bf63ca57 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -30,8 +30,9 @@ import javax.inject.Singleton /** * Convenience logger for feature flags. * - * This logger is meant to be used to log the current status of all feature flags once after the app - * has been launched. + * This logger is meant to be used for feature flag-related logging on every app launch. It is + * primarily used within the ApplicationLifeCycleObserver to log the status of feature flags in a + * given app session. */ @Singleton class FeatureFlagsLogger @Inject constructor( diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index 82e9532e2fc..524dd2989aa 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -299,7 +299,6 @@ oppia_android_test( ":dagger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:feature_flags_logger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", - "//domain/src/main/java/org/oppia/android/domain/oppialogger/survey:survey_events_logger", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 6e1c66e238c..61056c94f58 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -66,7 +66,7 @@ class FeatureFlagsLoggerTest { } @Test - fun testLogFeatureFlags_logsFeatureFlagsWithCorrectValues() { + fun testLogFeatureFlags_logsFeatureFlagsWithCorrectDefaultValues() { featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index 8df4b6a806f..fed75e8f47b 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -377,21 +377,21 @@ message EventLog { // The unique UUID of the user. string uuid = 1; - // The session id for the current session. + // The id of the current session. string session_id = 2; // List of Feature Flag items repeated FeatureFlagItem feature_flag = 3; - // Structure for the feature flag log item + // Structure for the feature flag log item. message FeatureFlagItem { - // The name of the feature flag or sync status flag + // The name of the feature flag or sync status flag. string flag_name = 1; - // The enabled state of the feature flag + // The enabled state of the feature flag. bool flag_enabled_state = 2; - // The status of the feature flag or sync status flag + // The sync status of the feature flag or sync status flag. PlatformParameter.SyncStatus flag_sync_status = 3; } } @@ -404,7 +404,7 @@ message EventLog { // but can be removed if they're the only ones there and size limit exceeds. ESSENTIAL = 1; // The priority of events whose logs can be removed from the storage if the size exceeds a - // certain limit + // certain limit. OPTIONAL = 2; } } diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 402b67655fb..0b589664aaa 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -2006,8 +2006,8 @@ class EventLogSubject private constructor( companion object { /** - * Returns a new [SurveyContextSubject] to verify aspects of the specified - * [EventLog.SurveyContext] value. + * Returns a new [FeatureFlagContextSubject] to verify aspects of the specified + * [EventLog.FeatureFlagContext] value. */ fun assertThat(actual: EventLog.FeatureFlagContext): FeatureFlagContextSubject = assertAbout(::FeatureFlagContextSubject).that(actual) diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 5dea78ed323..584167b8025 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -568,8 +568,8 @@ class EventBundleCreator @Inject constructor( value: FeatureFlagEventContext ) : EventActivityContext(activityName, value) { override fun EventLog.FeatureFlagContext.storeValue(store: PropertyStore) { - store.putNonSensitiveValue("uuid", uuid) - store.putNonSensitiveValue("session_id", sessionId) + store.putSensitiveValue("uuid", uuid) + store.putSensitiveValue("session_id", sessionId) store.putNonSensitiveValue("feature_flags", featureFlagList) } } From 99295f67172358c4f5a96118aa40cf9fec22a16d Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 5 Dec 2023 13:28:08 +0300 Subject: [PATCH 27/66] feat: Modify the approach used to compile feature flags for logging --- .../analytics/FeatureFlagsLogger.kt | 87 +++++-------------- 1 file changed, 23 insertions(+), 64 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 745bf63ca57..722e10c3fee 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -77,73 +77,32 @@ class FeatureFlagsLogger @Inject constructor( * @return a list of [FeatureFlagItem]s */ private fun compileFeatureFlagsForLogging(): List { - val enableDownloadsSupportFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(DOWNLOADS_SUPPORT) - .setFlagEnabledState(enableDownloadsSupport.value) - .setFlagSyncStatus(enableDownloadsSupport.syncStatus) - .build() - - val enableExtraTopicTabsUiFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(EXTRA_TOPIC_TABS_UI) - .setFlagEnabledState(enableExtraTopicTabsUi.value) - .setFlagSyncStatus(enableExtraTopicTabsUi.syncStatus) - .build() - - val enableLearnerStudyAnalyticsFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(LEARNER_STUDY_ANALYTICS) - .setFlagEnabledState(enableLearnerStudyAnalytics.value) - .setFlagSyncStatus(enableLearnerStudyAnalytics.syncStatus) - .build() - - val enableFastLanguageSwitchingInLessonFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(FAST_LANGUAGE_SWITCHING_IN_LESSON) - .setFlagEnabledState(enableFastLanguageSwitchingInLesson.value) - .setFlagSyncStatus(enableFastLanguageSwitchingInLesson.syncStatus) - .build() - - val enableLoggingLearnerStudyIdsFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(LOGGING_LEARNER_STUDY_IDS) - .setFlagEnabledState(enableLoggingLearnerStudyIds.value) - .setFlagSyncStatus(enableLoggingLearnerStudyIds.syncStatus) - .build() - - val enableEditAccountsOptionsUiFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(EDIT_ACCOUNTS_OPTIONS_UI) - .setFlagEnabledState(enableEditAccountsOptionsUi.value) - .setFlagSyncStatus(enableEditAccountsOptionsUi.syncStatus) - .build() - - val enablePerformanceMetricsCollectionFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(PERFORMANCE_METRICS_COLLECTION) - .setFlagEnabledState(enablePerformanceMetricsCollection.value) - .setFlagSyncStatus(enablePerformanceMetricsCollection.syncStatus) - .build() - - val enableSpotlightUiFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(SPOTLIGHT_UI) - .setFlagEnabledState(enableSpotlightUi.value) - .setFlagSyncStatus(enableSpotlightUi.syncStatus) - .build() + val featureFlagItemMap = mapOf( + DOWNLOADS_SUPPORT to enableDownloadsSupport, + EXTRA_TOPIC_TABS_UI to enableExtraTopicTabsUi, + LEARNER_STUDY_ANALYTICS to enableLearnerStudyAnalytics, + FAST_LANGUAGE_SWITCHING_IN_LESSON to enableFastLanguageSwitchingInLesson, + LOGGING_LEARNER_STUDY_IDS to enableLoggingLearnerStudyIds, + EDIT_ACCOUNTS_OPTIONS_UI to enableEditAccountsOptionsUi, + PERFORMANCE_METRICS_COLLECTION to enablePerformanceMetricsCollection, + SPOTLIGHT_UI to enableSpotlightUi, + INTERACTION_CONFIG_CHANGE_STATE_RETENTION to enableInteractionConfigChangeStateRetention, + APP_AND_OS_DEPRECATION to enableAppAndOsDeprecation, + ) - val enableInteractionConfigChangeStateRetentionFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(INTERACTION_CONFIG_CHANGE_STATE_RETENTION) - .setFlagEnabledState(enableInteractionConfigChangeStateRetention.value) - .setFlagSyncStatus(enableInteractionConfigChangeStateRetention.syncStatus) - .build() + val featureFlagItemList = mutableListOf() - val enableAppAndOsDeprecationFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(APP_AND_OS_DEPRECATION) - .setFlagEnabledState(enableAppAndOsDeprecation.value) - .setFlagSyncStatus(enableAppAndOsDeprecation.syncStatus) - .build() + for (entry in featureFlagItemMap) { + featureFlagItemList.add( + FeatureFlagItem.newBuilder() + .setFlagName(entry.key) + .setFlagEnabledState(entry.value.value) + .setFlagSyncStatus(entry.value.syncStatus) + .build() + ) + } - return listOf( - enableDownloadsSupportFlagItem, enableExtraTopicTabsUiFlagItem, - enableLearnerStudyAnalyticsFlagItem, enableFastLanguageSwitchingInLessonFlagItem, - enableLoggingLearnerStudyIdsFlagItem, enableEditAccountsOptionsUiFlagItem, - enablePerformanceMetricsCollectionFlagItem, enableSpotlightUiFlagItem, - enableInteractionConfigChangeStateRetentionFlagItem, enableAppAndOsDeprecationFlagItem - ) + return featureFlagItemList } /** From 154bd42e4ffd8020af272937d4d8309c4482c6ab Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 6 Dec 2023 13:32:34 +0300 Subject: [PATCH 28/66] feat: Make changes requested by Adhiambo --- .../analytics/FeatureFlagsLogger.kt | 7 +-- .../analytics/FeatureFlagsLoggerTest.kt | 49 ++++++++++++------- model/src/main/proto/oppia_logger.proto | 2 +- .../testing/logging/EventLogSubject.kt | 39 +++++++++------ .../TestPlatformParameterModule.kt | 9 +++- .../util/logging/EventBundleCreator.kt | 2 +- 6 files changed, 65 insertions(+), 43 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 722e10c3fee..4de86ad7b8f 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -91,7 +91,6 @@ class FeatureFlagsLogger @Inject constructor( ) val featureFlagItemList = mutableListOf() - for (entry in featureFlagItemMap) { featureFlagItemList.add( FeatureFlagItem.newBuilder() @@ -115,11 +114,9 @@ class FeatureFlagsLogger @Inject constructor( return EventLog.Context.newBuilder() .setFeatureFlagContext( FeatureFlagContext.newBuilder() - .setUuid("") + .setUniqueUserUuid("") .setSessionId(sessionId) - .addAllFeatureFlag( - compileFeatureFlagsForLogging() - ) + .addAllFeatureFlag(compileFeatureFlagsForLogging()) .build() ) .build() diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 61056c94f58..4b56ffd127b 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -11,7 +11,8 @@ import dagger.Provides import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItem +import org.oppia.android.app.model.PlatformParameter.SyncStatus import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.domain.oppialogger.LoggingIdentifierModule @@ -34,6 +35,7 @@ import org.oppia.android.util.logging.EnableFileLog import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -48,17 +50,17 @@ import javax.inject.Singleton class FeatureFlagsLoggerTest { private companion object { private const val TEST_SESSION_ID = "test_session_id" - private val INITIAL_SYNC_STATUS = PlatformParameter.SyncStatus.NOT_SYNCED_FROM_SERVER + private val INITIAL_SYNC_STATUS = SyncStatus.NOT_SYNCED_FROM_SERVER + private val testEnableDownloadsSupportFeatureFlagItem = FeatureFlagItem.newBuilder() + .setFlagName(DOWNLOADS_SUPPORT) + .setFlagEnabledState(false) + .setFlagSyncStatus(INITIAL_SYNC_STATUS) + .build() } - @Inject - lateinit var featureFlagsLogger: FeatureFlagsLogger - - @Inject - lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger - - @Inject - lateinit var testCoroutineDispatchers: TestCoroutineDispatchers + @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers + @Inject lateinit var featureFlagsLogger: FeatureFlagsLogger + @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger @Before fun setup() { @@ -66,7 +68,7 @@ class FeatureFlagsLoggerTest { } @Test - fun testLogFeatureFlags_logsFeatureFlagsWithCorrectDefaultValues() { + fun testLogFeatureFlags_logsFeatureFlagsWithCorrectSessionId() { featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() @@ -75,19 +77,29 @@ class FeatureFlagsLoggerTest { assertThat(eventLog).hasFeatureFlagContextThat { hasSessionIdThat().isEqualTo(TEST_SESSION_ID) } + } + + @Test + fun testLogFeatureFlags_logsFeatureFlagsWithCorrectDefaultValues() { + featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + testCoroutineDispatchers.runCurrent() + + val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() + + assertThat(eventLog).hasFeatureFlagContextThat { + hasNamedFeatureFlagThat(DOWNLOADS_SUPPORT) + .isEqualTo(testEnableDownloadsSupportFeatureFlagItem) + } assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureEnabledStateThat().isEqualTo(false) + hasNamedFeatureWithEnabledStateThat(DOWNLOADS_SUPPORT).isEqualTo(false) } assertThat(eventLog).hasFeatureFlagContextThat { - hasSyncStatusThat().isEqualTo(INITIAL_SYNC_STATUS) + hasNamedFeatureWithSyncStatusThat(DOWNLOADS_SUPPORT).isEqualTo(INITIAL_SYNC_STATUS) } } private fun setUpTestApplicationComponent() { - DaggerFeatureFlagsLoggerTest_TestApplicationComponent.builder() - .setApplication(ApplicationProvider.getApplicationContext()) - .build() - .inject(this) + ApplicationProvider.getApplicationContext().inject(this) } // TODO(#89): Move this to a common test application component. @@ -133,8 +145,7 @@ class FeatureFlagsLoggerTest { TestDispatcherModule::class, TestLogStorageModule::class, NetworkConnectionUtilDebugModule::class, LocaleProdModule::class, FakeOppiaClockModule::class, TestPlatformParameterModule::class, PlatformParameterSingletonModule::class, - LoggingIdentifierModule::class, SyncStatusTestModule::class, AssetModule::class, - ApplicationLifecycleModule::class + LoggingIdentifierModule::class, SyncStatusTestModule::class, AssetModule::class ] ) diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index fed75e8f47b..29d510b61bf 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -375,7 +375,7 @@ message EventLog { // Structure of a feature flag context. message FeatureFlagContext { // The unique UUID of the user. - string uuid = 1; + string unique_user_uuid = 1; // The id of the current session. string session_id = 2; diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 0b589664aaa..1d35bcc4a19 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -7,6 +7,7 @@ import com.google.common.truth.IntegerSubject import com.google.common.truth.IterableSubject import com.google.common.truth.LongSubject import com.google.common.truth.StringSubject +import com.google.common.truth.Subject import com.google.common.truth.Truth.assertAbout import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.LiteProtoSubject @@ -52,7 +53,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SUBMIT_A import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SWITCH_IN_LESSON_LANGUAGE import org.oppia.android.app.model.MarketFitAnswer import org.oppia.android.app.model.OppiaLanguage -import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.app.model.PlatformParameter.SyncStatus import org.oppia.android.app.model.SurveyQuestionName import org.oppia.android.app.model.UserTypeAnswer import org.oppia.android.app.model.WrittenTranslationLanguageSelection @@ -1985,24 +1986,32 @@ class EventLogSubject private constructor( fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) /** - * Returns a [BooleanSubject] to test the flagEnabledState of the first item on the feature flag - * list in the [EventLog.FeatureFlagContext]. - * - * This method never fails since the underlying property defaults to empty string if it's not - * defined in the context. + * Returns a [Subject] to test the of the properties of a feature flag with the passed + * name in the [EventLog.FeatureFlagContext] list. */ - fun hasFeatureEnabledStateThat(): BooleanSubject = - assertThat(actual.getFeatureFlag(0).flagEnabledState) + fun hasNamedFeatureFlagThat(name: String): Subject { + val filtered = actual.featureFlagList.filter { it.flagName == name } + + return assertThat(filtered[0]) + } /** - * Returns a [ComparableSubject] to test the flagSyncStatus of the - * [EventLog.FeatureFlagContext]. - * - * This method never fails since the underlying property defaults to empty string if it's not - * defined in the context. + * Returns a [BooleanSubject] to test the flagEnabledState of a feature flag with the passed + * name in the [EventLog.FeatureFlagContext] list. + */ + fun hasNamedFeatureWithEnabledStateThat(name: String): BooleanSubject { + val filtered = actual.featureFlagList.filter { it.flagName == name } + return assertThat(filtered[0].flagEnabledState) + } + + /** + * Returns a [ComparableSubject] with a [SyncStatus] to test the flagSyncStatus of a feature + * flag with the passed name in the [EventLog.FeatureFlagContext]. */ - fun hasSyncStatusThat(): ComparableSubject = - assertThat(actual.getFeatureFlag(0).flagSyncStatus) + fun hasNamedFeatureWithSyncStatusThat(name: String): ComparableSubject { + val filtered = actual.featureFlagList.filter { it.flagName == name } + return assertThat(filtered[0].flagSyncStatus) + } companion object { /** diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 9341414bfd8..3385d3cde26 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -8,6 +8,7 @@ import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering +import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE @@ -64,8 +65,12 @@ import javax.inject.Singleton class TestPlatformParameterModule { @Provides @EnableDownloadsSupport - fun provideEnableDownloadsSupport(): PlatformParameterValue = - PlatformParameterValue.createDefaultParameter(enableDownloadsSupport) + fun provideEnableDownloadsSupport( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) + ?: PlatformParameterValue.createDefaultParameter(enableDownloadsSupport) + } @TestStringParam @Provides diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 584167b8025..6a9507b0e52 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -568,7 +568,7 @@ class EventBundleCreator @Inject constructor( value: FeatureFlagEventContext ) : EventActivityContext(activityName, value) { override fun EventLog.FeatureFlagContext.storeValue(store: PropertyStore) { - store.putSensitiveValue("uuid", uuid) + store.putSensitiveValue("uuid", uniqueUserUuid) store.putSensitiveValue("session_id", sessionId) store.putNonSensitiveValue("feature_flags", featureFlagList) } From 79b35272b448c5ef81c8b50a2f99284d260cbe83 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 18 Dec 2023 10:42:13 +0300 Subject: [PATCH 29/66] fix: Make latest requested changes --- .../domain/oppialogger/analytics/FeatureFlagsLogger.kt | 3 +-- .../oppialogger/analytics/FeatureFlagsLoggerTest.kt | 5 ++--- model/src/main/proto/oppia_logger.proto | 2 +- .../oppia/android/testing/logging/EventLogSubject.kt | 10 +++++----- .../oppia/android/util/logging/EventBundleCreator.kt | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 4de86ad7b8f..ecc075fc658 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -114,9 +114,8 @@ class FeatureFlagsLogger @Inject constructor( return EventLog.Context.newBuilder() .setFeatureFlagContext( FeatureFlagContext.newBuilder() - .setUniqueUserUuid("") .setSessionId(sessionId) - .addAllFeatureFlag(compileFeatureFlagsForLogging()) + .addAllFeatureFlags(compileFeatureFlagsForLogging()) .build() ) .build() diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 4b56ffd127b..bf550be1892 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -68,7 +68,7 @@ class FeatureFlagsLoggerTest { } @Test - fun testLogFeatureFlags_logsFeatureFlagsWithCorrectSessionId() { + fun testLogFeatureFlags_logFeatureFlags_hasCorrectSessionId() { featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() @@ -87,8 +87,7 @@ class FeatureFlagsLoggerTest { val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasNamedFeatureFlagThat(DOWNLOADS_SUPPORT) - .isEqualTo(testEnableDownloadsSupportFeatureFlagItem) + hasFeatureFlagWithNameThat(DOWNLOADS_SUPPORT).isEqualTo(DOWNLOADS_SUPPORT) } assertThat(eventLog).hasFeatureFlagContextThat { hasNamedFeatureWithEnabledStateThat(DOWNLOADS_SUPPORT).isEqualTo(false) diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index 29d510b61bf..17a8063d3ea 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -381,7 +381,7 @@ message EventLog { string session_id = 2; // List of Feature Flag items - repeated FeatureFlagItem feature_flag = 3; + repeated FeatureFlagItem feature_flags = 3; // Structure for the feature flag log item. message FeatureFlagItem { diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 1d35bcc4a19..1f3974fcd82 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -1989,10 +1989,10 @@ class EventLogSubject private constructor( * Returns a [Subject] to test the of the properties of a feature flag with the passed * name in the [EventLog.FeatureFlagContext] list. */ - fun hasNamedFeatureFlagThat(name: String): Subject { - val filtered = actual.featureFlagList.filter { it.flagName == name } + fun hasFeatureFlagWithNameThat(name: String): Subject { + val featureFlag = actual.featureFlagsList.firstOrNull { it.flagName == name } - return assertThat(filtered[0]) + return assertThat(featureFlag?.flagName) } /** @@ -2000,7 +2000,7 @@ class EventLogSubject private constructor( * name in the [EventLog.FeatureFlagContext] list. */ fun hasNamedFeatureWithEnabledStateThat(name: String): BooleanSubject { - val filtered = actual.featureFlagList.filter { it.flagName == name } + val filtered = actual.featureFlagsList.filter { it.flagName == name } return assertThat(filtered[0].flagEnabledState) } @@ -2009,7 +2009,7 @@ class EventLogSubject private constructor( * flag with the passed name in the [EventLog.FeatureFlagContext]. */ fun hasNamedFeatureWithSyncStatusThat(name: String): ComparableSubject { - val filtered = actual.featureFlagList.filter { it.flagName == name } + val filtered = actual.featureFlagsList.filter { it.flagName == name } return assertThat(filtered[0].flagSyncStatus) } diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 6a9507b0e52..e566d4de9d2 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -570,7 +570,7 @@ class EventBundleCreator @Inject constructor( override fun EventLog.FeatureFlagContext.storeValue(store: PropertyStore) { store.putSensitiveValue("uuid", uniqueUserUuid) store.putSensitiveValue("session_id", sessionId) - store.putNonSensitiveValue("feature_flags", featureFlagList) + store.putNonSensitiveValue("feature_flags", featureFlagsList) } } } From c17dab526676d99877ffd34e8ef577e539da8aad Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 20 Dec 2023 12:40:12 +0300 Subject: [PATCH 30/66] feat: Made some changes to the feature flag tests --- .../analytics/FeatureFlagsLogger.kt | 10 ++++++ .../PlatformParameterAlphaKenyaModule.kt | 30 ++++++++++++++++ .../PlatformParameterAlphaModule.kt | 30 ++++++++++++++++ .../PlatformParameterModule.kt | 30 ++++++++++++++++ .../analytics/FeatureFlagsLoggerTest.kt | 36 +++++++++++-------- .../testing/logging/EventLogSubject.kt | 34 ++++++++---------- .../TestPlatformParameterModule.kt | 30 ++++++++++++++++ .../platformparameter/FeatureFlagConstants.kt | 22 ++++++++++++ 8 files changed, 189 insertions(+), 33 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index ecc075fc658..9e840a2bc2c 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -17,6 +17,8 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.EnableTestFeatureFlag +import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS @@ -24,6 +26,8 @@ import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPOTLIGHT_UI +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS import javax.inject.Inject import javax.inject.Singleton @@ -37,6 +41,10 @@ import javax.inject.Singleton @Singleton class FeatureFlagsLogger @Inject constructor( private val analyticsController: AnalyticsController, + @EnableTestFeatureFlag + private val testFeatureFlag: PlatformParameterValue, + @EnableTestFeatureFlagWithEnabledDefault + private val testFeatureFlagWithEnabledDefault: PlatformParameterValue, @EnableDownloadsSupport private val enableDownloadsSupport: PlatformParameterValue, @EnableExtraTopicTabsUi @@ -78,6 +86,8 @@ class FeatureFlagsLogger @Inject constructor( */ private fun compileFeatureFlagsForLogging(): List { val featureFlagItemMap = mapOf( + TEST_FEATURE_FLAG to testFeatureFlag, + TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS to testFeatureFlagWithEnabledDefault, DOWNLOADS_SUPPORT to enableDownloadsSupport, EXTRA_TOPIC_TABS_UI to enableExtraTopicTabsUi, LEARNER_STUDY_ANALYTICS to enableLearnerStudyAnalytics, diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 9509dff7f23..a6d029a0f6c 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -3,6 +3,7 @@ package org.oppia.android.domain.platformparameter import android.content.Context import dagger.Module import dagger.Provides +import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING @@ -30,6 +31,8 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.EnableTestFeatureFlag +import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode @@ -66,6 +69,10 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE // TODO(#4419): Remove this module. /** @@ -74,6 +81,29 @@ import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours */ @Module class PlatformParameterAlphaKenyaModule { + @Provides + @EnableTestFeatureFlag + fun provideEnableTestFeatureFlag( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) + ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) + } + + @Provides + @EnableTestFeatureFlagWithEnabledDefault + fun provideEnableTestFeatureFlagWithEnabledDefault( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS + ) + ?: PlatformParameterValue.createDefaultParameter( + defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, + defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER + ) + } + @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 2eba6e0d6e7..c59ce4ca63f 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -3,6 +3,7 @@ package org.oppia.android.domain.platformparameter import android.content.Context import dagger.Module import dagger.Provides +import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING @@ -29,6 +30,8 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.EnableTestFeatureFlag +import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE @@ -67,10 +70,37 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE /** Dagger module that provides bindings for platform parameters for the alpha app builds. */ @Module class PlatformParameterAlphaModule { + @Provides + @EnableTestFeatureFlag + fun provideEnableTestFeatureFlag( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) + ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) + } + + @Provides + @EnableTestFeatureFlagWithEnabledDefault + fun provideEnableTestFeatureFlagWithEnabledDefault( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS + ) + ?: PlatformParameterValue.createDefaultParameter( + defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, + defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER + ) + } + @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 3287dd469d8..9017d6bac12 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -3,6 +3,7 @@ package org.oppia.android.domain.platformparameter import android.content.Context import dagger.Module import dagger.Provides +import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING @@ -30,6 +31,8 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.EnableTestFeatureFlag +import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE @@ -69,10 +72,37 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE /** Dagger module that provides bindings for platform parameters. */ @Module class PlatformParameterModule { + @Provides + @EnableTestFeatureFlag + fun provideEnableTestFeatureFlag( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) + ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) + } + + @Provides + @EnableTestFeatureFlagWithEnabledDefault + fun provideEnableTestFeatureFlagWithEnabledDefault( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS + ) + ?: PlatformParameterValue.createDefaultParameter( + defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, + defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER + ) + } + @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index bf550be1892..1920f2fd350 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -11,7 +11,6 @@ import dagger.Provides import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItem import org.oppia.android.app.model.PlatformParameter.SyncStatus import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize @@ -35,7 +34,8 @@ import org.oppia.android.util.logging.EnableFileLog import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -50,12 +50,6 @@ import javax.inject.Singleton class FeatureFlagsLoggerTest { private companion object { private const val TEST_SESSION_ID = "test_session_id" - private val INITIAL_SYNC_STATUS = SyncStatus.NOT_SYNCED_FROM_SERVER - private val testEnableDownloadsSupportFeatureFlagItem = FeatureFlagItem.newBuilder() - .setFlagName(DOWNLOADS_SUPPORT) - .setFlagEnabledState(false) - .setFlagSyncStatus(INITIAL_SYNC_STATUS) - .build() } @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @@ -80,20 +74,34 @@ class FeatureFlagsLoggerTest { } @Test - fun testLogFeatureFlags_logsFeatureFlagsWithCorrectDefaultValues() { + fun testLogFeatureFlags_logsTestFeatureFlag_hasCorrectDefaultValues() { featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureFlagWithNameThat(DOWNLOADS_SUPPORT).isEqualTo(DOWNLOADS_SUPPORT) - } - assertThat(eventLog).hasFeatureFlagContextThat { - hasNamedFeatureWithEnabledStateThat(DOWNLOADS_SUPPORT).isEqualTo(false) + val testFeatureFlag = hasFeatureFlagThat(TEST_FEATURE_FLAG) + + assertFeatureFlag(testFeatureFlag).isNotNull() + featureFlagHasEnabledStateThat(testFeatureFlag).isEqualTo(false) + featureFlagHasSyncStatusThat(testFeatureFlag).isEqualTo(SyncStatus.NOT_SYNCED_FROM_SERVER) } + } + + @Test + fun testLogFeatureFlags_logsTestFeatureFlagWithEnabledDefaults_hasCorrectDefaultValues() { + featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + testCoroutineDispatchers.runCurrent() + + val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() + assertThat(eventLog).hasFeatureFlagContextThat { - hasNamedFeatureWithSyncStatusThat(DOWNLOADS_SUPPORT).isEqualTo(INITIAL_SYNC_STATUS) + val testFeatureFlag = hasFeatureFlagThat(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS) + + assertFeatureFlag(testFeatureFlag).isNotNull() + featureFlagHasEnabledStateThat(testFeatureFlag).isEqualTo(true) + featureFlagHasSyncStatusThat(testFeatureFlag).isEqualTo(SyncStatus.SYNCED_FROM_SERVER) } } diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 1f3974fcd82..c0cc3c08ab8 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -51,6 +51,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_CA import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_OVER_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SUBMIT_ANSWER_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SWITCH_IN_LESSON_LANGUAGE +import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItem import org.oppia.android.app.model.MarketFitAnswer import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.PlatformParameter.SyncStatus @@ -1986,32 +1987,27 @@ class EventLogSubject private constructor( fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) /** - * Returns a [Subject] to test the of the properties of a feature flag with the passed + * Returns a [FeatureFlagItem] to test the properties of a feature flag with the passed * name in the [EventLog.FeatureFlagContext] list. */ - fun hasFeatureFlagWithNameThat(name: String): Subject { - val featureFlag = actual.featureFlagsList.firstOrNull { it.flagName == name } + fun hasFeatureFlagThat(name: String): FeatureFlagItem? = + actual.featureFlagsList.firstOrNull { it.flagName == name } - return assertThat(featureFlag?.flagName) - } + /*** Returns a [Subject] to test whether the passed feature flag is null or not. */ + fun assertFeatureFlag(featureFlagItem: FeatureFlagItem?): Subject = assertThat(featureFlagItem) - /** - * Returns a [BooleanSubject] to test the flagEnabledState of a feature flag with the passed - * name in the [EventLog.FeatureFlagContext] list. - */ - fun hasNamedFeatureWithEnabledStateThat(name: String): BooleanSubject { - val filtered = actual.featureFlagsList.filter { it.flagName == name } - return assertThat(filtered[0].flagEnabledState) - } + /*** Returns a [BooleanSubject] to test the flagEnabledState of the passed feature flag. */ + fun featureFlagHasEnabledStateThat( + featureFlagItem: FeatureFlagItem? + ): BooleanSubject = assertThat(featureFlagItem?.flagEnabledState) /** - * Returns a [ComparableSubject] with a [SyncStatus] to test the flagSyncStatus of a feature - * flag with the passed name in the [EventLog.FeatureFlagContext]. + * Returns a [ComparableSubject] with a [SyncStatus] to test the flagSyncStatus of the passed + * feature flag. */ - fun hasNamedFeatureWithSyncStatusThat(name: String): ComparableSubject { - val filtered = actual.featureFlagsList.filter { it.flagName == name } - return assertThat(filtered[0].flagSyncStatus) - } + fun featureFlagHasSyncStatusThat( + featureFlagItem: FeatureFlagItem? + ): ComparableSubject = assertThat(featureFlagItem?.flagSyncStatus) companion object { /** diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 3385d3cde26..32ecc0f04fd 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -4,6 +4,7 @@ import android.content.Context import androidx.annotation.VisibleForTesting import dagger.Module import dagger.Provides +import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE @@ -27,6 +28,8 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.EnableTestFeatureFlag +import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode @@ -58,11 +61,38 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS +import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE import javax.inject.Singleton /* Fake Platform Parameter Module that provides individual Platform Parameters for testing. */ @Module class TestPlatformParameterModule { + @Provides + @EnableTestFeatureFlag + fun provideEnableTestFeatureFlag( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) + ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) + } + + @Provides + @EnableTestFeatureFlagWithEnabledDefault + fun provideEnableTestFeatureFlagWithEnabledDefault( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getBooleanPlatformParameter( + TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS + ) + ?: PlatformParameterValue.createDefaultParameter( + defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, + defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER + ) + } + @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index c108d5743ef..89748e6a847 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -12,6 +12,28 @@ import javax.inject.Qualifier * has been synced with Oppia Web. */ +/** + * Qualifier for a test feature flag + */ +@Qualifier annotation class EnableTestFeatureFlag + +/*** Name of the test feature flag */ +const val TEST_FEATURE_FLAG = "android_test_feature_flag" + +/** Default value of the test feature flag */ +const val TEST_FEATURE_FLAG_DEFAULT_VALUE = false + +/** + * Qualifier for a test feature flag with an enabled default value + */ +@Qualifier annotation class EnableTestFeatureFlagWithEnabledDefault + +/*** Name of the test feature flag with an enabled default value */ +const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS = "android_test_feature_flag_with_enabled_default" + +/** Default value of the test feature flag with an enabled default value */ +const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE = true + /** * Qualifier for the feature flag that controls whether the user has support for manually * downloading topics. From 77a3d2934c766676b5e4310169a6c565b67bbbe2 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 20 Dec 2023 13:03:14 +0300 Subject: [PATCH 31/66] fix: Fix failing kdoc validation checks --- .../oppia/android/testing/logging/EventLogSubject.kt | 4 ++-- .../util/platformparameter/FeatureFlagConstants.kt | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index c0cc3c08ab8..79360c969d1 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -1993,10 +1993,10 @@ class EventLogSubject private constructor( fun hasFeatureFlagThat(name: String): FeatureFlagItem? = actual.featureFlagsList.firstOrNull { it.flagName == name } - /*** Returns a [Subject] to test whether the passed feature flag is null or not. */ + /** Returns a [Subject] to test whether the passed feature flag is null or not. */ fun assertFeatureFlag(featureFlagItem: FeatureFlagItem?): Subject = assertThat(featureFlagItem) - /*** Returns a [BooleanSubject] to test the flagEnabledState of the passed feature flag. */ + /** Returns a [BooleanSubject] to test the flagEnabledState of the passed feature flag. */ fun featureFlagHasEnabledStateThat( featureFlagItem: FeatureFlagItem? ): BooleanSubject = assertThat(featureFlagItem?.flagEnabledState) diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 89748e6a847..787bfad15d3 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -17,21 +17,19 @@ import javax.inject.Qualifier */ @Qualifier annotation class EnableTestFeatureFlag -/*** Name of the test feature flag */ +/** Name of the test feature flag. */ const val TEST_FEATURE_FLAG = "android_test_feature_flag" -/** Default value of the test feature flag */ +/** Default value of the test feature flag. */ const val TEST_FEATURE_FLAG_DEFAULT_VALUE = false -/** - * Qualifier for a test feature flag with an enabled default value - */ +/** Qualifier for a test feature flag with an enabled default value. */ @Qualifier annotation class EnableTestFeatureFlagWithEnabledDefault -/*** Name of the test feature flag with an enabled default value */ +/** Name of the test feature flag with an enabled default value. */ const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS = "android_test_feature_flag_with_enabled_default" -/** Default value of the test feature flag with an enabled default value */ +/** Default value of the test feature flag with an enabled default value. */ const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE = true /** From ed41b4a8ab4c9bbdeb86451da5e06cb70903a4dd Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Thu, 4 Jan 2024 12:36:49 +0300 Subject: [PATCH 32/66] merge: Fix lint issues from merging changes --- .../platformparameter/PlatformParameterAlphaKenyaModule.kt | 1 - .../domain/platformparameter/PlatformParameterAlphaModule.kt | 1 - .../android/domain/platformparameter/PlatformParameterModule.kt | 1 - 3 files changed, 3 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 2416d6b23bd..4fd9abc5dd8 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -16,7 +16,6 @@ import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 3279c299394..0ac106fd838 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -16,7 +16,6 @@ import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 8c0ccde3c2b..176f646c25b 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -16,7 +16,6 @@ import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI From 31a26ea8f66c47fea3c2a6c7ffa13a53caf72aa0 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Thu, 11 Jan 2024 13:52:19 +0300 Subject: [PATCH 33/66] feat: Make suggested changes --- .../analytics/ApplicationLifecycleObserver.kt | 4 +- .../analytics/FeatureFlagsLogger.kt | 100 ++++++++--------- .../PlatformParameterAlphaKenyaModule.kt | 30 ----- .../PlatformParameterAlphaModule.kt | 30 ----- .../PlatformParameterModule.kt | 30 ----- .../analytics/FeatureFlagsLoggerTest.kt | 51 +++++---- model/src/main/proto/oppia_logger.proto | 4 +- .../testing/logging/EventLogSubject.kt | 106 ++++++++++++++---- .../TestPlatformParameterConstants.kt | 20 ++++ .../TestPlatformParameterModule.kt | 6 - .../platformparameter/FeatureFlagConstants.kt | 20 ---- 11 files changed, 190 insertions(+), 211 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index b337cd9ff1b..3fe6b708323 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -45,6 +45,7 @@ class ApplicationLifecycleObserver @Inject constructor( @BackgroundDispatcher private val backgroundDispatcher: CoroutineDispatcher, @EnablePerformanceMetricsCollection private val enablePerformanceMetricsCollection: PlatformParameterValue, + private val analyticsController: AnalyticsController, private val applicationLifecycleListeners: Set<@JvmSuppressWildcards ApplicationLifecycleListener> ) : ApplicationStartupListener, LifecycleObserver, Application.ActivityLifecycleCallbacks { @@ -170,13 +171,12 @@ class ApplicationLifecycleObserver @Inject constructor( private fun logAllFeatureFlags() { CoroutineScope(backgroundDispatcher).launch { val sessionId = loggingIdentifierController.getSessionIdFlow().value - featureFlagsLogger.logAllFeatureFlags(sessionId) }.invokeOnCompletion { failure -> if (failure != null) { oppiaLogger.e( "ActivityLifecycleObserver", - "Encountered error while trying to log app's feature flags.", + "Encountered error while logging feature flags.", failure ) } diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 9e840a2bc2c..4d348ebacd9 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -2,7 +2,7 @@ package org.oppia.android.domain.oppialogger.analytics import org.oppia.android.app.model.EventLog import org.oppia.android.app.model.EventLog.FeatureFlagContext -import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItem +import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItemContext import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI @@ -17,8 +17,6 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi -import org.oppia.android.util.platformparameter.EnableTestFeatureFlag -import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS @@ -26,8 +24,6 @@ import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPOTLIGHT_UI -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS import javax.inject.Inject import javax.inject.Singleton @@ -35,16 +31,12 @@ import javax.inject.Singleton * Convenience logger for feature flags. * * This logger is meant to be used for feature flag-related logging on every app launch. It is - * primarily used within the ApplicationLifeCycleObserver to log the status of feature flags in a + * primarily used within the ApplicationLifecycleObserver to log the status of feature flags in a * given app session. */ @Singleton class FeatureFlagsLogger @Inject constructor( private val analyticsController: AnalyticsController, - @EnableTestFeatureFlag - private val testFeatureFlag: PlatformParameterValue, - @EnableTestFeatureFlagWithEnabledDefault - private val testFeatureFlagWithEnabledDefault: PlatformParameterValue, @EnableDownloadsSupport private val enableDownloadsSupport: PlatformParameterValue, @EnableExtraTopicTabsUi @@ -67,51 +59,56 @@ class FeatureFlagsLogger @Inject constructor( private val enableAppAndOsDeprecation: PlatformParameterValue ) { /** - * This method logs the name, enabled status and sync status of all feature flags to Firebase. + * A variable containing a list of all the feature flags in the app. * - * @param sessionId denotes the id of the current appInForeground session + * @return a list of key-value pairs of [String] and [PlatformParameterValue] */ - fun logAllFeatureFlags(sessionId: String) { - analyticsController.logImportantEvent( - createFeatureFlagContext(sessionId = sessionId), - null - ) - } + private var featureFlagItemMap: Map> = mapOf( + DOWNLOADS_SUPPORT to enableDownloadsSupport, + EXTRA_TOPIC_TABS_UI to enableExtraTopicTabsUi, + LEARNER_STUDY_ANALYTICS to enableLearnerStudyAnalytics, + FAST_LANGUAGE_SWITCHING_IN_LESSON to enableFastLanguageSwitchingInLesson, + LOGGING_LEARNER_STUDY_IDS to enableLoggingLearnerStudyIds, + EDIT_ACCOUNTS_OPTIONS_UI to enableEditAccountsOptionsUi, + PERFORMANCE_METRICS_COLLECTION to enablePerformanceMetricsCollection, + SPOTLIGHT_UI to enableSpotlightUi, + INTERACTION_CONFIG_CHANGE_STATE_RETENTION to enableInteractionConfigChangeStateRetention, + APP_AND_OS_DEPRECATION to enableAppAndOsDeprecation, + ) /** - * Collects all the feature flags in the app, creates a FeatureFlagItem for them and adds them to - * a list that is returned to the calling object. + * This method can be used to override the featureFlagItemMap and sets its value to the given map. * - * @return a list of [FeatureFlagItem]s + * @param featureFlagItemMap denotes the map of feature flag names to their corresponding + * [PlatformParameterValue]s */ - private fun compileFeatureFlagsForLogging(): List { - val featureFlagItemMap = mapOf( - TEST_FEATURE_FLAG to testFeatureFlag, - TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS to testFeatureFlagWithEnabledDefault, - DOWNLOADS_SUPPORT to enableDownloadsSupport, - EXTRA_TOPIC_TABS_UI to enableExtraTopicTabsUi, - LEARNER_STUDY_ANALYTICS to enableLearnerStudyAnalytics, - FAST_LANGUAGE_SWITCHING_IN_LESSON to enableFastLanguageSwitchingInLesson, - LOGGING_LEARNER_STUDY_IDS to enableLoggingLearnerStudyIds, - EDIT_ACCOUNTS_OPTIONS_UI to enableEditAccountsOptionsUi, - PERFORMANCE_METRICS_COLLECTION to enablePerformanceMetricsCollection, - SPOTLIGHT_UI to enableSpotlightUi, - INTERACTION_CONFIG_CHANGE_STATE_RETENTION to enableInteractionConfigChangeStateRetention, - APP_AND_OS_DEPRECATION to enableAppAndOsDeprecation, - ) + fun setFeatureFlagItemMap(featureFlagItemMap: Map>) { + this.featureFlagItemMap = featureFlagItemMap + } - val featureFlagItemList = mutableListOf() - for (entry in featureFlagItemMap) { + /** + * This method logs the name, enabled status and sync status of all feature flags to Firebase. + * + * @param sessionId denotes the id of the current appInForeground session + */ + fun logAllFeatureFlags(sessionId: String) { + val featureFlagItemList = mutableListOf() + for (flag in featureFlagItemMap) { featureFlagItemList.add( - FeatureFlagItem.newBuilder() - .setFlagName(entry.key) - .setFlagEnabledState(entry.value.value) - .setFlagSyncStatus(entry.value.syncStatus) - .build() + createFeatureFlagItemContext(flag) ) } + val featureFlagContext = FeatureFlagContext.newBuilder() + .setSessionId(sessionId) + .addAllFeatureFlags(featureFlagItemList) + .build() - return featureFlagItemList + analyticsController.logLowPriorityEvent( + EventLog.Context.newBuilder() + .setFeatureFlagContext(featureFlagContext) + .build(), + profileId = null + ) } /** @@ -120,14 +117,13 @@ class FeatureFlagsLogger @Inject constructor( * @param sessionId denotes the session id of the current appInForeground session * @return an [EventLog.Context] for the feature flags to be logged */ - private fun createFeatureFlagContext(sessionId: String): EventLog.Context { - return EventLog.Context.newBuilder() - .setFeatureFlagContext( - FeatureFlagContext.newBuilder() - .setSessionId(sessionId) - .addAllFeatureFlags(compileFeatureFlagsForLogging()) - .build() - ) + private fun createFeatureFlagItemContext( + flagDetails: Map.Entry>, + ): FeatureFlagItemContext { + return FeatureFlagItemContext.newBuilder() + .setFlagName(flagDetails.key) + .setFlagEnabledState(flagDetails.value.value) + .setFlagSyncStatus(flagDetails.value.syncStatus) .build() } } diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 4fd9abc5dd8..dfa97fa413b 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -3,7 +3,6 @@ package org.oppia.android.domain.platformparameter import android.content.Context import dagger.Module import dagger.Provides -import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING @@ -29,8 +28,6 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi -import org.oppia.android.util.platformparameter.EnableTestFeatureFlag -import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode @@ -67,10 +64,6 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE // TODO(#4419): Remove this module. /** @@ -79,29 +72,6 @@ import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_D */ @Module class PlatformParameterAlphaKenyaModule { - @Provides - @EnableTestFeatureFlag - fun provideEnableTestFeatureFlag( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) - ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) - } - - @Provides - @EnableTestFeatureFlagWithEnabledDefault - fun provideEnableTestFeatureFlagWithEnabledDefault( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS - ) - ?: PlatformParameterValue.createDefaultParameter( - defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, - defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER - ) - } - @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt index 0ac106fd838..21b8f432c0d 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt @@ -3,7 +3,6 @@ package org.oppia.android.domain.platformparameter import android.content.Context import dagger.Module import dagger.Provides -import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING @@ -28,8 +27,6 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi -import org.oppia.android.util.platformparameter.EnableTestFeatureFlag -import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE @@ -68,37 +65,10 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE /** Dagger module that provides bindings for platform parameters for the alpha app builds. */ @Module class PlatformParameterAlphaModule { - @Provides - @EnableTestFeatureFlag - fun provideEnableTestFeatureFlag( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) - ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) - } - - @Provides - @EnableTestFeatureFlagWithEnabledDefault - fun provideEnableTestFeatureFlagWithEnabledDefault( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS - ) - ?: PlatformParameterValue.createDefaultParameter( - defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, - defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER - ) - } - @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 176f646c25b..db639dbadd9 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -3,7 +3,6 @@ package org.oppia.android.domain.platformparameter import android.content.Context import dagger.Module import dagger.Provides -import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING @@ -29,8 +28,6 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi -import org.oppia.android.util.platformparameter.EnableTestFeatureFlag -import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE @@ -70,37 +67,10 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE /** Dagger module that provides bindings for platform parameters. */ @Module class PlatformParameterModule { - @Provides - @EnableTestFeatureFlag - fun provideEnableTestFeatureFlag( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(TEST_FEATURE_FLAG) - ?: PlatformParameterValue.createDefaultParameter(TEST_FEATURE_FLAG_DEFAULT_VALUE) - } - - @Provides - @EnableTestFeatureFlagWithEnabledDefault - fun provideEnableTestFeatureFlagWithEnabledDefault( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS - ) - ?: PlatformParameterValue.createDefaultParameter( - defaultValue = TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE, - defaultSyncStatus = PlatformParameter.SyncStatus.SYNCED_FROM_SERVER - ) - } - @Provides @EnableDownloadsSupport fun provideEnableDownloadsSupport( diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 1920f2fd350..d0bd6bef33e 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -20,6 +20,10 @@ import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.logging.SyncStatusTestModule +import org.oppia.android.testing.platformparameter.EnableTestFeatureFlag +import org.oppia.android.testing.platformparameter.EnableTestFeatureFlagWithEnabledDefault +import org.oppia.android.testing.platformparameter.TEST_FEATURE_FLAG +import org.oppia.android.testing.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -34,8 +38,7 @@ import org.oppia.android.util.logging.EnableFileLog import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS +import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -48,17 +51,24 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FeatureFlagsLoggerTest.TestApplication::class) class FeatureFlagsLoggerTest { - private companion object { - private const val TEST_SESSION_ID = "test_session_id" - } - @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var featureFlagsLogger: FeatureFlagsLogger @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger + @field:[Inject EnableTestFeatureFlag] + lateinit var testFeatureFlag: PlatformParameterValue + @field:[Inject EnableTestFeatureFlagWithEnabledDefault] + lateinit var testFeatureFlagWithEnabledDefault: PlatformParameterValue + @Before fun setup() { setUpTestApplicationComponent() + + val mapOfTestFeatureFlags = mapOf( + TEST_FEATURE_FLAG to testFeatureFlag, + TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS to testFeatureFlagWithEnabledDefault + ) + featureFlagsLogger.setFeatureFlagItemMap(mapOfTestFeatureFlags) } @Test @@ -67,7 +77,6 @@ class FeatureFlagsLoggerTest { testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() - assertThat(eventLog).hasFeatureFlagContextThat { hasSessionIdThat().isEqualTo(TEST_SESSION_ID) } @@ -79,13 +88,13 @@ class FeatureFlagsLoggerTest { testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() - assertThat(eventLog).hasFeatureFlagContextThat { - val testFeatureFlag = hasFeatureFlagThat(TEST_FEATURE_FLAG) - - assertFeatureFlag(testFeatureFlag).isNotNull() - featureFlagHasEnabledStateThat(testFeatureFlag).isEqualTo(false) - featureFlagHasSyncStatusThat(testFeatureFlag).isEqualTo(SyncStatus.NOT_SYNCED_FROM_SERVER) + hasFeatureFlagItemContextThatHasName(TEST_FEATURE_FLAG).apply { + hasFeatureFlagItemContextThat().isNotNull() + hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG) + hasFeatureFlagEnabledStateThat().isEqualTo(false) + hasFeatureFlagSyncStateThat().isEqualTo(SyncStatus.NOT_SYNCED_FROM_SERVER) + } } } @@ -95,13 +104,13 @@ class FeatureFlagsLoggerTest { testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() - assertThat(eventLog).hasFeatureFlagContextThat { - val testFeatureFlag = hasFeatureFlagThat(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS) - - assertFeatureFlag(testFeatureFlag).isNotNull() - featureFlagHasEnabledStateThat(testFeatureFlag).isEqualTo(true) - featureFlagHasSyncStatusThat(testFeatureFlag).isEqualTo(SyncStatus.SYNCED_FROM_SERVER) + hasFeatureFlagItemContextThatHasName(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS).apply { + hasFeatureFlagItemContextThat().isNotNull() + hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS) + hasFeatureFlagEnabledStateThat().isEqualTo(true) + hasFeatureFlagSyncStateThat().isEqualTo(SyncStatus.SYNCED_FROM_SERVER) + } } } @@ -109,6 +118,10 @@ class FeatureFlagsLoggerTest { ApplicationProvider.getApplicationContext().inject(this) } + private companion object { + private const val TEST_SESSION_ID = "test_session_id" + } + // TODO(#89): Move this to a common test application component. @Module class TestModule { diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index 17a8063d3ea..899374dfed1 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -381,10 +381,10 @@ message EventLog { string session_id = 2; // List of Feature Flag items - repeated FeatureFlagItem feature_flags = 3; + repeated FeatureFlagItemContext feature_flags = 3; // Structure for the feature flag log item. - message FeatureFlagItem { + message FeatureFlagItemContext { // The name of the feature flag or sync status flag. string flag_name = 1; diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 79360c969d1..95820cce112 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -7,7 +7,6 @@ import com.google.common.truth.IntegerSubject import com.google.common.truth.IterableSubject import com.google.common.truth.LongSubject import com.google.common.truth.StringSubject -import com.google.common.truth.Subject import com.google.common.truth.Truth.assertAbout import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.LiteProtoSubject @@ -51,7 +50,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_CA import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_OVER_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SUBMIT_ANSWER_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SWITCH_IN_LESSON_LANGUAGE -import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItem +import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItemContext import org.oppia.android.app.model.MarketFitAnswer import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.PlatformParameter.SyncStatus @@ -1979,35 +1978,40 @@ class EventLogSubject private constructor( private val actual: EventLog.FeatureFlagContext ) : LiteProtoSubject(metadata, actual) { /** - * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.getSessionId]. + * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.uniqueUserUuid]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. */ - fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) + fun hasUniqueUserUuidThat(): StringSubject = assertThat(actual.uniqueUserUuid) /** - * Returns a [FeatureFlagItem] to test the properties of a feature flag with the passed - * name in the [EventLog.FeatureFlagContext] list. + * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.sessionId]. + * + * This method never fails since the underlying property defaults to empty string if it's not + * defined in the context. */ - fun hasFeatureFlagThat(name: String): FeatureFlagItem? = - actual.featureFlagsList.firstOrNull { it.flagName == name } - - /** Returns a [Subject] to test whether the passed feature flag is null or not. */ - fun assertFeatureFlag(featureFlagItem: FeatureFlagItem?): Subject = assertThat(featureFlagItem) + fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) - /** Returns a [BooleanSubject] to test the flagEnabledState of the passed feature flag. */ - fun featureFlagHasEnabledStateThat( - featureFlagItem: FeatureFlagItem? - ): BooleanSubject = assertThat(featureFlagItem?.flagEnabledState) + /** + * Returns a [IterableSubject] to test [EventLog.FeatureFlagContext.getFeatureFlagsList]. + * + * This method never fails since the underlying property defaults to empty string if it's not + * defined in the context. + */ + fun hasFeatureFlagThatListThat(): IterableSubject = assertThat(actual.featureFlagsList) /** - * Returns a [ComparableSubject] with a [SyncStatus] to test the flagSyncStatus of the passed - * feature flag. + * Returns a [FeatureFlagItemContextSubject] to test + * [EventLog.FeatureFlagContext.getFeatureFlagsList]. + * + * This method never fails since the underlying property defaults to empty string if it's not + * defined in the context. */ - fun featureFlagHasSyncStatusThat( - featureFlagItem: FeatureFlagItem? - ): ComparableSubject = assertThat(featureFlagItem?.flagSyncStatus) + fun hasFeatureFlagItemContextThatHasName(flagName: String): FeatureFlagItemContextSubject = + FeatureFlagItemContextSubject.assertThat( + actual.featureFlagsList.firstOrNull { it.flagName == flagName } + ) companion object { /** @@ -2019,6 +2023,68 @@ class EventLogSubject private constructor( } } + /** + * Truth subject for verifying properties of [EventLog.FeatureFlagContext.FeatureFlagItemContext]s. + * + * Note that this class is also a [LiteProtoSubject] so other aspects of the underlying + * [EventLog.FeatureFlagContext.FeatureFlagItemContext] proto can be verified through inherited + * methods. + * + * Call [FeatureFlagItemContextSubject.assertThat] to create the subject. + */ + class FeatureFlagItemContextSubject private constructor( + metadata: FailureMetadata, + private val actual: FeatureFlagItemContext + ) : LiteProtoSubject(metadata, actual) { + /** + * Returns a [StringSubject] to test [FeatureFlagItemContextSubject]. + * + * This method never fails since the underlying property defaults to empty object if it's not + * defined in the context. + */ + fun hasFeatureFlagItemContextThat(): FeatureFlagItemContextSubject = assertThat(actual) + + /** + * Returns a [StringSubject] to test + * [EventLog.FeatureFlagContext.FeatureFlagItemContext.getFlagName]. + * + * This method never fails since the underlying property defaults to empty object if it's not + * defined in the context. + */ + fun hasFeatureFlagNameThat(): StringSubject = + assertThat(actual.flagName) + + /** + * Returns a [StringSubject] to test + * [EventLog.FeatureFlagContext.FeatureFlagItemContext.getFlagEnabledState]. + * + * This method never fails since the underlying property defaults to empty object if it's not + * defined in the context. + */ + fun hasFeatureFlagEnabledStateThat(): BooleanSubject = + assertThat(actual.flagEnabledState) + + /** + * Returns a [StringSubject] to test + * [EventLog.FeatureFlagContext.FeatureFlagItemContext.getFlagSyncStatus]. + * + * This method never fails since the underlying property defaults to empty object if it's not + * defined in the context. + */ + fun hasFeatureFlagSyncStateThat(): ComparableSubject = + assertThat(actual.flagSyncStatus) + + companion object { + /** + * Returns a new [FeatureFlagItemContextSubject] to verify aspects of the specified + * [EventLog.FeatureFlagItemContext] value. + */ + fun assertThat(actual: FeatureFlagItemContext?): + FeatureFlagItemContextSubject = + assertAbout(::FeatureFlagItemContextSubject).that(actual) + } + } + companion object { /** Returns a new [EventLogSubject] to verify aspects of the specified [EventLog] value. */ fun assertThat(actual: EventLog): EventLogSubject = assertAbout(::EventLogSubject).that(actual) diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt index a904314f795..4e3156be33f 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterConstants.kt @@ -66,3 +66,23 @@ const val TEST_INTEGER_PARAM_DEFAULT_VALUE = 0 * Server value for the test integer platform parameter. Only used in tests related to platform parameter. */ const val TEST_INTEGER_PARAM_SERVER_VALUE = 1 + +/** + * Qualifier for a test feature flag + */ +@Qualifier annotation class EnableTestFeatureFlag + +/** Name of the test feature flag. */ +const val TEST_FEATURE_FLAG = "android_test_feature_flag" + +/** Default value of the test feature flag. */ +const val TEST_FEATURE_FLAG_DEFAULT_VALUE = false + +/** Qualifier for a test feature flag with an enabled default value. */ +@Qualifier annotation class EnableTestFeatureFlagWithEnabledDefault + +/** Name of the test feature flag with an enabled default value. */ +const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS = "android_test_feature_flag_with_enabled_default" + +/** Default value of the test feature flag with an enabled default value. */ +const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE = true diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 818afd15d50..19f13e50b08 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -26,8 +26,6 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi -import org.oppia.android.util.platformparameter.EnableTestFeatureFlag -import org.oppia.android.util.platformparameter.EnableTestFeatureFlagWithEnabledDefault import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON_DEFAULT_VALUE import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode @@ -59,10 +57,6 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS -import org.oppia.android.util.platformparameter.TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE import javax.inject.Singleton /* Fake Platform Parameter Module that provides individual Platform Parameters for testing. */ diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 787bfad15d3..c108d5743ef 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -12,26 +12,6 @@ import javax.inject.Qualifier * has been synced with Oppia Web. */ -/** - * Qualifier for a test feature flag - */ -@Qualifier annotation class EnableTestFeatureFlag - -/** Name of the test feature flag. */ -const val TEST_FEATURE_FLAG = "android_test_feature_flag" - -/** Default value of the test feature flag. */ -const val TEST_FEATURE_FLAG_DEFAULT_VALUE = false - -/** Qualifier for a test feature flag with an enabled default value. */ -@Qualifier annotation class EnableTestFeatureFlagWithEnabledDefault - -/** Name of the test feature flag with an enabled default value. */ -const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS = "android_test_feature_flag_with_enabled_default" - -/** Default value of the test feature flag with an enabled default value. */ -const val TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULT_VALUE = true - /** * Qualifier for the feature flag that controls whether the user has support for manually * downloading topics. From a6f915d23b09cb8126d2f072ce5652f7253c920a Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 17 Jan 2024 19:08:58 +0300 Subject: [PATCH 34/66] fix: Make changes and fixes requested after review --- model/src/main/proto/oppia_logger.proto | 4 ++-- .../java/org/oppia/android/testing/logging/EventLogSubject.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index 899374dfed1..ab545795203 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -177,7 +177,7 @@ message EventLog { // The event being logged is related to the response to the optional survey question. OptionalSurveyResponseContext optional_response = 42; - // The event being logged contains the feature flags and their current enabled and sync state + // The event being logged contains the feature flags and their current enabled and sync state. FeatureFlagContext feature_flag_context = 43; } } @@ -380,7 +380,7 @@ message EventLog { // The id of the current session. string session_id = 2; - // List of Feature Flag items + // List of Feature Flag items. repeated FeatureFlagItemContext feature_flags = 3; // Structure for the feature flag log item. diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 95820cce112..cdb40b42d4e 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -1996,10 +1996,10 @@ class EventLogSubject private constructor( /** * Returns a [IterableSubject] to test [EventLog.FeatureFlagContext.getFeatureFlagsList]. * - * This method never fails since the underlying property defaults to empty string if it's not + * This method never fails since the underlying property defaults to empty list if it's not * defined in the context. */ - fun hasFeatureFlagThatListThat(): IterableSubject = assertThat(actual.featureFlagsList) + fun hasFeatureFlagListThat(): IterableSubject = assertThat(actual.featureFlagsList) /** * Returns a [FeatureFlagItemContextSubject] to test From 178d8b51bc51c1c49797157a2dd460f2f34cc239 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 26 Jan 2024 13:36:29 +0300 Subject: [PATCH 35/66] feat: Move feature_flag_item_context from feature_flag_context --- .../analytics/FeatureFlagsLogger.kt | 2 +- model/src/main/proto/oppia_logger.proto | 21 +++++++++++-------- .../util/logging/EventBundleCreator.kt | 20 ++++++++++++++++-- ...entTypeToHumanReadableNameConverterImpl.kt | 1 + ...entTypeToHumanReadableNameConverterImpl.kt | 1 + 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 4d348ebacd9..4a23a094502 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -2,7 +2,7 @@ package org.oppia.android.domain.oppialogger.analytics import org.oppia.android.app.model.EventLog import org.oppia.android.app.model.EventLog.FeatureFlagContext -import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItemContext +import org.oppia.android.app.model.EventLog.FeatureFlagItemContext import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index ab545795203..7ce683b6803 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -179,6 +179,9 @@ message EventLog { // The event being logged contains the feature flags and their current enabled and sync state. FeatureFlagContext feature_flag_context = 43; + + // The event being logged contains the feature flag items. + FeatureFlagItemContext feature_flag_item_context = 44; } } @@ -382,18 +385,18 @@ message EventLog { // List of Feature Flag items. repeated FeatureFlagItemContext feature_flags = 3; + } - // Structure for the feature flag log item. - message FeatureFlagItemContext { - // The name of the feature flag or sync status flag. - string flag_name = 1; + // Structure for the feature flag log item. + message FeatureFlagItemContext { + // The name of the feature flag or sync status flag. + string flag_name = 1; - // The enabled state of the feature flag. - bool flag_enabled_state = 2; + // The enabled state of the feature flag. + bool flag_enabled_state = 2; - // The sync status of the feature flag or sync status flag. - PlatformParameter.SyncStatus flag_sync_status = 3; - } + // The sync status of the feature flag or sync status flag. + PlatformParameter.SyncStatus flag_sync_status = 3; } // Supported priority of events for event logging diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index e566d4de9d2..13153b6da52 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -91,8 +91,10 @@ import javax.inject.Singleton import org.oppia.android.app.model.EventLog.AbandonSurveyContext as AbandonSurveyEventContext import org.oppia.android.app.model.EventLog.CardContext as CardEventContext import org.oppia.android.app.model.EventLog.ConceptCardContext as ConceptCardEventContext +import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT import org.oppia.android.app.model.EventLog.ExplorationContext as ExplorationEventContext import org.oppia.android.app.model.EventLog.FeatureFlagContext as FeatureFlagEventContext +import org.oppia.android.app.model.EventLog.FeatureFlagItemContext as FeatureFlagItemEventContext import org.oppia.android.app.model.EventLog.HintContext as HintEventContext import org.oppia.android.app.model.EventLog.LearnerDetailsContext as LearnerDetailsEventContext import org.oppia.android.app.model.EventLog.MandatorySurveyResponseContext as MandatorySurveyResponseEventContext @@ -110,6 +112,8 @@ import org.oppia.android.app.model.OppiaMetricLog.MemoryUsageMetric as MemoryUsa import org.oppia.android.app.model.OppiaMetricLog.NetworkUsageMetric as NetworkUsagePerformanceLoggableMetric import org.oppia.android.app.model.OppiaMetricLog.StartupLatencyMetric as StartupLatencyPerformanceLoggableMetric import org.oppia.android.app.model.OppiaMetricLog.StorageUsageMetric as StorageUsagePerformanceLoggableMetric +import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagContext +import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagItemContext // See https://firebase.google.com/docs/reference/cpp/group/parameter-names for context. private const val MAX_CHARACTERS_IN_PARAMETER_NAME = 40 @@ -225,8 +229,8 @@ class EventBundleCreator @Inject constructor( ABANDON_SURVEY -> AbandonSurveyContext(activityName, abandonSurvey) MANDATORY_RESPONSE -> MandatorySurveyResponseContext(activityName, mandatoryResponse) OPTIONAL_RESPONSE -> OptionalSurveyResponseContext(activityName, optionalResponse) - FEATURE_FLAG_CONTEXT -> - EventActivityContext.FeatureFlagContext(activityName, featureFlagContext) + FEATURE_FLAG_CONTEXT -> FeatureFlagContext(activityName, featureFlagContext) + FEATURE_FLAG_ITEM_CONTEXT -> FeatureFlagItemContext(activityName, featureFlagItemContext) INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> SensitiveStringContext(activityName, installIdForFailedAnalyticsLog, "install_id") ACTIVITYCONTEXT_NOT_SET, null -> EmptyContext(activityName) // No context to create here. @@ -573,6 +577,18 @@ class EventBundleCreator @Inject constructor( store.putNonSensitiveValue("feature_flags", featureFlagsList) } } + + /** The [EventActivityContext] corresponding to [FeatureFlagItemEventContext]s. */ + class FeatureFlagItemContext( + activityName: String, + value: FeatureFlagItemEventContext + ) : EventActivityContext(activityName, value) { + override fun EventLog.FeatureFlagItemContext.storeValue(store: PropertyStore) { + store.putSensitiveValue("flag_name", flagName) + store.putSensitiveValue("enabled_state", flagEnabledState) + store.putSensitiveValue("sync_status", flagSyncStatus) + } + } } /** Represents an [OppiaMetricLog] loggable metric (denoted by [LoggableMetricTypeCase]). */ diff --git a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt index 05d0d9c5ce3..56f1a8ff58f 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt @@ -51,6 +51,7 @@ class KenyaAlphaEventTypeToHumanReadableNameConverterImpl @Inject constructor() ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" ActivityContextCase.FEATURE_FLAG_CONTEXT -> "feature_flag" + ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT -> "feature_flag_item" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> "failed_analytics_log" ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "unknown_activity_context" } diff --git a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt index 7c52ee09ec9..b0d07ae6060 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt @@ -61,6 +61,7 @@ class StandardEventTypeToHumanReadableNameConverterImpl @Inject constructor() : ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" ActivityContextCase.FEATURE_FLAG_CONTEXT -> "feature_flag" + ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT -> "feature_flag_item" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG, ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "ERROR_internal_logging_failure" } From 9b1f82f2c4b8134d3dfa9fe319ee6bc6d6915276 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 26 Jan 2024 13:37:56 +0300 Subject: [PATCH 36/66] fix: Fix linting issues --- .../org/oppia/android/util/logging/EventBundleCreator.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 13153b6da52..19b62cfdf6c 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -18,6 +18,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.DELETE_P import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.END_CARD_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.EXIT_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_CONTEXT +import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FINISH_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.HINT_UNLOCKED_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG @@ -64,6 +65,8 @@ import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.Ca import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.ConceptCardContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.EmptyContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.ExplorationContext +import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagContext +import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagItemContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.HintContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.LearnerDetailsContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.MandatorySurveyResponseContext @@ -91,7 +94,6 @@ import javax.inject.Singleton import org.oppia.android.app.model.EventLog.AbandonSurveyContext as AbandonSurveyEventContext import org.oppia.android.app.model.EventLog.CardContext as CardEventContext import org.oppia.android.app.model.EventLog.ConceptCardContext as ConceptCardEventContext -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT import org.oppia.android.app.model.EventLog.ExplorationContext as ExplorationEventContext import org.oppia.android.app.model.EventLog.FeatureFlagContext as FeatureFlagEventContext import org.oppia.android.app.model.EventLog.FeatureFlagItemContext as FeatureFlagItemEventContext @@ -112,8 +114,6 @@ import org.oppia.android.app.model.OppiaMetricLog.MemoryUsageMetric as MemoryUsa import org.oppia.android.app.model.OppiaMetricLog.NetworkUsageMetric as NetworkUsagePerformanceLoggableMetric import org.oppia.android.app.model.OppiaMetricLog.StartupLatencyMetric as StartupLatencyPerformanceLoggableMetric import org.oppia.android.app.model.OppiaMetricLog.StorageUsageMetric as StorageUsagePerformanceLoggableMetric -import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagContext -import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagItemContext // See https://firebase.google.com/docs/reference/cpp/group/parameter-names for context. private const val MAX_CHARACTERS_IN_PARAMETER_NAME = 40 From 0515950750a073f291240e6759ede03f437aff36 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 26 Jan 2024 13:50:11 +0300 Subject: [PATCH 37/66] fix: Fix failing build and tests --- .../java/org/oppia/android/testing/logging/EventLogSubject.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index cdb40b42d4e..ba7dacff67a 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -50,7 +50,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_CA import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_OVER_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SUBMIT_ANSWER_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SWITCH_IN_LESSON_LANGUAGE -import org.oppia.android.app.model.EventLog.FeatureFlagContext.FeatureFlagItemContext +import org.oppia.android.app.model.EventLog.FeatureFlagItemContext import org.oppia.android.app.model.MarketFitAnswer import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.PlatformParameter.SyncStatus From c63f5b567b3ea9b799be33e4ba1b3e4a43685d3e Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 26 Jan 2024 14:24:34 +0300 Subject: [PATCH 38/66] feat: Change how FeatureFlagItemContextSubject tests are run --- .../analytics/FeatureFlagsLoggerTest.kt | 18 ++++++++------- .../testing/logging/EventLogSubject.kt | 22 ++++++++++++------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index d0bd6bef33e..ff0dc991803 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -63,12 +63,6 @@ class FeatureFlagsLoggerTest { @Before fun setup() { setUpTestApplicationComponent() - - val mapOfTestFeatureFlags = mapOf( - TEST_FEATURE_FLAG to testFeatureFlag, - TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS to testFeatureFlagWithEnabledDefault - ) - featureFlagsLogger.setFeatureFlagItemMap(mapOfTestFeatureFlags) } @Test @@ -84,12 +78,16 @@ class FeatureFlagsLoggerTest { @Test fun testLogFeatureFlags_logsTestFeatureFlag_hasCorrectDefaultValues() { + featureFlagsLogger.setFeatureFlagItemMap( + mapOf(TEST_FEATURE_FLAG to testFeatureFlag) + ) featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureFlagItemContextThatHasName(TEST_FEATURE_FLAG).apply { + hasFeatureFlagItemContextThat { hasFeatureFlagItemContextThat().isNotNull() hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG) hasFeatureFlagEnabledStateThat().isEqualTo(false) @@ -100,12 +98,16 @@ class FeatureFlagsLoggerTest { @Test fun testLogFeatureFlags_logsTestFeatureFlagWithEnabledDefaults_hasCorrectDefaultValues() { + featureFlagsLogger.setFeatureFlagItemMap( + mapOf(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS to testFeatureFlagWithEnabledDefault) + ) featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureFlagItemContextThatHasName(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS).apply { + hasFeatureFlagItemContextThat { hasFeatureFlagItemContextThat().isNotNull() hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS) hasFeatureFlagEnabledStateThat().isEqualTo(true) diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index ba7dacff67a..9332b72b458 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -2008,10 +2008,18 @@ class EventLogSubject private constructor( * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. */ - fun hasFeatureFlagItemContextThatHasName(flagName: String): FeatureFlagItemContextSubject = - FeatureFlagItemContextSubject.assertThat( - actual.featureFlagsList.firstOrNull { it.flagName == flagName } - ) + fun hasFeatureFlagItemContextThat(): FeatureFlagItemContextSubject { + return FeatureFlagItemContextSubject.assertThat(actual.featureFlagsList.first()) + } + + /** + * Verifies the [EventLog]'s context and executes [block] in the same way as + * [hasFeatureFlagItemContextThat] except for the conditions of, and subject returned by, + * [hasFeatureFlagItemContextThat]. + */ + fun hasFeatureFlagItemContextThat(block: FeatureFlagItemContextSubject.() -> Unit) { + hasFeatureFlagItemContextThat().block() + } companion object { /** @@ -2051,8 +2059,7 @@ class EventLogSubject private constructor( * This method never fails since the underlying property defaults to empty object if it's not * defined in the context. */ - fun hasFeatureFlagNameThat(): StringSubject = - assertThat(actual.flagName) + fun hasFeatureFlagNameThat(): StringSubject = assertThat(actual.flagName) /** * Returns a [StringSubject] to test @@ -2061,8 +2068,7 @@ class EventLogSubject private constructor( * This method never fails since the underlying property defaults to empty object if it's not * defined in the context. */ - fun hasFeatureFlagEnabledStateThat(): BooleanSubject = - assertThat(actual.flagEnabledState) + fun hasFeatureFlagEnabledStateThat(): BooleanSubject = assertThat(actual.flagEnabledState) /** * Returns a [StringSubject] to test From e76f813345f18e33bf8388f91905248ef8baae69 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 29 Jan 2024 19:15:42 +0300 Subject: [PATCH 39/66] chore: Fix nits and make changes requested in latest review --- .../analytics/FeatureFlagsLoggerTest.kt | 2 - .../testing/logging/EventLogSubject.kt | 38 ++++++------------- .../util/logging/EventBundleCreator.kt | 6 +-- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index ff0dc991803..3311e398d00 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -88,7 +88,6 @@ class FeatureFlagsLoggerTest { val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { hasFeatureFlagItemContextThat { - hasFeatureFlagItemContextThat().isNotNull() hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG) hasFeatureFlagEnabledStateThat().isEqualTo(false) hasFeatureFlagSyncStateThat().isEqualTo(SyncStatus.NOT_SYNCED_FROM_SERVER) @@ -108,7 +107,6 @@ class FeatureFlagsLoggerTest { val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { hasFeatureFlagItemContextThat { - hasFeatureFlagItemContextThat().isNotNull() hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS) hasFeatureFlagEnabledStateThat().isEqualTo(true) hasFeatureFlagSyncStateThat().isEqualTo(SyncStatus.SYNCED_FROM_SERVER) diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index f325ef4ea90..6a51d58914f 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -2055,7 +2055,7 @@ class EventLogSubject private constructor( private val actual: EventLog.FeatureFlagContext ) : LiteProtoSubject(metadata, actual) { /** - * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.uniqueUserUuid]. + * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.getUniqueUserUuid]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. @@ -2063,21 +2063,13 @@ class EventLogSubject private constructor( fun hasUniqueUserUuidThat(): StringSubject = assertThat(actual.uniqueUserUuid) /** - * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.sessionId]. + * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.getSessionId]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. */ fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) - /** - * Returns a [IterableSubject] to test [EventLog.FeatureFlagContext.getFeatureFlagsList]. - * - * This method never fails since the underlying property defaults to empty list if it's not - * defined in the context. - */ - fun hasFeatureFlagListThat(): IterableSubject = assertThat(actual.featureFlagsList) - /** * Returns a [FeatureFlagItemContextSubject] to test * [EventLog.FeatureFlagContext.getFeatureFlagsList]. @@ -2109,10 +2101,10 @@ class EventLogSubject private constructor( } /** - * Truth subject for verifying properties of [EventLog.FeatureFlagContext.FeatureFlagItemContext]s. + * Truth subject for verifying properties of [EventLog.FeatureFlagItemContext]s. * * Note that this class is also a [LiteProtoSubject] so other aspects of the underlying - * [EventLog.FeatureFlagContext.FeatureFlagItemContext] proto can be verified through inherited + * [EventLog.FeatureFlagItemContext] proto can be verified through inherited * methods. * * Call [FeatureFlagItemContextSubject.assertThat] to create the subject. @@ -2121,35 +2113,27 @@ class EventLogSubject private constructor( metadata: FailureMetadata, private val actual: FeatureFlagItemContext ) : LiteProtoSubject(metadata, actual) { - /** - * Returns a [StringSubject] to test [FeatureFlagItemContextSubject]. - * - * This method never fails since the underlying property defaults to empty object if it's not - * defined in the context. - */ - fun hasFeatureFlagItemContextThat(): FeatureFlagItemContextSubject = assertThat(actual) - /** * Returns a [StringSubject] to test - * [EventLog.FeatureFlagContext.FeatureFlagItemContext.getFlagName]. + * [EventLog.FeatureFlagItemContext.getFlagName]. * - * This method never fails since the underlying property defaults to empty object if it's not + * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. */ fun hasFeatureFlagNameThat(): StringSubject = assertThat(actual.flagName) /** - * Returns a [StringSubject] to test - * [EventLog.FeatureFlagContext.FeatureFlagItemContext.getFlagEnabledState]. + * Returns a [BooleanSubject] to test + * [EventLog.FeatureFlagItemContext.getFlagEnabledState]. * - * This method never fails since the underlying property defaults to empty object if it's not + * This method never fails since the underlying property defaults to false if it's not * defined in the context. */ fun hasFeatureFlagEnabledStateThat(): BooleanSubject = assertThat(actual.flagEnabledState) /** - * Returns a [StringSubject] to test - * [EventLog.FeatureFlagContext.FeatureFlagItemContext.getFlagSyncStatus]. + * Returns a [ComparableSubject] to test + * [EventLog.FeatureFlagItemContext.getFlagSyncStatus]. * * This method never fails since the underlying property defaults to empty object if it's not * defined in the context. diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 19b62cfdf6c..fba3a6df37f 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -584,9 +584,9 @@ class EventBundleCreator @Inject constructor( value: FeatureFlagItemEventContext ) : EventActivityContext(activityName, value) { override fun EventLog.FeatureFlagItemContext.storeValue(store: PropertyStore) { - store.putSensitiveValue("flag_name", flagName) - store.putSensitiveValue("enabled_state", flagEnabledState) - store.putSensitiveValue("sync_status", flagSyncStatus) + store.putNonSensitiveValue("flag_name", flagName) + store.putNonSensitiveValue("enabled_state", flagEnabledState) + store.putNonSensitiveValue("sync_status", flagSyncStatus) } } } From b98dd1381dd35ea7b5786d22b5c9e35fe3c56afd Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sat, 3 Feb 2024 11:29:44 +0300 Subject: [PATCH 40/66] fix: Make changes requested in review --- .../analytics/ApplicationLifecycleObserver.kt | 1 - .../analytics/FeatureFlagsLogger.kt | 6 +-- .../ApplicationLifecycleObserverTest.kt | 41 +++++++++++++++++++ model/src/main/proto/oppia_logger.proto | 12 +++--- .../testing/logging/EventLogSubject.kt | 38 ++++++++--------- .../util/logging/EventBundleCreator.kt | 14 +++---- ...entTypeToHumanReadableNameConverterImpl.kt | 2 +- ...entTypeToHumanReadableNameConverterImpl.kt | 2 +- 8 files changed, 78 insertions(+), 38 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index 3fe6b708323..61eb4da10e3 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -45,7 +45,6 @@ class ApplicationLifecycleObserver @Inject constructor( @BackgroundDispatcher private val backgroundDispatcher: CoroutineDispatcher, @EnablePerformanceMetricsCollection private val enablePerformanceMetricsCollection: PlatformParameterValue, - private val analyticsController: AnalyticsController, private val applicationLifecycleListeners: Set<@JvmSuppressWildcards ApplicationLifecycleListener> ) : ApplicationStartupListener, LifecycleObserver, Application.ActivityLifecycleCallbacks { diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 4a23a094502..93a7d67ef64 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -1,8 +1,8 @@ package org.oppia.android.domain.oppialogger.analytics import org.oppia.android.app.model.EventLog -import org.oppia.android.app.model.EventLog.FeatureFlagContext import org.oppia.android.app.model.EventLog.FeatureFlagItemContext +import org.oppia.android.app.model.EventLog.FeatureFlagListContext import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI @@ -98,14 +98,14 @@ class FeatureFlagsLogger @Inject constructor( createFeatureFlagItemContext(flag) ) } - val featureFlagContext = FeatureFlagContext.newBuilder() + val featureFlagContext = FeatureFlagListContext.newBuilder() .setSessionId(sessionId) .addAllFeatureFlags(featureFlagItemList) .build() analyticsController.logLowPriorityEvent( EventLog.Context.newBuilder() - .setFeatureFlagContext(featureFlagContext) + .setFeatureFlagListContext(featureFlagContext) .build(), profileId = null ) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt index 2d7db431fcf..5e07d6b06c8 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt @@ -15,6 +15,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.OppiaMetricLog +import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.ScreenName import org.oppia.android.domain.oppialogger.ApplicationIdSeed @@ -28,6 +29,9 @@ import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TextInputActionTestActivity import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat +import org.oppia.android.testing.platformparameter.EnableTestFeatureFlag +import org.oppia.android.testing.platformparameter.EnableTestFeatureFlagWithEnabledDefault +import org.oppia.android.testing.platformparameter.TEST_FEATURE_FLAG import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers @@ -45,6 +49,7 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.concurrent.TimeUnit @@ -88,12 +93,21 @@ class ApplicationLifecycleObserverTest { @Inject lateinit var fakePerformanceMetricsEventLogger: FakePerformanceMetricsEventLogger + @Inject + lateinit var featureFlagsLogger: FeatureFlagsLogger + @field:[JvmField Inject ForegroundCpuLoggingTimePeriodMillis] var foregroundCpuLoggingTimePeriodMillis: Long = Long.MIN_VALUE @field:[JvmField Inject BackgroundCpuLoggingTimePeriodMillis] var backgroundCpuLoggingTimePeriodMillis: Long = Long.MIN_VALUE + @field:[Inject EnableTestFeatureFlag] + lateinit var testFeatureFlag: PlatformParameterValue + + @field:[Inject EnableTestFeatureFlagWithEnabledDefault] + lateinit var testFeatureFlagWithEnabledDefault: PlatformParameterValue + @get:Rule var activityRule = ActivityScenarioRule( @@ -369,6 +383,33 @@ class ApplicationLifecycleObserverTest { assertThat(event.currentScreen).isEqualTo(ScreenName.BACKGROUND_SCREEN) } + @Test + fun testObserver_onAppInForeground_logsAllFeatureFlags() { + setUpTestApplicationComponent() + + featureFlagsLogger.setFeatureFlagItemMap( + mapOf(TEST_FEATURE_FLAG to testFeatureFlag) + ) + + val sessionIdProvider = loggingIdentifierController.getSessionId() + val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) + + applicationLifecycleObserver.onCreate() + testCoroutineDispatchers.runCurrent() + testCoroutineDispatchers.advanceTimeBy(foregroundCpuLoggingTimePeriodMillis) + + val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() + + assertThat(eventLog).hasFeatureFlagContextThat { + hasSessionIdThat().isEqualTo(sessionId) + hasFeatureFlagItemContextThat { + hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG) + hasFeatureFlagEnabledStateThat().isEqualTo(false) + hasFeatureFlagSyncStateThat().isEqualTo(PlatformParameter.SyncStatus.NOT_SYNCED_FROM_SERVER) + } + } + } + private fun waitInBackgroundFor(millis: Long) { applicationLifecycleObserver.onAppInBackground() testCoroutineDispatchers.runCurrent() diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index 7ce683b6803..eeff6b40efb 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -177,8 +177,8 @@ message EventLog { // The event being logged is related to the response to the optional survey question. OptionalSurveyResponseContext optional_response = 42; - // The event being logged contains the feature flags and their current enabled and sync state. - FeatureFlagContext feature_flag_context = 43; + // The event being logged contains feature flags and their current enabled and sync state. + FeatureFlagListContext feature_flag_list_context = 43; // The event being logged contains the feature flag items. FeatureFlagItemContext feature_flag_item_context = 44; @@ -375,9 +375,9 @@ message EventLog { string profile_id = 2; } - // Structure of a feature flag context. - message FeatureFlagContext { - // The unique UUID of the user. + // Structure of a feature flag list context. + message FeatureFlagListContext { + // The client-local UUID of the user. string unique_user_uuid = 1; // The id of the current session. @@ -387,7 +387,7 @@ message EventLog { repeated FeatureFlagItemContext feature_flags = 3; } - // Structure for the feature flag log item. + // Structure for an individual feature flag log context. message FeatureFlagItemContext { // The name of the feature flag or sync status flag. string flag_name = 1; diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 6a51d58914f..0433724025d 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -1050,12 +1050,12 @@ class EventLogSubject private constructor( } /** - * Verifies the [EventLog]'s context and returns a [FeatureFlagContextSubject] to test the + * Verifies the [EventLog]'s context and returns a [FeatureFlagListContextSubject] to test the * corresponding context. */ - fun hasFeatureFlagContextThat(): FeatureFlagContextSubject { - return FeatureFlagContextSubject.assertThat( - actual.context.featureFlagContext + fun hasFeatureFlagContextThat(): FeatureFlagListContextSubject { + return FeatureFlagListContextSubject.assertThat( + actual.context.featureFlagListContext ) } @@ -1063,7 +1063,7 @@ class EventLogSubject private constructor( * Verifies the [EventLog]'s context and executes [block]. */ fun hasFeatureFlagContextThat( - block: FeatureFlagContextSubject.() -> Unit + block: FeatureFlagListContextSubject.() -> Unit ) { hasFeatureFlagContextThat().block() } @@ -2043,19 +2043,19 @@ class EventLogSubject private constructor( } /** - * Truth subject for verifying properties of [EventLog.FeatureFlagContext]s. + * Truth subject for verifying properties of [EventLog.FeatureFlagListContext]s. * * Note that this class is also a [LiteProtoSubject] so other aspects of the underlying * [EventLog.FeatureFlagContext] proto can be verified through inherited methods. * - * Call [FeatureFlagContextSubject.assertThat] to create the subject. + * Call [FeatureFlagListContextSubject.assertThat] to create the subject. */ - class FeatureFlagContextSubject private constructor( + class FeatureFlagListContextSubject private constructor( metadata: FailureMetadata, - private val actual: EventLog.FeatureFlagContext + private val actual: EventLog.FeatureFlagListContext ) : LiteProtoSubject(metadata, actual) { /** - * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.getUniqueUserUuid]. + * Returns a [StringSubject] to test [EventLog.FeatureFlagListContext.getUniqueUserUuid]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. @@ -2063,7 +2063,7 @@ class EventLogSubject private constructor( fun hasUniqueUserUuidThat(): StringSubject = assertThat(actual.uniqueUserUuid) /** - * Returns a [StringSubject] to test [EventLog.FeatureFlagContext.getSessionId]. + * Returns a [StringSubject] to test [EventLog.FeatureFlagListContext.getSessionId]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. @@ -2072,9 +2072,9 @@ class EventLogSubject private constructor( /** * Returns a [FeatureFlagItemContextSubject] to test - * [EventLog.FeatureFlagContext.getFeatureFlagsList]. + * [EventLog.FeatureFlagListContext.getFeatureFlagsList]. * - * This method never fails since the underlying property defaults to empty string if it's not + * This method never fails since the underlying property defaults to empty object if it's not * defined in the context. */ fun hasFeatureFlagItemContextThat(): FeatureFlagItemContextSubject { @@ -2092,11 +2092,11 @@ class EventLogSubject private constructor( companion object { /** - * Returns a new [FeatureFlagContextSubject] to verify aspects of the specified - * [EventLog.FeatureFlagContext] value. + * Returns a new [FeatureFlagListContextSubject] to verify aspects of the specified + * [EventLog.FeatureFlagListContext] value. */ - fun assertThat(actual: EventLog.FeatureFlagContext): FeatureFlagContextSubject = - assertAbout(::FeatureFlagContextSubject).that(actual) + fun assertThat(actual: EventLog.FeatureFlagListContext): FeatureFlagListContextSubject = + assertAbout(::FeatureFlagListContextSubject).that(actual) } } @@ -2135,8 +2135,8 @@ class EventLogSubject private constructor( * Returns a [ComparableSubject] to test * [EventLog.FeatureFlagItemContext.getFlagSyncStatus]. * - * This method never fails since the underlying property defaults to empty object if it's not - * defined in the context. + * This method never fails since the underlying property defaults to the unspecified enum value + * if it's not defined in the context. */ fun hasFeatureFlagSyncStateThat(): ComparableSubject = assertThat(actual.flagSyncStatus) diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 269b10354e1..00731bd3988 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -18,8 +18,8 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.CLOSE_RE import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.DELETE_PROFILE_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.END_CARD_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.EXIT_EXPLORATION_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT +import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_LIST_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FINISH_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.HINT_UNLOCKED_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG @@ -96,8 +96,8 @@ import org.oppia.android.app.model.EventLog.AbandonSurveyContext as AbandonSurve import org.oppia.android.app.model.EventLog.CardContext as CardEventContext import org.oppia.android.app.model.EventLog.ConceptCardContext as ConceptCardEventContext import org.oppia.android.app.model.EventLog.ExplorationContext as ExplorationEventContext -import org.oppia.android.app.model.EventLog.FeatureFlagContext as FeatureFlagEventContext import org.oppia.android.app.model.EventLog.FeatureFlagItemContext as FeatureFlagItemEventContext +import org.oppia.android.app.model.EventLog.FeatureFlagListContext as FeatureFlagListEventContext import org.oppia.android.app.model.EventLog.HintContext as HintEventContext import org.oppia.android.app.model.EventLog.LearnerDetailsContext as LearnerDetailsEventContext import org.oppia.android.app.model.EventLog.MandatorySurveyResponseContext as MandatorySurveyResponseEventContext @@ -236,7 +236,7 @@ class EventBundleCreator @Inject constructor( ABANDON_SURVEY -> AbandonSurveyContext(activityName, abandonSurvey) MANDATORY_RESPONSE -> MandatorySurveyResponseContext(activityName, mandatoryResponse) OPTIONAL_RESPONSE -> OptionalSurveyResponseContext(activityName, optionalResponse) - FEATURE_FLAG_CONTEXT -> FeatureFlagContext(activityName, featureFlagContext) + FEATURE_FLAG_LIST_CONTEXT -> FeatureFlagContext(activityName, featureFlagListContext) FEATURE_FLAG_ITEM_CONTEXT -> FeatureFlagItemContext(activityName, featureFlagItemContext) INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> SensitiveStringContext(activityName, installIdForFailedAnalyticsLog, "install_id") @@ -576,10 +576,10 @@ class EventBundleCreator @Inject constructor( /** The [EventActivityContext] corresponding to [FeatureFlagEventContext]s. */ class FeatureFlagContext( activityName: String, - value: FeatureFlagEventContext - ) : EventActivityContext(activityName, value) { - override fun EventLog.FeatureFlagContext.storeValue(store: PropertyStore) { - store.putSensitiveValue("uuid", uniqueUserUuid) + value: FeatureFlagListEventContext + ) : EventActivityContext(activityName, value) { + override fun EventLog.FeatureFlagListContext.storeValue(store: PropertyStore) { + store.putNonSensitiveValue("uuid", uniqueUserUuid) store.putSensitiveValue("session_id", sessionId) store.putNonSensitiveValue("feature_flags", featureFlagsList) } diff --git a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt index 56f1a8ff58f..a2a1cb2e65e 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt @@ -50,7 +50,7 @@ class KenyaAlphaEventTypeToHumanReadableNameConverterImpl @Inject constructor() ActivityContextCase.ABANDON_SURVEY -> "abandon_survey" ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" - ActivityContextCase.FEATURE_FLAG_CONTEXT -> "feature_flag" + ActivityContextCase.FEATURE_FLAG_LIST_CONTEXT -> "feature_flag_list" ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT -> "feature_flag_item" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> "failed_analytics_log" ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "unknown_activity_context" diff --git a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt index b0d07ae6060..6640b5ff63f 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt @@ -60,7 +60,7 @@ class StandardEventTypeToHumanReadableNameConverterImpl @Inject constructor() : ActivityContextCase.ABANDON_SURVEY -> "abandon_survey" ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" - ActivityContextCase.FEATURE_FLAG_CONTEXT -> "feature_flag" + ActivityContextCase.FEATURE_FLAG_LIST_CONTEXT -> "feature_flag_list" ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT -> "feature_flag_item" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG, ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "ERROR_internal_logging_failure" From 0ac776bff0f2cd360fcfd27e9aa107c1b2e5e32d Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 9 Feb 2024 12:28:53 +0300 Subject: [PATCH 41/66] fix: Fix failing build from merge --- .../domain/oppialogger/analytics/FeatureFlagsLogger.kt | 4 ++-- .../android/util/platformparameter/FeatureFlagConstants.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 93a7d67ef64..619f1fa59da 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -21,7 +21,7 @@ import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSO import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION +import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import javax.inject.Inject @@ -70,7 +70,7 @@ class FeatureFlagsLogger @Inject constructor( FAST_LANGUAGE_SWITCHING_IN_LESSON to enableFastLanguageSwitchingInLesson, LOGGING_LEARNER_STUDY_IDS to enableLoggingLearnerStudyIds, EDIT_ACCOUNTS_OPTIONS_UI to enableEditAccountsOptionsUi, - PERFORMANCE_METRICS_COLLECTION to enablePerformanceMetricsCollection, + ENABLE_PERFORMANCE_METRICS_COLLECTION to enablePerformanceMetricsCollection, SPOTLIGHT_UI to enableSpotlightUi, INTERACTION_CONFIG_CHANGE_STATE_RETENTION to enableInteractionConfigChangeStateRetention, APP_AND_OS_DEPRECATION to enableAppAndOsDeprecation, diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index 91253ee362e..ba9dafdb620 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -108,7 +108,7 @@ const val ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE = false annotation class EnablePerformanceMetricsCollection /** Name of the feature flag that controls whether to record performance metrics. */ -const val PERFORMANCE_METRICS_COLLECTION = "android_enable_performance_metrics_collection" +const val ENABLE_PERFORMANCE_METRICS_COLLECTION = "android_enable_performance_metrics_collection" /** Default value for whether to record performance metrics. */ const val ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE = false From 58ce67dcf8faeda7bec17756a9f128347e7b6d87 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 9 Feb 2024 12:30:03 +0300 Subject: [PATCH 42/66] fix: Fix failing build from merge --- .../android/domain/oppialogger/analytics/FeatureFlagsLogger.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 619f1fa59da..cfd4f41fe2a 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -6,6 +6,7 @@ import org.oppia.android.app.model.EventLog.FeatureFlagListContext import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI +import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableDownloadsSupport @@ -21,7 +22,6 @@ import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSO import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS -import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import javax.inject.Inject From bf3605a60d969683ae5982f58d54fbca0f5dd7e4 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 14 Feb 2024 12:19:29 +0300 Subject: [PATCH 43/66] feat: Modify the feature flag context into a list of properties --- .../vieweventlogs/ViewEventLogsViewModel.kt | 1 + model/src/main/proto/oppia_logger.proto | 3 --- .../util/logging/EventBundleCreator.kt | 24 ++++++------------- ...entTypeToHumanReadableNameConverterImpl.kt | 1 - ...entTypeToHumanReadableNameConverterImpl.kt | 1 - 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt index 274079e2ce8..c3b94b25cf8 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt @@ -36,6 +36,7 @@ class ViewEventLogsViewModel @Inject constructor( private fun processEventLogsList(): List { return (analyticsEvents + firestoreEvents) .map { + println("EventLogItemViewModel: $it") EventLogItemViewModel(it, machineLocale, resourceHandler) } .sortedByDescending { it.eventLog.timestamp } diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index eeff6b40efb..6352ba3d15b 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -179,9 +179,6 @@ message EventLog { // The event being logged contains feature flags and their current enabled and sync state. FeatureFlagListContext feature_flag_list_context = 43; - - // The event being logged contains the feature flag items. - FeatureFlagItemContext feature_flag_item_context = 44; } } diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 00731bd3988..9ff233480bb 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -18,7 +18,6 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.CLOSE_RE import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.DELETE_PROFILE_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.END_CARD_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.EXIT_EXPLORATION_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FEATURE_FLAG_LIST_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.FINISH_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.HINT_UNLOCKED_CONTEXT @@ -67,7 +66,6 @@ import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.Co import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.EmptyContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.ExplorationContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagContext -import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.FeatureFlagItemContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.HintContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.LearnerDetailsContext import org.oppia.android.util.logging.EventBundleCreator.EventActivityContext.MandatorySurveyResponseContext @@ -96,7 +94,6 @@ import org.oppia.android.app.model.EventLog.AbandonSurveyContext as AbandonSurve import org.oppia.android.app.model.EventLog.CardContext as CardEventContext import org.oppia.android.app.model.EventLog.ConceptCardContext as ConceptCardEventContext import org.oppia.android.app.model.EventLog.ExplorationContext as ExplorationEventContext -import org.oppia.android.app.model.EventLog.FeatureFlagItemContext as FeatureFlagItemEventContext import org.oppia.android.app.model.EventLog.FeatureFlagListContext as FeatureFlagListEventContext import org.oppia.android.app.model.EventLog.HintContext as HintEventContext import org.oppia.android.app.model.EventLog.LearnerDetailsContext as LearnerDetailsEventContext @@ -237,7 +234,6 @@ class EventBundleCreator @Inject constructor( MANDATORY_RESPONSE -> MandatorySurveyResponseContext(activityName, mandatoryResponse) OPTIONAL_RESPONSE -> OptionalSurveyResponseContext(activityName, optionalResponse) FEATURE_FLAG_LIST_CONTEXT -> FeatureFlagContext(activityName, featureFlagListContext) - FEATURE_FLAG_ITEM_CONTEXT -> FeatureFlagItemContext(activityName, featureFlagItemContext) INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> SensitiveStringContext(activityName, installIdForFailedAnalyticsLog, "install_id") ACTIVITYCONTEXT_NOT_SET, null -> EmptyContext(activityName) // No context to create here. @@ -579,21 +575,15 @@ class EventBundleCreator @Inject constructor( value: FeatureFlagListEventContext ) : EventActivityContext(activityName, value) { override fun EventLog.FeatureFlagListContext.storeValue(store: PropertyStore) { + val featureFlagNames = featureFlagsList.map { it.flagName } + val featureFlagSyncStatuses = featureFlagsList.map { it.flagSyncStatus } + val featureFlagEnabledStates = featureFlagsList.map { it.flagEnabledState } + store.putNonSensitiveValue("uuid", uniqueUserUuid) store.putSensitiveValue("session_id", sessionId) - store.putNonSensitiveValue("feature_flags", featureFlagsList) - } - } - - /** The [EventActivityContext] corresponding to [FeatureFlagItemEventContext]s. */ - class FeatureFlagItemContext( - activityName: String, - value: FeatureFlagItemEventContext - ) : EventActivityContext(activityName, value) { - override fun EventLog.FeatureFlagItemContext.storeValue(store: PropertyStore) { - store.putNonSensitiveValue("flag_name", flagName) - store.putNonSensitiveValue("enabled_state", flagEnabledState) - store.putNonSensitiveValue("sync_status", flagSyncStatus) + store.putNonSensitiveValue("feature_flag_names", featureFlagNames) + store.putNonSensitiveValue("feature_flag_enabled_states", featureFlagEnabledStates) + store.putNonSensitiveValue("feature_flag_sync_statuses", featureFlagSyncStatuses) } } } diff --git a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt index a2a1cb2e65e..3c920a99e5b 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt @@ -51,7 +51,6 @@ class KenyaAlphaEventTypeToHumanReadableNameConverterImpl @Inject constructor() ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" ActivityContextCase.FEATURE_FLAG_LIST_CONTEXT -> "feature_flag_list" - ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT -> "feature_flag_item" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> "failed_analytics_log" ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "unknown_activity_context" } diff --git a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt index 6640b5ff63f..294df2051f8 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt @@ -61,7 +61,6 @@ class StandardEventTypeToHumanReadableNameConverterImpl @Inject constructor() : ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" ActivityContextCase.FEATURE_FLAG_LIST_CONTEXT -> "feature_flag_list" - ActivityContextCase.FEATURE_FLAG_ITEM_CONTEXT -> "feature_flag_item" ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG, ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "ERROR_internal_logging_failure" } From 5ce5241e23e8c81071be3c49706f3229259d0776 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 26 Feb 2024 18:14:43 +0300 Subject: [PATCH 44/66] feat: Add tests to check if all feature flags were logged and improve existing feature flag tests --- .../vieweventlogs/ViewEventLogsViewModel.kt | 1 - .../analytics/FeatureFlagsLogger.kt | 12 +++++- .../ApplicationLifecycleObserverTest.kt | 2 +- .../analytics/FeatureFlagsLoggerTest.kt | 43 ++++++++++++++++++- .../testing/logging/EventLogSubject.kt | 20 ++++++--- .../util/logging/EventBundleCreator.kt | 2 +- .../platformparameter/FeatureFlagConstants.kt | 4 +- 7 files changed, 70 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt index c3b94b25cf8..274079e2ce8 100644 --- a/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/ViewEventLogsViewModel.kt @@ -36,7 +36,6 @@ class ViewEventLogsViewModel @Inject constructor( private fun processEventLogsList(): List { return (analyticsEvents + firestoreEvents) .map { - println("EventLogItemViewModel: $it") EventLogItemViewModel(it, machineLocale, resourceHandler) } .sortedByDescending { it.eventLog.timestamp } diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index cfd4f41fe2a..b82b6d9b115 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -26,6 +26,10 @@ import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import javax.inject.Inject import javax.inject.Singleton +import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY +import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 +import org.oppia.android.util.platformparameter.EnableNpsSurvey +import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 /** * Convenience logger for feature flags. @@ -56,7 +60,11 @@ class FeatureFlagsLogger @Inject constructor( @EnableInteractionConfigChangeStateRetention private val enableInteractionConfigChangeStateRetention: PlatformParameterValue, @EnableAppAndOsDeprecation - private val enableAppAndOsDeprecation: PlatformParameterValue + private val enableAppAndOsDeprecation: PlatformParameterValue, + @EnableNpsSurvey + private val enableNpsSurvey: PlatformParameterValue, + @EnableOnboardingFlowV2 + private val enableOnboardingFlowV2: PlatformParameterValue ) { /** * A variable containing a list of all the feature flags in the app. @@ -74,6 +82,8 @@ class FeatureFlagsLogger @Inject constructor( SPOTLIGHT_UI to enableSpotlightUi, INTERACTION_CONFIG_CHANGE_STATE_RETENTION to enableInteractionConfigChangeStateRetention, APP_AND_OS_DEPRECATION to enableAppAndOsDeprecation, + ENABLE_NPS_SURVEY to enableNpsSurvey, + ENABLE_ONBOARDING_FLOW_V2 to enableOnboardingFlowV2 ) /** diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt index 5e07d6b06c8..d0530d21d5f 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt @@ -402,7 +402,7 @@ class ApplicationLifecycleObserverTest { assertThat(eventLog).hasFeatureFlagContextThat { hasSessionIdThat().isEqualTo(sessionId) - hasFeatureFlagItemContextThat { + hasFeatureFlagItemContextThatAtIndex(0) { hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG) hasFeatureFlagEnabledStateThat().isEqualTo(false) hasFeatureFlagSyncStateThat().isEqualTo(PlatformParameter.SyncStatus.NOT_SYNCED_FROM_SERVER) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 3311e398d00..3942d00b8c0 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -8,6 +8,7 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides +import java.io.File import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -87,7 +88,7 @@ class FeatureFlagsLoggerTest { val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureFlagItemContextThat { + hasFeatureFlagItemContextThatAtIndex(0) { hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG) hasFeatureFlagEnabledStateThat().isEqualTo(false) hasFeatureFlagSyncStateThat().isEqualTo(SyncStatus.NOT_SYNCED_FROM_SERVER) @@ -106,7 +107,7 @@ class FeatureFlagsLoggerTest { val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureFlagItemContextThat { + hasFeatureFlagItemContextThatAtIndex(0) { hasFeatureFlagNameThat().isEqualTo(TEST_FEATURE_FLAG_WITH_ENABLED_DEFAULTS) hasFeatureFlagEnabledStateThat().isEqualTo(true) hasFeatureFlagSyncStateThat().isEqualTo(SyncStatus.SYNCED_FROM_SERVER) @@ -114,10 +115,48 @@ class FeatureFlagsLoggerTest { } } + @Test + fun testLogFeatureFlags_ensuresAllAnnotatedClassesAreLogged() { + val listOfAnnotatedClassNames = getAnnotatedClassNamesInFeatureFlagConstantsFile().toSet() + + featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + testCoroutineDispatchers.runCurrent() + + val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() + assertThat(eventLog).hasFeatureFlagContextThat { + hasFeatureFlagItemCountThat().isEqualTo(listOfAnnotatedClassNames.size) + } + } + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) } + private fun getAnnotatedClassNamesInFeatureFlagConstantsFile(): List { + val path = System.getProperty("user.dir") + val rootPath = path.replace("/domain", "") + + val fileNamePath = "$rootPath/utility/src/main/java/org/oppia/android/util/platformparameter/" + + "FeatureFlagConstants.kt" + val exists = File(fileNamePath).exists() + + if (!exists) { + println("File does not exist") + return emptyList() + } + + val inputStream: List = File(fileNamePath).readLines() + val listOfFeatureFlagNames = mutableListOf() + inputStream.forEach { + if (it.contains("android_enable")) { + val className = it.split(" ").last() + listOfFeatureFlagNames.add(className) + } + } + + return listOfFeatureFlagNames + } + private companion object { private const val TEST_SESSION_ID = "test_session_id" } diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index c7f6cae2381..e0491a26032 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -2077,6 +2077,14 @@ class EventLogSubject private constructor( */ fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) + /** + * Returns a [IntegerSubject] to test [EventLog.FeatureFlagListContext.getFeatureFlagsCount]. + * + * This method never fails since the underlying property defaults to 0 if it's not defined in the + * context. + */ + fun hasFeatureFlagItemCountThat(): IntegerSubject = assertThat(actual.featureFlagsCount) + /** * Returns a [FeatureFlagItemContextSubject] to test * [EventLog.FeatureFlagListContext.getFeatureFlagsList]. @@ -2084,17 +2092,17 @@ class EventLogSubject private constructor( * This method never fails since the underlying property defaults to empty object if it's not * defined in the context. */ - fun hasFeatureFlagItemContextThat(): FeatureFlagItemContextSubject { - return FeatureFlagItemContextSubject.assertThat(actual.featureFlagsList.first()) + fun hasFeatureFlagItemContextThatAtIndex(index: Int): FeatureFlagItemContextSubject { + return FeatureFlagItemContextSubject.assertThat(actual.featureFlagsList[index]) } /** * Verifies the [EventLog]'s context and executes [block] in the same way as - * [hasFeatureFlagItemContextThat] except for the conditions of, and subject returned by, - * [hasFeatureFlagItemContextThat]. + * [hasFeatureFlagItemContextThatAtIndex] except for the conditions of, and subject returned by, + * [hasFeatureFlagItemContextThatAtIndex]. */ - fun hasFeatureFlagItemContextThat(block: FeatureFlagItemContextSubject.() -> Unit) { - hasFeatureFlagItemContextThat().block() + fun hasFeatureFlagItemContextThatAtIndex(index: Int, block: FeatureFlagItemContextSubject.() -> Unit) { + hasFeatureFlagItemContextThatAtIndex(index).block() } companion object { diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 9ff233480bb..b37fbe1d5dc 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -569,7 +569,7 @@ class EventBundleCreator @Inject constructor( } } - /** The [EventActivityContext] corresponding to [FeatureFlagEventContext]s. */ + /** The [EventActivityContext] corresponding to [FeatureFlagListEventContext]s. */ class FeatureFlagContext( activityName: String, value: FeatureFlagListEventContext diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt index ba9dafdb620..ed23d8474eb 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/FeatureFlagConstants.kt @@ -162,7 +162,7 @@ const val ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false annotation class EnableNpsSurvey /** Name of the feature flag that toggles the NPS Survey. */ -const val ENABLE_NPS_SURVEY = "enable_nps_survey" +const val ENABLE_NPS_SURVEY = "android_enable_nps_survey" /** Default value of the feature flag corresponding to [EnableNpsSurvey]. */ const val ENABLE_NPS_SURVEY_DEFAULT_VALUE = false @@ -172,7 +172,7 @@ const val ENABLE_NPS_SURVEY_DEFAULT_VALUE = false annotation class EnableOnboardingFlowV2 /** Name of the feature flag that toggles the new onboarding flow. */ -const val ENABLE_ONBOARDING_FLOW_V2 = "enable_onboarding_flow_v2" +const val ENABLE_ONBOARDING_FLOW_V2 = "android_enable_onboarding_flow_v2" /** Default value of the feature flag corresponding to [EnableOnboardingFlowV2]. */ const val ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE = false From e01e2509d43d43e507301d55aac4a67605da5572 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 26 Feb 2024 18:15:31 +0300 Subject: [PATCH 45/66] fix: Fix lint issues --- .../domain/oppialogger/analytics/FeatureFlagsLogger.kt | 8 ++++---- .../oppialogger/analytics/FeatureFlagsLoggerTest.kt | 2 +- .../org/oppia/android/testing/logging/EventLogSubject.kt | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index b82b6d9b115..96eb0531f48 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -6,6 +6,8 @@ import org.oppia.android.app.model.EventLog.FeatureFlagListContext import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI +import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY +import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation @@ -16,6 +18,8 @@ import org.oppia.android.util.platformparameter.EnableFastLanguageSwitchingInLes import org.oppia.android.util.platformparameter.EnableInteractionConfigChangeStateRetention import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds +import org.oppia.android.util.platformparameter.EnableNpsSurvey +import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON @@ -26,10 +30,6 @@ import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import javax.inject.Inject import javax.inject.Singleton -import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY -import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 -import org.oppia.android.util.platformparameter.EnableNpsSurvey -import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 /** * Convenience logger for feature flags. diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 3942d00b8c0..42e5dd9a44f 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -8,7 +8,6 @@ import dagger.BindsInstance import dagger.Component import dagger.Module import dagger.Provides -import java.io.File import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -42,6 +41,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode +import java.io.File import javax.inject.Inject import javax.inject.Singleton diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index e0491a26032..a8637498ce8 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -2101,7 +2101,10 @@ class EventLogSubject private constructor( * [hasFeatureFlagItemContextThatAtIndex] except for the conditions of, and subject returned by, * [hasFeatureFlagItemContextThatAtIndex]. */ - fun hasFeatureFlagItemContextThatAtIndex(index: Int, block: FeatureFlagItemContextSubject.() -> Unit) { + fun hasFeatureFlagItemContextThatAtIndex( + index: Int, + block: FeatureFlagItemContextSubject.() -> Unit + ) { hasFeatureFlagItemContextThatAtIndex(index).block() } From a3176a179a02f005b23079cc49c23260559c2221 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 27 Feb 2024 11:37:48 +0300 Subject: [PATCH 46/66] fix: Fix failing bazel test --- .../analytics/FeatureFlagsLoggerTest.kt | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 42e5dd9a44f..17970ef945b 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -41,7 +41,6 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode -import java.io.File import javax.inject.Inject import javax.inject.Singleton @@ -117,14 +116,14 @@ class FeatureFlagsLoggerTest { @Test fun testLogFeatureFlags_ensuresAllAnnotatedClassesAreLogged() { - val listOfAnnotatedClassNames = getAnnotatedClassNamesInFeatureFlagConstantsFile().toSet() + val expectedClassNames = 12 featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureFlagItemCountThat().isEqualTo(listOfAnnotatedClassNames.size) + hasFeatureFlagItemCountThat().isEqualTo(expectedClassNames) } } @@ -132,31 +131,6 @@ class FeatureFlagsLoggerTest { ApplicationProvider.getApplicationContext().inject(this) } - private fun getAnnotatedClassNamesInFeatureFlagConstantsFile(): List { - val path = System.getProperty("user.dir") - val rootPath = path.replace("/domain", "") - - val fileNamePath = "$rootPath/utility/src/main/java/org/oppia/android/util/platformparameter/" + - "FeatureFlagConstants.kt" - val exists = File(fileNamePath).exists() - - if (!exists) { - println("File does not exist") - return emptyList() - } - - val inputStream: List = File(fileNamePath).readLines() - val listOfFeatureFlagNames = mutableListOf() - inputStream.forEach { - if (it.contains("android_enable")) { - val className = it.split(" ").last() - listOfFeatureFlagNames.add(className) - } - } - - return listOfFeatureFlagNames - } - private companion object { private const val TEST_SESSION_ID = "test_session_id" } From 9485d78d529552f916dbe4e565f33f67cb2436e6 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Thu, 29 Feb 2024 10:20:44 +0300 Subject: [PATCH 47/66] chore: Add TODO comment for future reference --- .../android/domain/oppialogger/analytics/FeatureFlagsLogger.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 96eb0531f48..871affe2d65 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -83,6 +83,7 @@ class FeatureFlagsLogger @Inject constructor( INTERACTION_CONFIG_CHANGE_STATE_RETENTION to enableInteractionConfigChangeStateRetention, APP_AND_OS_DEPRECATION to enableAppAndOsDeprecation, ENABLE_NPS_SURVEY to enableNpsSurvey, + ENABLE_ONBOARDING_FLOW_V2 to enableOnboardingFlowV2 ) @@ -108,6 +109,8 @@ class FeatureFlagsLogger @Inject constructor( createFeatureFlagItemContext(flag) ) } + + // TODO(#5341): Set the UUID value for this context val featureFlagContext = FeatureFlagListContext.newBuilder() .setSessionId(sessionId) .addAllFeatureFlags(featureFlagItemList) From 34cade61f3a10ad1b33b8c41415d0d4a341c615a Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 6 Mar 2024 15:25:48 +0300 Subject: [PATCH 48/66] chore: rename sessionId to appSessionId --- .../domain/oppialogger/analytics/FeatureFlagsLogger.kt | 2 +- model/src/main/proto/oppia_logger.proto | 2 +- .../java/org/oppia/android/testing/logging/EventLogSubject.kt | 4 ++-- .../java/org/oppia/android/util/logging/EventBundleCreator.kt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 871affe2d65..7004f63ba17 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -112,7 +112,7 @@ class FeatureFlagsLogger @Inject constructor( // TODO(#5341): Set the UUID value for this context val featureFlagContext = FeatureFlagListContext.newBuilder() - .setSessionId(sessionId) + .setAppSessionId(sessionId) .addAllFeatureFlags(featureFlagItemList) .build() diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index 6352ba3d15b..7fc989be3f6 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -378,7 +378,7 @@ message EventLog { string unique_user_uuid = 1; // The id of the current session. - string session_id = 2; + string app_session_id = 2; // List of Feature Flag items. repeated FeatureFlagItemContext feature_flags = 3; diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index a8637498ce8..9b2d67e19e7 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -2070,12 +2070,12 @@ class EventLogSubject private constructor( fun hasUniqueUserUuidThat(): StringSubject = assertThat(actual.uniqueUserUuid) /** - * Returns a [StringSubject] to test [EventLog.FeatureFlagListContext.getSessionId]. + * Returns a [StringSubject] to test [EventLog.FeatureFlagListContext.getAppSessionId]. * * This method never fails since the underlying property defaults to empty string if it's not * defined in the context. */ - fun hasSessionIdThat(): StringSubject = assertThat(actual.sessionId) + fun hasSessionIdThat(): StringSubject = assertThat(actual.appSessionId) /** * Returns a [IntegerSubject] to test [EventLog.FeatureFlagListContext.getFeatureFlagsCount]. diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index b9ee95b7e79..170abd0bb70 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -580,7 +580,7 @@ class EventBundleCreator @Inject constructor( val featureFlagEnabledStates = featureFlagsList.map { it.flagEnabledState } store.putNonSensitiveValue("uuid", uniqueUserUuid) - store.putSensitiveValue("session_id", sessionId) + store.putSensitiveValue("session_id", appSessionId) store.putNonSensitiveValue("feature_flag_names", featureFlagNames) store.putNonSensitiveValue("feature_flag_enabled_states", featureFlagEnabledStates) store.putNonSensitiveValue("feature_flag_sync_statuses", featureFlagSyncStatuses) From 5dead31191a1e0994c97f19a5fd619185aaa7a10 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 6 Mar 2024 15:39:22 +0300 Subject: [PATCH 49/66] feat: Add application session id and add it to the feature flags logger --- .../LoggingIdentifierController.kt | 26 +++++++++++++++++++ .../analytics/ApplicationLifecycleObserver.kt | 4 +-- .../analytics/FeatureFlagsLogger.kt | 9 ++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt index f0e35b7d079..f487ab6e2a9 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt @@ -17,6 +17,7 @@ import javax.inject.Inject import javax.inject.Singleton private const val SESSION_ID_DATA_PROVIDER_ID = "LoggingIdentifierController.session_id" +private const val APP_SESSION_ID_DATA_PROVIDER_ID = "LoggingIdentifierController.app_session_id" private const val INSTALLATION_ID_DATA_PROVIDER_ID = "LoggingIdentifierController.installation_id" /** Controller that handles logging identifiers related operations. */ @@ -33,15 +34,21 @@ class LoggingIdentifierController @Inject constructor( private val baseRandom = Random(applicationIdSeed) private val installationRandomSeed = baseRandom.nextLong() private val sessionRandomSeed = baseRandom.nextLong() + private val appSessionRandomSeed = baseRandom.nextLong() private val learnerRandomSeed = baseRandom.nextLong() private val installationIdRandom by lazy { Random(installationRandomSeed) } private val sessionIdRandom by lazy { Random(sessionRandomSeed) } + private val appSessionIdRandom by lazy { Random(appSessionRandomSeed) } private val learnerIdRandom by lazy { Random(learnerRandomSeed) } private val sessionId by lazy { MutableStateFlow(computeSessionId()) } + private val appSessionId by lazy { MutableStateFlow(computeAppSessionId()) } private val sessionIdDataProvider by lazy { dataProviders.run { sessionId.convertToAutomaticDataProvider(SESSION_ID_DATA_PROVIDER_ID) } } + private val appSessionIdDataProvider by lazy { + dataProviders.run { appSessionId.convertToAutomaticDataProvider(APP_SESSION_ID_DATA_PROVIDER_ID) } + } private val installationIdStore by lazy { persistentCacheStoreFactory.create( cacheName = "device_context_database", DeviceContextDatabase.getDefaultInstance() @@ -101,6 +108,14 @@ class LoggingIdentifierController @Inject constructor( */ fun getSessionId(): DataProvider = sessionIdDataProvider + /** + * Returns an in-memory data provider pointing to a class variable of [appSessionId]. + * + * This ID is unique to each app session. A session starts when the app is opened and ends when + * the app is destroyed by the Android system. + */ + fun getAppSessionId(): DataProvider = appSessionIdDataProvider + /** * Returns the [StateFlow] backing the current session ID indicated by [getSessionId]. * @@ -110,6 +125,15 @@ class LoggingIdentifierController @Inject constructor( */ fun getSessionIdFlow(): StateFlow = sessionId + /** + * Returns the [StateFlow] backing the current app session ID indicated by [getAppSessionId]. + * + * Where the [DataProvider] returned by [getAppSessionId] can be composed by domain controllers or + * observed by the UI layer, the [StateFlow] returned by this method can be observed in background + * contexts. + */ + fun getAppSessionIdFlow(): StateFlow = appSessionId + /** * Regenerates [sessionId] and notifies the data provider. * @@ -123,6 +147,8 @@ class LoggingIdentifierController @Inject constructor( private fun computeSessionId(): String = sessionIdRandom.randomUuid().toString() + private fun computeAppSessionId(): String = appSessionIdRandom.randomUuid().toString() + private fun computeInstallationId(): String { return machineLocale.run { MessageDigest.getInstance("SHA-1") diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index 61eb4da10e3..c6db4c61d4e 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -169,8 +169,8 @@ class ApplicationLifecycleObserver @Inject constructor( private fun logAllFeatureFlags() { CoroutineScope(backgroundDispatcher).launch { - val sessionId = loggingIdentifierController.getSessionIdFlow().value - featureFlagsLogger.logAllFeatureFlags(sessionId) + val appSessionId = loggingIdentifierController.getAppSessionIdFlow().value + featureFlagsLogger.logAllFeatureFlags(appSessionId) }.invokeOnCompletion { failure -> if (failure != null) { oppiaLogger.e( diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 7004f63ba17..27dba2db274 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -100,9 +100,9 @@ class FeatureFlagsLogger @Inject constructor( /** * This method logs the name, enabled status and sync status of all feature flags to Firebase. * - * @param sessionId denotes the id of the current appInForeground session + * @param appSessionId denotes the id of the current appInForeground session */ - fun logAllFeatureFlags(sessionId: String) { + fun logAllFeatureFlags(appSessionId: String) { val featureFlagItemList = mutableListOf() for (flag in featureFlagItemMap) { featureFlagItemList.add( @@ -112,7 +112,7 @@ class FeatureFlagsLogger @Inject constructor( // TODO(#5341): Set the UUID value for this context val featureFlagContext = FeatureFlagListContext.newBuilder() - .setAppSessionId(sessionId) + .setAppSessionId(appSessionId) .addAllFeatureFlags(featureFlagItemList) .build() @@ -127,7 +127,8 @@ class FeatureFlagsLogger @Inject constructor( /** * Creates an [EventLog] context for the feature flags to be logged. * - * @param sessionId denotes the session id of the current appInForeground session + * @param flagDetails denotes the key-value pair of the feature flag name and its corresponding + * [PlatformParameterValue] * @return an [EventLog.Context] for the feature flags to be logged */ private fun createFeatureFlagItemContext( From af6a3b2a0264142932c2c7d8a1ca3f749303d570 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 6 Mar 2024 15:40:53 +0300 Subject: [PATCH 50/66] fix: Fix lint issues --- .../android/domain/oppialogger/LoggingIdentifierController.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt index f487ab6e2a9..fb72b64d14f 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt @@ -47,7 +47,9 @@ class LoggingIdentifierController @Inject constructor( dataProviders.run { sessionId.convertToAutomaticDataProvider(SESSION_ID_DATA_PROVIDER_ID) } } private val appSessionIdDataProvider by lazy { - dataProviders.run { appSessionId.convertToAutomaticDataProvider(APP_SESSION_ID_DATA_PROVIDER_ID) } + dataProviders.run { + appSessionId.convertToAutomaticDataProvider(APP_SESSION_ID_DATA_PROVIDER_ID) + } } private val installationIdStore by lazy { persistentCacheStoreFactory.create( From ad2818104990d375b6476d69a873be3e81c08b28 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 6 Mar 2024 17:10:00 +0300 Subject: [PATCH 51/66] fix: Fix failing tests --- .../android/domain/oppialogger/LoggingIdentifierController.kt | 4 ++-- .../domain/oppialogger/analytics/FeatureFlagsLogger.kt | 1 - .../oppialogger/analytics/ApplicationLifecycleObserverTest.kt | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt index fb72b64d14f..f90e36ac141 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt @@ -34,12 +34,12 @@ class LoggingIdentifierController @Inject constructor( private val baseRandom = Random(applicationIdSeed) private val installationRandomSeed = baseRandom.nextLong() private val sessionRandomSeed = baseRandom.nextLong() - private val appSessionRandomSeed = baseRandom.nextLong() private val learnerRandomSeed = baseRandom.nextLong() + private val appSessionRandomSeed = baseRandom.nextLong() private val installationIdRandom by lazy { Random(installationRandomSeed) } private val sessionIdRandom by lazy { Random(sessionRandomSeed) } - private val appSessionIdRandom by lazy { Random(appSessionRandomSeed) } private val learnerIdRandom by lazy { Random(learnerRandomSeed) } + private val appSessionIdRandom by lazy { Random(appSessionRandomSeed) } private val sessionId by lazy { MutableStateFlow(computeSessionId()) } private val appSessionId by lazy { MutableStateFlow(computeAppSessionId()) } diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt index 27dba2db274..1175075751e 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLogger.kt @@ -83,7 +83,6 @@ class FeatureFlagsLogger @Inject constructor( INTERACTION_CONFIG_CHANGE_STATE_RETENTION to enableInteractionConfigChangeStateRetention, APP_AND_OS_DEPRECATION to enableAppAndOsDeprecation, ENABLE_NPS_SURVEY to enableNpsSurvey, - ENABLE_ONBOARDING_FLOW_V2 to enableOnboardingFlowV2 ) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt index d0530d21d5f..33281bf2c06 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt @@ -391,7 +391,7 @@ class ApplicationLifecycleObserverTest { mapOf(TEST_FEATURE_FLAG to testFeatureFlag) ) - val sessionIdProvider = loggingIdentifierController.getSessionId() + val sessionIdProvider = loggingIdentifierController.getAppSessionId() val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) applicationLifecycleObserver.onCreate() From e8503b7f016d6bc6192a191f76df591983005106 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Mon, 1 Apr 2024 09:11:27 +0300 Subject: [PATCH 52/66] feat: Add tests for the appSessionId and the user UUID --- .../analytics/ApplicationLifecycleObserver.kt | 1 + .../LoggingIdentifierControllerTest.kt | 38 +++++++++++++++++++ .../ApplicationLifecycleObserverTest.kt | 1 + .../analytics/FeatureFlagsLoggerTest.kt | 11 ++++++ .../util/logging/EventBundleCreator.kt | 2 +- 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index c6db4c61d4e..6df70747674 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -169,6 +169,7 @@ class ApplicationLifecycleObserver @Inject constructor( private fun logAllFeatureFlags() { CoroutineScope(backgroundDispatcher).launch { + // TODO(#5240): Replace appSessionId generation to the modified Twitter snowflake algorithm. val appSessionId = loggingIdentifierController.getAppSessionIdFlow().value featureFlagsLogger.logAllFeatureFlags(appSessionId) }.invokeOnCompletion { failure -> diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt index b2c74d34ad0..c39e202bd86 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt @@ -251,6 +251,44 @@ class LoggingIdentifierControllerTest { assertThat(sessionIdFlow.value).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } + @Test + fun testGetAppSessionId_initialState_returnsRandomId() { + val appSessionIdProvider = loggingIdentifierController.getAppSessionId() + + val appSessionId = monitorFactory.waitForNextSuccessfulResult(appSessionIdProvider) + assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") + } + + @Test + fun testGetAppSessionId_secondCall_returnsSameRandomId() { + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getAppSessionId()) + + val sessionIdProvider = loggingIdentifierController.getAppSessionId() + + // The second call should return the same ID (since the ID doesn't automatically change). + val appSessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) + assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") + } + + @Test + fun testGetAppSessionIdFlow_initialState_returnsFlowWithRandomId() { + val appSessionIdFlow = loggingIdentifierController.getAppSessionIdFlow() + + val appSessionId = appSessionIdFlow.waitForLatestValue() + assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") + } + + @Test + fun testGetAppSessionIdFlow_secondCall_returnsFlowWithSameRandomId() { + loggingIdentifierController.getSessionIdFlow().waitForLatestValue() + + val appSessionIdFlow = loggingIdentifierController.getAppSessionIdFlow() + + // The second call should return the same ID (since the ID doesn't automatically change). + val appSessionId = appSessionIdFlow.waitForLatestValue() + assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") + } + private fun writeFileCache(cacheName: String, value: T) { getCacheFile(cacheName).writeBytes(value.toByteArray()) } diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt index 33281bf2c06..d1d7b37bb45 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt @@ -391,6 +391,7 @@ class ApplicationLifecycleObserverTest { mapOf(TEST_FEATURE_FLAG to testFeatureFlag) ) + // TODO(#5240): Replace appSessionId generation to the modified Twitter snowflake algorithm. val sessionIdProvider = loggingIdentifierController.getAppSessionId() val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 17970ef945b..4c08ede2360 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -65,6 +65,17 @@ class FeatureFlagsLoggerTest { setUpTestApplicationComponent() } + @Test + fun testLogFeatureFlags_logFeatureFlags_hasCorrectUserUUID() { + featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + testCoroutineDispatchers.runCurrent() + + val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() + assertThat(eventLog).hasFeatureFlagContextThat { + hasUniqueUserUuidThat().isEqualTo("") + } + } + @Test fun testLogFeatureFlags_logFeatureFlags_hasCorrectSessionId() { featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index 170abd0bb70..22173de2db8 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -580,7 +580,7 @@ class EventBundleCreator @Inject constructor( val featureFlagEnabledStates = featureFlagsList.map { it.flagEnabledState } store.putNonSensitiveValue("uuid", uniqueUserUuid) - store.putSensitiveValue("session_id", appSessionId) + store.putNonSensitiveValue("app_session_id", appSessionId) store.putNonSensitiveValue("feature_flag_names", featureFlagNames) store.putNonSensitiveValue("feature_flag_enabled_states", featureFlagEnabledStates) store.putNonSensitiveValue("feature_flag_sync_statuses", featureFlagSyncStatuses) From 46d54844fbef20a51950a11b3f20501ce60f8f19 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 14 Apr 2024 09:47:47 +0300 Subject: [PATCH 53/66] test: Add parameterized test for FeatureFlagsLoggerTest --- .../analytics/FeatureFlagsLoggerTest.kt | 83 ++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 4c08ede2360..1b4a49ae74e 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -3,7 +3,6 @@ package org.oppia.android.domain.oppialogger.analytics import android.app.Application import android.content.Context import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 import dagger.BindsInstance import dagger.Component import dagger.Module @@ -18,6 +17,12 @@ import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.junit.OppiaParameterizedTestRunner +import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration +import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter +import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized +import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform +import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.platformparameter.EnableTestFeatureFlag @@ -38,7 +43,19 @@ import org.oppia.android.util.logging.EnableFileLog import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.platformparameter.APP_AND_OS_DEPRECATION +import org.oppia.android.util.platformparameter.DOWNLOADS_SUPPORT +import org.oppia.android.util.platformparameter.EDIT_ACCOUNTS_OPTIONS_UI +import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY +import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 +import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION +import org.oppia.android.util.platformparameter.EXTRA_TOPIC_TABS_UI +import org.oppia.android.util.platformparameter.FAST_LANGUAGE_SWITCHING_IN_LESSON +import org.oppia.android.util.platformparameter.INTERACTION_CONFIG_CHANGE_STATE_RETENTION +import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS +import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS import org.oppia.android.util.platformparameter.PlatformParameterValue +import org.oppia.android.util.platformparameter.SPOTLIGHT_UI import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -47,7 +64,8 @@ import javax.inject.Singleton /** Tests for [FeatureFlagsLogger]. */ // FunctionName: test names are conventionally named with underscores. @Suppress("FunctionName") -@RunWith(AndroidJUnit4::class) +@RunWith(OppiaParameterizedTestRunner::class) +@SelectRunnerPlatform(ParameterizedRobolectricTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FeatureFlagsLoggerTest.TestApplication::class) class FeatureFlagsLoggerTest { @@ -60,6 +78,9 @@ class FeatureFlagsLoggerTest { @field:[Inject EnableTestFeatureFlagWithEnabledDefault] lateinit var testFeatureFlagWithEnabledDefault: PlatformParameterValue + @Parameter var index: Int = Int.MIN_VALUE + @Parameter lateinit var flagName: String + @Before fun setup() { setUpTestApplicationComponent() @@ -138,6 +159,64 @@ class FeatureFlagsLoggerTest { } } + @Test + @RunParameterized( + Iteration("downloads_support", "index=0", "flagName=$DOWNLOADS_SUPPORT"), + Iteration("extra_topics_tabs_ui", "index=1", "flagName=$EXTRA_TOPIC_TABS_UI"), + Iteration( + "learner_study_analytics", "index=2", + "flagName=$LEARNER_STUDY_ANALYTICS" + ), + Iteration( + "fast_language_switching_in_lesson", "index=3", + "flagName=$FAST_LANGUAGE_SWITCHING_IN_LESSON" + ), + Iteration( + "logging_learner_study_ids", "index=4", + "flagName=$LOGGING_LEARNER_STUDY_IDS" + ), + Iteration( + "edit_accounts_options_ui", "index=5", + "flagName=$EDIT_ACCOUNTS_OPTIONS_UI" + ), + Iteration( + "enable_performance_metrics_collection", "index=6", + "flagName=$ENABLE_PERFORMANCE_METRICS_COLLECTION" + ), + Iteration( + "spotlight_ui", "index=7", + "flagName=$SPOTLIGHT_UI" + ), + Iteration( + "interaction_config_change_state_retention", "index=8", + "flagName=$INTERACTION_CONFIG_CHANGE_STATE_RETENTION" + ), + Iteration( + "app_and_os_deprecation", "index=9", + "flagName=$APP_AND_OS_DEPRECATION" + ), + Iteration( + "enable_nps_survey", "index=10", + "flagName=$ENABLE_NPS_SURVEY" + ), + Iteration( + "enable_onboarding_flow_v2", "index=11", + "flagName=$ENABLE_ONBOARDING_FLOW_V2" + ), + ) + fun testLogFeatureFlags_logsFeatureFlagsWithDifferentValues() { + featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) + + testCoroutineDispatchers.runCurrent() + + val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() + assertThat(eventLog).hasFeatureFlagContextThat { + hasFeatureFlagItemContextThatAtIndex(index) { + hasFeatureFlagNameThat().isEqualTo(flagName) + } + } + } + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) } From 4f03d9a153cf7036dba96edf7549ac960ba9e034 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 14 Apr 2024 17:13:22 +0300 Subject: [PATCH 54/66] fix: Fix failing parameterized tests and checks --- .../domain/oppialogger/analytics/BUILD.bazel | 2 + .../analytics/FeatureFlagsLoggerTest.kt | 47 ++++++------------- .../file_content_validation_checks.textproto | 1 + 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index 45c9d0221a6..0ed1644cbf0 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -305,6 +305,8 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", + "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", + "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", "//testing/src/main/java/org/oppia/android/testing/logging:sync_status_test_module", "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 1b4a49ae74e..b4a7ca857bb 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -2,6 +2,7 @@ package org.oppia.android.domain.oppialogger.analytics import android.app.Application import android.content.Context +import android.os.Build import androidx.test.core.app.ApplicationProvider import dagger.BindsInstance import dagger.Component @@ -67,7 +68,10 @@ import javax.inject.Singleton @RunWith(OppiaParameterizedTestRunner::class) @SelectRunnerPlatform(ParameterizedRobolectricTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) -@Config(application = FeatureFlagsLoggerTest.TestApplication::class) +@Config( + application = FeatureFlagsLoggerTest.TestApplication::class, + sdk = [Build.VERSION_CODES.O] +) class FeatureFlagsLoggerTest { @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var featureFlagsLogger: FeatureFlagsLogger @@ -147,7 +151,7 @@ class FeatureFlagsLoggerTest { } @Test - fun testLogFeatureFlags_ensuresAllAnnotatedClassesAreLogged() { + fun testLogFeatureFlags_correctNumberOfFeatureFlagsIsLogged() { val expectedClassNames = 12 featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) @@ -162,49 +166,28 @@ class FeatureFlagsLoggerTest { @Test @RunParameterized( Iteration("downloads_support", "index=0", "flagName=$DOWNLOADS_SUPPORT"), - Iteration("extra_topics_tabs_ui", "index=1", "flagName=$EXTRA_TOPIC_TABS_UI"), - Iteration( - "learner_study_analytics", "index=2", - "flagName=$LEARNER_STUDY_ANALYTICS" - ), + Iteration("extra_topic_tabs_ui", "index=1", "flagName=$EXTRA_TOPIC_TABS_UI"), + Iteration("learner_study_analytics", "index=2", "flagName=$LEARNER_STUDY_ANALYTICS"), Iteration( "fast_language_switching_in_lesson", "index=3", "flagName=$FAST_LANGUAGE_SWITCHING_IN_LESSON" ), - Iteration( - "logging_learner_study_ids", "index=4", - "flagName=$LOGGING_LEARNER_STUDY_IDS" - ), - Iteration( - "edit_accounts_options_ui", "index=5", - "flagName=$EDIT_ACCOUNTS_OPTIONS_UI" - ), + Iteration("logging_learner_study_ids", "index=4", "flagName=$LOGGING_LEARNER_STUDY_IDS"), + Iteration("edit_accounts_options_ui", "index=5", "flagName=$EDIT_ACCOUNTS_OPTIONS_UI"), Iteration( "enable_performance_metrics_collection", "index=6", "flagName=$ENABLE_PERFORMANCE_METRICS_COLLECTION" ), - Iteration( - "spotlight_ui", "index=7", - "flagName=$SPOTLIGHT_UI" - ), + Iteration("spotlight_ui", "index=7", "flagName=$SPOTLIGHT_UI"), Iteration( "interaction_config_change_state_retention", "index=8", "flagName=$INTERACTION_CONFIG_CHANGE_STATE_RETENTION" ), - Iteration( - "app_and_os_deprecation", "index=9", - "flagName=$APP_AND_OS_DEPRECATION" - ), - Iteration( - "enable_nps_survey", "index=10", - "flagName=$ENABLE_NPS_SURVEY" - ), - Iteration( - "enable_onboarding_flow_v2", "index=11", - "flagName=$ENABLE_ONBOARDING_FLOW_V2" - ), + Iteration("app_and_os_deprecation", "index=9", "flagName=$APP_AND_OS_DEPRECATION"), + Iteration("enable_nps_survey", "index=10", "flagName=$ENABLE_NPS_SURVEY"), + Iteration("enable_onboarding_flow_v2", "index=11", "flagName=$ENABLE_ONBOARDING_FLOW_V2"), ) - fun testLogFeatureFlags_logsFeatureFlagsWithDifferentValues() { + fun testLogFeatureFlags_allFeatureFlagNamesAreLogged() { featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() diff --git a/scripts/assets/file_content_validation_checks.textproto b/scripts/assets/file_content_validation_checks.textproto index c191320c152..b5260b5cc48 100644 --- a/scripts/assets/file_content_validation_checks.textproto +++ b/scripts/assets/file_content_validation_checks.textproto @@ -324,6 +324,7 @@ file_content_checks { exempted_file_name: "domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt" exempted_file_name: "domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt" exempted_file_name: "domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt" + exempted_file_name: "domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt" exempted_file_name: "domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt" exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" exempted_file_name: "testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt" From 5f1af8d40788343ae787cb7f80bf341a399ffaf1 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Wed, 1 May 2024 15:41:11 +0300 Subject: [PATCH 55/66] chore: Make changes made in last review. --- .../analytics/ApplicationLifecycleObserver.kt | 2 +- .../oppialogger/analytics/FeatureFlagsLoggerTest.kt | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index 8a15a9524a1..24eaf81f248 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -176,7 +176,7 @@ class ApplicationLifecycleObserver @Inject constructor( private fun logAllFeatureFlags() { CoroutineScope(backgroundDispatcher).launch { - // TODO(#5240): Replace appSessionId generation to the modified Twitter snowflake algorithm. + // TODO(#5341): Replace appSessionId generation to the modified Twitter snowflake algorithm. val appSessionId = loggingIdentifierController.getAppSessionIdFlow().value featureFlagsLogger.logAllFeatureFlags(appSessionId) }.invokeOnCompletion { failure -> diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index b4a7ca857bb..768ccfa2992 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -86,18 +86,20 @@ class FeatureFlagsLoggerTest { @Parameter lateinit var flagName: String @Before - fun setup() { + fun setUp() { setUpTestApplicationComponent() } @Test - fun testLogFeatureFlags_logFeatureFlags_hasCorrectUserUUID() { + fun testLogFeatureFlags_logFeatureFlags_hasEmptyUserUuid() { + // TODO(#5341):The user UUID is not set in this test context and is expected to be empty. + // This test should be updated if the user UUID is set in the future. featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasUniqueUserUuidThat().isEqualTo("") + hasUniqueUserUuidThat().isEmpty() } } @@ -152,14 +154,14 @@ class FeatureFlagsLoggerTest { @Test fun testLogFeatureFlags_correctNumberOfFeatureFlagsIsLogged() { - val expectedClassNames = 12 + val expectedFeatureFlagCount = 12 featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() val eventLog = fakeAnalyticsEventLogger.getMostRecentEvent() assertThat(eventLog).hasFeatureFlagContextThat { - hasFeatureFlagItemCountThat().isEqualTo(expectedClassNames) + hasFeatureFlagItemCountThat().isEqualTo(expectedFeatureFlagCount) } } From 3fa23aaaad9a24e44a5b864abe1cee7e4c1b5c57 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 3 May 2024 13:06:42 +0300 Subject: [PATCH 56/66] chore: Add test to ensure app session id changes on each request. --- .../oppialogger/LoggingIdentifierController.kt | 11 +++++++++++ .../analytics/ApplicationLifecycleObserver.kt | 1 - .../oppialogger/LoggingIdentifierControllerTest.kt | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt index f90e36ac141..ae0b0706bcf 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt @@ -147,6 +147,17 @@ class LoggingIdentifierController @Inject constructor( sessionId.value = computeSessionId() } + /** + * Regenerates [appSessionId] and notifies the data provider. + * + * The [appSessionId] is generally updated when: + * 1. The app is opened. + * 2. The app is destroyed by the Android system. + */ + fun updateAppSessionId() { + appSessionId.value = computeAppSessionId() + } + private fun computeSessionId(): String = sessionIdRandom.randomUuid().toString() private fun computeAppSessionId(): String = appSessionIdRandom.randomUuid().toString() diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index 24eaf81f248..a81c3d0e395 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -176,7 +176,6 @@ class ApplicationLifecycleObserver @Inject constructor( private fun logAllFeatureFlags() { CoroutineScope(backgroundDispatcher).launch { - // TODO(#5341): Replace appSessionId generation to the modified Twitter snowflake algorithm. val appSessionId = loggingIdentifierController.getAppSessionIdFlow().value featureFlagsLogger.logAllFeatureFlags(appSessionId) }.invokeOnCompletion { failure -> diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt index c39e202bd86..bd29eb64685 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt @@ -289,6 +289,19 @@ class LoggingIdentifierControllerTest { assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") } + @Test + fun testGetAppSessionId_secondAppOpen_providerReturnsDifferentIdValue() { + val installationId1 = monitorFactory + .waitForNextSuccessfulResult(loggingIdentifierController.getAppSessionId()) + assertThat(installationId1).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") + + loggingIdentifierController.updateAppSessionId() // Simulate a new app session. + + val installationId2 = + monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getAppSessionId()) + assertThat(installationId2).isEqualTo("5e6269a9-6bad-3fa2-a5e0-d6b2185f0ffb") + } + private fun writeFileCache(cacheName: String, value: T) { getCacheFile(cacheName).writeBytes(value.toByteArray()) } From 1a7cb3d3a31023616ff26b200b01e3b9760eec6a Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sat, 4 May 2024 01:08:59 +0300 Subject: [PATCH 57/66] fix: Fix failing todos check. --- .../domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 768ccfa2992..42126bc9642 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -93,7 +93,6 @@ class FeatureFlagsLoggerTest { @Test fun testLogFeatureFlags_logFeatureFlags_hasEmptyUserUuid() { // TODO(#5341):The user UUID is not set in this test context and is expected to be empty. - // This test should be updated if the user UUID is set in the future. featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() From c140838ba61609fc843499c2a680838081a7f976 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 5 May 2024 19:34:13 +0300 Subject: [PATCH 58/66] fix: Fix failing todos check. --- .../domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 42126bc9642..5299fe55889 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -92,7 +92,7 @@ class FeatureFlagsLoggerTest { @Test fun testLogFeatureFlags_logFeatureFlags_hasEmptyUserUuid() { - // TODO(#5341):The user UUID is not set in this test context and is expected to be empty. + // TODO(#5341): The user UUID is not set in this test context and is expected to be empty. featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID) testCoroutineDispatchers.runCurrent() From e4d6b57b24f5f3a293c90a300397939cb8fd6fa9 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 14 May 2024 20:39:39 +0300 Subject: [PATCH 59/66] feat: Make some of the changes. --- .../domain/oppialogger/LoggingIdentifierController.kt | 11 ----------- .../analytics/ApplicationLifecycleObserver.kt | 1 + 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt index ae0b0706bcf..f90e36ac141 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt @@ -147,17 +147,6 @@ class LoggingIdentifierController @Inject constructor( sessionId.value = computeSessionId() } - /** - * Regenerates [appSessionId] and notifies the data provider. - * - * The [appSessionId] is generally updated when: - * 1. The app is opened. - * 2. The app is destroyed by the Android system. - */ - fun updateAppSessionId() { - appSessionId.value = computeAppSessionId() - } - private fun computeSessionId(): String = sessionIdRandom.randomUuid().toString() private fun computeAppSessionId(): String = appSessionIdRandom.randomUuid().toString() diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt index a81c3d0e395..24eaf81f248 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserver.kt @@ -176,6 +176,7 @@ class ApplicationLifecycleObserver @Inject constructor( private fun logAllFeatureFlags() { CoroutineScope(backgroundDispatcher).launch { + // TODO(#5341): Replace appSessionId generation to the modified Twitter snowflake algorithm. val appSessionId = loggingIdentifierController.getAppSessionIdFlow().value featureFlagsLogger.logAllFeatureFlags(appSessionId) }.invokeOnCompletion { failure -> From c7184c7a5ad2df14c6dad29e09842fb842469795 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sat, 18 May 2024 20:31:36 +0300 Subject: [PATCH 60/66] fix: Remove unnecessary test. --- .../LoggingIdentifierControllerTest.kt | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt index bd29eb64685..45a5ab9fe4f 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt @@ -71,6 +71,8 @@ class LoggingIdentifierControllerTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @field:[BackgroundDispatcher Inject] lateinit var backgroundDispatcher: CoroutineDispatcher + var testLong = 0L + @Before fun setUp() { setUpTestApplicationComponent() @@ -289,19 +291,6 @@ class LoggingIdentifierControllerTest { assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") } - @Test - fun testGetAppSessionId_secondAppOpen_providerReturnsDifferentIdValue() { - val installationId1 = monitorFactory - .waitForNextSuccessfulResult(loggingIdentifierController.getAppSessionId()) - assertThat(installationId1).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") - - loggingIdentifierController.updateAppSessionId() // Simulate a new app session. - - val installationId2 = - monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getAppSessionId()) - assertThat(installationId2).isEqualTo("5e6269a9-6bad-3fa2-a5e0-d6b2185f0ffb") - } - private fun writeFileCache(cacheName: String, value: T) { getCacheFile(cacheName).writeBytes(value.toByteArray()) } From c6b9c6044c3028070f467cbc3f04cf62fb39d50e Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Thu, 30 May 2024 09:14:48 +0300 Subject: [PATCH 61/66] feat: Add test to check that appSessionId changes after app restart --- .../LoggingIdentifierControllerTest.kt | 110 ++++++++++++++++-- 1 file changed, 102 insertions(+), 8 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt index 45a5ab9fe4f..67092ab6825 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt @@ -1,9 +1,11 @@ package org.oppia.android.domain.oppialogger import android.app.Application +import android.app.Instrumentation import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry import com.google.common.truth.Truth.assertThat import com.google.protobuf.MessageLite import dagger.BindsInstance @@ -71,10 +73,9 @@ class LoggingIdentifierControllerTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @field:[BackgroundDispatcher Inject] lateinit var backgroundDispatcher: CoroutineDispatcher - var testLong = 0L - @Before fun setUp() { + TestLoggingIdentifierModule.applicationIdSeed = INITIAL_APPLICATION_ID setUpTestApplicationComponent() } @@ -101,7 +102,8 @@ class LoggingIdentifierControllerTest { @Test fun testGetInstallationId_secondAppOpen_providerReturnsSameInstallationIdValue() { monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getInstallationId()) - setUpTestApplicationComponent() // Simulate an app re-open. + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() // Simulate an app re-open with a new app ID. val installationId = monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getInstallationId()) @@ -112,15 +114,35 @@ class LoggingIdentifierControllerTest { @Test fun testGetInstallationId_secondAppOpen_emptiedDatabase_providerReturnsEmptyString() { + // Simulate initing the installation ID, then emptying/corrupting it, then reopening the app. + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getInstallationId()) writeFileCache("device_context_database", DeviceContextDatabase.getDefaultInstance()) + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() // Simulate an app re-open with a new app ID. val installationId = monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getInstallationId()) - // The installation ID is empty since the database was overwritten. + // If the file was emptied, no installation ID can be loaded (this is a critical failure case). assertThat(installationId).isEmpty() } + @Test + fun testGetInstallationId_secondAppOpen_deletedDatabase_providerReturnsNewInstallationIdValue() { + // Simulate initing the installation ID, then deleting it, then reopening the app. + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getInstallationId()) + deleteCacheFile("device_context_database") + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() // Simulate an app re-open with a new app ID. + + val installationId = + monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getInstallationId()) + + // It should seem like a reinstallation since the app's data has been cleared after restarting. + assertThat(installationId).isEqualTo("a52e69fcfedc") + assertThat(installationId.length).isEqualTo(12) + } + @Test fun testFetchInstallationId_initialAppState_returnsNewInstallationIdValue() { val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) @@ -132,7 +154,8 @@ class LoggingIdentifierControllerTest { @Test fun testFetchInstallationId_secondAppOpen_returnsSameInstallationIdValue() { monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getInstallationId()) - setUpTestApplicationComponent() // Simulate an app re-open. + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() // Simulate an app re-open with a new app ID. val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) @@ -142,14 +165,34 @@ class LoggingIdentifierControllerTest { @Test fun testFetchInstallationId_secondAppOpen_emptiedDatabase_returnsNull() { + // Simulate initing the installation ID, then emptying/corrupting it, then reopening the app. + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getInstallationId()) writeFileCache("device_context_database", DeviceContextDatabase.getDefaultInstance()) + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() // Simulate an app re-open with a new app ID. val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) - // The installation ID is null since the database was overwritten. + // If the file was emptied, no installation ID can be loaded (this is a critical failure case). assertThat(installationId).isNull() } + @Test + fun testFetchInstallationId_secondAppOpen_deletedDatabase_returnsNewInstallationIdValue() { + // Simulate initing the installation ID, then deleting it, then reopening the app. + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getInstallationId()) + deleteCacheFile("device_context_database") + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() // Simulate an app re-open with a new app ID. + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getInstallationId()) + + val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) + + // The installation ID is null since the database was overwritten. + assertThat(installationId).isEqualTo("a52e69fcfedc") + assertThat(installationId?.length).isEqualTo(12) + } + @Test fun testGetSessionId_initialState_returnsRandomId() { val sessionIdProvider = loggingIdentifierController.getSessionId() @@ -169,6 +212,19 @@ class LoggingIdentifierControllerTest { assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } + @Test + fun testGetSessionId_secondAppOpen_returnsNewRandomId() { + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getSessionId()) + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() // Simulate an app re-open with a new app ID. + + val sessionIdProvider = loggingIdentifierController.getSessionId() + + // The second call should return the same ID (since the ID doesn't automatically change). + val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) + assertThat(sessionId).isEqualTo("18c2816d-f7ad-312f-b696-d3fdd51f2e92") + } + @Test fun testGetSessionIdFlow_initialState_returnsFlowWithRandomId() { val sessionIdFlow = loggingIdentifierController.getSessionIdFlow() @@ -291,10 +347,32 @@ class LoggingIdentifierControllerTest { assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") } + @Test + fun testGetAppSessionId_onSecondAppOpen_returnsDifferentRandomId() { + val appSessionIdProvider = loggingIdentifierController.getAppSessionId() + + val appSessionId = monitorFactory.waitForNextSuccessfulResult(appSessionIdProvider) + assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") + + // Simulate a second app open. + TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID + setUpNewTestApplicationComponent() + + val appSessionIdProvider2 = loggingIdentifierController.getAppSessionId() + + // The app session ID should be different on the second app open. + val appSessionId2 = monitorFactory.waitForNextSuccessfulResult(appSessionIdProvider2) + assertThat(appSessionId2).isEqualTo("c9d50545-33dc-3231-a1db-6a2672498c74") + } + private fun writeFileCache(cacheName: String, value: T) { getCacheFile(cacheName).writeBytes(value.toByteArray()) } + private fun deleteCacheFile(cacheName: String) { + check(getCacheFile(cacheName).delete()) { "Failed to delete: $cacheName." } + } + private fun getCacheFile(cacheName: String) = File(context.filesDir, "$cacheName.cache") private fun File.writeBytes(data: ByteArray) { @@ -332,6 +410,17 @@ class LoggingIdentifierControllerTest { ApplicationProvider.getApplicationContext().inject(this) } + private fun setUpNewTestApplicationComponent() { + createNewTestApplication().inject(this) + } + + private fun createNewTestApplication(): TestApplication { + return Instrumentation.newApplication( + TestApplication::class.java, + InstrumentationRegistry.getInstrumentation().targetContext + ) as TestApplication + } + // TODO(#89): Move this to a common test application component. @Module class TestModule { @@ -367,12 +456,12 @@ class LoggingIdentifierControllerTest { @Module class TestLoggingIdentifierModule { companion object { - internal const val applicationIdSeed = 1L + internal var applicationIdSeed: Long? = null } @Provides @ApplicationIdSeed - fun provideApplicationIdSeed(): Long = applicationIdSeed + fun provideApplicationIdSeed(): Long = applicationIdSeed!! // Fail if not initialized. } @Module @@ -438,4 +527,9 @@ class LoggingIdentifierControllerTest { override fun getDataProvidersInjector(): DataProvidersInjector = component } + + companion object { + private const val INITIAL_APPLICATION_ID = 1L + private const val SECOND_APP_OPEN_APPLICATION_ID = 2L + } } From 3765671908d165ffdfa0299a97851c4e6c5f6ed3 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Thu, 30 May 2024 21:22:35 +0300 Subject: [PATCH 62/66] fix: Fix failing test on feature flag logger. --- .../org/oppia/android/domain/oppialogger/analytics/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index d88e36308c6..3a91ed280e8 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -199,7 +199,7 @@ kt_android_library( ], visibility = ["//:oppia_api_visibility"], deps = [ - ":dagger", + "//:dagger", "//domain/src/main/java/org/oppia/android/domain/oppialogger:oppia_logger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:controller", "//third_party:javax_inject_javax_inject", From df7a08cd916d5b0d43d8133f0559e0398e61e343 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Thu, 30 May 2024 21:58:24 +0300 Subject: [PATCH 63/66] fix: Fix failing test on feature flags logger. --- .../org/oppia/android/domain/oppialogger/analytics/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index 51de8fa71e5..ecdc2be1dbf 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -299,7 +299,7 @@ oppia_android_test( test_class = "org.oppia.android.domain.oppialogger.analytics.FeatureFlagsLoggerTest", test_manifest = "//domain:test_manifest", deps = [ - ":dagger", + "//:dagger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:feature_flags_logger", "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", From 22509fa6fccf224fecf52a2ed5417a20fb66ab5f Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 4 Jun 2024 17:32:32 +0300 Subject: [PATCH 64/66] test: Simplify the test for the second app open on AppSessionId generation --- .../oppialogger/LoggingIdentifierControllerTest.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt index 67092ab6825..b44cba6a347 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt @@ -349,20 +349,16 @@ class LoggingIdentifierControllerTest { @Test fun testGetAppSessionId_onSecondAppOpen_returnsDifferentRandomId() { - val appSessionIdProvider = loggingIdentifierController.getAppSessionId() - - val appSessionId = monitorFactory.waitForNextSuccessfulResult(appSessionIdProvider) - assertThat(appSessionId).isEqualTo("2a11efe0-70f8-3a40-8d94-4fc3a2bd4f14") + monitorFactory.ensureDataProviderExecutes(loggingIdentifierController.getAppSessionId()) // Simulate a second app open. TestLoggingIdentifierModule.applicationIdSeed = SECOND_APP_OPEN_APPLICATION_ID setUpNewTestApplicationComponent() - val appSessionIdProvider2 = loggingIdentifierController.getAppSessionId() - // The app session ID should be different on the second app open. - val appSessionId2 = monitorFactory.waitForNextSuccessfulResult(appSessionIdProvider2) - assertThat(appSessionId2).isEqualTo("c9d50545-33dc-3231-a1db-6a2672498c74") + val appSessionIdProvider = loggingIdentifierController.getAppSessionId() + val appSessionId = monitorFactory.waitForNextSuccessfulResult(appSessionIdProvider) + assertThat(appSessionId).isEqualTo("c9d50545-33dc-3231-a1db-6a2672498c74") } private fun writeFileCache(cacheName: String, value: T) { From fa3122bf8e49fb48edee157a1e0d88f461285b33 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sat, 15 Jun 2024 12:29:04 +0300 Subject: [PATCH 65/66] fix: Fix failing test on feature flags logger test --- .../org/oppia/android/domain/oppialogger/analytics/BUILD.bazel | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index ecdc2be1dbf..d951c281ebb 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -304,6 +304,7 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", + "//testing/src/main/java/org/oppia/android/testing/junit:initialize_default_locale_rule", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", @@ -313,6 +314,7 @@ oppia_android_test( "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:androidx_test_core", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", From 969ede4cd27a10691aa43a9e44f72a577aa600fd Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 16 Jun 2024 21:33:50 +0300 Subject: [PATCH 66/66] fix: Fix failing test on FeatureFlagsLoggerTest. --- .../domain/oppialogger/analytics/BUILD.bazel | 2 - .../analytics/FeatureFlagsLoggerTest.kt | 43 +++++++++---------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel index d951c281ebb..ecdc2be1dbf 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/BUILD.bazel @@ -304,7 +304,6 @@ oppia_android_test( "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", - "//testing/src/main/java/org/oppia/android/testing/junit:initialize_default_locale_rule", "//testing/src/main/java/org/oppia/android/testing/junit:oppia_parameterized_test_runner", "//testing/src/main/java/org/oppia/android/testing/junit:parameterized_robolectric_test_runner", "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", @@ -314,7 +313,6 @@ oppia_android_test( "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/threading:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", - "//third_party:androidx_test_core", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt index 5299fe55889..d62953c56f0 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FeatureFlagsLoggerTest.kt @@ -21,7 +21,6 @@ import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat @@ -165,29 +164,27 @@ class FeatureFlagsLoggerTest { } @Test - @RunParameterized( - Iteration("downloads_support", "index=0", "flagName=$DOWNLOADS_SUPPORT"), - Iteration("extra_topic_tabs_ui", "index=1", "flagName=$EXTRA_TOPIC_TABS_UI"), - Iteration("learner_study_analytics", "index=2", "flagName=$LEARNER_STUDY_ANALYTICS"), - Iteration( - "fast_language_switching_in_lesson", "index=3", - "flagName=$FAST_LANGUAGE_SWITCHING_IN_LESSON" - ), - Iteration("logging_learner_study_ids", "index=4", "flagName=$LOGGING_LEARNER_STUDY_IDS"), - Iteration("edit_accounts_options_ui", "index=5", "flagName=$EDIT_ACCOUNTS_OPTIONS_UI"), - Iteration( - "enable_performance_metrics_collection", "index=6", - "flagName=$ENABLE_PERFORMANCE_METRICS_COLLECTION" - ), - Iteration("spotlight_ui", "index=7", "flagName=$SPOTLIGHT_UI"), - Iteration( - "interaction_config_change_state_retention", "index=8", - "flagName=$INTERACTION_CONFIG_CHANGE_STATE_RETENTION" - ), - Iteration("app_and_os_deprecation", "index=9", "flagName=$APP_AND_OS_DEPRECATION"), - Iteration("enable_nps_survey", "index=10", "flagName=$ENABLE_NPS_SURVEY"), - Iteration("enable_onboarding_flow_v2", "index=11", "flagName=$ENABLE_ONBOARDING_FLOW_V2"), + @Iteration("downloads_support", "index=0", "flagName=$DOWNLOADS_SUPPORT") + @Iteration("extra_topic_tabs_ui", "index=1", "flagName=$EXTRA_TOPIC_TABS_UI") + @Iteration("learner_study_analytics", "index=2", "flagName=$LEARNER_STUDY_ANALYTICS") + @Iteration( + "fast_language_switching_in_lesson", "index=3", + "flagName=$FAST_LANGUAGE_SWITCHING_IN_LESSON" ) + @Iteration("logging_learner_study_ids", "index=4", "flagName=$LOGGING_LEARNER_STUDY_IDS") + @Iteration("edit_accounts_options_ui", "index=5", "flagName=$EDIT_ACCOUNTS_OPTIONS_UI") + @Iteration( + "enable_performance_metrics_collection", "index=6", + "flagName=$ENABLE_PERFORMANCE_METRICS_COLLECTION" + ) + @Iteration("spotlight_ui", "index=7", "flagName=$SPOTLIGHT_UI") + @Iteration( + "interaction_config_change_state_retention", "index=8", + "flagName=$INTERACTION_CONFIG_CHANGE_STATE_RETENTION" + ) + @Iteration("app_and_os_deprecation", "index=9", "flagName=$APP_AND_OS_DEPRECATION") + @Iteration("enable_nps_survey", "index=10", "flagName=$ENABLE_NPS_SURVEY") + @Iteration("enable_onboarding_flow_v2", "index=11", "flagName=$ENABLE_ONBOARDING_FLOW_V2") fun testLogFeatureFlags_allFeatureFlagNamesAreLogged() { featureFlagsLogger.logAllFeatureFlags(TEST_SESSION_ID)