Skip to content

Add survey sampling to throttle DefaultBrowserChangedSurveyEvaluator#8511

Open
catalinradoiu wants to merge 1 commit into
fix/cradoiu/fix-prompts-overlaping-when-opening-notificationfrom
feature/cradoiu/sample-default-browser-survey
Open

Add survey sampling to throttle DefaultBrowserChangedSurveyEvaluator#8511
catalinradoiu wants to merge 1 commit into
fix/cradoiu/fix-prompts-overlaping-when-opening-notificationfrom
feature/cradoiu/sample-default-browser-survey

Conversation

@catalinradoiu
Copy link
Copy Markdown
Contributor

@catalinradoiu catalinradoiu commented May 11, 2026

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

Description

Introduces per-evaluation sampling for the default-browser-changed survey. A new DefaultBrowserChangedSurveySampler reads a samplingRate (0–100) from the survey toggle's remote settings payload and uses it to probabilistically decide whether the survey should be shown on any given evaluation. If the samplingRate key is absent or the settings are malformed, the sampler defaults to 100% (always in sample). The sampler is only consulted after shouldTriggerSurvey() returns true, so it does not interfere with the existing eligibility checks.

Steps to test this PR

Sampling behaviour

Enable these feature flags by default: reactivateUsers, defaultBrowserWinBackPrompt and defaultBrowserChangedSurvey

  • Override const val PRIVACY_REMOTE_CONFIG_UR with "https://gist.githubusercontent.com/catalinradoiu/69a9e72f87a6524ba8ec5c8d7370066c/raw/7bee4df0ed05b24f93cac3d422d6662cc6fe57ba/scratch_5.json"
  • Launch the app
  • Set the app as default browser, resume the app and then set another app as default browser and resume again
  • Either the default browser survey or win-back prompt should be shown
  • Advance the device time by 1 day, resume the app and the other prompt should be shown (if the suvery was shown first then this time we show the win-back prompt; if the win-back prompt was shown the first time we are now showing the survey, unless the app was set again as default)
  • Repeat the test and until you see the order is different (we need to make sure that the sampling works)

UI changes

No UI changes


Note

Medium Risk
Changes the conditions under which the default-browser-changed survey is shown by adding probabilistic sampling driven by remote toggle settings, which could alter prompt frequency and ordering. Risk is limited to survey/prompt behavior but includes new settings parsing and randomness.

Overview
Adds per-evaluation sampling to throttle the default-browser-changed in-app survey: DefaultBrowserChangedSurveyEvaluatorImpl now consults a new DefaultBrowserChangedSurveySampler after shouldTriggerSurvey() and skips showing the survey when not in sample.

Introduces RealDefaultBrowserChangedSurveySampler, which reads a samplingRate (0–100) from the feature toggle settings JSON (defaulting to 100% on missing/malformed data) and uses randomness to decide inclusion, along with updated/new unit tests covering the new skip paths and sampling behavior.

Reviewed by Cursor Bugbot for commit 2c21db7. Bugbot is set up for automated code reviews on this repo. Configure here.

The evaluator now consults DefaultBrowserChangedSurveySampler after eligibility; the sampler reads samplingRate (0-100) from the defaultBrowserChangedSurvey toggle's remote settings and defaults to 100. Non-sampled evaluations return Skipped so the coordinator can fall through to the next modal evaluator
Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

Copy link
Copy Markdown
Contributor

@anikiki anikiki left a comment

Choose a reason for hiding this comment

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

Looks good and works as expected! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants