kopia lustrzana https://github.com/c9/core
Further refactoring
rodzic
8e61380009
commit
e0fd2d17fb
|
@ -10,12 +10,10 @@ define(function(require, exports, module) {
|
|||
var internalTestNames = ["c9test", "c9 test"];
|
||||
var regex = new RegExp("^(" + internalTestNames.join("|") + ")+");
|
||||
|
||||
function hasInternalTestName(user) {
|
||||
if (!user.name && !user.username) return false;
|
||||
function hasInternalTestName(name) {
|
||||
if (!name) return false;
|
||||
|
||||
var testedName = user.name ? user.name : user.username;
|
||||
|
||||
return regex.test(testedName);
|
||||
return regex.test(name);
|
||||
}
|
||||
|
||||
module.exports = hasInternalTestName;
|
||||
|
|
|
@ -10,13 +10,19 @@ define(function(require, exports, module) {
|
|||
var hasInternalDomain = require("c9/has-internal-domain");
|
||||
var hasInternalTestName = require("c9/has-internal-test-name");
|
||||
|
||||
function skipAnalytics(userId, user, allowUnauthorized) {
|
||||
function skipAnalytics(userId, name, email, allowUnauthorized) {
|
||||
|
||||
if (typeof userId == "object" && !name) {
|
||||
var user = userId;
|
||||
return skipAnalytics(user.id, user.name || user.username, user.email); // make it backwards for the client
|
||||
}
|
||||
|
||||
if (!allowUnauthorized && userId === -1) return true;
|
||||
|
||||
if (!userId || !user) return true;
|
||||
if (!userId) return true;
|
||||
|
||||
if (hasInternalTestName(user)) return true;
|
||||
if (hasInternalDomain(user.email)) return true;
|
||||
if (hasInternalTestName(name)) return true;
|
||||
if (hasInternalDomain(email)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ function plugin(options, imports, register) {
|
|||
|
||||
register(null, {
|
||||
"analytics": {
|
||||
log: function() {},
|
||||
track: function() {},
|
||||
identify: function() {},
|
||||
logClean: function() {},
|
||||
trackClean: function() {}
|
||||
updateTraits: function() {},
|
||||
alias: function() {},
|
||||
logClean: function() {} // huh??
|
||||
}
|
||||
});
|
||||
}
|
Ładowanie…
Reference in New Issue