Closes #47. Switch Analytics from Google Analytics to Segment.io
This commit is contained in:
parent
dc4339b81d
commit
fabed8fad3
|
@ -15,5 +15,8 @@
|
|||
"unused": true,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"smarttabs": true
|
||||
"smarttabs": true,
|
||||
"globals": {
|
||||
"atom": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ var beautifyPHP = require('./langs/php-beautify');
|
|||
var beautifyPython = require('./langs/python-beautify');
|
||||
var beautifyRuby = require('./langs/ruby-beautify');
|
||||
var beautifyLESS = require('./langs/less-beautify');
|
||||
var NA = require('nodealytics');
|
||||
var Analytics = require('analytics-node');
|
||||
var pkg = require('../package.json');
|
||||
|
||||
module.exports = {
|
||||
|
@ -121,30 +121,31 @@ module.exports = {
|
|||
unsupportedGrammar = true;
|
||||
}
|
||||
|
||||
// Google Analytics
|
||||
if (atom.config.get('atom-beautify.googleAnalytics')) {
|
||||
NA.initialize('UA-52729731-2', 'https://atom.io/packages/atom-beautify',
|
||||
function () {
|
||||
// category, action, label, value
|
||||
NA.trackEvent('grammar', grammar, function (err, resp) {
|
||||
// console.log(err, resp);
|
||||
// if (!err && resp.statusCode === 200) {
|
||||
// console.log('Event has been tracked with Google Analytics');
|
||||
// }
|
||||
});
|
||||
NA.trackEvent('version', pkg.version, function (err, resp) {
|
||||
// console.log(err, resp);
|
||||
// if (!err && resp.statusCode === 200) {
|
||||
// console.log('Event has been tracked with Google Analytics');
|
||||
// }
|
||||
});
|
||||
if (unsupportedGrammar) {
|
||||
NA.trackEvent('unsupportedGrammar', grammar, function (err, resp) {
|
||||
//
|
||||
// Analytics
|
||||
var analyticsWriteKey = 'u3c26xkae8';
|
||||
// Setup Analytics
|
||||
var analytics = new Analytics(analyticsWriteKey);
|
||||
if (!atom.config.get('atom-beautify._analyticsUserId')) {
|
||||
var uuid = require('node-uuid');
|
||||
atom.config.set('atom-beautify._analyticsUserId', uuid.v4());
|
||||
}
|
||||
// Setup Analytics User Id
|
||||
var userId = atom.config.get('atom-beautify._analyticsUserId');
|
||||
analytics.identify({
|
||||
userId: userId
|
||||
});
|
||||
var version = pkg.version;
|
||||
analytics.track({
|
||||
userId: atom.config.get('atom-beautify._analyticsUserId'),
|
||||
event: 'Beautify',
|
||||
properties: {
|
||||
grammar: grammar,
|
||||
version: version,
|
||||
options: allOptions,
|
||||
label: grammar,
|
||||
category: version
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -73,8 +73,9 @@
|
|||
"strip-json-comments": "^0.1.3",
|
||||
"js-yaml": "^3.0.2",
|
||||
"temp": "^0.8.0",
|
||||
"nodealytics": "0.0.6",
|
||||
"prettydiff": "^1.0.23"
|
||||
"prettydiff": "^1.0.23",
|
||||
"node-uuid": "^1.4.1",
|
||||
"analytics-node": "^1.0.2"
|
||||
},
|
||||
"activationEvents": [
|
||||
"beautify"
|
||||
|
|
Loading…
Reference in New Issue