diff --git a/.github/workflows/build_tests.yml b/.github/workflows/build_tests.yml index f61837598b8..3e6027d0aa0 100644 --- a/.github/workflows/build_tests.yml +++ b/.github/workflows/build_tests.yml @@ -422,7 +422,7 @@ jobs: run: | bazel build --compilation_mode=opt -- //:oppia_alpha_kitkat - # Note that caching only works on non-forks. + # Note that caching only works on non-forks. 4419: should remove this? - name: Build Oppia alpha Kenya-specific AAB (with caching, non-fork only) if: ${{ env.ENABLE_CACHING == 'true' && github.event.pull_request.head.repo.full_name == 'oppia/oppia-android' }} env: diff --git a/app/src/main/java/org/oppia/android/app/application/alpha/BUILD.bazel b/app/src/main/java/org/oppia/android/app/application/alpha/BUILD.bazel index ce982039b52..823732c57a7 100644 --- a/app/src/main/java/org/oppia/android/app/application/alpha/BUILD.bazel +++ b/app/src/main/java/org/oppia/android/app/application/alpha/BUILD.bazel @@ -32,7 +32,6 @@ kt_android_library( "AlphaBuildFlavorModule.kt", ], visibility = [ - "//app/src/main/java/org/oppia/android/app/application/alphakenya:__pkg__", "//app/src/test/java/org/oppia/android/app/application/alpha:__pkg__", ], deps = [ diff --git a/app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaApplicationComponent.kt b/app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaApplicationComponent.kt deleted file mode 100644 index 75d07359cd4..00000000000 --- a/app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaApplicationComponent.kt +++ /dev/null @@ -1,116 +0,0 @@ -package org.oppia.android.app.application.alphakenya - -import dagger.Component -import org.oppia.android.app.activity.route.ActivityRouterModule -import org.oppia.android.app.application.ApplicationComponent -import org.oppia.android.app.application.ApplicationModule -import org.oppia.android.app.application.ApplicationStartupListenerModule -import org.oppia.android.app.application.alpha.AlphaBuildFlavorModule -import org.oppia.android.app.devoptions.DeveloperOptionsModule -import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule -import org.oppia.android.app.shim.IntentFactoryShimModule -import org.oppia.android.app.shim.ViewBindingShimModule -import org.oppia.android.app.translation.ActivityRecreatorProdModule -import org.oppia.android.data.backends.gae.NetworkConfigProdModule -import org.oppia.android.data.backends.gae.NetworkModule -import org.oppia.android.domain.auth.AuthenticationModule -import org.oppia.android.domain.classify.InteractionsModule -import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule -import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule -import org.oppia.android.domain.classify.rules.dragAndDropSortInput.DragDropSortInputModule -import org.oppia.android.domain.classify.rules.fractioninput.FractionInputModule -import org.oppia.android.domain.classify.rules.imageClickInput.ImageClickInputModule -import org.oppia.android.domain.classify.rules.itemselectioninput.ItemSelectionInputModule -import org.oppia.android.domain.classify.rules.mathequationinput.MathEquationInputModule -import org.oppia.android.domain.classify.rules.multiplechoiceinput.MultipleChoiceInputModule -import org.oppia.android.domain.classify.rules.numberwithunits.NumberWithUnitsRuleModule -import org.oppia.android.domain.classify.rules.numericexpressioninput.NumericExpressionInputModule -import org.oppia.android.domain.classify.rules.numericinput.NumericInputRuleModule -import org.oppia.android.domain.classify.rules.ratioinput.RatioInputModule -import org.oppia.android.domain.classify.rules.textinput.TextInputRuleModule -import org.oppia.android.domain.exploration.ExplorationProgressModule -import org.oppia.android.domain.exploration.ExplorationStorageModule -import org.oppia.android.domain.hintsandsolution.HintsAndSolutionConfigAlphaKenyaModule -import org.oppia.android.domain.hintsandsolution.HintsAndSolutionProdModule -import org.oppia.android.domain.onboarding.ExpirationMetaDataRetrieverModule -import org.oppia.android.domain.oppialogger.LogStorageModule -import org.oppia.android.domain.oppialogger.LoggingIdentifierModule -import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule -import org.oppia.android.domain.oppialogger.analytics.CpuPerformanceSnapshotterModule -import org.oppia.android.domain.oppialogger.exceptions.UncaughtExceptionLoggerModule -import org.oppia.android.domain.oppialogger.logscheduler.MetricLogSchedulerModule -import org.oppia.android.domain.oppialogger.loguploader.LogReportWorkerModule -import org.oppia.android.domain.platformparameter.PlatformParameterAlphaKenyaModule -import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule -import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUpWorkerModule -import org.oppia.android.domain.question.QuestionModule -import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule -import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.util.accessibility.AccessibilityProdModule -import org.oppia.android.util.caching.AssetModule -import org.oppia.android.util.caching.CachingModule -import org.oppia.android.util.gcsresource.GcsResourceModule -import org.oppia.android.util.locale.LocaleProdModule -import org.oppia.android.util.logging.KenyaAlphaEventLoggingConfigurationModule -import org.oppia.android.util.logging.LoggerModule -import org.oppia.android.util.logging.SyncStatusModule -import org.oppia.android.util.logging.firebase.FirebaseLogUploaderModule -import org.oppia.android.util.logging.firebase.LogReportingModule -import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsAssessorModule -import org.oppia.android.util.logging.performancemetrics.PerformanceMetricsConfigurationsModule -import org.oppia.android.util.networking.NetworkConnectionDebugUtilModule -import org.oppia.android.util.networking.NetworkConnectionUtilProdModule -import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule -import org.oppia.android.util.parser.image.GlideImageLoaderModule -import org.oppia.android.util.parser.image.ImageParsingModule -import org.oppia.android.util.system.OppiaClockModule -import org.oppia.android.util.threading.DispatcherModule -import javax.inject.Singleton - -/** - * Root Dagger component for the alpha version of the application specific to a user study in Kenya. - * - * All application-scoped modules should be included in this component. - */ -@Singleton -@Component( - modules = [ - ApplicationModule::class, DispatcherModule::class, LoggerModule::class, OppiaClockModule::class, - ContinueModule::class, FractionInputModule::class, ItemSelectionInputModule::class, - MultipleChoiceInputModule::class, NumberWithUnitsRuleModule::class, - NumericInputRuleModule::class, TextInputRuleModule::class, DragDropSortInputModule::class, - InteractionsModule::class, GcsResourceModule::class, GlideImageLoaderModule::class, - ImageParsingModule::class, HtmlParserEntityTypeModule::class, CachingModule::class, - QuestionModule::class, AccessibilityProdModule::class, ImageClickInputModule::class, - LogStorageModule::class, IntentFactoryShimModule::class, ViewBindingShimModule::class, - PrimeTopicAssetsControllerModule::class, ExpirationMetaDataRetrieverModule::class, - RatioInputModule::class, UncaughtExceptionLoggerModule::class, - ApplicationStartupListenerModule::class, LogReportWorkerModule::class, - WorkManagerConfigurationModule::class, HintsAndSolutionConfigAlphaKenyaModule::class, - FirebaseLogUploaderModule::class, NetworkModule::class, - PlatformParameterAlphaKenyaModule::class, PlatformParameterSingletonModule::class, - ExplorationStorageModule::class, DeveloperOptionsModule::class, - PlatformParameterSyncUpWorkerModule::class, NetworkConfigProdModule::class, AssetModule::class, - LocaleProdModule::class, ActivityRecreatorProdModule::class, ActivityRouterModule::class, - NumericExpressionInputModule::class, AlgebraicExpressionInputModule::class, - MathEquationInputModule::class, SplitScreenInteractionModule::class, - LoggingIdentifierModule::class, ApplicationLifecycleModule::class, - NetworkConnectionDebugUtilModule::class, LoggingIdentifierModule::class, - SyncStatusModule::class, LogReportingModule::class, NetworkConnectionUtilProdModule::class, - HintsAndSolutionProdModule::class, MetricLogSchedulerModule::class, - PerformanceMetricsConfigurationsModule::class, AlphaBuildFlavorModule::class, - KenyaAlphaEventLoggingConfigurationModule::class, CpuPerformanceSnapshotterModule::class, - PerformanceMetricsAssessorModule::class, ExplorationProgressModule::class, - AuthenticationModule::class, - ] -) -interface AlphaKenyaApplicationComponent : ApplicationComponent { - /** - * The [ApplicationComponent.Builder] for this component. Dagger will generate an implementation - * of this builder for use. - */ - @Component.Builder - interface Builder : ApplicationComponent.Builder { - override fun build(): AlphaKenyaApplicationComponent - } -} diff --git a/app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaOppiaApplication.kt b/app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaOppiaApplication.kt deleted file mode 100644 index 00566b9b6f6..00000000000 --- a/app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaOppiaApplication.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.oppia.android.app.application.alphakenya - -import org.oppia.android.app.application.AbstractOppiaApplication - -// TODO(#4419): Remove this application class & broader Kenya-specific alpha package. -/** The root [AbstractOppiaApplication] for the Kenya-specific alpha build of the Oppia app. */ -class AlphaKenyaOppiaApplication : AbstractOppiaApplication( - DaggerAlphaKenyaApplicationComponent::builder -) diff --git a/app/src/main/java/org/oppia/android/app/application/alphakenya/BUILD.bazel b/app/src/main/java/org/oppia/android/app/application/alphakenya/BUILD.bazel deleted file mode 100644 index ff7623c9481..00000000000 --- a/app/src/main/java/org/oppia/android/app/application/alphakenya/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -""" -This package contains the root application definitions for a Kenya user study specific alpha build -of the app. -""" - -load("@dagger//:workspace_defs.bzl", "dagger_rules") -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") - -kt_android_library( - name = "alpha_kenya_application", - srcs = [ - "AlphaKenyaApplicationComponent.kt", - "AlphaKenyaOppiaApplication.kt", - ], - visibility = ["//:oppia_binary_visibility"], - deps = [ - ":dagger", - "//app", - "//app/src/main/java/org/oppia/android/app/application:abstract_application", - "//app/src/main/java/org/oppia/android/app/application:application_component", - "//app/src/main/java/org/oppia/android/app/application:common_application_modules", - "//app/src/main/java/org/oppia/android/app/application/alpha:alpha_build_flavor_module", - "//domain/src/main/java/org/oppia/android/domain/auth:auth_module", - "//utility/src/main/java/org/oppia/android/util/logging:kenya_alpha_event_logging_configuration_module", - "//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module", - "//utility/src/main/java/org/oppia/android/util/networking:prod_module", - ], -) - -dagger_rules() diff --git a/build_flavors.bzl b/build_flavors.bzl index 0440b171a55..af69888d5a4 100644 --- a/build_flavors.bzl +++ b/build_flavors.bzl @@ -3,7 +3,7 @@ Macros & definitions corresponding to Oppia binary build flavors. """ load("//:oppia_android_application.bzl", "declare_deployable_application", "oppia_android_application") -load("//:version.bzl", "MAJOR_VERSION", "MINOR_VERSION", "OPPIA_ALPHA_KENYA_VERSION_CODE", "OPPIA_ALPHA_KITKAT_VERSION_CODE", "OPPIA_ALPHA_VERSION_CODE", "OPPIA_BETA_VERSION_CODE", "OPPIA_DEV_KITKAT_VERSION_CODE", "OPPIA_DEV_VERSION_CODE", "OPPIA_GA_VERSION_CODE") +load("//:version.bzl", "MAJOR_VERSION", "MINOR_VERSION", "OPPIA_ALPHA_KITKAT_VERSION_CODE", "OPPIA_ALPHA_VERSION_CODE", "OPPIA_BETA_VERSION_CODE", "OPPIA_DEV_KITKAT_VERSION_CODE", "OPPIA_DEV_VERSION_CODE", "OPPIA_GA_VERSION_CODE") # Defines the list of flavors available to build the Oppia app in. Note to developers: this list # should be ordered by the development pipeline (i.e. features go through dev first, then other @@ -13,7 +13,6 @@ AVAILABLE_FLAVORS = [ "dev_kitkat", "alpha", "alpha_kitkat", - "alpha_kenya", "beta", "ga", ] @@ -41,7 +40,6 @@ _PRODUCTION_PROGUARD_SPECS = [ ] # Note to developers: keys of this dict should follow the order of AVAILABLE_FLAVORS. -# TODO(#4419): Remove the Kenya-specific alpha flavor. _FLAVOR_METADATA = { "dev": { "manifest": "//app:src/main/AndroidManifest.xml", @@ -101,20 +99,6 @@ _FLAVOR_METADATA = { "version_code": OPPIA_ALPHA_KITKAT_VERSION_CODE, "application_class": ".app.application.alpha.AlphaOppiaApplication", }, - "alpha_kenya": { - "manifest": "//app:src/main/AndroidManifest.xml", - "min_sdk_version": 21, - "target_sdk_version": 33, - "multidex": "native", - "proguard_specs": _PRODUCTION_PROGUARD_SPECS, - "production_release": True, - "deps": [ - "//app/src/main/java/org/oppia/android/app/application/alphakenya:alpha_kenya_application", - "//config/src/java/org/oppia/android/config:all_languages_config", - ], - "version_code": OPPIA_ALPHA_KENYA_VERSION_CODE, - "application_class": ".app.application.alphakenya.AlphaKenyaOppiaApplication", - }, "beta": { "manifest": "//app:src/main/AndroidManifest.xml", "min_sdk_version": 21, 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 deleted file mode 100644 index 634755addb5..00000000000 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ /dev/null @@ -1,338 +0,0 @@ -package org.oppia.android.domain.platformparameter - -import android.content.Context -import dagger.Module -import dagger.Provides -import org.oppia.android.util.extensions.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_DOWNLOADS_SUPPORT_DEFAULT_VALUE -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_NPS_SURVEY -import org.oppia.android.util.platformparameter.ENABLE_NPS_SURVEY_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2 -import org.oppia.android.util.platformparameter.ENABLE_ONBOARDING_FLOW_V2_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 -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.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 -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 -import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.LowestSupportedApiLevel -import org.oppia.android.util.platformparameter.NPS_SURVEY_GRACE_PERIOD_IN_DAYS -import org.oppia.android.util.platformparameter.NPS_SURVEY_GRACE_PERIOD_IN_DAYS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES -import org.oppia.android.util.platformparameter.NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES_DEFAULT_VALUE -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_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 -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES -import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL -import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes -import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes -import org.oppia.android.util.platformparameter.PerformanceMetricsCollectionUploadTimeIntervalInMinutes -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 -import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours - -// TODO(#4419): Remove this module. -/** - * Dagger module that provides bindings for platform parameters for the Kenya-specific alpha build - * of the app. - */ -@Module -class PlatformParameterAlphaKenyaModule { - @Provides - @EnableDownloadsSupport - fun provideEnableDownloadsSupport( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(DOWNLOADS_SUPPORT) - ?: PlatformParameterValue.createDefaultParameter(ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE) - } - - @Provides - @SplashScreenWelcomeMsg - fun provideSplashScreenWelcomeMsgParam( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(SPLASH_SCREEN_WELCOME_MSG) - ?: PlatformParameterValue.createDefaultParameter(SPLASH_SCREEN_WELCOME_MSG_DEFAULT_VALUE) - } - - @Provides - @SyncUpWorkerTimePeriodHours - fun provideSyncUpWorkerTimePeriod( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS - ) ?: PlatformParameterValue.createDefaultParameter( - SYNC_UP_WORKER_TIME_PERIOD_IN_HOURS_DEFAULT_VALUE - ) - } - - @Provides - @EnableEditAccountsOptionsUi - fun provideEnableEditAccountsOptionsUi( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - EDIT_ACCOUNTS_OPTIONS_UI - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE - ) - } - - @Provides - @EnableLearnerStudyAnalytics - fun provideLearnerStudyAnalytics( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - // Turn on the learner study platform parameter by default. - return platformParameterSingleton.getBooleanPlatformParameter(LEARNER_STUDY_ANALYTICS) - ?: PlatformParameterValue.createDefaultParameter(true) - } - - @Provides - @EnableFastLanguageSwitchingInLesson - fun provideFastInLessonLanguageSwitching( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - // Turn on fast language switching functionality by default. - return platformParameterSingleton.getBooleanPlatformParameter(FAST_LANGUAGE_SWITCHING_IN_LESSON) - ?: PlatformParameterValue.createDefaultParameter(true) - } - - @Provides - @EnableLoggingLearnerStudyIds - fun provideLoggingLearnerStudyIds( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - // Turn on fast language switching functionality by default. - return platformParameterSingleton.getBooleanPlatformParameter(LOGGING_LEARNER_STUDY_IDS) - ?: PlatformParameterValue.createDefaultParameter(true) - } - - @Provides - @CacheLatexRendering - fun provideCacheLatexRendering( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(CACHE_LATEX_RENDERING) - ?: PlatformParameterValue.createDefaultParameter(CACHE_LATEX_RENDERING_DEFAULT_VALUE) - } - - @Provides - @EnablePerformanceMetricsCollection - fun provideEnablePerformanceMetricCollection( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - ENABLE_PERFORMANCE_METRICS_COLLECTION - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE - ) - } - - @Provides - @PerformanceMetricsCollectionUploadTimeIntervalInMinutes - fun providePerformanceMetricsCollectionUploadTimeIntervalInMinutes( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_UPLOAD_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL - ) - } - - @Provides - @PerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes - fun providePerformanceMetricsCollectionHighFrequencyTimeIntervalInMinutes( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL - ) - } - - @Provides - @PerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes - fun providePerformanceMetricsCollectionLowFrequencyTimeIntervalInMinutes( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL - ) - } - - @Provides - @EnableExtraTopicTabsUi - 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( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - INTERACTION_CONFIG_CHANGE_STATE_RETENTION - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE - ) - } - - @Provides - @EnableSpotlightUi - fun provideEnableSpotlightUi( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(SPOTLIGHT_UI) - ?: PlatformParameterValue.createDefaultParameter(ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE) - } - - @Provides - @EnableAppAndOsDeprecation - fun provideEnableAppAndOsDeprecation( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter( - APP_AND_OS_DEPRECATION - ) ?: PlatformParameterValue.createDefaultParameter( - ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE - ) - } - - @Provides - @OptionalAppUpdateVersionCode - fun provideOptionalAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton, - context: Context - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - OPTIONAL_APP_UPDATE_VERSION_CODE - ) ?: PlatformParameterValue.createDefaultParameter( - context.getVersionCode() - ) - } - - @Provides - @ForcedAppUpdateVersionCode - fun provideForcedAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton, - context: Context - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - FORCED_APP_UPDATE_VERSION_CODE - ) ?: PlatformParameterValue.createDefaultParameter( - context.getVersionCode() - ) - } - - @Provides - @LowestSupportedApiLevel - fun provideLowestSupportedApiLevel( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - LOWEST_SUPPORTED_API_LEVEL - ) ?: PlatformParameterValue.createDefaultParameter( - LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE - ) - } - - @Provides - @NpsSurveyGracePeriodInDays - fun provideNpsSurveyGracePeriodInDays( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - NPS_SURVEY_GRACE_PERIOD_IN_DAYS - ) ?: PlatformParameterValue.createDefaultParameter( - NPS_SURVEY_GRACE_PERIOD_IN_DAYS_DEFAULT_VALUE - ) - } - - @Provides - @NpsSurveyMinimumAggregateLearningTimeInATopicInMinutes - fun provideNpsSurveyMinimumAggregateLearningTimeInATopicInMinutes( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES - ) ?: PlatformParameterValue.createDefaultParameter( - NPS_SURVEY_MINIMUM_AGGREGATE_LEARNING_TIME_IN_A_TOPIC_IN_MINUTES_DEFAULT_VALUE - ) - } - - @Provides - @EnableNpsSurvey - fun provideEnableNpsSurvey( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_NPS_SURVEY) - ?: PlatformParameterValue.createDefaultParameter( - ENABLE_NPS_SURVEY_DEFAULT_VALUE - ) - } - - @Provides - @EnableOnboardingFlowV2 - fun provideEnableOnboardingFlowV2( - platformParameterSingleton: PlatformParameterSingleton - ): PlatformParameterValue { - return platformParameterSingleton.getBooleanPlatformParameter(ENABLE_ONBOARDING_FLOW_V2) - ?: PlatformParameterValue.createDefaultParameter( - ENABLE_ONBOARDING_FLOW_V2_DEFAULT_VALUE - ) - } -} diff --git a/scripts/assets/test_file_exemptions.textproto b/scripts/assets/test_file_exemptions.textproto index 0a1f51904ad..d4c71360f76 100644 --- a/scripts/assets/test_file_exemptions.textproto +++ b/scripts/assets/test_file_exemptions.textproto @@ -54,9 +54,6 @@ exempted_file_path: "app/src/main/java/org/oppia/android/app/application/Applica exempted_file_path: "app/src/main/java/org/oppia/android/app/application/ApplicationStartupListenerModule.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/alpha/AlphaOppiaApplication.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/alpha/AlphaApplicationComponent.kt" -exempted_file_path: "app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaApplicationComponent.kt" -exempted_file_path: "app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaBuildFlavorModule.kt" -exempted_file_path: "app/src/main/java/org/oppia/android/app/application/alphakenya/AlphaKenyaOppiaApplication.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/beta/BetaOppiaApplication.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/beta/BetaApplicationComponent.kt" exempted_file_path: "app/src/main/java/org/oppia/android/app/application/dev/DeveloperOppiaApplication.kt" @@ -690,7 +687,6 @@ exempted_file_path: "domain/src/main/java/org/oppia/android/domain/feedbackrepor exempted_file_path: "domain/src/main/java/org/oppia/android/domain/hintsandsolution/DelayShowAdditionalHintsFromWrongAnswerMillis.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/hintsandsolution/DelayShowAdditionalHintsMillis.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/hintsandsolution/DelayShowInitialHintMillis.kt" -exempted_file_path: "domain/src/main/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionConfigAlphaKenyaModule.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionConfigFastShowTestModule.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionConfigModule.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/hintsandsolution/HintHandler.kt" @@ -712,7 +708,6 @@ exempted_file_path: "domain/src/main/java/org/oppia/android/domain/oppialogger/e exempted_file_path: "domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorkerFactory.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerFactory.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkerModule.kt" -exempted_file_path: "domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaModule.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt" exempted_file_path: "domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonModule.kt" diff --git a/utility/src/main/java/org/oppia/android/util/logging/BUILD.bazel b/utility/src/main/java/org/oppia/android/util/logging/BUILD.bazel index e0bb6856702..39c77ea4e8e 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/BUILD.bazel +++ b/utility/src/main/java/org/oppia/android/util/logging/BUILD.bazel @@ -150,19 +150,6 @@ kt_android_library( ], ) -kt_android_library( - name = "kenya_alpha_event_logging_configuration_module", - srcs = [ - "KenyaAlphaEventLoggingConfigurationModule.kt", - "KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt", - ], - visibility = ["//:oppia_prod_module_visibility"], - deps = [ - ":dagger", - ":event_type_to_human_readable_name_converter", - ], -) - kt_android_library( name = "log_uploader", srcs = [ diff --git a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventLoggingConfigurationModule.kt b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventLoggingConfigurationModule.kt deleted file mode 100644 index 447525e5488..00000000000 --- a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventLoggingConfigurationModule.kt +++ /dev/null @@ -1,16 +0,0 @@ -package org.oppia.android.util.logging - -import dagger.Binds -import dagger.Module - -/** - * Module to provide event logging infrastructure configurations specific to Kenya study alpha - * builds of the app. - */ -@Module -interface KenyaAlphaEventLoggingConfigurationModule { - @Binds - fun bindKenyaAlphaSpecificEventTypeToHumanReadableNameConverter( - impl: KenyaAlphaEventTypeToHumanReadableNameConverterImpl - ): EventTypeToHumanReadableNameConverter -} 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 deleted file mode 100644 index 726eb02c85e..00000000000 --- a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt +++ /dev/null @@ -1,62 +0,0 @@ -package org.oppia.android.util.logging - -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase -import javax.inject.Inject - -// TODO(#4419): Remove this implementation and the extra piping for event name mapping. -/** - * Implementation of [EventTypeToHumanReadableNameConverter] which provides legacy event names for - * interoperability with previously logged data in the Kenya user study. - * - * The event names provided by this implementation are expected to never change as these names are - * the primary ways each corresponding event is identified in logged event queries. - */ -class KenyaAlphaEventTypeToHumanReadableNameConverterImpl @Inject constructor() : - EventTypeToHumanReadableNameConverter { - override fun convertToHumanReadableName(eventType: ActivityContextCase): String { - return when (eventType) { - ActivityContextCase.OPEN_EXPLORATION_ACTIVITY -> "open_exploration_activity" - ActivityContextCase.OPEN_INFO_TAB -> "open_info_tab" - ActivityContextCase.OPEN_LESSONS_TAB -> "open_lessons_tab" - ActivityContextCase.OPEN_PRACTICE_TAB -> "open_practice_tab" - ActivityContextCase.OPEN_REVISION_TAB -> "open_revision_tab" - ActivityContextCase.OPEN_QUESTION_PLAYER -> "open_question_player" - ActivityContextCase.OPEN_STORY_ACTIVITY -> "open_story_activity" - ActivityContextCase.OPEN_CONCEPT_CARD -> "open_concept_card" - ActivityContextCase.OPEN_REVISION_CARD -> "open_revision_card" - ActivityContextCase.CLOSE_REVISION_CARD -> "close_revision_card" - ActivityContextCase.START_CARD_CONTEXT -> "start_card_context" - ActivityContextCase.END_CARD_CONTEXT -> "end_card_context" - ActivityContextCase.HINT_UNLOCKED_CONTEXT -> "hint_offered_context" - ActivityContextCase.ACCESS_HINT_CONTEXT -> "access_hint_context" - ActivityContextCase.SOLUTION_UNLOCKED_CONTEXT -> "solution_offered_context" - ActivityContextCase.ACCESS_SOLUTION_CONTEXT -> "access_solution_context" - ActivityContextCase.SUBMIT_ANSWER_CONTEXT -> "submit_answer_context" - ActivityContextCase.PLAY_VOICE_OVER_CONTEXT -> "play_voice_over_context" - ActivityContextCase.PAUSE_VOICE_OVER_CONTEXT -> "pause_voice_over_context" - ActivityContextCase.APP_IN_BACKGROUND_CONTEXT -> "app_in_background_context" - ActivityContextCase.APP_IN_FOREGROUND_CONTEXT -> "app_in_foreground_context" - ActivityContextCase.EXIT_EXPLORATION_CONTEXT -> "exit_exploration_context" - ActivityContextCase.FINISH_EXPLORATION_CONTEXT -> "finish_exploration_context" - ActivityContextCase.RESUME_EXPLORATION_CONTEXT -> "resume_exploration_context" - ActivityContextCase.START_OVER_EXPLORATION_CONTEXT -> "start_over_exploration_context" - ActivityContextCase.DELETE_PROFILE_CONTEXT -> "delete_profile_context" - ActivityContextCase.OPEN_HOME -> "open_home" - ActivityContextCase.OPEN_PROFILE_CHOOSER -> "open_profile_chooser" - ActivityContextCase.REACH_INVESTED_ENGAGEMENT -> "reached_invested_engagement" - ActivityContextCase.SWITCH_IN_LESSON_LANGUAGE -> "switch_in_lesson_language" - ActivityContextCase.SHOW_SURVEY_POPUP -> "show_survey_popup" - ActivityContextCase.BEGIN_SURVEY -> "begin_survey" - ActivityContextCase.ABANDON_SURVEY -> "abandon_survey" - ActivityContextCase.MANDATORY_RESPONSE -> "mandatory_response" - ActivityContextCase.OPTIONAL_RESPONSE -> "optional_response" - ActivityContextCase.INSTALL_ID_FOR_FAILED_ANALYTICS_LOG -> "failed_analytics_log" - ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -> "unknown_activity_context" - ActivityContextCase.COMPLETE_APP_ONBOARDING -> "complete_app_onboarding" - ActivityContextCase.CONSOLE_LOG -> "console_log" - ActivityContextCase.RETROFIT_CALL_CONTEXT -> "retrofit_call_context" - ActivityContextCase.RETROFIT_CALL_FAILED_CONTEXT -> "retrofit_call_failed_context" - ActivityContextCase.APP_IN_FOREGROUND_TIME -> "app_in_foreground_time" - } - } -} diff --git a/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel index 15aa68e6b79..7d220d7172e 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/logging/BUILD.bazel @@ -62,43 +62,6 @@ oppia_android_test( ], ) -oppia_android_test( - name = "KenyaAlphaEventBundleCreatorTest", - srcs = ["KenyaAlphaEventBundleCreatorTest.kt"], - custom_package = "org.oppia.android.util.logging", - test_class = "org.oppia.android.util.logging.KenyaAlphaEventBundleCreatorTest", - test_manifest = "//utility:test_manifest", - deps = [ - ":dagger", - "//testing", - "//third_party:androidx_test_ext_junit", - "//third_party:androidx_test_ext_truth", - "//third_party:com_google_truth_truth", - "//third_party:org_robolectric_robolectric", - "//third_party:robolectric_android-all", - "//utility/src/main/java/org/oppia/android/util/logging:event_bundle_creator", - "//utility/src/main/java/org/oppia/android/util/logging:kenya_alpha_event_logging_configuration_module", - ], -) - -oppia_android_test( - name = "KenyaAlphaEventLoggingConfigurationModuleTest", - srcs = ["KenyaAlphaEventLoggingConfigurationModuleTest.kt"], - custom_package = "org.oppia.android.util.logging", - test_class = "org.oppia.android.util.logging.KenyaAlphaEventLoggingConfigurationModuleTest", - test_manifest = "//utility:test_manifest", - deps = [ - ":dagger", - "//testing", - "//third_party:androidx_test_ext_junit", - "//third_party:androidx_test_ext_truth", - "//third_party:com_google_truth_truth", - "//third_party:org_robolectric_robolectric", - "//third_party:robolectric_android-all", - "//utility/src/main/java/org/oppia/android/util/logging:kenya_alpha_event_logging_configuration_module", - ], -) - oppia_android_test( name = "StandardEventTypeToHumanReadableNameConverterImplTest", srcs = ["StandardEventTypeToHumanReadableNameConverterImplTest.kt"], 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 deleted file mode 100644 index ccc9f65bf3f..00000000000 --- a/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventBundleCreatorTest.kt +++ /dev/null @@ -1,1616 +0,0 @@ -package org.oppia.android.util.logging - -import android.app.Application -import android.content.Context -import android.os.Bundle -import androidx.test.core.app.ApplicationProvider -import androidx.test.core.content.pm.ApplicationInfoBuilder -import androidx.test.core.content.pm.PackageInfoBuilder -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.ext.truth.os.BundleSubject.assertThat -import com.google.common.truth.Truth.assertThat -import dagger.BindsInstance -import dagger.Component -import dagger.Module -import dagger.Provides -import org.junit.After -import org.junit.Test -import org.junit.runner.RunWith -import org.oppia.android.app.model.EventLog -import org.oppia.android.app.model.EventLog.CardContext -import org.oppia.android.app.model.EventLog.ConceptCardContext -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.ACCESS_HINT_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.ACCESS_SOLUTION_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.ACTIVITYCONTEXT_NOT_SET -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.APP_IN_BACKGROUND_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.APP_IN_FOREGROUND_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.CLOSE_REVISION_CARD -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.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 -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_CONCEPT_CARD -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_EXPLORATION_ACTIVITY -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_HOME -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_INFO_TAB -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_LESSONS_TAB -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_PRACTICE_TAB -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_PROFILE_CHOOSER -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_QUESTION_PLAYER -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_REVISION_CARD -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_REVISION_TAB -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_STORY_ACTIVITY -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.PAUSE_VOICE_OVER_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.PLAY_VOICE_OVER_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.RESUME_EXPLORATION_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SOLUTION_UNLOCKED_CONTEXT -import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_CARD_CONTEXT -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.ExplorationContext -import org.oppia.android.app.model.EventLog.HintContext -import org.oppia.android.app.model.EventLog.LearnerDetailsContext -import org.oppia.android.app.model.EventLog.Priority.ESSENTIAL -import org.oppia.android.app.model.EventLog.Priority.OPTIONAL -import org.oppia.android.app.model.EventLog.QuestionContext -import org.oppia.android.app.model.EventLog.RevisionCardContext -import org.oppia.android.app.model.EventLog.StoryContext -import org.oppia.android.app.model.EventLog.SubmitAnswerContext -import org.oppia.android.app.model.EventLog.SwitchInLessonLanguageEventContext -import org.oppia.android.app.model.EventLog.TopicContext -import org.oppia.android.app.model.EventLog.VoiceoverActionContext -import org.oppia.android.app.model.OppiaLanguage -import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds -import org.oppia.android.util.platformparameter.LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.PlatformParameterValue -import org.robolectric.Shadows -import org.robolectric.annotation.Config -import org.robolectric.annotation.LooperMode -import javax.inject.Inject -import javax.inject.Singleton -import org.oppia.android.app.model.EventLog.Context.Builder as EventContextBuilder - -private const val TEST_ANDROID_SDK_VERSION = 30 - -// TODO(#4419): Remove this test suite post-Kenya user study. -/** - * Variant of [EventBundleCreatorTest] but for testing behaviors specific to alpha builds of the app - * intended for users in the Kenya user study. - */ -// FunctionName: test names are conventionally named with underscores. -@Suppress("FunctionName") -@RunWith(AndroidJUnit4::class) -@LooperMode(LooperMode.Mode.PAUSED) -@Config( - application = KenyaAlphaEventBundleCreatorTest.TestApplication::class, - sdk = [TEST_ANDROID_SDK_VERSION] -) -class KenyaAlphaEventBundleCreatorTest { - private companion object { - private const val TEST_TIMESTAMP_1 = 1556094120000 - private const val TEST_TIMESTAMP_2 = 1234567898765 - private const val TEST_TOPIC_ID = "test_topic_id" - private const val TEST_STORY_ID = "test_story_id" - private const val TEST_EXPLORATION_ID = "test_exploration_id" - private const val TEST_QUESTION_ID = "test_question_id" - private const val TEST_SKILL_ID_1 = "test_skill_id_1" - private const val TEST_SKILL_ID_2 = "test_skill_id_2" - private const val TEST_SUB_TOPIC_INDEX = 1 - private const val TEST_SUB_TOPIC_INDEX_STR = "1" - private const val TEST_LEARNER_ID = "test_ed_ld_learner_id" - private const val TEST_INSTALLATION_ID = "test_installation_id" - private const val TEST_LEARNER_SESSION_ID = "test_session_id" - private const val TEST_EXPLORATION_VERSION = 5 - private const val TEST_EXPLORATION_VERSION_STR = "5" - private const val TEST_STATE_NAME = "test_state_name" - private const val TEST_HINT_INDEX = 1 - private const val TEST_HINT_INDEX_STR = "1" - private const val TEST_IS_ANSWER_CORRECT = true - private const val TEST_IS_ANSWER_CORRECT_STR = "true" - private const val TEST_CONTENT_ID = "test_content_id" - private const val TEST_LANGUAGE_CODE = "en" - private const val TEST_APP_VERSION_NAME = "oppia-android-test-0123456789" - private const val TEST_APP_VERSION_CODE = 125L - } - - @Inject lateinit var context: Context - @Inject lateinit var eventBundleCreator: EventBundleCreator - - @After - fun tearDown() { - TestModule.enableLoggingLearnerStudyIds = LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE - } - - @Test - fun testFillEventBundle_defaultEvent_defaultsBundleAndReturnsUnknownActivityContext() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val typeName = eventBundleCreator.fillEventBundle(EventLog.getDefaultInstance(), bundle) - - assertThat(typeName).isEqualTo("unknown_activity_context") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(0) - assertThat(bundle).string("priority").isEqualTo("unspecified_priority") - assertThat(bundle).integer("event_type").isEqualTo(ACTIVITYCONTEXT_NOT_SET.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_eventWithDefaultedContext_fillsPriorityAndTimeAndRetsUnknownContext() { - setUpTestApplicationComponent() - val bundle = Bundle() - val eventLog = createEventLog(timestamp = TEST_TIMESTAMP_1, priority = ESSENTIAL) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - - assertThat(typeName).isEqualTo("unknown_activity_context") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(ACTIVITYCONTEXT_NOT_SET.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_eventWithDifferentTimestamp_savesDifferentTimestampInBundle() { - setUpTestApplicationComponent() - val bundle = Bundle() - val eventLog = createEventLog(timestamp = TEST_TIMESTAMP_2) - - eventBundleCreator.fillEventBundle(eventLog, bundle) - - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_2) - } - - @Test - fun testFillEventBundle_eventWithDifferentPriority_savesDifferentPriorityInBundle() { - setUpTestApplicationComponent() - val bundle = Bundle() - val eventLog = createEventLog(priority = OPTIONAL) - - eventBundleCreator.fillEventBundle(eventLog, bundle) - - assertThat(bundle).string("priority").isEqualTo("optional") - } - - @Test - fun testFillEventBundle_openExpActivityEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenExplorationActivity()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_exploration_activity") - assertThat(bundle).hasSize(17) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_EXPLORATION_ACTIVITY.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - } - - @Test - fun testFillEventBundle_openExpActivityEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenExplorationActivity()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_exploration_activity") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_EXPLORATION_ACTIVITY.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_openInfoTabContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenInfoTab()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_info_tab") - assertThat(bundle).hasSize(12) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_INFO_TAB.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - } - - @Test - fun testFillEventBundle_openLessonsTabContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenLessonsTab()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_lessons_tab") - assertThat(bundle).hasSize(12) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_LESSONS_TAB.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - } - - @Test - fun testFillEventBundle_openPracticeTabContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenPracticeTab()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_practice_tab") - assertThat(bundle).hasSize(12) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_PRACTICE_TAB.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - } - - @Test - fun testFillEventBundle_openRevisionTabContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenRevisionTab()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_revision_tab") - assertThat(bundle).hasSize(12) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_REVISION_TAB.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - } - - @Test - fun testFillEventBundle_openQuestionPlayerContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenQuestionPlayer()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_question_player") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_QUESTION_PLAYER.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("question_id").isEqualTo(TEST_QUESTION_ID) - assertThat(bundle).string("skill_ids").isEqualTo("$TEST_SKILL_ID_1,$TEST_SKILL_ID_2") - } - - @Test - fun testFillEventBundle_openStoryActivityContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenStoryActivity()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_story_activity") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_STORY_ACTIVITY.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - } - - @Test - fun testFillEventBundle_openConceptCardContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenConceptCard()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_concept_card") - assertThat(bundle).hasSize(12) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_CONCEPT_CARD.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("skill_id").isEqualTo(TEST_SKILL_ID_1) - } - - @Test - fun testFillEventBundle_openRevisionCardContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenRevisionCard()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_revision_card") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_REVISION_CARD.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("subtopic_index").isEqualTo(TEST_SUB_TOPIC_INDEX_STR) - } - - @Test - fun testFillEventBundle_closeRevisionCardContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createCloseRevisionCard()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("close_revision_card") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(CLOSE_REVISION_CARD.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("subtopic_index").isEqualTo(TEST_SUB_TOPIC_INDEX_STR) - } - - @Test - fun testFillEventBundle_startCardContextEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createStartCardContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("start_card_context") - assertThat(bundle).hasSize(18) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(START_CARD_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("skill_id").isEqualTo(TEST_SKILL_ID_1) - } - - @Test - fun testFillEventBundle_startCardContextEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createStartCardContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("start_card_context") - assertThat(bundle).hasSize(20) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(START_CARD_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("skill_id").isEqualTo(TEST_SKILL_ID_1) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_endCardContextEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createEndCardContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("end_card_context") - assertThat(bundle).hasSize(18) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(END_CARD_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("skill_id").isEqualTo(TEST_SKILL_ID_1) - } - - @Test - fun testFillEventBundle_endCardContextEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createEndCardContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("end_card_context") - assertThat(bundle).hasSize(20) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(END_CARD_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("skill_id").isEqualTo(TEST_SKILL_ID_1) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_hintUnlockedEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createHintUnlockedContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("hint_offered_context") - assertThat(bundle).hasSize(18) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(HINT_UNLOCKED_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("hint_index").isEqualTo(TEST_HINT_INDEX_STR) - } - - @Test - fun testFillEventBundle_hintUnlockedEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createHintUnlockedContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("hint_offered_context") - assertThat(bundle).hasSize(20) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(HINT_UNLOCKED_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("hint_index").isEqualTo(TEST_HINT_INDEX_STR) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_accessHintContextEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAccessHintContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("access_hint_context") - assertThat(bundle).hasSize(18) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(ACCESS_HINT_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("hint_index").isEqualTo(TEST_HINT_INDEX_STR) - } - - @Test - fun testFillEventBundle_accessHintContextEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAccessHintContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("access_hint_context") - assertThat(bundle).hasSize(20) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(ACCESS_HINT_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("hint_index").isEqualTo(TEST_HINT_INDEX_STR) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_solutionUnlockedEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createSolutionUnlockedContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("solution_offered_context") - assertThat(bundle).hasSize(17) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(SOLUTION_UNLOCKED_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - } - - @Test - fun testFillEventBundle_solutionUnlockedEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createSolutionUnlockedContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("solution_offered_context") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(SOLUTION_UNLOCKED_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_accessSolutionEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAccessSolutionContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("access_solution_context") - assertThat(bundle).hasSize(17) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(ACCESS_SOLUTION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - } - - @Test - fun testFillEventBundle_accessSolutionEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAccessSolutionContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("access_solution_context") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(ACCESS_SOLUTION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_submitAnswerEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createSubmitAnswerContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("submit_answer_context") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(SUBMIT_ANSWER_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("submitted_answer").isEmpty() - assertThat(bundle).string("is_answer_correct").isEqualTo(TEST_IS_ANSWER_CORRECT_STR) - } - - @Test - fun testFillEventBundle_submitAnswerEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createSubmitAnswerContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("submit_answer_context") - assertThat(bundle).hasSize(21) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(SUBMIT_ANSWER_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("submitted_answer").isEmpty() - assertThat(bundle).string("is_answer_correct").isEqualTo(TEST_IS_ANSWER_CORRECT_STR) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_playVoiceOverEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createPlayVoiceOverContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("play_voice_over_context") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(PLAY_VOICE_OVER_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("content_id").isEqualTo(TEST_CONTENT_ID) - assertThat(bundle).string("language_code").isEqualTo(TEST_LANGUAGE_CODE) - } - - @Test - fun testFillEventBundle_playVoiceOverEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createPlayVoiceOverContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("play_voice_over_context") - assertThat(bundle).hasSize(21) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(PLAY_VOICE_OVER_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("content_id").isEqualTo(TEST_CONTENT_ID) - assertThat(bundle).string("language_code").isEqualTo(TEST_LANGUAGE_CODE) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_pauseVoiceOverEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createPauseVoiceOverContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("pause_voice_over_context") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(PAUSE_VOICE_OVER_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("content_id").isEqualTo(TEST_CONTENT_ID) - assertThat(bundle).string("language_code").isEqualTo(TEST_LANGUAGE_CODE) - } - - @Test - fun testFillEventBundle_pauseVoiceOverEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createPauseVoiceOverContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("pause_voice_over_context") - assertThat(bundle).hasSize(21) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(PAUSE_VOICE_OVER_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("content_id").isEqualTo(TEST_CONTENT_ID) - assertThat(bundle).string("language_code").isEqualTo(TEST_LANGUAGE_CODE) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_appInBackgroundEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAppInBackgroundContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("app_in_background_context") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(APP_IN_BACKGROUND_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_appInBackgroundEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAppInBackgroundContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("app_in_background_context") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(APP_IN_BACKGROUND_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_appInForegroundEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAppInForegroundContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("app_in_foreground_context") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(APP_IN_FOREGROUND_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_appInForegroundEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createAppInForegroundContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("app_in_foreground_context") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(APP_IN_FOREGROUND_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_exitExplorationEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createExitExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("exit_exploration_context") - assertThat(bundle).hasSize(17) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(EXIT_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - } - - @Test - fun testFillEventBundle_exitExplorationEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createExitExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("exit_exploration_context") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(EXIT_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_finishExplorationEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createFinishExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("finish_exploration_context") - assertThat(bundle).hasSize(17) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(FINISH_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - } - - @Test - fun testFillEventBundle_finishExplorationEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createFinishExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("finish_exploration_context") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(FINISH_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_resumeExplorationEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createResumeExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("resume_exploration_context") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(RESUME_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_resumeExplorationEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createResumeExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("resume_exploration_context") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(RESUME_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_startOverExpEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createStartOverExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("start_over_exploration_context") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(START_OVER_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_startOverExpEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createStartOverExplorationContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("start_over_exploration_context") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(START_OVER_EXPLORATION_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_deleteProfileEvent_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createDeleteProfileContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("delete_profile_context") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(DELETE_PROFILE_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_deleteProfileEvent_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createDeleteProfileContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("delete_profile_context") - assertThat(bundle).hasSize(13) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(DELETE_PROFILE_CONTEXT.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - @Test - fun testFillEventBundle_openHomeContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenHomeContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_home") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_HOME.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_openProfileChooserContextEvent_fillsAllFieldsInBundleAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createOpenProfileChooserContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("open_profile_chooser") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(OPEN_PROFILE_CHOOSER.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_switchInLessonLanguageEvent_studyOff_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponent() - val bundle = Bundle() - - val eventLog = createEventLog(context = createSwitchInLessonLanguageContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("switch_in_lesson_language") - assertThat(bundle).hasSize(19) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(SWITCH_IN_LESSON_LANGUAGE.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("from_language").isEqualTo("English") - assertThat(bundle).string("to_language").isEqualTo("Swahili") - } - - @Test - fun testFillEventBundle_switchInLessonLanguageEvent_studyOn_fillsNonSensitiveDataAndRetsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createSwitchInLessonLanguageContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("switch_in_lesson_language") - assertThat(bundle).hasSize(21) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(SWITCH_IN_LESSON_LANGUAGE.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("ed_topic_id").isEqualTo(TEST_TOPIC_ID) - assertThat(bundle).string("ed_story_id").isEqualTo(TEST_STORY_ID) - assertThat(bundle).string("ed_exploration_id").isEqualTo(TEST_EXPLORATION_ID) - assertThat(bundle).string("ed_session_id").isEqualTo(TEST_LEARNER_SESSION_ID) - assertThat(bundle).string("ed_exploration_version").isEqualTo(TEST_EXPLORATION_VERSION_STR) - assertThat(bundle).string("ed_state_name").isEqualTo(TEST_STATE_NAME) - assertThat(bundle).string("ed_ld_learner_id").isEqualTo(TEST_LEARNER_ID) - assertThat(bundle).string("ed_ld_install_id").isEqualTo(TEST_INSTALLATION_ID) - assertThat(bundle).string("from_language").isEqualTo("English") - assertThat(bundle).string("to_language").isEqualTo("Swahili") - } - - @Test - fun testFillEventBundle_failedEventInstallId_studyOff_fillsOnlyNonSensitiveFieldsAndRetsName() { - setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createInstallationIdForFailedAnalyticsLogContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("failed_analytics_log") - assertThat(bundle).hasSize(11) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(INSTALL_ID_FOR_FAILED_ANALYTICS_LOG.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - } - - @Test - fun testFillEventBundle_failedEventInstallId_studyOn_fillsAllFieldsAndReturnsName() { - setUpTestApplicationComponentWithLearnerAnalyticsStudy() - val bundle = Bundle() - - val eventLog = createEventLog(context = createInstallationIdForFailedAnalyticsLogContext()) - - val typeName = eventBundleCreator.fillEventBundle(eventLog, bundle) - assertThat(typeName).isEqualTo("failed_analytics_log") - assertThat(bundle).hasSize(12) - assertThat(bundle).longInt("timestamp").isEqualTo(TEST_TIMESTAMP_1) - assertThat(bundle).string("priority").isEqualTo("essential") - assertThat(bundle).integer("event_type").isEqualTo(INSTALL_ID_FOR_FAILED_ANALYTICS_LOG.number) - assertThat(bundle).integer("android_sdk").isEqualTo(TEST_ANDROID_SDK_VERSION) - assertThat(bundle).string("app_version_name").isEqualTo(TEST_APP_VERSION_NAME) - assertThat(bundle).integer("app_version_code").isEqualTo(TEST_APP_VERSION_CODE) - assertThat(bundle).string("install_id").isEqualTo(TEST_INSTALLATION_ID) - } - - private fun createEventLog( - timestamp: Long = TEST_TIMESTAMP_1, - priority: EventLog.Priority = ESSENTIAL, - context: EventLog.Context = EventLog.Context.getDefaultInstance() - ) = EventLog.newBuilder().apply { - this.timestamp = timestamp - this.priority = priority - this.context = context - }.build() - - private fun createOpenExplorationActivity( - explorationContext: ExplorationContext = createExplorationContext() - ) = createEventContext(explorationContext, EventContextBuilder::setOpenExplorationActivity) - - private fun createOpenInfoTab(topicContext: TopicContext = createTopicContext()) = - createEventContext(topicContext, EventContextBuilder::setOpenInfoTab) - - private fun createOpenLessonsTab(topicContext: TopicContext = createTopicContext()) = - createEventContext(topicContext, EventContextBuilder::setOpenLessonsTab) - - private fun createOpenPracticeTab(topicContext: TopicContext = createTopicContext()) = - createEventContext(topicContext, EventContextBuilder::setOpenPracticeTab) - - private fun createOpenRevisionTab(topicContext: TopicContext = createTopicContext()) = - createEventContext(topicContext, EventContextBuilder::setOpenRevisionTab) - - private fun createOpenQuestionPlayer(questionContext: QuestionContext = createQuestionContext()) = - createEventContext(questionContext, EventContextBuilder::setOpenQuestionPlayer) - - private fun createOpenStoryActivity(storyContext: StoryContext = createStoryContext()) = - createEventContext(storyContext, EventContextBuilder::setOpenStoryActivity) - - private fun createOpenConceptCard( - conceptCardContext: ConceptCardContext = createConceptCardContext() - ) = createEventContext(conceptCardContext, EventContextBuilder::setOpenConceptCard) - - private fun createOpenRevisionCard( - revisionCardContext: RevisionCardContext = createRevisionCardContext() - ) = createEventContext(revisionCardContext, EventContextBuilder::setOpenRevisionCard) - - private fun createCloseRevisionCard( - revisionCardContext: RevisionCardContext = createRevisionCardContext() - ) = createEventContext(revisionCardContext, EventContextBuilder::setCloseRevisionCard) - - private fun createStartCardContext(cardContext: CardContext = createCardContext()) = - createEventContext(cardContext, EventContextBuilder::setStartCardContext) - - private fun createEndCardContext(cardContext: CardContext = createCardContext()) = - createEventContext(cardContext, EventContextBuilder::setEndCardContext) - - private fun createHintUnlockedContext(hintContext: HintContext = createHintContext()) = - createEventContext(hintContext, EventContextBuilder::setHintUnlockedContext) - - private fun createAccessHintContext(hintContext: HintContext = createHintContext()) = - createEventContext(hintContext, EventContextBuilder::setAccessHintContext) - - private fun createSolutionUnlockedContext( - explorationContext: ExplorationContext = createExplorationContext() - ) = createEventContext(explorationContext, EventContextBuilder::setSolutionUnlockedContext) - - private fun createAccessSolutionContext( - explorationContext: ExplorationContext = createExplorationContext() - ) = createEventContext(explorationContext, EventContextBuilder::setAccessSolutionContext) - - private fun createSubmitAnswerContext( - submitAnswerContext: SubmitAnswerContext = createSubmitAnswerContextDetails() - ) = createEventContext(submitAnswerContext, EventContextBuilder::setSubmitAnswerContext) - - private fun createPlayVoiceOverContext( - playVoiceOverContext: VoiceoverActionContext = createPlayVoiceOverContextDetails() - ) = createEventContext(playVoiceOverContext, EventContextBuilder::setPlayVoiceOverContext) - - private fun createPauseVoiceOverContext( - pauseVoiceOverContext: VoiceoverActionContext = createPauseVoiceOverContextDetails() - ) = createEventContext(pauseVoiceOverContext, EventContextBuilder::setPauseVoiceOverContext) - - private fun createAppInBackgroundContext( - learnerDetails: LearnerDetailsContext = createLearnerDetailsContext() - ) = createEventContext(learnerDetails, EventContextBuilder::setAppInBackgroundContext) - - private fun createAppInForegroundContext( - learnerDetails: LearnerDetailsContext = createLearnerDetailsContext() - ) = createEventContext(learnerDetails, EventContextBuilder::setAppInForegroundContext) - - private fun createExitExplorationContext( - explorationContext: ExplorationContext = createExplorationContext() - ) = createEventContext(explorationContext, EventContextBuilder::setExitExplorationContext) - - private fun createFinishExplorationContext( - explorationContext: ExplorationContext = createExplorationContext() - ) = createEventContext(explorationContext, EventContextBuilder::setFinishExplorationContext) - - private fun createResumeExplorationContext( - learnerDetails: LearnerDetailsContext = createLearnerDetailsContext() - ) = createEventContext(learnerDetails, EventContextBuilder::setResumeExplorationContext) - - private fun createStartOverExplorationContext( - learnerDetails: LearnerDetailsContext = createLearnerDetailsContext() - ) = createEventContext(learnerDetails, EventContextBuilder::setStartOverExplorationContext) - - private fun createDeleteProfileContext( - learnerDetails: LearnerDetailsContext = createLearnerDetailsContext() - ) = createEventContext(learnerDetails, EventContextBuilder::setDeleteProfileContext) - - private fun createOpenHomeContext() = - createEventContext(value = true, EventContextBuilder::setOpenHome) - - private fun createOpenProfileChooserContext() = - createEventContext(value = true, EventContextBuilder::setOpenProfileChooser) - - private fun createSwitchInLessonLanguageContext( - switchLanguageContext: SwitchInLessonLanguageEventContext = - createSwitchInLessonLanguageEventContext(), - ) = createEventContext(switchLanguageContext, EventContextBuilder::setSwitchInLessonLanguage) - - private fun createInstallationIdForFailedAnalyticsLogContext( - installationId: String = TEST_INSTALLATION_ID - ) = createEventContext(installationId, EventContextBuilder::setInstallIdForFailedAnalyticsLog) - - private fun createEventContext( - value: T, - setter: EventContextBuilder.(T) -> EventContextBuilder - ) = EventLog.Context.newBuilder().setter(value).build() - - private fun createExplorationContext( - topicId: String = TEST_TOPIC_ID, - storyId: String = TEST_STORY_ID, - explorationId: String = TEST_EXPLORATION_ID, - sessionId: String = TEST_LEARNER_SESSION_ID, - explorationVersion: Int = TEST_EXPLORATION_VERSION, - stateName: String = TEST_STATE_NAME, - learnerDetails: LearnerDetailsContext = createLearnerDetailsContext() - ) = ExplorationContext.newBuilder().apply { - this.topicId = topicId - this.storyId = storyId - this.explorationId = explorationId - this.sessionId = sessionId - this.explorationVersion = explorationVersion - this.stateName = stateName - this.learnerDetails = learnerDetails - }.build() - - private fun createLearnerDetailsContext( - learnerId: String = TEST_LEARNER_ID, - installId: String = TEST_INSTALLATION_ID - ) = LearnerDetailsContext.newBuilder().apply { - this.learnerId = learnerId - this.installId = installId - }.build() - - private fun createTopicContext(topicId: String = TEST_TOPIC_ID) = - TopicContext.newBuilder().apply { this.topicId = topicId }.build() - - private fun createQuestionContext( - questionId: String = TEST_QUESTION_ID, - skillIds: List = listOf(TEST_SKILL_ID_1, TEST_SKILL_ID_2) - ) = QuestionContext.newBuilder().apply { - this.questionId = questionId - addAllSkillId(skillIds) - }.build() - - private fun createStoryContext( - topicId: String = TEST_TOPIC_ID, - storyId: String = TEST_STORY_ID - ) = StoryContext.newBuilder().apply { - this.topicId = topicId - this.storyId = storyId - }.build() - - private fun createConceptCardContext(skillId: String = TEST_SKILL_ID_1) = - ConceptCardContext.newBuilder().apply { this.skillId = skillId }.build() - - private fun createRevisionCardContext( - topicId: String = TEST_TOPIC_ID, - subTopicIndex: Int = TEST_SUB_TOPIC_INDEX - ) = RevisionCardContext.newBuilder().apply { - this.topicId = topicId - subTopicId = subTopicIndex - }.build() - - private fun createCardContext( - explorationDetails: ExplorationContext = createExplorationContext(), - skillId: String = TEST_SKILL_ID_1 - ) = CardContext.newBuilder().apply { - this.explorationDetails = explorationDetails - this.skillId = skillId - }.build() - - private fun createHintContext( - explorationDetails: ExplorationContext = createExplorationContext(), - hintIndex: Int = TEST_HINT_INDEX - ) = HintContext.newBuilder().apply { - this.explorationDetails = explorationDetails - this.hintIndex = hintIndex - }.build() - - private fun createSubmitAnswerContextDetails( - explorationDetails: ExplorationContext = createExplorationContext(), - isAnswerCorrect: Boolean = TEST_IS_ANSWER_CORRECT - ) = SubmitAnswerContext.newBuilder().apply { - this.explorationDetails = explorationDetails - this.isAnswerCorrect = isAnswerCorrect - }.build() - - private fun createPlayVoiceOverContextDetails( - explorationDetails: ExplorationContext = createExplorationContext(), - contentId: String = TEST_CONTENT_ID, - languageCode: String = TEST_LANGUAGE_CODE - ) = VoiceoverActionContext.newBuilder().apply { - this.explorationDetails = explorationDetails - this.contentId = contentId - this.languageCode = languageCode - }.build() - - private fun createPauseVoiceOverContextDetails( - explorationDetails: ExplorationContext = createExplorationContext(), - contentId: String = TEST_CONTENT_ID, - languageCode: String = TEST_LANGUAGE_CODE - ) = VoiceoverActionContext.newBuilder().apply { - this.explorationDetails = explorationDetails - this.contentId = contentId - this.languageCode = languageCode - }.build() - - private fun createSwitchInLessonLanguageEventContext( - explorationDetails: ExplorationContext = createExplorationContext(), - switchFromLanguage: OppiaLanguage = OppiaLanguage.ENGLISH, - switchToLanguage: OppiaLanguage = OppiaLanguage.SWAHILI - ) = SwitchInLessonLanguageEventContext.newBuilder().apply { - this.explorationDetails = explorationDetails - this.switchFromLanguage = switchFromLanguage - this.switchToLanguage = switchToLanguage - }.build() - - private fun registerTestApplication() { - val packageManager = Shadows.shadowOf(context.packageManager) - val applicationInfo = - ApplicationInfoBuilder.newBuilder() - .setPackageName(context.packageName) - .build() - val packageInfo = - PackageInfoBuilder.newBuilder() - .setPackageName(context.packageName) - .setApplicationInfo(applicationInfo) - .build() - packageInfo.versionName = TEST_APP_VERSION_NAME - packageInfo.longVersionCode = TEST_APP_VERSION_CODE - packageManager.installPackage(packageInfo) - } - - private fun setUpTestApplicationComponentWithoutLearnerAnalyticsStudy() { - TestModule.enableLoggingLearnerStudyIds = false - setUpTestApplicationComponent() - } - - private fun setUpTestApplicationComponentWithLearnerAnalyticsStudy() { - TestModule.enableLoggingLearnerStudyIds = true - setUpTestApplicationComponent() - } - - private fun setUpTestApplicationComponent() { - ApplicationProvider.getApplicationContext().inject(this) - registerTestApplication() - } - - // TODO(#89): Move this to a common test application component. - @Module - class TestModule { - internal companion object { - // This is expected to be off by default, so this helps the tests above confirm that the - // feature's default value is, indeed, off. - var enableLoggingLearnerStudyIds = LOGGING_LEARNER_STUDY_IDS_DEFAULT_VALUE - } - - @Provides - @Singleton - fun provideContext(application: Application): Context { - return application - } - - // The scoping here is to ensure changes to the module value above don't change the parameter - // within the same application instance. - @Provides - @Singleton - @EnableLoggingLearnerStudyIds - fun provideLoggingLearnerStudyIds(): PlatformParameterValue { - // Snapshot the value so that it doesn't change between injection and use. - val enableFeature = enableLoggingLearnerStudyIds - return PlatformParameterValue.createDefaultParameter( - defaultValue = enableFeature - ) - } - } - - // TODO(#89): Move this to a common test application component. - @Singleton - @Component(modules = [TestModule::class, KenyaAlphaEventLoggingConfigurationModule::class]) - interface TestApplicationComponent { - @Component.Builder - interface Builder { - @BindsInstance - fun setApplication(application: Application): Builder - - fun build(): TestApplicationComponent - } - - fun inject(test: KenyaAlphaEventBundleCreatorTest) - } - - class TestApplication : Application() { - private val component: TestApplicationComponent by lazy { - DaggerKenyaAlphaEventBundleCreatorTest_TestApplicationComponent.builder() - .setApplication(this) - .build() - } - - fun inject(test: KenyaAlphaEventBundleCreatorTest) { - component.inject(test) - } - } -} diff --git a/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventLoggingConfigurationModuleTest.kt b/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventLoggingConfigurationModuleTest.kt deleted file mode 100644 index 31d1130c3d0..00000000000 --- a/utility/src/test/java/org/oppia/android/util/logging/KenyaAlphaEventLoggingConfigurationModuleTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -package org.oppia.android.util.logging - -import android.app.Application -import android.content.Context -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.google.common.truth.Truth.assertThat -import dagger.BindsInstance -import dagger.Component -import dagger.Module -import dagger.Provides -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.annotation.Config -import org.robolectric.annotation.LooperMode -import javax.inject.Inject -import javax.inject.Singleton - -/** Tests for [KenyaAlphaEventLoggingConfigurationModule]. */ -// FunctionName: test names are conventionally named with underscores. -@Suppress("FunctionName") -@RunWith(AndroidJUnit4::class) -@LooperMode(LooperMode.Mode.PAUSED) -@Config(manifest = Config.NONE) -class KenyaAlphaEventLoggingConfigurationModuleTest { - @Inject lateinit var eventTypeToHumanReadableNameConverter: EventTypeToHumanReadableNameConverter - - @Before - fun setUp() { - setUpTestApplicationComponent() - } - - @Test - fun testModule_injectedEventTypeToHumanReadableNameConverter_isStudySpecificImplementation() { - assertThat(eventTypeToHumanReadableNameConverter) - .isInstanceOf(KenyaAlphaEventTypeToHumanReadableNameConverterImpl::class.java) - } - - private fun setUpTestApplicationComponent() { - DaggerKenyaAlphaEventLoggingConfigurationModuleTest_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(#89): Move this to a common test application component. - @Singleton - @Component(modules = [KenyaAlphaEventLoggingConfigurationModule::class]) - interface TestApplicationComponent { - @Component.Builder - interface Builder { - @BindsInstance - fun setApplication(application: Application): Builder - - fun build(): TestApplicationComponent - } - - fun inject(test: KenyaAlphaEventLoggingConfigurationModuleTest) - } -} diff --git a/version.bzl b/version.bzl index eb277cfabb8..a0316b23c90 100644 --- a/version.bzl +++ b/version.bzl @@ -12,10 +12,8 @@ the app (that are potentially not broadly released yet). MAJOR_VERSION = 0 MINOR_VERSION = 13 -# TODO(#4419): Remove the Kenya-specific alpha version code. OPPIA_DEV_VERSION_CODE = 117 OPPIA_DEV_KITKAT_VERSION_CODE = 116 -OPPIA_ALPHA_KENYA_VERSION_CODE = 115 OPPIA_ALPHA_VERSION_CODE = 114 OPPIA_ALPHA_KITKAT_VERSION_CODE = 113 OPPIA_BETA_VERSION_CODE = 112