Skip to content

Commit

Permalink
Record UMA for NoticeCardFulfilled
Browse files Browse the repository at this point in the history
Bug: b/162435720
Change-Id: If23e4026e65ea28c6f78c7064dc05bb6c7cfcf86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354417
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: Ian Wells <iwells@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798269}
  • Loading branch information
Dan Harrington authored and Commit Bot committed Aug 14, 2020
1 parent b179b12 commit 9e85646
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
13 changes: 13 additions & 0 deletions components/feed/core/v2/feed_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/test/bind_test_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "base/test/simple_test_clock.h"
#include "base/test/simple_test_tick_clock.h"
Expand All @@ -35,6 +36,7 @@
#include "components/feed/core/v2/feed_network.h"
#include "components/feed/core/v2/image_fetcher.h"
#include "components/feed/core/v2/metrics_reporter.h"
#include "components/feed/core/v2/prefs.h"
#include "components/feed/core/v2/protocol_translator.h"
#include "components/feed/core/v2/refresh_task_scheduler.h"
#include "components/feed/core/v2/scheduling.h"
Expand Down Expand Up @@ -1396,11 +1398,22 @@ TEST_F(FeedStreamTest, LoadMoreBeforeLoad) {
}

TEST_F(FeedStreamTest, ReadNetworkResponse) {
base::HistogramTester histograms;
network_.InjectRealResponse();
TestSurface surface(stream_.get());
WaitForIdleTaskQueue();

ASSERT_EQ("loading -> 10 slices", surface.DescribeUpdates());

// Verify we're processing some of the data on the request.

// The response has a privacy_notice_fulfilled=true.
histograms.ExpectUniqueSample("ContentSuggestions.Feed.NoticeCardFulfilled",
1, 1);

// A request schedule with two entries was in the response.
RequestSchedule schedule = prefs::GetRequestSchedule(profile_prefs_);
EXPECT_EQ(std::vector<base::TimeDelta>({}), schedule.refresh_offsets);
}

TEST_F(FeedStreamTest, ClearAllAfterLoadResultsInRefresh) {
Expand Down
5 changes: 5 additions & 0 deletions components/feed/core/v2/metrics_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ void MetricsReporter::OnUploadActions(UploadActionsStatus status) {
status);
}

void MetricsReporter::NoticeCardFulfilled(bool response_has_notice_card) {
base::UmaHistogramBoolean("ContentSuggestions.Feed.NoticeCardFulfilled",
response_has_notice_card);
}

void MetricsReporter::SurfaceReceivedContent(SurfaceId surface_id) {
ReportGetMoreIfNeeded(surface_id, true);
}
Expand Down
2 changes: 2 additions & 0 deletions components/feed/core/v2/metrics_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class MetricsReporter {
static void OnUploadActionsBatch(UploadActionsBatchStatus status);
static void OnUploadActions(UploadActionsStatus status);

static void NoticeCardFulfilled(bool response_has_notice_card);

private:
base::WeakPtr<MetricsReporter> GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
Expand Down
6 changes: 6 additions & 0 deletions components/feed/core/v2/tasks/load_stream_task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "components/feed/core/proto/v2/wire/request.pb.h"
#include "components/feed/core/v2/feed_network.h"
#include "components/feed/core/v2/feed_stream.h"
#include "components/feed/core/v2/metrics_reporter.h"
#include "components/feed/core/v2/proto_util.h"
#include "components/feed/core/v2/protocol_translator.h"
#include "components/feed/core/v2/stream_model.h"
Expand Down Expand Up @@ -152,6 +153,11 @@ void LoadStreamTask::QueryRequestComplete(
if (!response_data.model_update_request)
return Done(LoadStreamStatus::kProtoTranslationFailed);

MetricsReporter::NoticeCardFulfilled(result.response_body->feed_response()
.feed_response_metadata()
.chrome_feed_response_metadata()
.privacy_notice_fulfilled());

loaded_new_content_from_network_ = true;
stream_->GetStore()->OverwriteStream(
std::make_unique<StreamModelUpdateRequest>(
Expand Down
8 changes: 7 additions & 1 deletion components/feed/core/v2/testdata/response.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,17 @@ feed_response {
seconds: 86308
nanos: 822963644
}
refresh_time_from_response_time {
seconds: 120000
}
}
}
}
feed_response_metadata {
response_time_ms: 1587056924
#response_time_ms: 1587056924
chrome_feed_response_metadata {
privacy_notice_fulfilled: true
}
}
}

Binary file modified components/test/data/feed/response.binarypb
Binary file not shown.

0 comments on commit 9e85646

Please sign in to comment.