Skip to content

Conversation

@lmac012
Copy link
Contributor

@lmac012 lmac012 commented Dec 9, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1205648422731273/task/1212344118527513?focus=true

Description

This PR instruments restore subscription operation with a new wide event.

Steps to test this PR

Prerequisites

Successful restore using Google Play

  • Purchase a test subscription
  • Remove subscription from device
  • Go to app settings -> I have a subscription -> google play
  • Verify in logcat that wide_subscription-restore event has been sent with status=SUCCESS and restore_platform=google_play

Successful restore using email address

  • Purchase a test subscription
  • Ensure an email address is linked to the subscription
  • Remove subscription from device
  • Go to app settings -> I have a subscription -> email
  • Proceed with the restore flow until success page is shown
  • Verify in logcat that wide_subscription-restore event has been sent with status=SUCCESS and restore_platform=email_address

Unsuccessful restore using Google Play

  • Cancel any active subscription, wait for it to expire and remove from device.
  • Go to app settings -> I have a subscription -> google play
  • Verify in logcat that wide_subscription-restore event has been sent with status=FAILURE and restore_platform=google_play

Unsuccessful restore using email address

  • Go to app settings -> I have a subscription -> email
  • Close the app, kill the app process.
  • Launch the app
  • Verify in logcat that wide_subscription-restore event has been sent with status=FAILURE and restore_platform=email_address

Successful restore using Google Play when attempting to purchase new subscription

  • Purchase a test subscription
  • Remove subscription from device
  • Attempt to purchase new subscription
  • Verify in logcat that wide_subscription-restore event has been sent with status=SUCCESS and restore_platform=google_play and is_purchase_attempt=true

Unsuccessful restore using Google Play when attempting to purchase new subscription

  • Cancel any active subscription, wait for it to expire and remove from device.
  • Purchase new subscription
  • Verify in logcat that wide_subscription-restore event has been sent with status=FAILURE and restore_platform=google_play and is_purchase_attempt=true

No UI changes


Note

Instruments the subscription restore flow (Google Play/email) with a new wide event, integrates it in manager and UI, and adds tests and pixel definitions.

  • Wide Event & Pixels
    • Add PixelDefinitions/pixels/wide_subscription_restore.json5 defining subscription-restore wide pixel with restore_platform, is_purchase_attempt, restore_latency_ms_bucketed, failure reason, and email-step markers.
    • Implement SubscriptionRestoreWideEvent (SubscriptionRestoreWideEventImpl) to start/finish flows, record latency, and report success/failure.
  • Backend Integration
    • Wire SubscriptionRestoreWideEvent into RealSubscriptionsManager to track restore during purchase attempts; add helper recoverSubscriptionFromStoreOnPurchaseAttempt.
    • Improve store login failure message in recoverSubscriptionFromStore and add feature flag sendSubscriptionRestoreWideEvent() to PrivacyProFeature.
  • UI Integration
    • Update RestoreSubscriptionViewModel to emit wide events on store/email restore start and on success/failure.
  • Tests
    • Add SubscriptionRestoreWideEventTest covering flow start/success/failure, interval handling, caching, and feature toggle.
    • Update RealSubscriptionsManagerTest and RestoreSubscriptionViewModelTest to inject and verify new wide event behavior.

Written by Cursor Bugbot for commit 1cbf653. This will update automatically on new commits. Configure here.

Copy link
Contributor Author

lmac012 commented Dec 9, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

Privacy Review task: https://app.asana.com/0/69071770703008/1212352085517594

@lmac012 lmac012 requested a review from nalcalag December 9, 2025 00:41
@lmac012 lmac012 force-pushed the feature/lukasz/subscription-restore-wide-event branch from 9e8d549 to dcb39cb Compare December 9, 2025 00:49
@lmac012 lmac012 marked this pull request as ready for review December 9, 2025 00:49
private suspend fun onRestoreFlowStarted(restorePlatform: String, purchaseAttempt: Boolean) {
getCurrentWideEventId()?.let { wideEventId ->
wideEventClient.flowFinish(wideEventId = wideEventId, status = FlowStatus.Unknown)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing cachedFlowId reset after finishing previous flow

In onRestoreFlowStarted, when a previous flow exists, flowFinish is called on line 94 but cachedFlowId is not set to null afterwards. This differs from the pattern in SubscriptionPurchaseWideEventImpl.onPurchaseFlowStarted() which correctly clears the cache after finishing a previous flow. If flowStart subsequently fails (returns null on line 106), cachedFlowId will still hold the stale ID of the already-finished flow, potentially causing incorrect behavior when success/failure methods are later called.


Please tell me if this was useful or not with a 👍 or 👎.

Fix in Cursor Fix in Web

Copy link
Contributor

@nalcalag nalcalag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although when testing Unsuccessful restore using email address, the wide event status came through as UNKNOWN instead of FAILURE.

Also, I noticed in the pixel definition that there are parameters, like context, that aren’t included in the implementation yet. I assume you’re planning to add those later?

@lmac012 lmac012 force-pushed the feature/lukasz/subscription-restore-wide-event branch from dcb39cb to 1cbf653 Compare December 10, 2025 17:33
suspend fun onEmailRestoreSuccess()
suspend fun onGooglePlayRestoreSuccess()
suspend fun onGooglePlayRestoreFailure(error: String)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing email restore failure handling method

The SubscriptionRestoreWideEvent interface exposes onGooglePlayRestoreFailure(error: String) but has no corresponding onEmailRestoreFailure method. This asymmetry means email restore failures cannot be explicitly reported with a failure reason. The PR test steps expect to verify status=FAILURE for unsuccessful email restores, but the current implementation only handles this through CleanupPolicy.OnProcessStart, which uses the default FlowStatus.Unknown status instead of FlowStatus.Failure. This prevents proper instrumentation of email restore failures.


Please tell me if this was useful or not with a 👍 or 👎.

Fix in Cursor Fix in Web

@lmac012 lmac012 merged commit 8b41e5f into develop Dec 10, 2025
12 checks passed
@lmac012 lmac012 deleted the feature/lukasz/subscription-restore-wide-event branch December 10, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants