Commit 31868d75 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[EoC] Change CLOSED events to track opened.

Changes the current UI_CLOSED to UI_CLOSED_OBSOLETE, and adds
new UI_DISMISSED_WITHOUT_OPEN and UI_DISMISSED_AFTER_OPEN events
that will log to a new UMA enums for the existing hitogram.

BUG=838951

Change-Id: I90ee3c786188e65a1db5f40f04670554f93f2d3c
Reviewed-on: https://chromium-review.googlesource.com/1040682Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Commit-Queue: Donn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555980}
parent fcee59f1
......@@ -262,8 +262,11 @@ class ContextualSuggestionsMediator
mModel.setCloseButtonOnClickListener(view -> {
TrackerFactory.getTrackerForProfile(mProfile).notifyEvent(
EventConstants.CONTEXTUAL_SUGGESTIONS_DISMISSED);
reportEvent(ContextualSuggestionsEvent.UI_CLOSED);
@ContextualSuggestionsEvent
int openedEvent =
mHasSheetBeenOpened ? ContextualSuggestionsEvent.UI_DISMISSED_AFTER_OPEN
: ContextualSuggestionsEvent.UI_DISMISSED_WITHOUT_OPEN;
reportEvent(openedEvent);
clearSuggestions();
});
mModel.setMenuButtonVisibility(false);
......
......@@ -77,7 +77,8 @@ void ContextualSuggestionsMetricsReporter::RecordUmaMetrics(
return;
sheet_opened_ = true;
break;
case UI_CLOSED:
case UI_DISMISSED_WITHOUT_OPEN:
case UI_DISMISSED_AFTER_OPEN:
if (sheet_closed_)
return;
sheet_closed_ = true;
......@@ -92,9 +93,12 @@ void ContextualSuggestionsMetricsReporter::RecordUmaMetrics(
return;
any_suggestion_taken_ = true;
break;
case UI_CLOSED_OBSOLETE:
NOTREACHED() << "Obsolete event, do not use!";
return;
default:
NOTREACHED() << "Unexpected event, not correctly handled!";
break;
return;
}
UMA_HISTOGRAM_ENUMERATION("ContextualSuggestions.Events", event);
}
......
......@@ -52,15 +52,21 @@ enum ContextualSuggestionsEvent {
UI_PEEK_REVERSE_SCROLL = 8,
// The UI sheet was opened.
UI_OPENED = 9,
// The UI was closed (via the close box).
UI_CLOSED = 10,
// The UI was closed. General event for closed/dismissed, now obsolete.
UI_CLOSED_OBSOLETE = 10,
// A suggestion was downloaded.
SUGGESTION_DOWNLOADED = 11,
// A suggestion was taken, either with a click, or opened in a separate tab.
SUGGESTION_CLICKED = 12,
// The UI was dismissed without ever being opened. This means the sheet was
// closed while peeked before ever being expanded.
UI_DISMISSED_WITHOUT_OPEN = 13,
// The UI was dismissed after having been opened. This means the sheet was
// closed from any position after it was expanded at least once.
UI_DISMISSED_AFTER_OPEN = 14,
// Special name that marks the maximum value in an Enum used for UMA.
// https://cs.chromium.org/chromium/src/tools/metrics/histograms/README.md.
kMaxValue = SUGGESTION_CLICKED,
kMaxValue = UI_DISMISSED_AFTER_OPEN,
};
class ContextualSuggestionsMetricsReporter;
......
......@@ -30,9 +30,11 @@ const int kFetchEmpty = 6;
const int kFetchCompleted = 7;
const int kUiPeekReverseScroll = 8;
const int kUiOpened = 9;
const int kUiClosed = 10;
const int kUiClosedObsolete = 10;
const int kSuggestionDownloaded = 11;
const int kSuggestionClicked = 12;
const int kUiDismissedWithoutOpen = 13;
const int kUiDismissedAfterOpen = 14;
} // namespace
class ContextualSuggestionsMetricsReporterTest : public ::testing::Test {
......@@ -103,11 +105,16 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, BaseTest) {
histogram_tester.ExpectBucketCount(kEventsHistogramName, kUiPeekReverseScroll,
1);
histogram_tester.ExpectBucketCount(kEventsHistogramName, kUiOpened, 1);
histogram_tester.ExpectBucketCount(kEventsHistogramName, kUiClosed, 0);
histogram_tester.ExpectBucketCount(kEventsHistogramName, kUiClosedObsolete,
0);
histogram_tester.ExpectBucketCount(kEventsHistogramName,
kSuggestionDownloaded, 1);
histogram_tester.ExpectBucketCount(kEventsHistogramName, kSuggestionClicked,
1);
histogram_tester.ExpectBucketCount(kEventsHistogramName,
kUiDismissedWithoutOpen, 0);
histogram_tester.ExpectBucketCount(kEventsHistogramName,
kUiDismissedAfterOpen, 0);
}
void ContextualSuggestionsMetricsReporterTest::ExpectMultipleEventsCountOnce(
......@@ -138,8 +145,12 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, UiOpenedTest) {
ExpectMultipleEventsCountOnce(UI_OPENED);
}
TEST_F(ContextualSuggestionsMetricsReporterTest, UiClosedTest) {
ExpectMultipleEventsCountOnce(UI_CLOSED);
TEST_F(ContextualSuggestionsMetricsReporterTest, UiDismissedWithoutOpenTest) {
ExpectMultipleEventsCountOnce(UI_DISMISSED_WITHOUT_OPEN);
}
TEST_F(ContextualSuggestionsMetricsReporterTest, UiDismissedAfterOpenTest) {
ExpectMultipleEventsCountOnce(UI_DISMISSED_AFTER_OPEN);
}
TEST_F(ContextualSuggestionsMetricsReporterTest, SuggestionDownloadedTest) {
......
......@@ -70,10 +70,8 @@ void ContextualSuggestionsUkmEntry::RecordEventMetrics(
was_sheet_opened_ = true;
StartTimerIfNeeded();
break;
case UI_CLOSED:
if (!was_sheet_opened_)
closed_from_peek_ = true;
StopTimerIfNeeded();
case UI_CLOSED_OBSOLETE:
NOTREACHED();
break;
case SUGGESTION_DOWNLOADED:
any_suggestion_downloaded_ = true;
......@@ -83,6 +81,13 @@ void ContextualSuggestionsUkmEntry::RecordEventMetrics(
any_suggestion_taken_ = true;
StopTimerIfNeeded();
break;
case UI_DISMISSED_WITHOUT_OPEN:
closed_from_peek_ = true;
StopTimerIfNeeded();
break;
case UI_DISMISSED_AFTER_OPEN:
StopTimerIfNeeded();
break;
}
}
......
......@@ -7386,9 +7386,11 @@ Called by update_net_error_codes.py.-->
<int value="7" label="Fetch completed"/>
<int value="8" label="UI peek from reverse-scroll"/>
<int value="9" label="UI opened"/>
<int value="10" label="UI closed"/>
<int value="10" label="UI closed (generic, obsolete)"/>
<int value="11" label="Suggestion downloaded"/>
<int value="12" label="Suggestion clicked"/>
<int value="13" label="UI dismissed without open"/>
<int value="14" label="UI dismissed after open"/>
</enum>
<enum name="CookieCommitProblem">
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