Switch Plan Wide Event implementation #7176
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211542241177650?focus=true
Description
Add wide event for switch flow
Steps to test this PR
Pre steps
Test 1: Successful Upgrade (Monthly → Yearly)
validate_current_subscription.success = trueretrieve_target_plan.success = truebilling_flow_switch.success = trueconfirm_switch.success = trueui_refreshcontext.name = "subscription_settings"from_plan = "ddg.privacy.pro.monthly.renews.[us|row]"to_plan = "ddg.privacy.pro.yearly.renews.[us|row]"switch_type = "upgrade"activation_latency_ms_bucketedwith a valuefeature.status = SUCCESSTest 2: Successful Downgrade (Yearly → Monthly)
from_plan = "ddg.privacy.pro.yearly.renews.[us|row]"to_plan = "ddg.privacy.pro.monthly.renews.[us|row]"switch_type = "downgrade"feature.status = SUCCESSTest 3: User Cancels in Play Billing Flow
feature.status = CANCELLEDTest 4: Billing Flow Error
feature.status = FAILUREfeature.data.ext.errorcontains billing error detailsbilling_flow_switch.success = falseTest 5: Switch from Dev Settings (Optional)
context.name = "dev_settings"feature.status = SUCCESSTest 6: Feature Flag Disabled
sendSubscriptionSwitchWideEventTest 7: Multiple Switch Attempts
.c) is sent on every switch attempt.d) is sent at most once per dayglobal.sample_rate = 1in all eventsTest 8: Wide Event Metadata Validation
For any successful switch, verify all required fields are present:
context.name(e.g., "subscription_settings", "dev_settings")feature.name = "subscription-switch"feature.status(SUCCESS/FAILURE/CANCELLED)feature.data.ext.from_planfeature.data.ext.to_planfeature.data.ext.switch_type(upgrade/downgrade)feature.data.ext.activation_latency_ms_bucketed(when billing successful)No UI changes