Skip to content

Commit

Permalink
Log analytic event on click open full screen code editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Sep 27, 2023
1 parent 6798b7e commit 1f899c7
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ class StepQuizCodeViewModel: ObservableObject {
provideModuleInputCallback(self)
}

func logClickedCodeDetailsEvent() {
moduleOutput?.handleChildQuizAnalyticEventMessage(StepQuizFeatureMessageClickedCodeDetailsEventMessage())
func doFullScreenCodeEditorPresentation() {
navigationState.presentingFullScreen = true

moduleOutput?.handleChildQuizAnalyticEventMessage(
StepQuizFeatureMessageClickedOpenFullScreenCodeEditorEventMessage()
)
}

func handleCodeDidChange(_ newCode: String?) {
Expand All @@ -55,6 +59,10 @@ class StepQuizCodeViewModel: ObservableObject {
self.syncReply(code: newCode)
}
}

func logClickedCodeDetailsEvent() {
moduleOutput?.handleChildQuizAnalyticEventMessage(StepQuizFeatureMessageClickedCodeDetailsEventMessage())
}
}

// MARK: - StepQuizCodeViewModel: StepQuizChildQuizInputProtocol -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ struct StepQuizCodeView: View {
),
codeTemplate: viewData.codeTemplate,
language: viewData.language,
onExpandButtonTap: {
viewModel.navigationState.presentingFullScreen = true
}
onExpandButtonTap: viewModel.doFullScreenCodeEditorPresentation
)
.padding(.horizontal, -LayoutInsets.defaultInset)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ struct StepQuizPyCharmView: View {
),
codeTemplate: viewData.codeTemplate,
language: viewData.language,
onExpandButtonTap: {
viewModel.navigationState.presentingFullScreen = true
}
onExpandButtonTap: viewModel.doFullScreenCodeEditorPresentation
)
.padding(.horizontal, -LayoutInsets.defaultInset)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ struct StepQuizSQLView: View {
),
codeTemplate: viewData.codeTemplate,
language: viewData.language,
onExpandButtonTap: {
viewModel.navigationState.presentingFullScreen = true
}
onExpandButtonTap: viewModel.doFullScreenCodeEditorPresentation
)
.padding(.horizontal, -LayoutInsets.defaultInset)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ enum class HyperskillAnalyticPart(val partName: String) {
STAGE_COMPLETED_MODAL("stage_completed_modal"),
PROJECT_COMPLETED_MODAL("project_completed_modal"),
NEXT_LEARNING_ACTIVITY_WIDGET("next_learning_activity_widget"),
FULL_SCREEN_CODE_EDITOR("full_screen_code_editor")
FULL_SCREEN_CODE_EDITOR("full_screen_code_editor"),
CODE_EDITOR("code_editor")
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ enum class HyperskillAnalyticTarget(val targetName: String) {
BADGE_MODAL("badge_modal"),
EARNED_BADGE_MODAL("earned_badge_modal"),
ALLOW_NOTIFICATIONS("allow_notifications"),
REMIND_ME_LATER("remind_me_later")
REMIND_ME_LATER("remind_me_later"),
FULL_SCREEN_CODE_EDITOR("full_screen_code_editor")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.hyperskill.app.step_quiz.domain.analytic

import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticAction
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticEvent
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticPart
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticRoute
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticTarget

/**
* Represents click on the button that triggers navigation to the full screen code editor analytic event.
*
* JSON payload:
* ```
* {
* "route": "/learn/step/1",
* "action": "click",
* "part": "code_editor",
* "target": "full_screen_code_editor"
* }
* ```
* @see HyperskillAnalyticEvent
*/
class StepQuizClickedOpenFullScreenCodeEditorHyperskillAnalyticEvent(
route: HyperskillAnalyticRoute
) : HyperskillAnalyticEvent(
route,
HyperskillAnalyticAction.CLICK,
HyperskillAnalyticPart.CODE_EDITOR,
HyperskillAnalyticTarget.FULL_SCREEN_CODE_EDITOR
)
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ interface StepQuizFeature {
object ClickedStepTextDetailsEventMessage : Message
object FullScreenCodeEditorClickedStepTextDetailsEventMessage : Message

object ClickedOpenFullScreenCodeEditorEventMessage : Message

object ClickedRetryEventMessage : Message

object ProblemsLimitReachedModalShownEventMessage : Message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.hyperskill.app.step_quiz.domain.analytic.ProblemsLimitReachedModalCli
import org.hyperskill.app.step_quiz.domain.analytic.ProblemsLimitReachedModalHiddenHyperskillAnalyticEvent
import org.hyperskill.app.step_quiz.domain.analytic.ProblemsLimitReachedModalShownHyperskillAnalyticEvent
import org.hyperskill.app.step_quiz.domain.analytic.StepQuizClickedCodeDetailsHyperskillAnalyticEvent
import org.hyperskill.app.step_quiz.domain.analytic.StepQuizClickedOpenFullScreenCodeEditorHyperskillAnalyticEvent
import org.hyperskill.app.step_quiz.domain.analytic.StepQuizClickedRetryHyperskillAnalyticEvent
import org.hyperskill.app.step_quiz.domain.analytic.StepQuizClickedRunHyperskillAnalyticEvent
import org.hyperskill.app.step_quiz.domain.analytic.StepQuizClickedSendHyperskillAnalyticEvent
Expand Down Expand Up @@ -237,6 +238,14 @@ class StepQuizReducer(
null
}
}
is Message.ClickedOpenFullScreenCodeEditorEventMessage -> {
if (state.stepQuizState is StepQuizState.AttemptLoaded) {
val event = StepQuizClickedOpenFullScreenCodeEditorHyperskillAnalyticEvent(stepRoute.analyticRoute)
state to setOf(Action.LogAnalyticEvent(event))
} else {
null
}
}
is Message.TheoryToolbarItemClicked ->
handleTheoryToolbarItemClicked(state)
is Message.ClickedRetryEventMessage ->
Expand Down

0 comments on commit 1f899c7

Please sign in to comment.