Skip to content

Add the search metrics for the quick setup onboarding experiment according to the experiment design#8658

Merged
catalinradoiu merged 3 commits into
developfrom
feature/cradoiu/add-quick-setup-search-metrics
May 28, 2026
Merged

Add the search metrics for the quick setup onboarding experiment according to the experiment design#8658
catalinradoiu merged 3 commits into
developfrom
feature/cradoiu/add-quick-setup-search-metrics

Conversation

@catalinradoiu

@catalinradoiu catalinradoiu commented May 21, 2026

Copy link
Copy Markdown
Contributor

Task/Issue URL: https://app.asana.com/1/137249556945/project/1211724162604201/task/1214753739886022

Description

Adds the search-count metrics for the quick-setup onboarding experiment (onboardingQuickSetupExperimentMay26).

The plugin lives alongside the experiment's feature flag in com.duckduckgo.app.onboardingquicksetup and is wired as an AtbLifecyclePlugin that fires on onSearchRetentionAtbRefreshed. It injects OnboardingQuickSetupToggles directly (not via inventory-by-name) so removing the flag at experiment end will surface this code as a compile-time usage to clean up.

Metrics emitted per search-refresh ATB:

  • search value 1 on a single D1..D3 conversion window (mirrors the experiment's "first search" milestone).
  • search values 2..10 on daily D0..D7 conversion windows.

Both gates are required: the experiment toggle must be isEnabled() and isEnrolled() — otherwise no metrics are emitted.

Steps to test this PR

Quick-setup search metrics

  • On a build where the onboardingQuickSetupExperimentMay26 toggle is disabled or the user is not enrolled, refresh the search retention ATB and confirm no search_* experiment pixels are sent for this toggle.
  • Enroll a user into the experiment (either cohort) and enable the toggle remotely, then trigger search retention ATB refreshes and confirm search pixels are emitted with values 1..10 and the documented conversion windows.
  • Verify the unit tests in OnboardingQuickSetupSearchMetricsAtbLifecyclePluginTest pass (./gradlew :app:testPlayDebugUnitTest --tests "com.duckduckgo.app.onboardingquicksetup.OnboardingQuickSetupSearchMetricsAtbLifecyclePluginTest").

UI changes

Before After
No UI changes No UI changes

Note

Low Risk
Analytics-only plugin with strict toggle enrollment gates; no user-facing or security-sensitive behavior.

Overview
Adds an AtbLifecyclePlugin that emits experiment search metrics when the search retention ATB refreshes, gated on onboardingQuickSetupExperimentMay26 being both enabled and enrolled.

On each refresh it sends COUNT_WHEN_IN_WINDOW pixels for search counts 1 (single D1–D3 window) and 2, 3, 4, 5, 7, 8, 9, 10 (each with daily D0–D7 windows). onAppRetentionAtbRefreshed is left as a no-op. Unit tests cover toggle gating, window shapes, and metric binding to the experiment toggle.

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

Copy link
Copy Markdown
Contributor Author

Move the search-count pixels for the quick-setup onboarding experiment
out of feature-toggles-impl into the app module, alongside the
OnboardingQuickSetupToggles feature flag. The plugin now injects the
toggle directly instead of looking it up by name in the inventory, so
removing the flag at experiment end will surface this code as a
compile-time usage to clean up.

The metrics are now only emitted when the experiment toggle is enabled
and the user is enrolled. Adds value=6 to the daily-windowed counts
(was missing from the 2..10 sequence).

Task/Issue URL: https://app.asana.com/1/137249556945/project/1211724162604201/task/1214753739886022

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@catalinradoiu catalinradoiu marked this pull request as ready for review May 22, 2026 05:29

@lmac012 lmac012 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should consider moving search metrics to SearchMetricPixelsPlugin. Yes that would mean we would log them for all experiments, but that won't cause any harm. Otherwise, if we just deduplicate them now across 2 plugins, someone else can add more metrics / conversion windows to SearchMetricPixelsPlugin at any time, and not realize they are creating duplicates until the experiment is shipped and the data is looks off.

Comment on lines +87 to +93
MetricsPixel(
metric = "search",
type = MetricType.COUNT_WHEN_IN_WINDOW,
value = "6",
toggle = toggle,
conversionWindow = d0toD7Daily,
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is duplicating metrics already defined in SearchMetricPixelsPlugin. If I understand correctly, both metrics will share the underlying storage for the counter, so we are going to increment the counter 2x for each search event and fire the pixel after just 3 searches instead of 6. cc @marcosholgado

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed the duplicate and left only the ones that are not already in SearchMetricPixelsPlugin

SearchMetricPixelsPlugin already emits value=6 with daily 0-14 windows
for every active experiment toggle, which overlaps with the quick-setup
plugin's value=6 daily 0-7. Both share the same storage key, so the
counter incremented twice per ATB refresh and would have fired at 3
searches instead of 6.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@catalinradoiu

Copy link
Copy Markdown
Contributor Author

@lmac012 the reason why I created a different plugin for these metrics was because I didn’t want to send the metrics for all of the experiments as they are not needed. This PR adds a lot of metrics (we are measuring the search count for d0, d1,…d7, and we check if there is 1,2…10 searches for each of these windows. That would mean a lot of metrics being sent when they are not needed.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b5e755a. Configure here.

value = "7",
toggle = toggle,
conversionWindow = d0toD7Daily,
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Value "6" missing from sequential search metric range

High Severity

The metrics list emits values "1", "2", "3", "4", "5", "7", "8", "9", "10" — jumping from "5" directly to "7" and omitting "6". This leaves a gap in the intended sequential 1–10 range, meaning the 6th-search milestone will never be recorded for this experiment. The test assertion on the expected set mirrors the same omission, so it passes despite the bug.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b5e755a. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is already covered by SearchMetricPixelsPlugin

@catalinradoiu catalinradoiu merged commit 844b82f into develop May 28, 2026
21 checks passed
@catalinradoiu catalinradoiu deleted the feature/cradoiu/add-quick-setup-search-metrics branch May 28, 2026 13:01
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