Skip to content

Commit

Permalink
fix: code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan-arshad-dev committed Jul 8, 2024
1 parent b5d79c2 commit 548b673
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<string name="core_android_os_version" translatable="false">OS version: </string>
<string name="core_android_device_model" translatable="false">Device model: </string>
<string name="core_email_subject" translatable="false">Feedback</string>
<string name="core_error_upgrading_course_in_app" translatable="false">Error upgrading course in app</string>
<string name="core_date_format_MMM_dd_yyyy">MMM dd, yyyy</string>
<string name="core_full_date_with_time">dd MMM yyyy hh:mm aaa</string>
<string name="core_app_upgrade_title">App Update</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand All @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class SettingsFragment : Fragment() {
buildMap {
put(
IAPAnalyticsKeys.ACTION.key,
IAPAction.ACTION_CLOSE
IAPAction.ACTION_CLOSE.action
)
}.toMutableMap()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -271,21 +272,22 @@ 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())
}

fun showFeedbackScreen(context: Context, message: String) {
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())
}

Expand All @@ -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)
})
Expand Down

0 comments on commit 548b673

Please sign in to comment.