Add DWA metric for IsPrivateAggregationAllowed status
Adds a new DWA metric paralleling the existing PrivacySandbox.IsPrivateAggregationAllowed UMA metric. Bug: 403319682 Change-Id: I0bda67fbcedf755aa798e482adca609a1fb3612c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6355069 Commit-Queue: Alex Turner <alexmt@chromium.org> Reviewed-by: Nan Lin <linnan@chromium.org> Reviewed-by: Robert Kaplow <rkaplow@chromium.org> Reviewed-by: Fiona Macintosh <fmacintosh@google.com> Cr-Commit-Position: refs/heads/main@{#1437134}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d8532b0b82
commit
b8f8be4ea0
components/privacy_sandbox
tools/metrics/dwa
@ -197,6 +197,8 @@ if (use_blink) {
|
||||
"//components/content_settings/core/browser:cookie_settings",
|
||||
"//components/content_settings/core/common",
|
||||
"//components/keyed_service/core:core",
|
||||
"//components/metrics/dwa:dwa",
|
||||
"//components/metrics/dwa:dwa_builders",
|
||||
"//components/pref_registry:pref_registry",
|
||||
"//components/prefs",
|
||||
"//components/privacy_sandbox/privacy_sandbox_attestations",
|
||||
@ -230,11 +232,14 @@ if (use_blink) {
|
||||
"//components/content_settings/core/browser:browser",
|
||||
"//components/content_settings/core/common:common",
|
||||
"//components/content_settings/core/test:test_support",
|
||||
"//components/metrics/dwa:dwa",
|
||||
"//components/metrics/dwa:dwa_builders",
|
||||
"//components/prefs:test_support",
|
||||
"//components/privacy_sandbox/privacy_sandbox_attestations",
|
||||
"//components/privacy_sandbox/privacy_sandbox_attestations:test_support",
|
||||
"//components/sync_preferences:test_support",
|
||||
"//content/test:test_support",
|
||||
"//net",
|
||||
"//testing/gmock",
|
||||
"//testing/gtest:gtest",
|
||||
"//ui/base:base",
|
||||
|
@ -5,6 +5,7 @@ include_rules = [
|
||||
"+components/content_settings/core",
|
||||
"+components/embedder_support/android",
|
||||
"+components/keyed_service/core",
|
||||
"+components/metrics/dwa",
|
||||
"+components/pref_registry",
|
||||
"+components/prefs",
|
||||
"+components/signin/public/identity_manager",
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
@ -25,6 +26,8 @@
|
||||
#include "components/content_settings/core/browser/cookie_settings.h"
|
||||
#include "components/content_settings/core/browser/host_content_settings_map.h"
|
||||
#include "components/content_settings/core/common/pref_names.h"
|
||||
#include "components/metrics/dwa/dwa_builders.h"
|
||||
#include "components/metrics/dwa/dwa_recorder.h"
|
||||
#include "components/prefs/pref_change_registrar.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/prefs/scoped_user_pref_update.h"
|
||||
@ -789,6 +792,10 @@ bool PrivacySandboxSettingsImpl::IsPrivateAggregationAllowed(
|
||||
attestation_status, out_block_is_site_setting_specific);
|
||||
if (!IsAllowed(attestation_status)) {
|
||||
JoinHistogram(kIsPrivateAggregationAllowedHistogram, attestation_status);
|
||||
dwa::builders::PrivacySandbox_IsPrivateAggregationAllowed()
|
||||
.SetContent(reporting_origin.Serialize())
|
||||
.SetStatus(static_cast<int64_t>(attestation_status))
|
||||
.Record(metrics::dwa::DwaRecorder::Get());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -797,6 +804,10 @@ bool PrivacySandboxSettingsImpl::IsPrivateAggregationAllowed(
|
||||
SetOutBlockIsSiteSettingSpecificFromStatus(
|
||||
status, out_block_is_site_setting_specific);
|
||||
JoinHistogram(kIsPrivateAggregationAllowedHistogram, status);
|
||||
dwa::builders::PrivacySandbox_IsPrivateAggregationAllowed()
|
||||
.SetContent(reporting_origin.Serialize())
|
||||
.SetStatus(static_cast<int64_t>(status))
|
||||
.Record(metrics::dwa::DwaRecorder::Get());
|
||||
return IsAllowed(status);
|
||||
}
|
||||
|
||||
|
@ -8,17 +8,21 @@
|
||||
#include <variant>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/metrics/metrics_hashes.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "components/content_settings/core/browser/cookie_settings.h"
|
||||
#include "components/content_settings/core/browser/host_content_settings_map.h"
|
||||
#include "components/content_settings/core/common/pref_names.h"
|
||||
#include "components/content_settings/core/test/content_settings_mock_provider.h"
|
||||
#include "components/content_settings/core/test/content_settings_test_utils.h"
|
||||
#include "components/metrics/dwa/dwa_recorder.h"
|
||||
#include "components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations.h"
|
||||
#include "components/privacy_sandbox/privacy_sandbox_features.h"
|
||||
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
|
||||
#include "components/sync_preferences/testing_pref_service_syncable.h"
|
||||
#include "content/public/test/browser_task_environment.h"
|
||||
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "url/origin.h"
|
||||
@ -738,12 +742,47 @@ void CheckOutput(
|
||||
GetItemValueForKey<url::Origin>(InputKey::kTopFrameOrigin, input);
|
||||
auto reporting_origin = GetItemValueForKey<url::Origin>(
|
||||
InputKey::kAdMeasurementReportingOrigin, input);
|
||||
|
||||
base::test::ScopedFeatureList scoped_feature_list_{
|
||||
metrics::dwa::kDwaFeature};
|
||||
|
||||
// Ensures that metrics are only counted for this call.
|
||||
// TODO(crbug.com/403946431): Consider implementing a scoped object to
|
||||
// improve ergonomics.
|
||||
metrics::dwa::DwaRecorder::Get()->EnableRecording();
|
||||
metrics::dwa::DwaRecorder::Get()->Purge();
|
||||
ASSERT_THAT(metrics::dwa::DwaRecorder::Get()->GetEntriesForTesting(),
|
||||
testing::IsEmpty());
|
||||
|
||||
std::ignore = privacy_sandbox_settings->IsPrivateAggregationAllowed(
|
||||
top_frame_origin, reporting_origin,
|
||||
/*out_block_is_site_setting_specific=*/nullptr);
|
||||
auto histogram_value = GetItemValue<int>(output_value);
|
||||
histogram_tester.ExpectUniqueSample(
|
||||
"PrivacySandbox.IsPrivateAggregationAllowed", histogram_value, 1);
|
||||
|
||||
ASSERT_THAT(metrics::dwa::DwaRecorder::Get()->GetEntriesForTesting(),
|
||||
testing::SizeIs(1));
|
||||
EXPECT_THAT(
|
||||
metrics::dwa::DwaRecorder::Get()
|
||||
->GetEntriesForTesting()[0]
|
||||
->event_hash,
|
||||
base::HashMetricName("PrivacySandbox.IsPrivateAggregationAllowed"));
|
||||
|
||||
// DWA content sanitization extracts the eTLD+1 from the provided
|
||||
// reporting origin.
|
||||
EXPECT_THAT(
|
||||
metrics::dwa::DwaRecorder::Get()
|
||||
->GetEntriesForTesting()[0]
|
||||
->content_hash,
|
||||
base::HashMetricName(
|
||||
net::registry_controlled_domains::GetDomainAndRegistry(
|
||||
reporting_origin.GetURL(), net::registry_controlled_domains::
|
||||
INCLUDE_PRIVATE_REGISTRIES)));
|
||||
EXPECT_THAT(
|
||||
metrics::dwa::DwaRecorder::Get()->GetEntriesForTesting()[0]->metrics,
|
||||
testing::UnorderedElementsAre(
|
||||
testing::Pair(base::HashMetricName("Status"), histogram_value)));
|
||||
return;
|
||||
}
|
||||
case (OutputKey::kTopicsConsentGiven): {
|
||||
|
@ -149,4 +149,17 @@ be describing additional metrics about the same event.
|
||||
</metric>
|
||||
</event>
|
||||
|
||||
<event name="PrivacySandbox.IsPrivateAggregationAllowed">
|
||||
<owner>alexmt@chromium.org</owner>
|
||||
<owner>linnan@chromium.org</owner>
|
||||
<owner>measurement-api-dev+metrics@google.com</owner>
|
||||
<metric name="Status" enum="PrivacySandboxApiAllowed">
|
||||
<summary>
|
||||
Whether or not the IsPrivateAggregationAllowed operation was allowed by
|
||||
Privacy Sandbox settings and why. Recorded at the time settings are
|
||||
checked when performing the operation.
|
||||
</summary>
|
||||
</metric>
|
||||
</event>
|
||||
|
||||
</dwa-configuration>
|
||||
|
Reference in New Issue
Block a user