"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "Telemeter", {
  enumerable: true,
  get: function get() {
    return _telemeter["default"];
  }
});
exports.setTelemetryEnabled = exports.track = exports.flush = void 0;

var _telemeter = _interopRequireDefault(require("./telemeter"));

var _createFlush = _interopRequireDefault(require("./util/create-flush"));

var telemeter = new _telemeter["default"]();
var flush = (0, _createFlush["default"])(telemeter.isTrackingEnabled());
exports.flush = flush;

if (flush) {
  process.on("exit", flush);
}

var track = function track(event) {
  var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  telemeter.track(event, data);
};

exports.track = track;

var setTelemetryEnabled = function setTelemetryEnabled() {
  var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  telemeter.setTelemetryEnabled(enabled);
};

exports.setTelemetryEnabled = setTelemetryEnabled;