Bug 1966727 - Record BTP Nimbus exposure in MODE_ENABLED_DRY_RUN too. r=anti-tracking-reviewers,timhuang

Differential Revision: https://phabricator.services.mozilla.com/D249636
This commit is contained in:
Emma Zuehlcke
2025-05-20 12:29:33 +00:00
committed by ezuehlcke@mozilla.com
parent 801a301e56
commit 3f2694f51e
2 changed files with 23 additions and 13 deletions

View File

@@ -1002,6 +1002,20 @@ BounceTrackingProtection::PurgeBounceTrackers() {
}
}
// Record exposure of the feature for Nimbus
// experimentation.
// The error result returned by this method isn't very
// useful, so we ignore it. Thee method will also return
// errors if the client is not enrolled in an experiment
// involving BTP which we don't consider a failure state.
//
// We record exposure for MODE_ENABLED_DRY_RUN in addition to
// MODE_ENABLED so we know in Nimbus when a client would have
// been exposed to BTP had it been enabled. This enables us to
// compare the control and treatment branches with exposure.
Unused << NimbusFeatures::RecordExposureEvent(
"bounceTrackingProtection"_ns, false);
if (StaticPrefs::privacy_bounceTrackingProtection_mode() ==
nsIBounceTrackingProtection::MODE_ENABLED) {
// Log successful purges.
@@ -1021,15 +1035,6 @@ BounceTrackingProtection::PurgeBounceTrackers() {
// Record successful purges via nsITrackingDBService for
// tracker stats.
ReportPurgedTrackersToAntiTrackingDB(purgedSites);
// Record exposure of the feature for Nimbus
// experimentation.
// The error result returned by this method isn't very
// useful, so we ignore it. Thee method will also return
// errors if the client is not enrolled in an experiment
// involving BTP which we don't consider a failure state.
Unused << NimbusFeatures::RecordExposureEvent(
"bounceTrackingProtection"_ns, false);
}
}

View File

@@ -96,7 +96,7 @@ add_task(async function test_nimbus_exposure() {
Services.fog.testResetFOG();
});
add_task(async function test_nimbus_no_exposure_dry_run() {
add_task(async function test_nimbus_exposure_dry_run() {
Services.fog.testResetFOG();
Assert.equal(
@@ -134,9 +134,14 @@ add_task(async function test_nimbus_no_exposure_dry_run() {
exposureEvents = Glean.normandy.exposeNimbusExperiment.testGetValue();
Assert.equal(
undefined,
exposureEvents,
"No Glean exposure events after BTP dry-run purge."
1,
exposureEvents?.length,
"There should be one exposure event after BTP purged."
);
Assert.equal(
"bounceTrackingProtection",
exposureEvents[0].extra.featureId,
"Feature ID matches BTP."
);
await doExperimentCleanup();