Skip to content

Commit

Permalink
Implement logging of start_exploration event
Browse files Browse the repository at this point in the history
  • Loading branch information
theMr17 committed Jul 3, 2024
1 parent c31c6d6 commit 71e5e6d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions model/src/main/proto/oppia_logger.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 71e5e6d

Please sign in to comment.