Commit 9653f166 authored by Ajit Narayanan's avatar Ajit Narayanan Committed by Chromium LUCI CQ

Adds UMA for pause/resume in Select-to-speak.

Adds new user actions for when the user manually pauses or resumes
Select-to-speak. Additionally, since the new STS bubble provides an
alternative way to cancel, adds a new point of logging for CancelSpeech
when performed through the close icon.

Bug: 1143817
Change-Id: Ifc53543d4e6278b725ff418e4461562d37e56501
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580479Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Ajit Narayanan <ajitnarayanan@google.com>
Cr-Commit-Position: refs/heads/master@{#836269}
parent 287ea237
......@@ -9,12 +9,15 @@ class MetricsUtils {
/**
* Records a cancel event if speech was in progress.
* @param {boolean} speaking Whether speech was in progress
*/
static recordCancelIfSpeaking(speaking) {
if (speaking) {
MetricsUtils.recordCancelEvent_();
}
static recordCancelIfSpeaking() {
// TODO(b/1157214): Use select-to-speak's internal state instead of TTS
// state.
chrome.tts.isSpeaking((speaking) => {
if (speaking) {
MetricsUtils.recordCancelEvent_();
}
});
}
/**
......@@ -45,6 +48,20 @@ class MetricsUtils {
chrome.metricsPrivate.recordUserAction(MetricsUtils.CANCEL_SPEECH_METRIC);
}
/**
* Records an event that Select-to-Speak speech has been paused.
*/
static recordPauseEvent() {
chrome.metricsPrivate.recordUserAction(MetricsUtils.PAUSE_SPEECH_METRIC);
}
/**
* Records an event that Select-to-Speak speech has been resumed from pause.
*/
static recordResumeEvent() {
chrome.metricsPrivate.recordUserAction(MetricsUtils.RESUME_SPEECH_METRIC);
}
/**
* Records a user-requested state change event from a given state.
* @param {number} changeType
......@@ -120,6 +137,20 @@ MetricsUtils.START_SPEECH_METRIC =
MetricsUtils.CANCEL_SPEECH_METRIC =
'Accessibility.CrosSelectToSpeak.CancelSpeech';
/**
* The pause speech metric name.
* @type {string}
*/
MetricsUtils.PAUSE_SPEECH_METRIC =
'Accessibility.CrosSelectToSpeak.PauseSpeech';
/**
* The resume speech after pausing metric name.
* @type {string}
*/
MetricsUtils.RESUME_SPEECH_METRIC =
'Accessibility.CrosSelectToSpeak.ResumeSpeech';
/**
* The background shading metric name.
* @type {string}
......
......@@ -842,6 +842,8 @@ class SelectToSpeak {
},
// onRequestCancel: User requested canceling input/speech.
onRequestCancel: () => {
// User manually requested cancel, so log cancel metric.
MetricsUtils.recordCancelIfSpeaking();
this.cancelIfSpeaking_(true /* clear the focus ring */);
},
// onTextReceived: Text received from a 'paste' event to read aloud.
......@@ -875,7 +877,8 @@ class SelectToSpeak {
MetricsUtils.StateChangeEvent.START_SELECTION);
break;
case SelectToSpeakState.SPEAKING:
// Stop speaking.
// Stop speaking. User manually requested, so log cancel metric.
MetricsUtils.recordCancelIfSpeaking();
this.cancelIfSpeaking_(true /* clear the focus ring */);
MetricsUtils.recordSelectToSpeakStateChangeEvent(
MetricsUtils.StateChangeEvent.CANCEL_SPEECH);
......@@ -916,13 +919,19 @@ class SelectToSpeak {
this.navigateToNextSentence_(constants.Dir.BACKWARD);
break;
case SelectToSpeakPanelAction.EXIT:
// User manually requested, so log cancel metric.
MetricsUtils.recordCancelIfSpeaking();
this.stopAll_();
break;
case SelectToSpeakPanelAction.PAUSE:
MetricsUtils.recordPauseEvent();
this.pause_();
break;
case SelectToSpeakPanelAction.RESUME:
this.resume_();
if (this.isPaused_()) {
MetricsUtils.recordResumeEvent();
this.resume_();
}
break;
case SelectToSpeakPanelAction.CHANGE_SPEED:
if (!value) {
......@@ -1473,16 +1482,12 @@ class SelectToSpeak {
}
/**
* Cancels the current speech queue after doing a callback to
* record a cancel event if speech was in progress. We must cancel
* before the callback (rather than in it) to avoid race conditions
* where cancel is called twice.
* Cancels the current speech queue.
* @param {boolean} clearFocusRing Whether to clear the focus ring
* as well.
* @private
*/
cancelIfSpeaking_(clearFocusRing) {
chrome.tts.isSpeaking(MetricsUtils.recordCancelIfSpeaking);
if (clearFocusRing) {
this.stopAll_();
} else {
......
......@@ -1501,6 +1501,18 @@ should be able to be added at any place in this file.
</description>
</action>
<action name="Accessibility.CrosSelectToSpeak.PauseSpeech">
<owner>ajitnarayanan@google.com</owner>
<description>A Chrome OS user manually pauses Select To Speak.</description>
</action>
<action name="Accessibility.CrosSelectToSpeak.ResumeSpeech">
<owner>ajitnarayanan@google.com</owner>
<description>
A Chrome OS user manually resumes Select To Speak after pausing.
</description>
</action>
<action name="Accessibility.CrosSelectToSpeak.StartSpeech">
<owner>katie@chromium.org</owner>
<description>A Chrome OS user manually starts Select To Speak.</description>
......
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