Skip to content

Commit

Permalink
Feedback: Add metrics to record number of clicks on viewScreenshot
Browse files Browse the repository at this point in the history
* Emit metrics when user click button to view screenshot
* This is true-only boolean histogram, can fire 0 or more times.
* Screenshot: http://screen/8rwagSMHmqswNV3

Bug: b:185624798
Test: browser_tests --gtest_filter=OSFeedbackBrowserTest.*;
Change-Id: I3a1652ec018ee72aa1a860de65a51f9c8d006d36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3792916
Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org>
Reviewed-by: Mustafa Emre Acer <meacer@chromium.org>
Reviewed-by: Xiangdong Kong <xiangdongkong@google.com>
Commit-Queue: Longbo Wei <longbowei@google.com>
Cr-Commit-Position: refs/heads/main@{#1031643}
  • Loading branch information
Longbo Wei authored and Chromium LUCI CQ committed Aug 4, 2022
1 parent ed730e9 commit 1177df3
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ash/webui/os_feedback_ui/backend/feedback_service_provider.cc
Expand Up @@ -73,6 +73,11 @@ void FeedbackServiceProvider::RecordPostSubmitAction(
os_feedback_ui::metrics::EmitFeedbackAppPostSubmitAction(action);
}

void FeedbackServiceProvider::RecordPreSubmitAction(
os_feedback_ui::mojom::FeedbackAppPreSubmitAction action) {
os_feedback_ui::metrics::EmitFeedbackAppPreSubmitAction(action);
}

void FeedbackServiceProvider::BindInterface(
mojo::PendingReceiver<os_feedback_ui::mojom::FeedbackServiceProvider>
receiver) {
Expand Down
2 changes: 2 additions & 0 deletions ash/webui/os_feedback_ui/backend/feedback_service_provider.h
Expand Up @@ -39,6 +39,8 @@ class FeedbackServiceProvider
void OpenSystemInfoDialog() override;
void RecordPostSubmitAction(
os_feedback_ui::mojom::FeedbackAppPostSubmitAction) override;
void RecordPreSubmitAction(
os_feedback_ui::mojom::FeedbackAppPreSubmitAction) override;

void BindInterface(
mojo::PendingReceiver<os_feedback_ui::mojom::FeedbackServiceProvider>
Expand Down
5 changes: 5 additions & 0 deletions ash/webui/os_feedback_ui/backend/histogram_util.cc
Expand Up @@ -16,6 +16,11 @@ void EmitFeedbackAppPostSubmitAction(
base::UmaHistogramEnumeration(kFeedbackAppPostSubmitAction, action);
}

void EmitFeedbackAppPreSubmitAction(mojom::FeedbackAppPreSubmitAction action) {
// TODO(longbowei) Add preSubmit actions and use switch case statement.
base::UmaHistogramBoolean(kFeedbackAppViewedScreenshot, true);
}

void EmitFeedbackAppIncludedScreenshot(bool included_screenshot) {
base::UmaHistogramBoolean(kFeedbackAppIncludedScreenshot,
included_screenshot);
Expand Down
4 changes: 4 additions & 0 deletions ash/webui/os_feedback_ui/backend/histogram_util.h
Expand Up @@ -18,11 +18,15 @@ constexpr char kFeedbackAppPostSubmitAction[] =
"Feedback.ChromeOSApp.PostSubmitAction";
constexpr char kFeedbackAppIncludedScreenshot[] =
"Feedback.ChromeOSApp.IncludedScreenshot";
constexpr char kFeedbackAppViewedScreenshot[] =
"Feedback.ChromeOSApp.ViewedScreenshot";

void EmitFeedbackAppOpenDuration(const base::TimeDelta& time_elapsed);

void EmitFeedbackAppPostSubmitAction(mojom::FeedbackAppPostSubmitAction action);

void EmitFeedbackAppPreSubmitAction(mojom::FeedbackAppPreSubmitAction action);

void EmitFeedbackAppIncludedScreenshot(bool included_screenshot);

} // namespace ash::os_feedback_ui::metrics
Expand Down
16 changes: 16 additions & 0 deletions ash/webui/os_feedback_ui/mojom/os_feedback_ui.mojom
Expand Up @@ -145,6 +145,20 @@ enum FeedbackAppPostSubmitAction {
// tools/metrics/histograms/enums.xml.
};

// User actions before sending the feedback.
enum FeedbackAppPreSubmitAction {
// User clicked the help content on search page.
kViewedHelpContent,
// User viewed the screenshot on share data page.
kViewedScreenshot,
// User viewed the selected image to be attached on share data page.
kViewedImage,
// User viewed the system and app info on share data page.
kViewedSystemAndAppInfo,
// User viewed the metrics on share data page.
kViewedMetrics
};

// Provides services needed by the feedback UI to display data and send reports.
// Implemented in the browser process and called by the Feedback SWA
// (a renderer process).
Expand All @@ -168,4 +182,6 @@ interface FeedbackServiceProvider {
OpenSystemInfoDialog();
// Record the metrics of users' first action on confirmation page.
RecordPostSubmitAction(FeedbackAppPostSubmitAction action);
// Record metrics of users' action before sending the feedback.
RecordPreSubmitAction(FeedbackAppPreSubmitAction action);
};
Expand Up @@ -4,7 +4,7 @@

import {FakeMethodResolver} from 'chrome://resources/ash/common/fake_method_resolver.js';

import {FeedbackAppPostSubmitAction, FeedbackContext, FeedbackServiceProviderInterface, Report, SendReportStatus} from './feedback_types.js';
import {FeedbackAppPostSubmitAction, FeedbackAppPreSubmitAction, FeedbackContext, FeedbackServiceProviderInterface, Report, SendReportStatus} from './feedback_types.js';

/**
* @fileoverview
Expand Down Expand Up @@ -48,6 +48,9 @@ export class FakeFeedbackServiceProvider {

/** @type {?FeedbackAppPostSubmitAction} */
this.postSubmitAction_ = null;

/** @type {Map<FeedbackAppPreSubmitAction, number>} */
this.preSubmitActionMap_ = new Map();
}

/**
Expand Down Expand Up @@ -200,4 +203,21 @@ export class FakeFeedbackServiceProvider {
this.postSubmitAction_ = action;
}
}

/**
* @param {!FeedbackAppPreSubmitAction} action
* @return {number}
*/
getRecordPreSubmitActionCallCount(action) {
return this.preSubmitActionMap_.get(action) || 0;
}

/**
* @param {!FeedbackAppPreSubmitAction} action
* @return {void}
*/
recordPreSubmitAction(action) {
this.preSubmitActionMap_.set(
action, this.preSubmitActionMap_.get(action) + 1 || 1);
}
}
6 changes: 6 additions & 0 deletions ash/webui/os_feedback_ui/resources/feedback_types.js
Expand Up @@ -78,6 +78,12 @@ export const HelpContentProvider = ash.osFeedbackUi.mojom.HelpContentProvider;
*/
export const FeedbackContext = ash.osFeedbackUi.mojom.FeedbackContext;

/**
* Type alias for FeedbackAppPreSubmitAction.
* @typedef {ash.osFeedbackUi.mojom.FeedbackAppPreSubmitAction}
*/
export const FeedbackAppPreSubmitAction =
ash.osFeedbackUi.mojom.FeedbackAppPreSubmitAction;

/**
* Type alias for FeedbackAppPostSubmitAction.
Expand Down
4 changes: 3 additions & 1 deletion ash/webui/os_feedback_ui/resources/share_data_page.js
Expand Up @@ -14,7 +14,7 @@ import {html, mixinBehaviors, PolymerElement} from 'chrome://resources/polymer/v

import {FEEDBACK_LEGAL_HELP_URL, FEEDBACK_PRIVACY_POLICY_URL, FEEDBACK_TERMS_OF_SERVICE_URL} from './feedback_constants.js';
import {FeedbackFlowState} from './feedback_flow.js';
import {AttachedFile, FeedbackContext, FeedbackServiceProviderInterface, Report} from './feedback_types.js';
import {AttachedFile, FeedbackAppPreSubmitAction, FeedbackContext, FeedbackServiceProviderInterface, Report} from './feedback_types.js';
import {getFeedbackServiceProvider} from './mojo_interface_provider.js';

/**
Expand Down Expand Up @@ -114,6 +114,8 @@ export class ShareDataPageElement extends ShareDataPageElementBase {
handleScreenshotClick_() {
this.$.screenshotDialog.showModal();
this.$.closeDialogButton.focus();
this.feedbackServiceProvider_.recordPreSubmitAction(
FeedbackAppPreSubmitAction.kViewedScreenshot);
}

/** @protected */
Expand Down
Expand Up @@ -8,7 +8,7 @@ import 'chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-lite.js';
import {fakeEmptyFeedbackContext, fakeFeedbackContext} from 'chrome://os-feedback/fake_data.js';
import {FakeFeedbackServiceProvider} from 'chrome://os-feedback/fake_feedback_service_provider.js';
import {FeedbackFlowState} from 'chrome://os-feedback/feedback_flow.js';
import {FeedbackContext} from 'chrome://os-feedback/feedback_types.js';
import {FeedbackAppPreSubmitAction, FeedbackContext} from 'chrome://os-feedback/feedback_types.js';
import {setFeedbackServiceProviderForTesting} from 'chrome://os-feedback/mojo_interface_provider.js';
import {ShareDataPageElement} from 'chrome://os-feedback/share_data_page.js';
import {mojoString16ToString, stringToMojoString16} from 'chrome://resources/ash/common/mojo_utils.js';
Expand Down Expand Up @@ -69,6 +69,17 @@ export function shareDataPageTestSuite() {
return element.textContent.trim();
}

/**
* @param {number} callCounts
* @param {FeedbackAppPreSubmitAction} action
* @private
*/
function verifyRecordPreSubmitActionCallCount(callCounts, action) {
assertEquals(
callCounts,
feedbackServiceProvider.getRecordPreSubmitActionCallCount(action));
}

/**
* Helper function which will click the send button, wait for the event
* 'continue-click', and return the detail data of the event.
Expand Down Expand Up @@ -400,6 +411,8 @@ export function shareDataPageTestSuite() {
// focus on the close dialog icon button.
test('screenshotPreview', async () => {
await initializePage();
verifyRecordPreSubmitActionCallCount(
0, FeedbackAppPreSubmitAction.kViewedScreenshot);
page.feedbackContext = fakeFeedbackContext;
page.screenshotUrl = fakeImageUrl;
assertEquals(fakeImageUrl, getElement('#screenshotImage').src);
Expand All @@ -418,6 +431,8 @@ export function shareDataPageTestSuite() {
assertTrue(isVisible(closeDialogButton));
// The preview dialog's close icon button is focused.
assertEquals(closeDialogButton, getDeepActiveElement());
verifyRecordPreSubmitActionCallCount(
1, FeedbackAppPreSubmitAction.kViewedScreenshot);

// Press enter should close the preview dialog.
closeDialogButton.dispatchEvent(
Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/metadata/others/histograms.xml
Expand Up @@ -5801,6 +5801,17 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>

<histogram name="Feedback.ChromeOSApp.ViewedScreenshot" units="boolean"
expires_after="2023-07-27">
<owner>longbowei@google.com</owner>
<owner>xiangdongkong@google.com</owner>
<owner>cros-feedback-app@google.com</owner>
<summary>
Record number of times the user viewed the screenshot. Fires when user
clicks the thumbnail on and views the larger screenshot.
</summary>
</histogram>

<histogram name="Feedback.Duration.FetchSystemInformation" units="ms"
expires_after="2023-03-25">
<owner>xiangdongkong@google.com</owner>
Expand Down

0 comments on commit 1177df3

Please sign in to comment.