@google/dscc-gen
Version:
Create component & connector projects with sane defaults.
46 lines (45 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const uuid4 = require("uuid/v4");
const Insight = require('insight');
const pkg = require('../package.json');
const executionId = uuid4();
exports.insight = new Insight({
// Google Analytics tracking code
trackingCode: 'UA-41425441-15',
pkg,
});
var Category;
(function (Category) {
Category["EXECUTION"] = "execution";
})(Category = exports.Category || (exports.Category = {}));
var Action;
(function (Action) {
Action["START"] = "start";
Action["STOP"] = "stop";
Action["ERROR_STOP"] = "error_stop";
Action["GSUTIL_NOT_INSTALLED"] = "gsutil_not_installed";
Action["SIGINT_STOP"] = "sigint_stop";
})(Action = exports.Action || (exports.Action = {}));
exports.trackEvent = (category, action) => {
exports.insight.trackEvent({
category,
action,
label: executionId,
});
};
exports.checkForOptOut = async () => {
if (exports.insight.optOut === undefined) {
await new Promise((resolve, reject) => {
exports.insight.askPermission(null, (err, success) => {
if (err) {
reject(err);
}
else {
resolve(success);
}
});
});
}
return exports.insight.optOut;
};