Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function track(payload = {}) : LoggerType {
if (!isBrowser()) {
return logger; // eslint-disable-line no-use-before-define
}
const trackingPayload : Payload = objFilter(payload);
for (const builder of trackingBuilders) {
extendIfDefined(trackingPayload, builder(trackingPayload));
}
print(LOG_LEVEL.DEBUG, 'track', trackingPayload);
tracking.push(trackingPayload);
return logger; // eslint-disable-line no-use-before-define
}
for (const builder of trackingBuilders) {
extendIfDefined(trackingPayload, builder(trackingPayload));
}
print(LOG_LEVEL.DEBUG, 'track', trackingPayload);
tracking.push(trackingPayload);
return logger; // eslint-disable-line no-use-before-define
}
function setTransport(newTransport : Transport) : LoggerType {
transport = newTransport;
return logger; // eslint-disable-line no-use-before-define
}
if (isBrowser()) {
safeInterval(flush, flushInterval);
}
const logger = {
debug,
info,
warn,
error,
track,
flush,
immediateFlush,
addPayloadBuilder,
addMetaBuilder,
addTrackingBuilder,
addHeaderBuilder,
setTransport
for (var _i8 = 0; _i8 < trackingBuilders.length; _i8++) {
var builder = trackingBuilders[_i8];
extendIfDefined(trackingPayload, builder(trackingPayload));
}
print(LOG_LEVEL.DEBUG, 'track', trackingPayload);
tracking.push(trackingPayload);
return logger; // eslint-disable-line no-use-before-define
}
function setTransport(newTransport) {
transport = newTransport;
return logger; // eslint-disable-line no-use-before-define
}
if (isBrowser()) {
safeInterval(flush, flushInterval);
}
var logger = {
debug: debug,
info: info,
warn: warn,
error: error,
track: track,
flush: flush,
immediateFlush: immediateFlush,
addPayloadBuilder: addPayloadBuilder,
addMetaBuilder: addMetaBuilder,
addTrackingBuilder: addTrackingBuilder,
addHeaderBuilder: addHeaderBuilder,
setTransport: setTransport
function log(level, event, payload) {
if (payload === void 0) {
payload = {};
}
if (!isBrowser()) {
return logger; // eslint-disable-line no-use-before-define
}
if (prefix) {
event = prefix + "_" + event;
}
var logPayload = _extends({}, objFilter(payload), {
timestamp: Date.now().toString()
});
for (var _i6 = 0; _i6 < payloadBuilders.length; _i6++) {
var builder = payloadBuilders[_i6];
extendIfDefined(logPayload, builder(logPayload));
}
function print(level, event, payload) {
if (!isBrowser() || !window.console || !window.console.log) {
return;
}
if (LOG_LEVEL_PRIORITY.indexOf(level) > LOG_LEVEL_PRIORITY.indexOf(logLevel)) {
return;
}
var args = [event];
args.push(payload);
if (payload.error || payload.warning) {
args.push('\n\n', payload.error || payload.warning);
}
try {
if (window.console[level] && window.console[level].apply) {
function print(level : $Values, event : string, payload : Payload) {
if (!isBrowser() || !window.console || !window.console.log) {
return;
}
if (LOG_LEVEL_PRIORITY.indexOf(level) > LOG_LEVEL_PRIORITY.indexOf(logLevel)) {
return;
}
const args = [ event ];
args.push(payload);
if (payload.error || payload.warning) {
args.push('\n\n', payload.error || payload.warning);
}
try {
return ZalgoPromise.try(function () {
if (!isBrowser() || window.location.protocol === PROTOCOL.FILE) {
return;
}
if (!events.length && !tracking.length) {
return;
}
var meta = {};
for (var _i2 = 0; _i2 < metaBuilders.length; _i2++) {
var builder = metaBuilders[_i2];
extendIfDefined(meta, builder(meta));
}
var headers = {};