Skip to content

Commit

Permalink
refactor: Optimize code
Browse files Browse the repository at this point in the history
Fixes: LEARNER-10041
  • Loading branch information
HamzaIsrar12 committed Jul 3, 2024
1 parent 7be7bc9 commit 9a835fe
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
5 changes: 3 additions & 2 deletions app/src/main/java/org/openedx/app/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ class MainViewModel(
}

private fun logScreenEvent(event: AppAnalyticsEvent) {
analytics.logScreenEvent(event.eventName,
buildMap {
analytics.logScreenEvent(
screenName = event.eventName,
params = buildMap {
put(AppAnalyticsKey.NAME.key, event.biValue)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LogistrationViewModel(
private val discoveryTypeWebView get() = config.getDiscoveryConfig().isViewTypeWebView()

init {
logScreenEvent(AuthAnalyticsEvent.Logistration)
logLogistrationScreenEvent()
}

fun navigateToSignIn(parentFragmentManager: FragmentManager) {
Expand Down Expand Up @@ -67,15 +67,12 @@ class LogistrationViewModel(
)
}

private fun logScreenEvent(
event: AuthAnalyticsEvent,
params: Map<String, Any?> = emptyMap(),
) {
private fun logLogistrationScreenEvent() {
val event = AuthAnalyticsEvent.Logistration
analytics.logScreenEvent(
screenName = event.eventName,
params = buildMap {
put(AuthAnalyticsKey.NAME.key, event.biValue)
putAll(params)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class SignInViewModel(

init {
collectAppUpgradeEvent()
logScreenEvent(AuthAnalyticsEvent.SIGN_IN)
logSignInScreenEvent()
}

fun login(username: String, password: String) {
Expand Down Expand Up @@ -247,15 +247,12 @@ class SignInViewModel(
)
}

private fun logScreenEvent(
event: AuthAnalyticsEvent,
params: Map<String, Any?> = emptyMap(),
) {
private fun logSignInScreenEvent() {
val event = AuthAnalyticsEvent.SIGN_IN
analytics.logScreenEvent(
screenName = event.eventName,
params = buildMap {
put(AuthAnalyticsKey.NAME.key, event.biValue)
putAll(params)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SignUpViewModel(

init {
collectAppUpgradeEvent()
logScreenEvent(AuthAnalyticsEvent.REGISTER)
logRegisterScreenEvent()
}

fun getRegistrationFields() {
Expand Down Expand Up @@ -326,15 +326,12 @@ class SignUpViewModel(
)
}

private fun logScreenEvent(
event: AuthAnalyticsEvent,
params: Map<String, Any?> = emptyMap(),
) {
private fun logRegisterScreenEvent() {
val event = AuthAnalyticsEvent.REGISTER
analytics.logScreenEvent(
screenName = event.eventName,
params = buildMap {
put(AuthAnalyticsKey.NAME.key, event.biValue)
putAll(params)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class LearnViewModel(
}

private fun logScreenEvent(event: DashboardAnalyticsEvent) {
analytics.logScreenEvent(event.eventName,
buildMap {
analytics.logScreenEvent(
screenName = event.eventName,
params = buildMap {
put(DashboardAnalyticsKey.NAME.key, event.biValue)
}
)
Expand Down

0 comments on commit 9a835fe

Please sign in to comment.