Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Fixes #1800 add speech telemetry #1894

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extension/background/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export function send() {
}
}
ping.wakewordEnabled = s.enableWakeword;
ping.speechOutputEnabled = s.speechOutput;
ping.optInAudio = s.collectAudio;
ping.optInAcceptanceTime = s.collectTranscriptsOptinAnswered;
browser.telemetry
Expand Down
16 changes: 12 additions & 4 deletions extension/intents/search/cardSpeech.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function humanReadableDate(rawDate) {
return eventStringParts;
}

export function getSpeechForCard(card) {
export function getCardType(card) {
const CARD_TYPE_SELECTORS = {
WEATHER: "#wob_wc",
DIRECTIONS: ".BbbuR",
Expand All @@ -329,14 +329,12 @@ export function getSpeechForCard(card) {
};

const parentCard = card.parentNode;
let text;
let language;
let cardType;

const BANNER_CARD_SELECTOR = "#botabar";
const bannerCardContainer = document.querySelector(BANNER_CARD_SELECTOR);
if (bannerCardContainer) {
return handleBannerCards(bannerCardContainer); // We don't currently show banner-type cards within the popup, and there may be searches that yield both banner cards and sidebar cards.
return "BANNER";
}

for (const [type, tag] of Object.entries(CARD_TYPE_SELECTORS)) {
Expand All @@ -345,6 +343,16 @@ export function getSpeechForCard(card) {
break;
}
}
return cardType;
}

export function getSpeechForCard(card, cardType) {
if (cardType === "BANNER") {
return handleBannerCards(bannerCardContainer); // We don't currently show banner-type cards within the popup, and there may be searches that yield both banner cards and sidebar cards.
}

let text;
let language;

switch (cardType) {
case "WEATHER":
Expand Down
4 changes: 3 additions & 1 deletion extension/intents/search/queryScript.content.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ registerHandler("cardContent", message => {
ctx.drawWindow(window, rect.x, rect.y, rect.width, rect.height, "#fff");

let speech;
let cardType = cardSpeech.getCardType(card);

if (message.speechOutput && !message.polling) {
speech = cardSpeech.getSpeechForCard(card);
speech = cardSpeech.getSpeechForCard(card, cardType);
}

return {
Expand All @@ -167,6 +168,7 @@ registerHandler("cardContent", message => {
src: canvas.toDataURL(),
alt: card.innerText,
hasWidget,
cardType,
speech,
};
});
5 changes: 4 additions & 1 deletion extension/intents/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ intentRunner.registerIntent({
searchUrl: searchInfo.searchUrl,
index: -1,
});
telemetry.add({ hasCard: true });
telemetry.add({
hasCard: true,
cardType: card.cardType,
});
if (card.hasWidget) {
pollForCard();
} else {
Expand Down
4 changes: 4 additions & 0 deletions extension/popup/popupController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ export const PopupController = function() {
utterance.onend = () => {
closePopup(2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add outputSpokenCompleted (true) to this method

};
sendMessage({
type: "addTelemetry",
properties: { outputSpoken: true },
});
};

const clearTimer = async ({ totalInMS, followup }) => {
Expand Down