diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt index de477ebfdda..9f0d7923a47 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt @@ -905,6 +905,10 @@ class ExplorationProgressController @Inject constructor( val state = progress.stateDeck.getCurrentState() hintHandler.startWatchingForHintsInNewState(state) startState(logStartCard = true) + + if (!isRestart) { + explorationAnalyticsLogger.logStartExploration() + } } // Advance the stage, but do not notify observers since the current state can be reported diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLogger.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLogger.kt index d701ba9d54d..059a435ba50 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLogger.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLogger.kt @@ -239,6 +239,11 @@ class LearnerAnalyticsLogger @Inject constructor( } } + /** Logs that an exploration has been started by the learner. */ + fun logStartExploration() { + getExpectedStateLogger()?.logStartExploration() + } + /** Logs that the current exploration has been exited (i.e. not finished). */ fun logExitExploration() { getExpectedStateLogger()?.logExitExploration() @@ -325,6 +330,11 @@ class LearnerAnalyticsLogger @Inject constructor( ) { private val linkedSkillId by lazy { currentState.linkedSkillId } + /** Logs that an exploration has been started (at this state). */ + internal fun logStartExploration() { + logStateEvent(EventBuilder::setStartExplorationContext) + } + /** Logs that the current exploration has been exited (at this state). */ internal fun logExitExploration() { logStateEvent(EventBuilder::setExitExplorationContext) diff --git a/model/src/main/proto/oppia_logger.proto b/model/src/main/proto/oppia_logger.proto index 1d88d10ee72..4b0f713768e 100644 --- a/model/src/main/proto/oppia_logger.proto +++ b/model/src/main/proto/oppia_logger.proto @@ -126,6 +126,9 @@ message EventLog { // The event being logged is related to foregrounding of the application. LearnerDetailsContext app_in_foreground_context = 25; + // The event being logged is related to starting an exploration. + ExplorationContext start_exploration_context = 54; + // The event being logged is related to exiting an exploration. ExplorationContext exit_exploration_context = 26; diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index 24953f669ab..1a91e4c272e 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -53,6 +53,7 @@ import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.RESUME_L import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.SHOW_SURVEY_POPUP 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_EXPLORATION_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 @@ -712,6 +713,32 @@ class EventLogSubject private constructor( hasAppInForegroundContextThat().block() } + /** + * Verifies that the [EventLog] under test has a context corresponding to + * [START_EXPLORATION_CONTEXT] (per [EventLog.Context.getActivityContextCase]). + */ + fun hasStartExplorationContext() { + assertThat(actual.context.activityContextCase).isEqualTo(START_EXPLORATION_CONTEXT) + } + + /** + * Verifies the [EventLog]'s context per [hasStartExplorationContext] and returns an + * [ExplorationContextSubject] to test the corresponding context. + */ + fun hasStartExplorationContextThat(): ExplorationContextSubject { + hasStartExplorationContext() + return ExplorationContextSubject.assertThat(actual.context.startExplorationContext) + } + + /** + * Verifies the [EventLog]'s context and executes [block] in the same way as + * [hasOpenExplorationActivityContextThat] except for the conditions of, and subject returned by, + * [hasStartExplorationContextThat]. + */ + fun hasStartExplorationContextThat(block: ExplorationContextSubject.() -> Unit) { + hasStartExplorationContextThat().block() + } + /** * Verifies that the [EventLog] under test has a context corresponding to * [EXIT_EXPLORATION_CONTEXT] (per [EventLog.Context.getActivityContextCase]). diff --git a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt index fddf84da279..9be04ca5378 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/EventBundleCreator.kt @@ -111,6 +111,7 @@ import org.oppia.android.app.model.EventLog.CardContext as CardEventContext import org.oppia.android.app.model.EventLog.CompleteAppOnboardingContext as CompleteAppOnboardingEventContext import org.oppia.android.app.model.EventLog.ConceptCardContext as ConceptCardEventContext import org.oppia.android.app.model.EventLog.ConsoleLoggerContext as ConsoleLoggerEventContext +import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.START_EXPLORATION_CONTEXT import org.oppia.android.app.model.EventLog.ExplorationContext as ExplorationEventContext import org.oppia.android.app.model.EventLog.FeatureFlagListContext as FeatureFlagListEventContext import org.oppia.android.app.model.EventLog.HintContext as HintEventContext @@ -237,6 +238,7 @@ class EventBundleCreator @Inject constructor( PAUSE_VOICE_OVER_CONTEXT -> VoiceoverActionContext(activityName, pauseVoiceOverContext) APP_IN_BACKGROUND_CONTEXT -> LearnerDetailsContext(activityName, appInBackgroundContext) APP_IN_FOREGROUND_CONTEXT -> LearnerDetailsContext(activityName, appInForegroundContext) + START_EXPLORATION_CONTEXT -> ExplorationContext(activityName, startExplorationContext) EXIT_EXPLORATION_CONTEXT -> ExplorationContext(activityName, exitExplorationContext) FINISH_EXPLORATION_CONTEXT -> ExplorationContext(activityName, finishExplorationContext) PROGRESS_SAVING_SUCCESS_CONTEXT -> diff --git a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt index 342333d65eb..bf8f3d52f10 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/KenyaAlphaEventTypeToHumanReadableNameConverterImpl.kt @@ -36,6 +36,7 @@ class KenyaAlphaEventTypeToHumanReadableNameConverterImpl @Inject constructor() 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.START_EXPLORATION_CONTEXT -> "start_exploration_context" ActivityContextCase.EXIT_EXPLORATION_CONTEXT -> "exit_exploration_context" ActivityContextCase.FINISH_EXPLORATION_CONTEXT -> "finish_exploration_context" ActivityContextCase.PROGRESS_SAVING_SUCCESS_CONTEXT -> "progress_saving_success_context" diff --git a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt index 55097655e74..7cd8a253a6a 100644 --- a/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/logging/StandardEventTypeToHumanReadableNameConverterImpl.kt @@ -46,6 +46,7 @@ class StandardEventTypeToHumanReadableNameConverterImpl @Inject constructor() : ActivityContextCase.PAUSE_VOICE_OVER_CONTEXT -> "click_pause_voiceover_button" ActivityContextCase.APP_IN_BACKGROUND_CONTEXT -> "send_app_to_background" ActivityContextCase.APP_IN_FOREGROUND_CONTEXT -> "bring_app_to_foreground" + ActivityContextCase.START_EXPLORATION_CONTEXT -> "start_exploration_context" ActivityContextCase.EXIT_EXPLORATION_CONTEXT -> "leave_exploration" ActivityContextCase.FINISH_EXPLORATION_CONTEXT -> "complete_exploration" ActivityContextCase.PROGRESS_SAVING_SUCCESS_CONTEXT -> "progress_saving_success"