Skip to content

Commit 1897a89

Browse files
committed
Added origin to switch flow start
1 parent 8a39fc8 commit 1897a89

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/SubscriptionsManager.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,15 @@ interface SubscriptionsManager {
253253
* @param planId The new plan ID to switch to
254254
* @param offerId The offer ID for the new plan (optional)
255255
* @param replacementMode The replacement mode for the subscription switch
256+
* @param origin The entry point where the switch was initiated (e.g., "subscription_settings", "dev_settings")
256257
*
257258
*/
258259
suspend fun switchSubscriptionPlan(
259260
activity: Activity,
260261
planId: String,
261262
offerId: String? = null,
262263
replacementMode: SubscriptionReplacementMode,
264+
origin: String? = null,
263265
)
264266

265267
/**
@@ -500,6 +502,7 @@ class RealSubscriptionsManager @Inject constructor(
500502
planId: String,
501503
offerId: String?,
502504
replacementMode: SubscriptionReplacementMode,
505+
origin: String?,
503506
) = withContext(dispatcherProvider.io()) {
504507
try {
505508
if (!isSignedIn()) {
@@ -520,6 +523,7 @@ class RealSubscriptionsManager @Inject constructor(
520523
val isUpgrade = currentSubscription.productId in listOf(MONTHLY_PLAN_US, MONTHLY_PLAN_ROW)
521524
val switchType = if (isUpgrade) "upgrade" else "downgrade"
522525
subscriptionSwitchWideEvent.onSwitchFlowStarted(
526+
context = origin,
523527
fromPlan = currentSubscription.productId,
524528
toPlan = planId,
525529
switchType = switchType,

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/switch_plan/SwitchPlanBottomSheetDialog.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class SwitchPlanBottomSheetDialog @AssistedInject constructor(
228228
planId = targetPlanId,
229229
offerId = null,
230230
replacementMode = SubscriptionReplacementMode.WITHOUT_PRORATION,
231+
origin = "subscription_settings",
231232
)
232233
}
233234
} catch (e: Exception) {

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/wideevents/SubscriptionSwitchWideEvent.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import javax.inject.Inject
3333

3434
interface SubscriptionSwitchWideEvent {
3535
suspend fun onSwitchFlowStarted(
36+
context: String?,
3637
fromPlan: String,
3738
toPlan: String,
3839
switchType: String,
@@ -83,6 +84,7 @@ class SubscriptionSwitchWideEventImpl @Inject constructor(
8384
private var cachedFlowId: Long? = null
8485

8586
override suspend fun onSwitchFlowStarted(
87+
context: String?,
8688
fromPlan: String,
8789
toPlan: String,
8890
switchType: String,
@@ -100,6 +102,7 @@ class SubscriptionSwitchWideEventImpl @Inject constructor(
100102
cachedFlowId = wideEventClient
101103
.flowStart(
102104
name = SUBSCRIPTION_SWITCH_FEATURE_NAME,
105+
flowEntryPoint = context,
103106
metadata = mapOf(
104107
KEY_FROM_PLAN to fromPlan,
105108
KEY_TO_PLAN to toPlan,

subscriptions/subscriptions-internal/src/main/java/com/duckduckgo/subscriptions/internal/settings/SwitchSubscriptionView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ class SwitchSubscriptionView @JvmOverloads constructor(
299299
planId = planOption.planId,
300300
offerId = planOption.offerId,
301301
replacementMode = replacementMode,
302+
origin = "dev_settings",
302303
)
303304
} catch (e: Exception) {
304305
launch(dispatcherProvider.main()) {

0 commit comments

Comments
 (0)