diff --git a/README.md b/README.md index d9176bc98..c4d3a5dca 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/atom-beautify.js b/lib/atom-beautify.js index f367b8bb6..ed1fd65cf 100644 --- a/lib/atom-beautify.js +++ b/lib/atom-beautify.js @@ -297,7 +297,7 @@ function handleSaveEvent() { } plugin.configDefaults = _.merge({ - googleAnalytics: true, + analytics: true, beautifyOnSave: false }, defaultLanguageOptions); diff --git a/lib/language-options.js b/lib/language-options.js index 0d2e51ddf..8fb867e80 100644 --- a/lib/language-options.js +++ b/lib/language-options.js @@ -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 + } + }); + } },