diff --git a/configs/client-default.js b/configs/client-default.js index 3c5cbac5..ea4f66e0 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -156,6 +156,10 @@ module.exports = function(options) { staticPrefix: staticPrefix + "/plugins/c9.ide.layout.classic", defaultShow: options.local }, + { + packagePath: "plugins/c9.ide.metrics/metrics", + hosted: hosted + }, // Ace && Commands "plugins/c9.ide.keys/commands", diff --git a/configs/standalone.js b/configs/standalone.js index 22a63d77..7cad6942 100644 --- a/configs/standalone.js +++ b/configs/standalone.js @@ -150,6 +150,7 @@ module.exports = function(config, optimist) { "./c9.nodeapi/nodeapi", { packagePath: "./c9.vfs.standalone/standalone", + sdk: config.sdk, local: config.local, packed: argv.packed, collab: config.collab, diff --git a/plugins/c9.nodeapi/util.js b/plugins/c9.nodeapi/util.js index 9fbff737..9628e42c 100644 --- a/plugins/c9.nodeapi/util.js +++ b/plugins/c9.nodeapi/util.js @@ -463,7 +463,9 @@ function isPrimitive(arg) { exports.isPrimitive = isPrimitive; function isBuffer(arg) { - return arg instanceof Buffer; + // Not relevant outside of node + // return arg instanceof Buffer; + return false; } exports.isBuffer = isBuffer; diff --git a/plugins/c9.vfs.client/endpoint.js b/plugins/c9.vfs.client/endpoint.js index 102b5723..1ed7ee29 100644 --- a/plugins/c9.vfs.client/endpoint.js +++ b/plugins/c9.vfs.client/endpoint.js @@ -1,7 +1,7 @@ define(function(require, exports, module) { "use strict"; - main.consumes = ["Plugin", "auth", "http", "api", "error_handler"]; + main.consumes = ["Plugin", "auth", "http", "api", "error_handler", "metrics"]; main.provides = ["vfs.endpoint"]; return main; @@ -11,6 +11,7 @@ define(function(require, exports, module) { var http = imports.http; var api = imports.api; var errorHandler = imports.error_handler; + var metrics = imports.metrics; /***** Initialization *****/ @@ -168,8 +169,10 @@ define(function(require, exports, module) { // just take the first server that doesn't return an error (function tryNext(i) { - if (i >= servers.length) + if (i >= servers.length) { + metrics.increment("connect_failed_all", 1, true); return callback(new Error("Disconnected: Could not reach your workspace. Please try again later.")); + } var server = servers[i]; auth.request(server.url + "/" + options.pid, { diff --git a/plugins/c9.vfs.client/vfs.ping.js b/plugins/c9.vfs.client/vfs.ping.js index 13ae4c44..fcebcf6e 100644 --- a/plugins/c9.vfs.client/vfs.ping.js +++ b/plugins/c9.vfs.client/vfs.ping.js @@ -1,7 +1,7 @@ define(function(require, exports, module) { "use strict"; - main.consumes = ["Plugin", "ext", "c9", "vfs"]; + main.consumes = ["Plugin", "ext", "c9", "vfs", "metrics"]; main.provides = ["vfs.ping"]; return main; @@ -9,6 +9,7 @@ define(function(require, exports, module) { var Plugin = imports.Plugin; var c9 = imports.c9; var ext = imports.ext; + var metrics = imports.metrics; /***** Initialization *****/ diff --git a/plugins/c9.vfs.client/vfs_client.js b/plugins/c9.vfs.client/vfs_client.js index b44e2c30..0398223f 100644 --- a/plugins/c9.vfs.client/vfs_client.js +++ b/plugins/c9.vfs.client/vfs_client.js @@ -7,7 +7,10 @@ define(function(require, exports, module) { "use strict"; - main.consumes = ["Plugin", "auth", "vfs.endpoint", "dialog.error", "dialog.alert", "error_handler"]; + main.consumes = [ + "Plugin", "auth", "vfs.endpoint", "dialog.error", + "dialog.alert", "error_handler", "metrics" + ]; main.provides = ["vfs"]; return main; @@ -34,6 +37,7 @@ define(function(require, exports, module) { var hideError = errorDialog.hide; var showAlert = imports["dialog.alert"].show; var errorHandler = imports.error_handler; + var metrics = imports.metrics; var eio = require("engine.io"); var Consumer = require("vfs-socket/consumer").Consumer; @@ -50,7 +54,7 @@ define(function(require, exports, module) { var plugin = new Plugin("Ajax.org", main.consumes); var emit = plugin.getEmitter(); - // Give reference to vfs to plugin + // Give reference to vfs to plugins errorDialog.vfs = plugin; var buffer = []; @@ -209,6 +213,7 @@ define(function(require, exports, module) { vfsEndpoint.get(protocolVersion, function(err, urls) { if (err) { + metrics.increment("connect_failed", 1, true); if (!showErrorTimer) { showErrorTimer = setTimeout(function() { showVfsError(showErrorTimerMessage); diff --git a/plugins/c9.vfs.standalone/standalone.js b/plugins/c9.vfs.standalone/standalone.js index 55d2c8a4..ff449c2f 100644 --- a/plugins/c9.vfs.standalone/standalone.js +++ b/plugins/c9.vfs.standalone/standalone.js @@ -48,7 +48,7 @@ function plugin(options, imports, register) { imports.connect.use(api); api.get("/", function(req, res, next) { - res.writeHead(302, { "Location": "/ide.html" }); + res.writeHead(302, { "Location": options.sdk ? "/ide.html" : "/static/places.html" }); res.end(); }); diff --git a/plugins/c9.vfs.standalone/www/test.js b/plugins/c9.vfs.standalone/www/test.js index a4ac2afb..414b1b37 100644 --- a/plugins/c9.vfs.standalone/www/test.js +++ b/plugins/c9.vfs.standalone/www/test.js @@ -407,6 +407,10 @@ require([ } }, + "metrics": { + getLastPing: function() { throw Error("Not implemented"); }, + getLastest: function() { throw Error("Not implemented"); }, + }, error_handler: {reportError: function(){}}, installer: { show: function(){} diff --git a/settings/standalone.js b/settings/standalone.js index 92a162c9..11821818 100644 --- a/settings/standalone.js +++ b/settings/standalone.js @@ -11,6 +11,7 @@ module.exports = function(manifest, installPath) { var builders = require("../plugins/c9.ide.run.build/builders_list"); var workspaceDir = path.resolve(__dirname + "/../"); + var sdk = !path.existsSync(workspaceDir + "/.sdkconfig.js"); if (process.platform == "win32" && process.env.HOME === undefined) { process.env.HOME = process.env.HOMEDRIVE + process.env.HOMEPATH; @@ -37,6 +38,7 @@ module.exports = function(manifest, installPath) { home: home, uid: "-1", dev: true, + sdk: sdk, pid: process.pid, port: process.env.PORT || 8181, host: process.env.IP || "0.0.0.0",