mirror of
https://github.com/zhigang1992/firebase-tools.git
synced 2026-05-25 18:31:37 +08:00
* 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")
33 lines
846 B
JavaScript
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();
|
|
}
|
|
});
|
|
};
|