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,
|
"unused": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"trailing": 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 beautifyPython = require('./langs/python-beautify');
|
||||||
var beautifyRuby = require('./langs/ruby-beautify');
|
var beautifyRuby = require('./langs/ruby-beautify');
|
||||||
var beautifyLESS = require('./langs/less-beautify');
|
var beautifyLESS = require('./langs/less-beautify');
|
||||||
var NA = require('nodealytics');
|
var Analytics = require('analytics-node');
|
||||||
var pkg = require('../package.json');
|
var pkg = require('../package.json');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -121,30 +121,31 @@ module.exports = {
|
||||||
unsupportedGrammar = true;
|
unsupportedGrammar = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google Analytics
|
// Analytics
|
||||||
if (atom.config.get('atom-beautify.googleAnalytics')) {
|
var analyticsWriteKey = 'u3c26xkae8';
|
||||||
NA.initialize('UA-52729731-2', 'https://atom.io/packages/atom-beautify',
|
// Setup Analytics
|
||||||
function () {
|
var analytics = new Analytics(analyticsWriteKey);
|
||||||
// category, action, label, value
|
if (!atom.config.get('atom-beautify._analyticsUserId')) {
|
||||||
NA.trackEvent('grammar', grammar, function (err, resp) {
|
var uuid = require('node-uuid');
|
||||||
// console.log(err, resp);
|
atom.config.set('atom-beautify._analyticsUserId', uuid.v4());
|
||||||
// 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) {
|
|
||||||
//
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
// 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",
|
"strip-json-comments": "^0.1.3",
|
||||||
"js-yaml": "^3.0.2",
|
"js-yaml": "^3.0.2",
|
||||||
"temp": "^0.8.0",
|
"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": [
|
"activationEvents": [
|
||||||
"beautify"
|
"beautify"
|
||||||
|
|
Loading…
Reference in New Issue