Commit fb8fd1c7 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

camera: Migrate google-analytics-bundle.js to analytics.js

Bug: 980846
Test: Launch CCA and CCA can send metrics successfully
Tricium: disable
Change-Id: I2ed39b7fc1b133fd2ed8d6dc122f029101837b7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106984
Commit-Queue: Wei Lee <wtlee@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Reviewed-by: default avatarKuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759149}
parent c19ac978
...@@ -140,8 +140,8 @@ copy("chrome_camera_app_js_device") { ...@@ -140,8 +140,8 @@ copy("chrome_camera_app_js_device") {
copy("chrome_camera_app_js_lib") { copy("chrome_camera_app_js_lib") {
sources = [ sources = [
"src/js/lib/analytics.js",
"src/js/lib/comlink.js", "src/js/lib/comlink.js",
"src/js/lib/google-analytics-bundle.js",
] ]
outputs = [ "$chrome_camera_app_dir/js/lib/{{source_file_part}}" ] outputs = [ "$chrome_camera_app_dir/js/lib/{{source_file_part}}" ]
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<structures> <structures>
<structure name="IDR_CAMERA_ASYNC_WRITER_JS" file="src/js/models/async_writer.js" type="chrome_html" /> <structure name="IDR_CAMERA_ASYNC_WRITER_JS" file="src/js/models/async_writer.js" type="chrome_html" />
<structure name="IDR_CAMERA_BACKGROUND_JS" file="src/js/background.js" type="chrome_html" /> <structure name="IDR_CAMERA_BACKGROUND_JS" file="src/js/background.js" type="chrome_html" />
<structure name="IDR_CAMERA_BUNDLE_JS" file="src/js/lib/google-analytics-bundle.js" type="chrome_html" /> <structure name="IDR_CAMERA_ANALYTICS_JS" file="src/js/lib/analytics.js" type="chrome_html" />
<structure name="IDR_CAMERA_CAMERA3_DEVICE_INFO_JS" file="src/js/device/camera3_device_info.js" type="chrome_html" /> <structure name="IDR_CAMERA_CAMERA3_DEVICE_INFO_JS" file="src/js/device/camera3_device_info.js" type="chrome_html" />
<structure name="IDR_CAMERA_CAMERA_JS" file="src/js/views/camera.js" type="chrome_html" /> <structure name="IDR_CAMERA_CAMERA_JS" file="src/js/views/camera.js" type="chrome_html" />
<structure name="IDR_CAMERA_CAMERA_INTENT_JS" file="src/js/views/camera_intent.js" type="chrome_html" /> <structure name="IDR_CAMERA_CAMERA_INTENT_JS" file="src/js/views/camera_intent.js" type="chrome_html" />
......
...@@ -63,7 +63,7 @@ js_library("gallerybutton") { ...@@ -63,7 +63,7 @@ js_library("gallerybutton") {
js_library("metrics") { js_library("metrics") {
deps = [ deps = [
":state", ":state",
"externs:chrome_platform_analytics", "externs:universal_analytics_api",
] ]
} }
......
...@@ -124,6 +124,13 @@ class ChromeAppBrowserProxy { ...@@ -124,6 +124,13 @@ class ChromeAppBrowserProxy {
sendMessage(extensionId, message) { sendMessage(extensionId, message) {
chrome.runtime.sendMessage(extensionId, message); chrome.runtime.sendMessage(extensionId, message);
} }
/** @override */
addDummyHistoryIfNotAvailable() {
// Since GA will use history.length to generate hash but it is not available
// in platform apps, set it to 1 manually.
window.history.length = 1;
}
} }
export const browserProxy = new ChromeAppBrowserProxy(); export const browserProxy = new ChromeAppBrowserProxy();
...@@ -117,4 +117,9 @@ export class BrowserProxy { ...@@ -117,4 +117,9 @@ export class BrowserProxy {
* @abstract * @abstract
*/ */
sendMessage(extensionId, message) {} sendMessage(extensionId, message) {}
/**
* @abstract
*/
addDummyHistoryIfNotAvailable() {}
} }
...@@ -136,6 +136,11 @@ class WebUIBrowserProxy { ...@@ -136,6 +136,11 @@ class WebUIBrowserProxy {
sendMessage(extensionId, message) { sendMessage(extensionId, message) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
/** @override */
addDummyHistoryIfNotAvailable() {
// no-ops
}
} }
export const browserProxy = new WebUIBrowserProxy(); export const browserProxy = new WebUIBrowserProxy();
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
js_library("chrome_platform_analytics") { js_library("universal_analytics_api") {
sources = [] sources = []
externs_list = [ "chrome_platform_analytics.js" ] externs_list = [ "universal_analytics_api.js" ]
} }
js_library("w3c_fileapi") { js_library("w3c_fileapi") {
......
// 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 */
const 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;
# google-analytics-bundle.js # analytics.js
* [Project Page](https://github.com/googlearchive/chrome-platform-analytics) * [Project Page](https://developers.google.com/analytics/devguides/collection/analyticsjs)
* The extern file [universal_analytics_api.js]((https://github.com/google/closure-compiler/blob/master/contrib/externs/universal_analytics_api.js)) is copied from the [closure compiler project](https://github.com/google/closure-compiler)
# comlink.js # comlink.js
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
found in the LICENSE file. --> found in the LICENSE file. -->
<html> <html>
<head> <head>
<script src="../js/lib/google-analytics-bundle.js"></script>
<script src="../js/mojo/mojo_bindings_lite.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_intent.mojom-lite.js"></script>
<script src="../js/mojo/camera_app_helper.mojom-lite.js"></script> <script src="../js/mojo/camera_app_helper.mojom-lite.js"></script>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<title>&#xfeff;</title> <title>&#xfeff;</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="../css/main.css"> <link rel="stylesheet" href="../css/main.css">
<script src="../js/lib/google-analytics-bundle.js"></script>
<script src="../js/mojo/mojo_bindings_lite.js"></script> <script src="../js/mojo/mojo_bindings_lite.js"></script>
<script src="../js/mojo/time.mojom-lite.js"></script> <script src="../js/mojo/time.mojom-lite.js"></script>
<script src="../js/mojo/idle_manager.mojom-lite.js"></script> <script src="../js/mojo/idle_manager.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