Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Removing Application Insights Telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
devinb authored and devinb committed Apr 17, 2018
1 parent 6d1f708 commit e600b0e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 110 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -58,11 +58,11 @@ See [Contributing][contributingLink] for guidelines
- **Q: Are you taking feedback?**
- **A:** Of course. Please open an issue at [yodockerissues] or choose to [contribute][contributingLink].

## Collecting usage data
Generator-docker collects anonymized data on the options you selected in the tool to understand and improve the experience. You are given a choice to opt-in or opt-out first time you run the tool. If you opt-in and decide to opt-out later, simply delete the `~/.config/configstore/generator-docker.json` file from your machine.
However, we really need your feedback, so please help us help you by opting in.

## Version History

###v0.0.36
+ Removed Application Insights telemetry

###v0.0.35
+ Added support for .Net Core Console Apps.
+ Updated Docker for Windows beta address to http://localhost
Expand Down
94 changes: 0 additions & 94 deletions generators/app/index.js
Expand Up @@ -14,7 +14,6 @@ var NodejsHelper = require('./nodejsHelper.js');
var GolangHelper = require('./golangHelper.js');
var DotNetHelper = require('./dotnetHelper.js');
var Configstore = require('configstore');
var appInsights = require('applicationinsights');
var os = require('os');
var uuid = require('node-uuid');

Expand Down Expand Up @@ -42,9 +41,6 @@ var updateProgramCSNoteForUser = null;

// Application insights variables.
var pkg = require(__dirname + '/../../package.json');
var AppInsightsOptInName = 'appInsightsOptIn';
var AppInsightsUserIdName = 'userId';
var AppInsightsKey = '21098969-0721-47bc-87cb-e346d186a9f5';
var trackData = false;
var userId = '';

Expand Down Expand Up @@ -339,99 +335,10 @@ function end() {
this.log(updateProjectJsonNoteForUser);
}

logData();
this.log('Your project is now ready to run in a Docker container!');
this.log('Run ' + chalk.green(util.getDestinationScriptName()) + ' to build a Docker image and run your app in a container.');
}

/**
* Sends the data to application insights.
*/
function logData() {
if (!trackData) {
return;
}

if (DockerGenerator.config !== undefined && DockerGenerator.config.get('runningTests') !== undefined) {
return;
}

var client = appInsights.getClient(AppInsightsKey);
client.config.maxBatchIntervalMs = 1000;
appInsights.setup(AppInsightsKey).start();

client.trackEvent('YoDockerLaunch', {
'userId': userId,
'version': pkg.version,
'osPlatform': os.platform(),
'projectType': projectType,
'portNumber': portNumber,
'imageName': imageName,
'isWebProject': isWebProject === undefined ? 'undefined' : isWebProject,
'baseImageName': imageName === undefined ? 'undefined' : baseImageName
});

// Workaround for https://github.com/Microsoft/ApplicationInsights-node.js/issues/54
appInsights.setAutoCollectPerformance(false);
}

/**
* Prompts for data tracking permission and sets up the global opt-in.
*/
function handleAppInsights(yo) {
// Config is stored at: ~/.config/configstore/generator-docker.json
var config = new Configstore(pkg.name);

if (config.get('runningTests') !== undefined) {
return;
}

if (config.get(AppInsightsOptInName) === undefined) {
var done = yo.async();
var q = {
type: 'confirm',
name: 'optIn',
message: 'Generator-docker would like to collect anonymized data\n' +
'on the options you selected to understand and improve your experience.\n' +
'To opt out later, you can delete ' + chalk.red('~/.config/configstore/' + pkg.name + '.json.\n') +
'Will you help us help you and your fellow developers?',
default: true
};

yo.prompt(q, function (props) {
trackData = props.optIn;

// Set the userId only if user opted-in.
userId = trackData ? uuid.v1() : '';

config.set(AppInsightsOptInName, trackData);
config.set(AppInsightsUserIdName, userId);

var client = appInsights.getClient(AppInsightsKey);
client.config.maxBatchIntervalMs = 1000;
appInsights.setup(AppInsightsKey).start();

client.trackEvent('YoDockerCollectData', {
'opt-in': trackData.toString(),
'userId': userId
});

appInsights.setAutoCollectPerformance(false);

done();
}.bind(yo));
} else {
trackData = config.get(AppInsightsOptInName);
userId = config.get(AppInsightsUserIdName);

// Create a user Id for opted-in users.
if (trackData && userId === undefined) {
userId = uuid.v1();
config.set(AppInsightsUserIdName, userId);
}
}
}

