Skip to content

Metrics API

phoenixide edited this page Feb 3, 2024 · 4 revisions

utils/Metrics

The Metrics API can be used to send analytics data to track feature usage in accordance with users privacy settings.

Status: Internal - Not to be used by third party extensions.

Import

// usage within core:
const Metrics = require("utils/Metrics");

// usage within default extensions:
const Metrics = brackets.getModule("utils/Metrics");

API

This section outlines the properties and methods available in this module

EVENT_TYPE

The Type of events that can be specified as an eventType in the API calls.

Properties

PLATFORM, PROJECT, THEMES, EXTENSIONS, EXTENSIONS, UI, UI_DIALOG, UI_BOTTOM_PANEL, UI_SIDE_PANEL, LIVE_PREVIEW, CODE_HINTS, EDITOR, SEARCH, SHARING, PERFORMANCE, NEW_PROJECT

Type: Object

countEvent

log a numeric count >=0

Type: function

Parameters

  • eventType (EVENT_TYPE | string) The kind of Event Type that needs to be logged- should be a js var compatible string. Some standard event types are available as EVENT_TYPE.
  • eventCategory string The kind of Event Category that needs to be logged- should be a js var compatible string
  • eventSubCategory string The kind of Event Sub Category that needs to be logged- should be a js var compatible string
  • count number > =0 , optional, if not set defaults to 1 (optional, default 1)

Examples

To log that user clicked searchButton 5 times:

Metrics.countEvent(Metrics.EVENT_TYPE.UI, "searchButton", "click");
Metrics.countEvent(Metrics.EVENT_TYPE.UI, "searchButton", "click", 5);

valueEvent

log a numeric value (number).

Type: function

Parameters

  • eventType (EVENT_TYPE | string) The kind of Event Type that needs to be logged- should be a js var compatible string. some standard event types are available as EVENT_TYPE.
  • eventCategory string The kind of Event Category that needs to be logged- should be a js var compatible string
  • eventSubCategory string The kind of Event Sub Category that needs to be logged- should be a js var compatible string
  • value number

Examples

To log that startup time is 200ms:

Metrics.valueEvent(Metrics.EVENT_TYPE.PERFORMANCE, "startupTime", "ms", 200);

flushMetrics

Send all pending metrics, useful before app quit. Will never throw Error.