Commit a8b6155b authored by Shik Chen's avatar Shik Chen Committed by Chromium LUCI CQ

CCA: Add metrics for QR code detection

This CL adds the metrics for
1. QR code toggle enabled event.
2. QR code detected event with the content type.

Bug: b/172879638
Test: Manually
Change-Id: Ia4ed19b83bb2970cef424949eb701ad46e72b685
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2603707
Commit-Queue: Shik Chen <shik@chromium.org>
Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839450}
parent b4db63fc
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import {browserProxy} from './browser_proxy/browser_proxy.js'; import {browserProxy} from './browser_proxy/browser_proxy.js';
import {assert} from './chrome_util.js'; import {assert} from './chrome_util.js';
import * as dom from './dom.js'; import * as dom from './dom.js';
import {BarcodeContentType, sendBarcodeDetectedEvent} from './metrics.js';
import * as snackbar from './snackbar.js'; import * as snackbar from './snackbar.js';
import * as state from './state.js'; import * as state from './state.js';
import {OneShotTimer} from './timer.js'; import {OneShotTimer} from './timer.js';
...@@ -170,8 +171,10 @@ export async function show(code) { ...@@ -170,8 +171,10 @@ export async function show(code) {
currentCode = code; currentCode = code;
if (isSafeUrl(code)) { if (isSafeUrl(code)) {
sendBarcodeDetectedEvent({contentType: BarcodeContentType.URL});
showUrl(code); showUrl(code);
} else { } else {
sendBarcodeDetectedEvent({contentType: BarcodeContentType.TEXT});
showText(code); showText(code);
} }
} }
......
...@@ -371,3 +371,41 @@ export function sendErrorEvent( ...@@ -371,3 +371,41 @@ export function sendErrorEvent(
[20, colNo], [20, colNo],
])); ]));
} }
/**
* Sends the barcode enabled event.
*/
export function sendBarcodeEnabledEvent() {
sendEvent({
eventCategory: 'barcode',
eventAction: 'enable',
});
}
/**
* Types of the decoded barcode content.
* @enum {string}
*/
export const BarcodeContentType = {
TEXT: 'text',
URL: 'url',
};
/**
* @typedef {{
* contentType: !BarcodeContentType,
* }}
*/
export let BarcodeDetectedEventParam;
/**
* Sends the barcode detected event.
* @param {!BarcodeDetectedEventParam} param
*/
export function sendBarcodeDetectedEvent({contentType}) {
sendEvent({
eventCategory: 'barcode',
eventAction: 'detect',
eventLabel: contentType,
});
}
...@@ -8,6 +8,7 @@ import {Camera3DeviceInfo} from '../../device/camera3_device_info.js'; ...@@ -8,6 +8,7 @@ import {Camera3DeviceInfo} from '../../device/camera3_device_info.js';
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
import {DeviceInfoUpdater} from '../../device/device_info_updater.js'; import {DeviceInfoUpdater} from '../../device/device_info_updater.js';
import * as dom from '../../dom.js'; import * as dom from '../../dom.js';
import {sendBarcodeEnabledEvent} from '../../metrics.js';
import * as nav from '../../nav.js'; import * as nav from '../../nav.js';
import * as state from '../../state.js'; import * as state from '../../state.js';
import {Facing, Mode, PerfEvent, ViewName} from '../../type.js'; import {Facing, Mode, PerfEvent, ViewName} from '../../type.js';
...@@ -264,6 +265,9 @@ export class Options { ...@@ -264,6 +265,9 @@ export class Options {
*/ */
updateBarcode_() { updateBarcode_() {
state.set(state.State.SCAN_BARCODE, this.toggleBarcode_.checked); state.set(state.State.SCAN_BARCODE, this.toggleBarcode_.checked);
if (this.toggleBarcode_.checked) {
sendBarcodeEnabledEvent();
}
} }
/** /**
......
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