Skip to content

feat(nimbus): Advanced targeting for users who have not accepted ToU yet, have not disabled ads, and are on Mac or Win #12596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions experimenter/experimenter/targeting/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,93 @@ def __post_init__(self):
CORE_ACTIVE_USERS_TARGETING = "'{event}'|eventCountNonZero('Days', 28, 0) >= 21"
RECENTLY_LOGGED_IN_USERS_TARGETING = "'{event}'|eventCountNonZero('Weeks', 12, 0) >= 1"

# The following indicate whether the user accepted the terms of use in one of our initial phases of experimentation/rollout
ACCEPTED_TOU_IN_NIMBUS_EXPERIMENT = "'datareporting.policy.dataSubmissionPolicyAcceptedVersion'|preferenceValue == 3"
# Accepted in 100% on-train rollout in 139 release (after May 27, 6am PT timestamp)
ACCEPTED_TOU_IN_FULL_ON_TRAIN_ROLLOUT = """
(
'datareporting.policy.dataSubmissionPolicyNotifiedTime'|preferenceValue >= '1748350800000'
&&
'datareporting.policy.dataSubmissionPolicyAcceptedVersion'|preferenceValue == 2
&&
'browser.preonboarding.enrolledInOnTrainRollout'|preferenceValue
)
"""
# Accepted in earlier partial rollout indicated by presence of on-train rollout population value
ACCEPTED_TOU_IN_PARTIAL_ON_TRAIN_ROLLOUT = """
(
'browser.preonboarding.enrolledInOnTrainRollout'|preferenceValue
&&
'browser.preonboarding.onTrainRolloutPopulation'|preferenceValue
&&
'datareporting.policy.dataSubmissionPolicyAcceptedVersion'|preferenceValue == 2
)
"""
ACCEPTED_TOU_V1 = "'termsofuse.acceptedVersion'|preferenceValue == 1"
ACCEPTED_TOU = f"""
(
{ACCEPTED_TOU_IN_NIMBUS_EXPERIMENT}
||
{ACCEPTED_TOU_IN_FULL_ON_TRAIN_ROLLOUT}
||
{ACCEPTED_TOU_IN_PARTIAL_ON_TRAIN_ROLLOUT}
||
{ACCEPTED_TOU_V1}
)
"""
TOU_NOTIFICATION_BYPASS_ENABLED = """
(
'datareporting.policy.dataSubmissionPolicyBypassNotification'|preferenceValue
||
'termsOfUse.bypassNotification'|preferenceValue
)
"""

# The following indicate whether the user has changed prefs suggesting they prefer not to see ads or ad-like features
NEW_TAB_AND_HOMEPAGE_NOT_DEFAULT = """
(
(
!newtabSettings.isDefault
||
!'browser.newtabpage.enabled'|preferenceValue
)
&&
!homePageSettings.isDefault
)
"""
SPONSORED_SEARCH_SUGGESTIONS_DISABLED = "!'browser.urlbar.suggest.quicksuggest.sponsored'|preferenceValue"
TOPSITES_OR_SPONSORED_TOPSITES_DISABLED = """
(
!'browser.newtabpage.activity-stream.feeds.topsites'|preferenceValue
||
!'browser.newtabpage.activity-stream.showSponsoredTopSites'|preferenceValue
)
"""
SPONSORED_STORIES_DISABLED = """
(
!'browser.newtabpage.activity-stream.feeds.section.topstories'|preferenceValue
||
!'browser.newtabpage.activity-stream.showSponsored'|preferenceValue
)
"""
ADS_DISABLED = f"""
(
(
{NEW_TAB_AND_HOMEPAGE_NOT_DEFAULT}
&&
{SPONSORED_SEARCH_SUGGESTIONS_DISABLED}
)
||
(
{TOPSITES_OR_SPONSORED_TOPSITES_DISABLED}
&&
{SPONSORED_STORIES_DISABLED}
&&
{SEARCH_SUGGESTIONS_DISABLED}
)
)
"""
Copy link
Member

Choose a reason for hiding this comment

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

@mikeconley Do we want to also handle browser.newtabpage.enabled just to be on the safe side? It is in the codebase a fair bit: https://searchfox.org/mozilla-central/search?q=browser.newtabpage.enabled&path=&case=false&regexp=false. Of course, maybe that's all just dead code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think that's a good idea. I just tested it, and it doesn't appear that that state gets reflected in newtabSettings. :/ So we should check that pref too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something like this?

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me. r=dmose


NO_TARGETING = NimbusTargetingConfig(
name="No Targeting",
slug="no_targeting",
Expand Down Expand Up @@ -2561,6 +2648,34 @@ def __post_init__(self):
application_choice_names=(Application.DESKTOP.name,),
)

TOU_NOT_ACCEPTED_ADS_ENABLED_MAC_OR_WIN = NimbusTargetingConfig(
name="TOU not accepted yet, ads enabled, Mac or Win",
slug="tou_not_accepted_ads_enabled_mac_win",
description=(
"Users who have not accepted the terms of use yet, "
"have not disabled ads, "
"and are on Mac or Windows"
),
targeting=f"""
(
(
os.isWindows
||
os.isMac
)
&&
!{ACCEPTED_TOU}
&&
!{TOU_NOTIFICATION_BYPASS_ENABLED}
&&
!{ADS_DISABLED}
)
""",
desktop_telemetry="",
sticky_required=False,
is_first_run_required=False,
application_choice_names=(Application.DESKTOP.name,),
)

class TargetingConstants:
TARGETING_VERSION = "version|versionCompare('{version}') >= 0"
Expand Down