Commit ed26a98b authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Add closure compiler check to metrics.js

Bug: b/141518780
Test: Pass closure compiler check.
Change-Id: I9c0370ebc71fdd8526c6619a1e63da4d9d05a928
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866492Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706850}
parent 3fb5a589
......@@ -19,6 +19,7 @@ js_type_check("compile_resources") {
deps = [
":background",
":intent",
":metrics",
":nav",
":resolution_event_broker",
":state",
......@@ -34,6 +35,12 @@ js_library("intent") {
]
}
js_library("metrics") {
deps = [
"externs:chrome_platform_analytics",
]
}
js_library("resolution_event_broker") {
}
......
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
js_library("chrome_platform_analytics") {
sources = []
externs_list = [ "chrome_platform_analytics.js" ]
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Externs for chrome-platform-analytics library.
* @see https://github.com/googlearchive/chrome-platform-analytics/wiki
* @externs
*/
/* eslint-disable valid-jsdoc */
var analytics = {};
/**
* @constructor
* @struct
*/
analytics.EventBuilder = function() {};
/**
* @param {!analytics.EventBuilder.Dimension} dimension
* @return {!analytics.EventBuilder}
*/
analytics.EventBuilder.prototype.dimension = function(dimension) {};
/**
* @param {string} category
* @return {!analytics.EventBuilder}
*/
analytics.EventBuilder.prototype.category = function(category) {};
/**
* @param {string} action
* @return {!analytics.EventBuilder}
*/
analytics.EventBuilder.prototype.action = function(action) {};
/**
* @param {string} label
* @return {!analytics.EventBuilder}
*/
analytics.EventBuilder.prototype.label = function(label) {};
/**
* @param {number} value
* @return {!analytics.EventBuilder}
*/
analytics.EventBuilder.prototype.value = function(value) {};
/**
* @typedef {{
* index: number,
* value: string
* }}
*/
analytics.EventBuilder.Dimension;
/**
* @interface
*/
analytics.Tracker = function() {};
/**
* @param {!analytics.EventBuilder} eventBuilder
*/
analytics.Tracker.prototype.send;
......@@ -16,21 +16,18 @@ cca.metrics = cca.metrics || {};
/**
* Event builder for basic metrics.
* @type {analytics.EventBuilder}
* @type {?analytics.EventBuilder}
* @private
*/
cca.metrics.base_ = null;
/**
* @type {analytics}
*/
var analytics = window['analytics'] || {};
/**
* Fixes analytics.EventBuilder's dimension() method.
* @param {number} i
* @param {string} v
* @return {analytics.EventBuilder}
* @return {!analytics.EventBuilder}
*/
analytics.EventBuilder.prototype.dimen = function(i, v) {
return this.dimension({index: i, value: v});
......@@ -39,6 +36,7 @@ analytics.EventBuilder.prototype.dimen = function(i, v) {
/**
* Promise for Google Analytics tracker.
* @type {Promise<analytics.Tracker>}
* @suppress {checkTypes}
* @private
*/
cca.metrics.ga_ = (function() {
......@@ -83,7 +81,7 @@ cca.metrics.ga_ = (function() {
/**
* Returns event builder for the metrics type: launch.
* @param {boolean} ackMigrate Whether acknowledged to migrate during launch.
* @return {analytics.EventBuilder}
* @return {!analytics.EventBuilder}
* @private
*/
cca.metrics.launchType_ = function(ackMigrate) {
......@@ -95,13 +93,12 @@ cca.metrics.launchType_ = function(ackMigrate) {
* Returns event builder for the metrics type: capture.
* @param {?string} facingMode Camera facing-mode of the capture.
* @param {number} length Length of 1 minute buckets for captured video.
* @param {number} width The width of the capture resolution.
* @param {number} height The height of the capture resolution.
* @return {analytics.EventBuilder}
* @param {!{width: number, height: number}} resolution Capture resolution.
* @return {!analytics.EventBuilder}
* @private
*/
cca.metrics.captureType_ = function(facingMode, length, {width, height}) {
var condState = (states, cond, strict) => {
var condState = (states, cond = undefined, strict = undefined) => {
// Return the first existing state among the given states only if there is
// no gate condition or the condition is met.
const prerequisite = !cond || cca.state.get(cond);
......@@ -130,7 +127,7 @@ cca.metrics.captureType_ = function(facingMode, length, {width, height}) {
/**
* Metrics types.
* @enum {function(*=)}
* @enum {function(...): !analytics.EventBuilder}
*/
cca.metrics.Type = {
LAUNCH: cca.metrics.launchType_,
......@@ -139,7 +136,7 @@ cca.metrics.Type = {
/**
* Logs the given metrics.
* @param {cca.metrics.Type} type Metrics type.
* @param {!cca.metrics.Type} type Metrics type.
* @param {...*} args Optional rest parameters for logging metrics.
*/
cca.metrics.log = function(type, ...args) {
......
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