summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/print_preview/metrics.js
blob: bdeaf141efbb8ccad2760a4bd521f041b76a711f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2012 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.

cr.define('print_preview', function() {
  'use strict';

  /**
   * Object used to measure usage statistics.
   * @constructor
   */
  function Metrics() {};

  /**
   * Enumeration of metrics buckets to record.
   * @enum {number}
   */
  Metrics.Bucket = {
    // Used when the print destination search widget is shown.
    DESTINATION_SEARCH_SHOWN: 0,
    // Used when the user selects a print destination.
    DESTINATION_SELECTED: 1,
    // Used when the print destination search widget is closed without selecting
    // a print destination.
    DESTINATION_SELECTION_CANCELED: 2,
    // Used when the Google Cloud Print promotions is shown to the user.
    CLOUDPRINT_PROMO_SHOWN: 3,
    // Used when the user chooses to sign-in to their Google account.
    SIGNIN_TRIGGERED: 4
  };

  Metrics.prototype = {
    /**
     * Increments the counter for a given bucket.
     * @param {!print_preview.Metrics.Bucket} bucket Bucket to increment.
     */
    increment: function(bucket) {
      chrome.send('reportDestinationEvent', bucket);
    }
  };

  // Export
  return {
    Metrics: Metrics
  };
});