Commit d218dc52 authored by Hui Yingst's avatar Hui Yingst Committed by Commit Bot

Record metrics for toggling two-up view mode in the PDF viewer.

Bug: 51472
Change-Id: I381c851fb51e6948976951cbb2f3445f5e0de35a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092119Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748972}
parent 9d83ac16
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {FittingType} from './constants.js';
import {FittingType, TwoUpViewAction} from './constants.js';
/**
* Handles events specific to the PDF viewer and logs the corresponding metrics.
......@@ -23,6 +23,18 @@ export class PDFMetrics {
// the open param "view=FitV".
}
/**
* Records when the two up view mode is enabled or disabled.
*
* @param {TwoUpViewAction} twoUpViewAction the new TwoUpViewAction.
*/
static recordTwoUpView(twoUpViewAction) {
PDFMetrics.record(
twoUpViewAction === TwoUpViewAction.TWO_UP_VIEW_ENABLE ?
PDFMetrics.UserAction.TWO_UP_VIEW_ENABLE :
PDFMetrics.UserAction.TWO_UP_VIEW_DISABLE);
}
/**
* Records the given action to chrome.metricsPrivate.
*
......@@ -149,7 +161,15 @@ PDFMetrics.UserAction = {
ANNOTATE_STROKE_DEVICE_PEN_FIRST: 33,
ANNOTATE_STROKE_DEVICE_PEN: 34,
NUMBER_OF_ACTIONS: 35,
/** Recorded when two-up view mode is enabled. */
TWO_UP_VIEW_ENABLE_FIRST: 35,
TWO_UP_VIEW_ENABLE: 36,
/** Recorded when two-up view mode is disabled. */
TWO_UP_VIEW_DISABLE_FIRST: 37,
TWO_UP_VIEW_DISABLE: 38,
NUMBER_OF_ACTIONS: 39,
};
// Map from UserAction to the 'FIRST' action. These metrics are recorded
......@@ -224,4 +244,12 @@ PDFMetrics.firstMap_ = new Map([
PDFMetrics.UserAction.ANNOTATE_STROKE_DEVICE_PEN,
PDFMetrics.UserAction.ANNOTATE_STROKE_DEVICE_PEN_FIRST,
],
[
PDFMetrics.UserAction.TWO_UP_VIEW_ENABLE,
PDFMetrics.UserAction.TWO_UP_VIEW_ENABLE_FIRST,
],
[
PDFMetrics.UserAction.TWO_UP_VIEW_DISABLE,
PDFMetrics.UserAction.TWO_UP_VIEW_DISABLE_FIRST,
],
]);
......@@ -746,7 +746,7 @@ export class PDFViewer {
this.toolbar_.annotationAvailable =
(e.detail !== TwoUpViewAction.TWO_UP_VIEW_ENABLE);
// TODO(crbug.com/51472): Record to metrics.
PDFMetrics.recordTwoUpView(e.detail);
}
/**
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {FittingType} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/constants.js';
import {FittingType, TwoUpViewAction} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/constants.js';
import {PDFMetrics} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/metrics.js';
chrome.test.runTests(function() {
......@@ -82,6 +82,29 @@ chrome.test.runTests(function() {
chrome.test.succeed();
},
function testMetricsTwoUpView() {
PDFMetrics.resetForTesting();
chrome.metricsPrivate = new MockMetricsPrivate();
PDFMetrics.record(PDFMetrics.UserAction.DOCUMENT_OPENED);
PDFMetrics.recordTwoUpView(TwoUpViewAction.TWO_UP_VIEW_ENABLE);
PDFMetrics.recordTwoUpView(TwoUpViewAction.TWO_UP_VIEW_DISABLE);
PDFMetrics.recordTwoUpView(TwoUpViewAction.TWO_UP_VIEW_ENABLE);
PDFMetrics.recordTwoUpView(TwoUpViewAction.TWO_UP_VIEW_DISABLE);
PDFMetrics.recordTwoUpView(TwoUpViewAction.TWO_UP_VIEW_ENABLE);
chrome.test.assertEq(
{
[PDFMetrics.UserAction.DOCUMENT_OPENED]: 1,
[PDFMetrics.UserAction.TWO_UP_VIEW_ENABLE_FIRST]: 1,
[PDFMetrics.UserAction.TWO_UP_VIEW_ENABLE]: 3,
[PDFMetrics.UserAction.TWO_UP_VIEW_DISABLE_FIRST]: 1,
[PDFMetrics.UserAction.TWO_UP_VIEW_DISABLE]: 2
},
chrome.metricsPrivate.actionCounter);
chrome.test.succeed();
},
function testMetricsBookmarks() {
PDFMetrics.resetForTesting();
......
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