See #47. Update configuration to allow users to disable analytics.

This commit is contained in:
Glavin Wiechert 2014-08-03 23:51:40 -04:00
parent 7ce01efc8a
commit 8d90b30448
3 changed files with 38 additions and 30 deletions

View File

@ -58,11 +58,13 @@ For example:
- `beautifyOnSave`
You can also choose to beautify on every file save.
- `googleAnalytics`
There is Google Analytics to track what languages
- `analytics`
There is [Segment.io](https://segment.io/),
which forwards the data to [Google Analytics](http://www.google.com/analytics/),
to track what languages
are being used the most and other stats.
Everything is anonymized and no personal information,
such as source code, is sent to Google.
such as source code, is sent.
See https://github.com/Glavin001/atom-beautify/issues/47
for more details.

View File

@ -297,7 +297,7 @@ function handleSaveEvent() {
}
plugin.configDefaults = _.merge({
googleAnalytics: true,
analytics: true,
beautifyOnSave: false
}, defaultLanguageOptions);

View File

@ -20,12 +20,16 @@ var beautifyCoffeeScript = require('./langs/coffeescript-beautify');
// Misc
var Analytics = require('analytics-node');
var pkg = require('../package.json');
// Analytics
var analyticsWriteKey = 'u3c26xkae8';
module.exports = {
// Supported unique configuration keys
// Used for detecting nested configurations in .jsbeautifyrc
languages: ['js', 'html', 'css', 'sql', 'php', 'python', 'ruby','coffeescript'],
languages: ['js', 'html', 'css', 'sql', 'php', 'python', 'ruby',
'coffeescript'
],
// Default options per language
defaultLanguageOptions: {
@ -85,7 +89,8 @@ module.exports = {
beautifyCompleted(text);
break;
case 'CoffeeScript':
beautifyCoffeeScript(text, self.getOptions('js', allOptions), beautifyCompleted);
beautifyCoffeeScript(text, self.getOptions('js', allOptions),
beautifyCompleted);
break;
case 'Handlebars':
// jshint ignore: start
@ -127,31 +132,32 @@ module.exports = {
unsupportedGrammar = true;
}
// 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
// Check if Analytics is enabled
if (atom.config.get('atom-beautify.analytics')) {
// 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
}
});
}
},