OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Object used to measure usage statistics. | 9 * Object used to measure usage statistics. |
10 * @constructor | 10 * @constructor |
11 */ | 11 */ |
12 function Metrics() {}; | 12 function Metrics() {}; |
13 | 13 |
14 /** | 14 /** |
15 * Enumeration of metrics bucket groups. Each group describes a set of events | 15 * Enumeration of metrics bucket groups. Each group describes a set of events |
16 * that can happen in order. This implies that an event cannot occur twice and | 16 * that can happen in order. This implies that an event cannot occur twice and |
17 * an event that occurs semantically before another event, should not occur | 17 * an event that occurs semantically before another event, should not occur |
18 * after. | 18 * after. |
19 * @enum {number} | 19 * @enum {number} |
20 */ | 20 */ |
21 Metrics.BucketGroup = { | 21 Metrics.BucketGroup = { |
22 DESTINATION_SEARCH: 0 | 22 DESTINATION_SEARCH: 0, |
| 23 GCP_PROMO: 1 |
23 }; | 24 }; |
24 | 25 |
25 /** | 26 /** |
26 * Enumeration of buckets that a user can enter while using the destination | 27 * Enumeration of buckets that a user can enter while using the destination |
27 * search widget. | 28 * search widget. |
28 * @enum {number} | 29 * @enum {number} |
29 */ | 30 */ |
30 Metrics.DestinationSearchBucket = { | 31 Metrics.DestinationSearchBucket = { |
31 // Used when the print destination search widget is shown. | 32 // Used when the print destination search widget is shown. |
32 SHOWN: 0, | 33 SHOWN: 0, |
33 // Used when the user selects a print destination. | 34 // Used when the user selects a print destination. |
34 DESTINATION_SELECTED: 1, | 35 DESTINATION_SELECTED: 1, |
35 // Used when the print destination search widget is closed without selecting | 36 // Used when the print destination search widget is closed without selecting |
36 // a print destination. | 37 // a print destination. |
37 CANCELED: 2, | 38 CANCELED: 2, |
38 // Used when the Google Cloud Print promotion (shown in the destination | 39 // Used when the Google Cloud Print promotion (shown in the destination |
39 // search widget) is shown to the user. | 40 // search widget) is shown to the user. |
40 CLOUDPRINT_PROMO_SHOWN: 3, | 41 CLOUDPRINT_PROMO_SHOWN: 3, |
41 // Used when the user chooses to sign-in to their Google account. | 42 // Used when the user chooses to sign-in to their Google account. |
42 SIGNIN_TRIGGERED: 4 | 43 SIGNIN_TRIGGERED: 4 |
43 }; | 44 }; |
44 | 45 |
45 /** | 46 /** |
| 47 * Enumeration of buckets that a user can enter while using the Google Cloud |
| 48 * Print promotion. |
| 49 * @enum {number} |
| 50 */ |
| 51 Metrics.GcpPromoBucket = { |
| 52 // Used when the Google Cloud Print pomotion (shown above the pdf preview |
| 53 // plugin) is shown to the user. |
| 54 SHOWN: 0, |
| 55 // Used when the user clicks the "Get started" link in the promotion shown |
| 56 // in CLOUDPRINT_BIG_PROMO_SHOWN. |
| 57 CLICKED: 1, |
| 58 // Used when the user dismisses the promotion shown in |
| 59 // CLOUDPRINT_BIG_PROMO_SHOWN. |
| 60 DISMISSED: 2 |
| 61 }; |
| 62 |
| 63 /** |
46 * Name of the C++ function to call to increment bucket counts. | 64 * Name of the C++ function to call to increment bucket counts. |
47 * @type {string} | 65 * @type {string} |
48 * @const | 66 * @const |
49 * @private | 67 * @private |
50 */ | 68 */ |
51 Metrics.NATIVE_FUNCTION_NAME_ = 'reportUiEvent'; | 69 Metrics.NATIVE_FUNCTION_NAME_ = 'reportUiEvent'; |
52 | 70 |
53 Metrics.prototype = { | 71 Metrics.prototype = { |
54 /** | 72 /** |
55 * Increments the counter of a destination-search bucket. | 73 * Increments the counter of a destination-search bucket. |
56 * @param {!Metrics.DestinationSearchBucket} bucket Bucket to increment. | 74 * @param {!Metrics.DestinationSearchBucket} bucket Bucket to increment. |
57 */ | 75 */ |
58 incrementDestinationSearchBucket: function(bucket) { | 76 incrementDestinationSearchBucket: function(bucket) { |
59 chrome.send(Metrics.NATIVE_FUNCTION_NAME_, | 77 chrome.send(Metrics.NATIVE_FUNCTION_NAME_, |
60 [Metrics.BucketGroup.DESTINATION_SEARCH, bucket]); | 78 [Metrics.BucketGroup.DESTINATION_SEARCH, bucket]); |
| 79 }, |
| 80 |
| 81 /** |
| 82 * Increments the counter of a gcp-promo bucket. |
| 83 * @param {!Metrics.GcpPromoBucket} bucket Bucket to increment. |
| 84 */ |
| 85 incrementGcpPromoBucket: function(bucket) { |
| 86 chrome.send(Metrics.NATIVE_FUNCTION_NAME_, |
| 87 [Metrics.BucketGroup.GCP_PROMO, bucket]); |
61 } | 88 } |
62 }; | 89 }; |
63 | 90 |
64 // Export | 91 // Export |
65 return { | 92 return { |
66 Metrics: Metrics | 93 Metrics: Metrics |
67 }; | 94 }; |
68 }); | 95 }); |
OLD | NEW |