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

26 wiersze
792 B
JavaScript

define(function(require, exports, module) {
"use strict";
var hasInternalDomain = require("c9/has-internal-domain");
var hasInternalTestName = require("c9/has-internal-test-name");
function skipAnalytics(user, allowUnauthorized) {
if (!user) return true;
if (!user.id && !user.uid) return true; // users without an id should never reach the Segment library
if (!allowUnauthorized && hasUnauthorizedId(user)) return true;
if (hasInternalTestName(user)) return true;
if (hasInternalDomain(user.email)) return true;
return false;
}
function hasUnauthorizedId(user) {
if (user.id === -1) return true;
if (!user.id && user.uid === -1) return true;
}
module.exports = skipAnalytics;
});