2015-10-23 11:46:43 +00:00
|
|
|
if (define === undefined) {
|
|
|
|
var define = function(fn) {
|
|
|
|
fn(require, exports, module);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
define(function(require, exports, module) {
|
|
|
|
"use strict";
|
2015-12-08 11:56:38 +00:00
|
|
|
|
2015-10-23 11:46:43 +00:00
|
|
|
var hasInternalDomain = require("c9/has-internal-domain");
|
2015-11-23 18:35:15 +00:00
|
|
|
var hasInternalTestName = require("c9/has-internal-test-name");
|
2015-10-23 11:46:43 +00:00
|
|
|
|
2016-01-25 10:24:23 +00:00
|
|
|
function skipAnalytics(userId, name, email, allowUnauthorized) {
|
|
|
|
|
2016-01-25 13:27:38 +00:00
|
|
|
if (typeof userId == "object") {
|
2016-01-25 10:24:23 +00:00
|
|
|
var user = userId;
|
2016-01-25 13:27:38 +00:00
|
|
|
return skipAnalytics(user.id, user.name || user.username, user.email, name); // make it backwards compatible for the client
|
2016-01-25 10:24:23 +00:00
|
|
|
}
|
|
|
|
|
2016-01-22 15:59:35 +00:00
|
|
|
if (!allowUnauthorized && userId === -1) return true;
|
2016-01-21 09:18:25 +00:00
|
|
|
|
2016-01-25 10:24:23 +00:00
|
|
|
if (!userId) return true;
|
2015-11-23 18:35:15 +00:00
|
|
|
|
2016-01-25 10:24:23 +00:00
|
|
|
if (hasInternalTestName(name)) return true;
|
|
|
|
if (hasInternalDomain(email)) return true;
|
2015-10-23 11:46:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = skipAnalytics;
|
|
|
|
});
|