Skip to content

Commit

Permalink
See #47. Update configuration to allow users to disable analytics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Aug 4, 2014
1 parent 7ce01ef commit 8d90b30
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 30 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion lib/atom-beautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function handleSaveEvent() {
}

plugin.configDefaults = _.merge({
googleAnalytics: true,
analytics: true,
beautifyOnSave: false
}, defaultLanguageOptions);

Expand Down
58 changes: 32 additions & 26 deletions lib/language-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
});
}

},

Expand Down

0 comments on commit 8d90b30

Please sign in to comment.