Commit 3baf2260 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Record OpenInNewTab and OpenAction from bottom sheet

A server change caused us to fail to compute the index
of the card when the action originates from the bottom sheet.
This change lets us continue to record metrics even if we
don't identify the card index, using MAX_INT as a special
value.

While this fix isn't ideal, it's better than missing out
on these metrics. We can improve this later.

Bug: 1111101
Change-Id: I063835a44ad4abb92f05e997fd27c535dc4dcb23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522574
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825987}
parent 2e1a0d6b
...@@ -710,16 +710,18 @@ void FeedStream::UnloadModel() { ...@@ -710,16 +710,18 @@ void FeedStream::UnloadModel() {
void FeedStream::ReportOpenAction(const std::string& slice_id) { void FeedStream::ReportOpenAction(const std::string& slice_id) {
int index = surface_updater_->GetSliceIndexFromSliceId(slice_id); int index = surface_updater_->GetSliceIndexFromSliceId(slice_id);
if (index >= 0) if (index < 0)
metrics_reporter_->OpenAction(index); index = MetricsReporter::kUnknownCardIndex;
metrics_reporter_->OpenAction(index);
} }
void FeedStream::ReportOpenVisitComplete(base::TimeDelta visit_time) { void FeedStream::ReportOpenVisitComplete(base::TimeDelta visit_time) {
metrics_reporter_->OpenVisitComplete(visit_time); metrics_reporter_->OpenVisitComplete(visit_time);
} }
void FeedStream::ReportOpenInNewTabAction(const std::string& slice_id) { void FeedStream::ReportOpenInNewTabAction(const std::string& slice_id) {
int index = surface_updater_->GetSliceIndexFromSliceId(slice_id); int index = surface_updater_->GetSliceIndexFromSliceId(slice_id);
if (index >= 0) if (index < 0)
metrics_reporter_->OpenInNewTabAction(index); index = MetricsReporter::kUnknownCardIndex;
metrics_reporter_->OpenInNewTabAction(index);
} }
void FeedStream::ReportOpenInNewIncognitoTabAction() { void FeedStream::ReportOpenInNewIncognitoTabAction() {
metrics_reporter_->OpenInNewIncognitoTabAction(); metrics_reporter_->OpenInNewIncognitoTabAction();
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef COMPONENTS_FEED_CORE_V2_METRICS_REPORTER_H_ #ifndef COMPONENTS_FEED_CORE_V2_METRICS_REPORTER_H_
#define COMPONENTS_FEED_CORE_V2_METRICS_REPORTER_H_ #define COMPONENTS_FEED_CORE_V2_METRICS_REPORTER_H_
#include <climits>
#include <map> #include <map>
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
...@@ -61,6 +62,11 @@ enum class FeedUserActionType { ...@@ -61,6 +62,11 @@ enum class FeedUserActionType {
// Note this is inherited only for testing. // Note this is inherited only for testing.
class MetricsReporter { class MetricsReporter {
public: public:
// For 'index_in_stream' parameters, when the card index is unknown.
// This is most likely to happen when the action originates from the bottom
// sheet.
static const int kUnknownCardIndex = INT_MAX;
explicit MetricsReporter(const base::TickClock* clock, explicit MetricsReporter(const base::TickClock* clock,
PrefService* profile_prefs); PrefService* profile_prefs);
virtual ~MetricsReporter(); virtual ~MetricsReporter();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment