chromium/extensions/common/api/metrics_private.json

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

[
  {
    "namespace": "metricsPrivate",
    "description": "none",
    "types": [
      {
        "id": "MetricTypeType",
        "type": "string",
        "enum": ["histogram-log", "histogram-linear"],
        "description": "The type of metric, such as 'histogram-log' or 'histogram-linear'."
      },
      {
        "id": "MetricType",
        "type":  "object",
        "description": "Describes the type of metric that is to be collected.",
        "properties": {
          "metricName": {"type": "string", "description": "A unique name within the extension for the metric."},
          "type": {
            "$ref": "MetricTypeType"
          },
          "min": {"type": "integer", "description": "The minimum sample value to be recoded.  Must be greater than zero."},
          "max": {"type": "integer", "description": "The maximum sample value to be recoded."},
          "buckets": {"type": "integer", "description": "The number of buckets to use when separating the recorded values."}
        }
      },
      {
        "id": "HistogramBucket",
        "type": "object",
        "properties": {
          "min": {"type": "integer", "description": "Minimum sample value that can be stored in this bucket (i.e. inclusive)."},
          "max": {"type": "integer", "description": "Exclusive maximum value for samples stored this bucket."},
          "count": {"type": "integer", "description": "Number of samples stored in this bucket."}
        }
      },
      {
        "id": "Histogram",
        "type":  "object",
        "properties": {
          "sum": {"type": "number", "description": "Sum of the all entries."},
          "buckets": {
            "type": "array",
            "description": "Buckets containing samples.",
            "items": {
              "$ref": "HistogramBucket"
            }
          }
        }
      }
    ],
    "functions": [
      {
        "name": "getHistogram",
        "description": "Get details about a histogram displayed at chrome://histogram.",
        "type": "function",
        "parameters": [
          {
            "name": "name",
            "type": "string",
            "description": "Histogram name, e.g. 'Accessibility.CrosAutoclick'."
          }
        ],
        "returns_async": {
          "name": "callback",
          "description": "Invoked with details.",
          "parameters": [
            { "name": "histogram", "$ref": "Histogram" }
          ]
        }
      },
      {
        "name": "getIsCrashReportingEnabled",
        "description": "Returns true if the user opted in to sending crash reports.",
        "type": "function",
        "parameters": [],
        "returns_async": {
          "name": "callback",
          "parameters": [
            { "name": "is_enabled", "type": "boolean" }
          ]
        }
      },
      {
        "name": "getFieldTrial",
        "description": "Returns the group name chosen for the named trial, or the empty string if the trial does not exist or is not enabled.",
        "type": "function",
        "parameters": [
          {"name": "name", "type": "string"}
        ],
        "returns_async": {
          "name": "callback",
          "parameters": [
            { "name": "group", "type": "string" }
          ]
        }
      },
      {
        "name": "getVariationParams",
        "description": "Returns variation parameters for the named trial if available, or undefined otherwise.",
        "type": "function",
        "parameters": [
          {"name": "name", "type": "string"}
        ],
        "returns_async": {
          "name": "callback",
          "parameters": [
            {
              "name": "params",
              "optional": true,
              "type": "object",
              "additionalProperties": { "type": "string" }
            }
          ]
        }
      },
      {
        "name": "recordUserAction",
        "type": "function",
        "description": "Records an action performed by the user.",
        "parameters": [
          {"name": "name", "type": "string"}
        ]
      },
      {
        "name": "recordPercentage",
        "type": "function",
        "description": "Records a percentage value from 1 to 100.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordCount",
        "type": "function",
        "description": "Records a value than can range from 1 to 1,000,000.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordSmallCount",
        "type": "function",
        "description": "Records a value than can range from 1 to 100.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordMediumCount",
        "type": "function",
        "description": "Records a value than can range from 1 to 10,000.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordTime",
        "type": "function",
        "description": "Records an elapsed time of no more than 10 seconds.  The sample value is specified in milliseconds.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordMediumTime",
        "type": "function",
        "description": "Records an elapsed time of no more than 3 minutes.  The sample value is specified in milliseconds.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordLongTime",
        "type": "function",
        "description": "Records an elapsed time of no more than 1 hour.  The sample value is specified in milliseconds.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordSparseValueWithHashMetricName",
        "type": "function",
        "description": "Increments the count associated with the hash of |value| in the sparse histogram defined by the |metricName| using base::HashMetricName(value).",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "string"}
        ]
      },
      {
        "name": "recordSparseValueWithPersistentHash",
        "type": "function",
        "description": "Increments the count associated with the hash of |value| in the sparse histogram defined by the |metricName| using base::PersistentHash(value).",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "string"}
        ]
      },
      {
        "name": "recordSparseValue",
        "type": "function",
        "description": "Increments the count associated with |value| in the sparse histogram defined by the |metricName|.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordValue",
        "type": "function",
        "description": "Adds a value to the given metric.",
        "parameters": [
          {"name": "metric", "$ref": "MetricType"},
          {"name": "value", "type": "integer"}
        ]
      },
      {
        "name": "recordBoolean",
        "type": "function",
        "description": "Records a boolean value to the given metric. Analogous to base::UmaHistogramBoolean().",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "boolean"}
        ]
      },
      {
        "name": "recordEnumerationValue",
        "type": "function",
        "description": "Records an enumeration value to the given metric. Analogous to base::UmaHistogramEnumeration(). Use recordSparseValue for sparse enums or enums not starting at 0.",
        "parameters": [
          {"name": "metricName", "type": "string"},
          {"name": "value", "type": "integer"},
          {"name": "enumSize", "type": "integer"}
        ]
      }
    ],
    "events": []
  }
]