/**
* Docker Generator.
*/
Expand All @@ -442,7 +349,6 @@ var DockerGenerator = yeoman.generators.Base.extend({

init: function () {
this.log(yosay('Welcome to the ' + chalk.red('Docker') + ' generator!' + chalk.green('\nLet\'s add Docker container magic to your app!')));
handleAppInsights(this);
},
askFor: showPrompts,
writing: function () {
Expand Down
16 changes: 8 additions & 8 deletions test/dotnettests.js
Expand Up @@ -108,7 +108,7 @@ describe('.NET RC1 project file creation (Web project)', function () {
.inTmpDir(function (dir) {
createTestProjectJson(dir); })
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'dotnet', isWebProject: true, baseImageName: 'aspnet:1.0.0-rc1-update1', imageName: 'testimagename' })
.on('end', done);
});
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('.NET RC1 project file creation (Non Web project)', function () {
.inTmpDir(function (dir) {
createTestProjectJson(dir); })
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'dotnet', isWebProject: false, baseImageName: 'aspnet:1.0.0-rc1-update1', imageName: 'testimagename' })
.on('end', done);
});
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('.NET RC2 project file creation (Web project)', function () {
createTestProjectJson(dir);
createTestProgramCS(dir); })
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'dotnet', isWebProject: true, baseImageName: 'dotnet:1.0.0-preview1', imageName: 'testimagename' })
.on('end', done);
});
Expand Down Expand Up @@ -441,7 +441,7 @@ describe('.NET RC2 project file creation (Non Web project)', function () {
createTestProjectJson(dir);
createTestProgramCS(dir); })
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return { "runningTests": true }; })
.withPrompts({ projectType: 'dotnet', isWebProject: false, baseImageName: 'dotnet:1.0.0-preview1', imageName: 'testimagename' })
.on('end', done);
});
Expand Down Expand Up @@ -568,7 +568,7 @@ describe('.NET RTM project file creation (Web project)', function () {
createTestProgramCS(dir);
})
.withLocalConfig(function () {
return { "appInsightsOptIn": false, "runningTests": true };
return {"runningTests": true };
})
.withPrompts({ projectType: 'dotnet', isWebProject: true, baseImageName: 'dotnet:1.0.0-preview2-sdk', imageName: 'testimagename' })
.on('end', done);
Expand Down Expand Up @@ -691,7 +691,7 @@ describe('.NET RTM project file creation (Non Web project)', function () {
createTestProgramCS(dir);
})
.withLocalConfig(function () {
return { "appInsightsOptIn": false, "runningTests": true };
return {"runningTests": true };
})
.withPrompts({ projectType: 'dotnet', isWebProject: false, baseImageName: 'dotnet:1.0.0-preview2-sdk', imageName: 'testimagename' })
.on('end', done);
Expand Down Expand Up @@ -812,7 +812,7 @@ describe('.NET RC1 project file creation when web command exists', function () {
.inTmpDir(function(dir) {
createTestProjectJson(dir, 'EXISTING_WEB_COMMAND'); })
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'dotnet', baseImageName: 'aspnet:1.0.0-rc1-update1' })
.on('end', done);
});
Expand All @@ -835,7 +835,7 @@ describe('.NET RC2 project file creation when UseUrls exists', function () {
createTestProjectJson(dir);
createTestProgramCSWithUseUrls(dir); })
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'dotnet', baseImageName: 'dotnet:1.0.0-preview1' })
.on('end', done);
});
Expand Down
4 changes: 2 additions & 2 deletions test/golangtests.js
Expand Up @@ -13,7 +13,7 @@ describe('Golang project file creation (Non Web project)', function () {
before(function (done) {
helpers.run(path.join( __dirname, '../generators/app'))
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'golang', isWebProject: false, imageName: 'testimagename' })
.on('end', done);
});
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('Golang project file creation (Web project)', function () {
before(function (done) {
helpers.run(path.join( __dirname, '../generators/app'))
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'golang', isWebProject: true, imageName: 'testimagename' })
.on('end', done);
});
Expand Down
4 changes: 2 additions & 2 deletions test/nodejstests.js
Expand Up @@ -13,7 +13,7 @@ describe('Node.js project file creation (Non Web project)', function () {
before(function (done) {
helpers.run(path.join( __dirname, '../generators/app'))
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'nodejs', isWebProject: false, imageName: 'testimagename' })
.on('end', done);
});
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('Node.js project file creation (Web project)', function () {
before(function (done) {
helpers.run(path.join( __dirname, '../generators/app'))
.withLocalConfig(function() {
return { "appInsightsOptIn": false, "runningTests": true }; })
return {"runningTests": true }; })
.withPrompts({ projectType: 'nodejs', isWebProject: true, imageName: 'testimagename' })
.on('end', done);
});
Expand Down

0 comments on commit e600b0e

Please sign in to comment.