From 548b673a9abf2aafc9814b9fc16796abaa4c4146 Mon Sep 17 00:00:00 2001 From: Farhan Arshad Date: Mon, 8 Jul 2024 21:08:33 +0500 Subject: [PATCH] fix: code improvements --- .../org/openedx/core/presentation/iap/IAPUIState.kt | 2 +- .../openedx/core/presentation/iap/IAPViewModel.kt | 3 ++- core/src/main/res/values/strings.xml | 1 + .../dashboard/presentation/DashboardListViewModel.kt | 11 ++++++----- .../presentation/settings/SettingsFragment.kt | 2 +- .../presentation/settings/SettingsViewModel.kt | 12 +++++++----- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt b/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt index a19b62e34..95bced19f 100644 --- a/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt +++ b/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt @@ -49,7 +49,7 @@ enum class IAPRequestType(val request: String) { CHECKOUT_CODE("checkout"), PAYMENT_SDK_CODE("payment"), EXECUTE_ORDER_CODE("execute"), - NO_SKU_CODE("no_sku"), + NO_SKU_CODE("sku"), CONSUME_CODE("consume"), UNFULFILLED_CODE("unfulfilled"), RESTORE_CODE("restore"), diff --git a/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt b/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt index dcdde987c..2946ef5df 100644 --- a/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt +++ b/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt @@ -261,6 +261,7 @@ class IAPViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), feedback = message, appVersion = appData.versionName ) @@ -340,7 +341,7 @@ class IAPViewModel( ) { analytics.logEvent(event.eventName, params.apply { put(IAPAnalyticsKeys.NAME.key, event.biValue) - purchaseFlowData.let { + purchaseFlowData.takeIf { it.courseId.isNullOrBlank().not() }?.let { put(IAPAnalyticsKeys.COURSE_ID.key, purchaseFlowData.courseId) put( IAPAnalyticsKeys.PACING.key, diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index a0cc25c6f..6360227e1 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -46,6 +46,7 @@ OS version: Device model: Feedback + Error upgrading course in app MMM dd, yyyy dd MMM yyyy hh:mm aaa App Update diff --git a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt index 82affb640..863e742b0 100644 --- a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt +++ b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt @@ -275,19 +275,20 @@ class DashboardListViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), feedback = message, appVersion = appData.versionName ) logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP.action) }.toMutableMap()) } fun logIAPCancelEvent() { logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE.action) }.toMutableMap()) } @@ -297,7 +298,7 @@ class DashboardListViewModel( ) { iapAnalytics.logEvent(event.eventName, params.apply { put(IAPAnalyticsKeys.NAME.key, event.biValue) - put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.COURSE_ENROLLMENT) + put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.COURSE_ENROLLMENT.screenName) put(IAPAnalyticsKeys.IAP_FLOW_TYPE.key, IAPFlow.SILENT.value) put(IAPAnalyticsKeys.CATEGORY.key, IAPAnalyticsKeys.IN_APP_PURCHASES.key) }) diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt index 95de33a51..7a3f3f7eb 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt @@ -136,7 +136,7 @@ class SettingsFragment : Fragment() { buildMap { put( IAPAnalyticsKeys.ACTION.key, - IAPAction.ACTION_CLOSE + IAPAction.ACTION_CLOSE.action ) }.toMutableMap() ) diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt index bdc70bd13..b4c82ae98 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt @@ -191,6 +191,7 @@ class SettingsViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), appVersion = appData.versionName ) logProfileEvent(ProfileAnalyticsEvent.CONTACT_SUPPORT_CLICKED) @@ -271,8 +272,8 @@ class SettingsViewModel( fun logIAPCancelEvent() { logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_RESTORE) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_RESTORE.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE.action) }.toMutableMap()) } @@ -280,12 +281,13 @@ class SettingsViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), feedback = message, appVersion = appData.versionName ) logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP.action) }.toMutableMap()) } @@ -295,7 +297,7 @@ class SettingsViewModel( ) { analytics.logEvent(event.eventName, params.apply { put(IAPAnalyticsKeys.NAME.key, event.biValue) - put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.PROFILE) + put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.PROFILE.screenName) put(IAPAnalyticsKeys.IAP_FLOW_TYPE.key, IAPFlow.RESTORE.value) put(IAPAnalyticsKeys.CATEGORY.key, IAPAnalyticsKeys.IN_APP_PURCHASES.key) })