Skip to content

Commit

Permalink
Merge pull request #11 from ayeung/master
Browse files Browse the repository at this point in the history
TIMOB-9067: Add analytics for sdk install and update
  • Loading branch information
cb1kenobi committed Oct 8, 2012
2 parents fad804a + 667e986 commit dfd0f73
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
16 changes: 16 additions & 0 deletions lib/commands/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var async = require('async'),
wrench = require('wrench'),
prompt = require('prompt'),
appc = require('node-appc'),
addAnalyticsEvent,
urls = {
branches: 'http://builds.appcelerator.com.s3.amazonaws.com/mobile/branches.json',
branch: 'http://builds.appcelerator.com.s3.amazonaws.com/mobile/$BRANCH/index.json',
Expand Down Expand Up @@ -124,6 +125,7 @@ exports.config = function (logger, config, cli) {
};

exports.run = function (logger, config, cli) {
addAnalyticsEvent = cli.addAnalyticsEvent;
function onSuccess(ver) {
if (cli.argv.default) {
logger.log(__('Saving SDK %s as the default.', ver.cyan));
Expand Down Expand Up @@ -286,6 +288,10 @@ function install(logger, argv, env, onSuccess) {
process.exit(1);
}
downloadSDK(logger, urls.build.replace(/\$BRANCH/, branch).replace(/\$FILENAME/, filename), version, env, onSuccess);
addAnalyticsEvent('sdk.install', {
version: version,
branch: branch,
});
});
});
} else {
Expand Down Expand Up @@ -321,6 +327,9 @@ function install(logger, argv, env, onSuccess) {
isLatest && logger.log(__('New version available! %s', version.cyan) + '\n');

downloadSDK(logger, releases[version], version, env, onSuccess);
addAnalyticsEvent('sdk.install', {
version: version
});
});
}
}
Expand Down Expand Up @@ -535,6 +544,10 @@ function update(logger, argv, env, onSuccess) {
process.exit(1);
}
downloadSDK(logger, urls.build.replace(/\$BRANCH/, branch).replace(/\$FILENAME/, filename), version, env, onSuccess);
addAnalyticsEvent('sdk.update', {
version: version,
branch: branch,
});
});
});
} else {
Expand All @@ -544,6 +557,9 @@ function update(logger, argv, env, onSuccess) {
logger.log(__("You're up-to-date. Version %s is currently the newest version available.", latest.cyan) + '\n');
} else if (argv.force || argv.install) {
downloadSDK(logger, releases[latest], latest, env, onSuccess);
addAnalyticsEvent('sdk.update', {
version: latest
});
} else {
logger.log(__('New version available! %s', latest.cyan) + '\n');
logger.log(__("Run '%s' to download and install", (argv.$ + ' sdk update --install').cyan) + '\n');
Expand Down
15 changes: 10 additions & 5 deletions lib/titanium.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,23 @@ require('i18n').configure({
updateFiles: false
});

// when the app exits, submit analytics
process.on('exit', function () {
cli.addAnalyticsEvent = appc.analytics.addEvent;
cli.sendAnalytics = sendAnalytics;

function sendAnalytics () {
// sadly, this will never be called on Windows if the user presses ctrl+c
appc.analytics.send({
appc.analytics.send(appc.util.mix({
appId: pkginfo.about.id,
appName: pkginfo.about.name,
appGuid: 'cf5c67ed-1c3b-494b-afe0-01b958ef0f40',
directory: path.join('~', '.titanium'),
version: pkginfo.version,
deployType: 'production'
});
});
}, appc.auth.status()));
}

// when the app exits, submit analytics
process.on('exit', sendAnalytics);

// find all built-in commands
env.scanCommands(env.commands, path.join(path.dirname(module.filename), 'commands'));
Expand Down
8 changes: 7 additions & 1 deletion locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@
"Xcode installation: %s": "Xcode installation: %s",
"Installed iOS SDKs: %s": "Installed iOS SDKs: %s",
"Installed iOS Simulators: %s": "Installed iOS Simulators: %s",
"iOS development certificates: %s": "iOS development certificates: %s",
"iOS distribution certificates: %s": "iOS distribution certificates: %s",
"iOS WWDR certificate: %s": "iOS WWDR certificate: %s",
"installed": "installed",
"not found": "not found",
Expand Down Expand Up @@ -451,6 +453,9 @@
"Writing application routing source file: %s": "Writing application routing source file: %s",
"Titanium symbol file already up-to-date: %s": "Titanium symbol file already up-to-date: %s",
"Writing application modules source file: %s": "Writing application modules source file: %s",
"Invalid required option \"--output-dir\"": "Invalid required option \"--output-dir\"",
"The debug host must be in the format \"host:port\".": "The debug host must be in the format \"host:port\".",
"Failed to create icons": "Failed to create icons",
"use the retina version of the iOS Simulator": "use the retina version of the iOS Simulator",
"Running application in iOS Simulator": "Running application in iOS Simulator",
"Terminating all iOS simulators": "Terminating all iOS simulators",
Expand Down Expand Up @@ -518,5 +523,6 @@
"Requires version %s, currently %s": "Requires version %s, currently %s",
"Command \"%s\" incompatible with this version of the Titanium CLI": "Command \"%s\" incompatible with this version of the Titanium CLI",
"Titanium CLI has not yet been configured": "Titanium CLI has not yet been configured",
"Run %s to run the setup wizard": "Run %s to run the setup wizard"
"Run %s to run the setup wizard": "Run %s to run the setup wizard",
"debug connection info; airkey and hosts required for %s and %s, ignored for %s": "debug connection info; airkey and hosts required for %s and %s, ignored for %s"
}

0 comments on commit dfd0f73

Please sign in to comment.