Skip to content

Commit

Permalink
fix: address PR comments by Hamza-1
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan-arshad-dev committed Jul 25, 2024
1 parent 5ae073e commit d61d2d1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enum class IAPAnalyticsEvent(val eventName: String, val biValue: String) {
"Payments: Restore Purchases Clicked",
"edx.bi.app.payments.restore_purchases.clicked"
),
PAYMENTS_VALUE_PROP_VIEWED(
IAP_VALUE_PROP_VIEWED(
"Payments: Value Prop Viewed",
"edx.bi.app.payments.value_prop.viewed"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class IAPDialogFragment : DialogFragment() {

val isFullScreenLoader =
(iapState as? IAPUIState.Loading)?.loaderType == IAPLoaderType.FULL_SCREEN

isCancelable = !isFullScreenLoader
Scaffold(
modifier = Modifier.fillMaxSize(),
backgroundColor = MaterialTheme.appColors.background,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ class IAPViewModel(
}.toMutableMap())
}

private fun incorporateIAPEventParams(params: MutableMap<String, Any?> = mutableMapOf()): MutableMap<String, Any?> {
return params.apply {
private fun getIAPEventParams(): MutableMap<String, Any?> {
return buildMap {
purchaseFlowData.takeIf { it.courseId.isNullOrBlank().not() }?.let {
put(IAPAnalyticsKeys.COURSE_ID.key, purchaseFlowData.courseId)
put(
Expand All @@ -360,36 +360,34 @@ class IAPViewModel(
put(IAPAnalyticsKeys.COMPONENT_ID.key, componentId)
}
put(IAPAnalyticsKeys.CATEGORY.key, IAPAnalyticsKeys.IN_APP_PURCHASES.key)
}
}.toMutableMap()
}

private fun logIAPEvent(
event: IAPAnalyticsEvent,
params: MutableMap<String, Any?> = mutableMapOf(),
) {
params.apply {
put(IAPAnalyticsKeys.NAME.key, event.biValue)
putAll(getIAPEventParams())
}
analytics.logIAPEvent(
event = event,
params = incorporateIAPEventParams(params.apply {
put(
IAPAnalyticsKeys.NAME.key,
event.biValue
)
}),
params = params,
screenName = purchaseFlowData.screenName.orEmpty()
)
}

private fun loadIAPScreenEvent() {
val event = IAPAnalyticsEvent.PAYMENTS_VALUE_PROP_VIEWED
analytics.logScreenEvent(
screenName = event.eventName,
params = incorporateIAPEventParams(buildMap {
put(IAPAnalyticsKeys.NAME.key, event.biValue)
purchaseFlowData.screenName?.takeIfNotEmpty()?.let { screenName ->
put(IAPAnalyticsKeys.SCREEN_NAME.key, screenName)
}
}.toMutableMap())
)
val event = IAPAnalyticsEvent.IAP_VALUE_PROP_VIEWED
val params = buildMap {
put(IAPAnalyticsKeys.NAME.key, event.biValue)
purchaseFlowData.screenName?.takeIfNotEmpty()?.let { screenName ->
put(IAPAnalyticsKeys.SCREEN_NAME.key, screenName)
}
putAll(getIAPEventParams())
}
analytics.logScreenEvent(screenName = event.eventName, params = params)
}

fun clearIAPFLow() {
Expand Down
11 changes: 10 additions & 1 deletion core/src/main/java/org/openedx/core/ui/IAPUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import org.openedx.core.R
import org.openedx.core.exception.iap.IAPException
import org.openedx.core.presentation.iap.IAPAction
Expand Down Expand Up @@ -183,6 +184,7 @@ fun NoSkuErrorDialog(
onClick = onConfirm
)
},
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
onDismissRequest = {}
)
}
Expand Down Expand Up @@ -252,6 +254,7 @@ fun CourseAlreadyPurchasedExecuteErrorDialog(
)
}
},
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
onDismissRequest = {}
)
}
Expand Down Expand Up @@ -302,13 +305,17 @@ fun UpgradeErrorDialog(
onClick = onDismiss
)
},
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
onDismissRequest = {}
)
}

@Composable
fun CheckingPurchasesDialog() {
Dialog(onDismissRequest = {}) {
Dialog(
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
onDismissRequest = {}
) {
Column(
Modifier
.padding(16.dp)
Expand Down Expand Up @@ -372,6 +379,7 @@ fun FakePurchasesFulfillmentCompleted(onCancel: () -> Unit, onGetHelp: () -> Uni
onClick = onGetHelp
)
},
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
onDismissRequest = {}
)
}
Expand Down Expand Up @@ -415,6 +423,7 @@ fun PurchasesFulfillmentCompletedDialog(onConfirm: () -> Unit, onDismiss: () ->
onClick = onDismiss
)
},
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
onDismissRequest = {}
)
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit d61d2d1

Please sign in to comment.