Commit 0ae381bb authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Add intent type GA event log.

Bug: 1014829
Test: tast run <DUT> 'camera.CCAUI*'
Change-Id: I727d3a6660a2416b6b5ff2f265ca4234161618a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2053870Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741330}
parent a144c340
......@@ -41,6 +41,7 @@ js_library("chrome_util") {
js_library("intent") {
deps = [
":chrome_util",
":metrics",
":type",
"mojo:chrome_helper",
]
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as metrics from './metrics.js';
import {ChromeHelper} from './mojo/chrome_helper.js';
import {Mode} from './type.js';
......@@ -108,6 +109,7 @@ export class Intent {
}
this.done_ = true;
await this.chromeHelper_.finish(this.intentId);
metrics.log(metrics.Type.INTENT, this, metrics.IntentResultType.CONFIRMED);
}
/**
......@@ -120,6 +122,7 @@ export class Intent {
}
this.done_ = true;
await this.chromeHelper_.cancel(this.intentId);
metrics.log(metrics.Type.INTENT, this, metrics.IntentResultType.CANCELED);
}
/**
......
......@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// eslint-disable-next-line no-unused-vars
import {Intent} from './intent.js';
import * as state from './state.js';
import {Mode,
Resolution, // eslint-disable-line no-unused-vars
import {
Mode,
Resolution, // eslint-disable-line no-unused-vars
} from './type.js';
/**
......@@ -153,6 +156,23 @@ function perfType(event, duration, extras = {}) {
.dimen(3, `${resolution}`);
}
/**
* Returns event builder for the metrics type: intent.
* @param {!Intent} intent Intent to be logged.
* @param {!IntentResultType} intentResult
* @return {!analytics.EventBuilder}
*/
function intentType(intent, intentResult) {
const getBoolValue = (b) => b ? '1' : '0';
return base.category('intent')
.action(intent.mode)
.label(intentResult)
.dimen(12, intentResult)
.dimen(13, getBoolValue(intent.shouldHandleResult))
.dimen(14, getBoolValue(intent.shouldDownScale))
.dimen(15, getBoolValue(intent.isSecure));
}
/**
* Metrics types.
* @enum {function(...): !analytics.EventBuilder}
......@@ -161,6 +181,7 @@ export const Type = {
LAUNCH: launchType,
CAPTURE: captureType,
PERF: perfType,
INTENT: intentType,
};
/**
......
......@@ -4,6 +4,7 @@
found in the LICENSE file. -->
<html>
<head>
<script src="../js/google-analytics-bundle.js"></script>
<script src="../js/mojo/mojo_bindings_lite.js"></script>
<script src="../js/mojo/camera_intent.mojom-lite.js"></script>
<script src="../js/mojo/camera_app_helper.mojom-lite.js"></script>
......
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