Files
firebase-tools/lib/track.js
Michael Bleigh cc93653f9b Lots of changes.
* New auth fully operational and used throughout
* Renames "blank" to "deploy:empty"
* Adds "data:get" command (whee!)
* Use random UUID for Google Analytics
* Remove "bootstrap" (to be merged with "init")
2015-10-12 10:42:24 -07:00

33 lines
846 B
JavaScript

'use strict';
var ua = require('universal-analytics');
var RSVP = require('rsvp');
var configstore = require('./configstore');
var pkg = require('../package.json');
var uuid = require('node-uuid');
var anonId = configstore.get('analytics-uuid');
if (!anonId) {
anonId = uuid.v4();
configstore.set('analytics-uuid', anonId);
}
var visitor = ua(process.env.FIREBASE_ANALYTICS_UA || 'UA-66650807-2', anonId, {
strictCidFormat: false,
https: true
});
module.exports = function(action, label, duration) {
return new RSVP.Promise(function(resolve) {
if (configstore.get('session') && configstore.get('usage')) {
visitor.event('Firebase CLI ' + pkg.version, action, label, duration).send(function() {
// we could handle errors here, but we won't
resolve();
});
} else {
resolve();
}
});
};