c9-core/node_modules/c9/skip-analytics.js

30 wiersze
964 B
JavaScript
Czysty Zwykły widok Historia

2016-01-25 09:01:41 +00:00
if (typeof define === "undefined") {
var define = function(fn) {
fn(require, exports, module);
};
}
2015-10-23 11:46:43 +00:00
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-25 13:30:55 +00:00
if (!userId) return true; // users without an id should never reach the Segment library
2016-01-22 15:59:35 +00:00
if (!allowUnauthorized && userId === -1) 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;
});