Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
};
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
};
domain: domain || WILDCARD,
name
};
let requestListener = addRequestListener({ name, win, domain }, listenerOptions);
if (options.once) {
let handler = listenerOptions.handler;
listenerOptions.handler = onceFunction(function listenOnce() : mixed | ZalgoPromise {
requestListener.cancel();
return handler.apply(this, arguments);
});
}
if (listenerOptions.window && options.errorOnClose) {
let interval = safeInterval(() => {
if (win && typeof win === 'object' && isWindowClosed(win)) {
interval.cancel();
listenerOptions.handleError(new Error('Post message target window is closed'));
}
}, 50);
}
return {
cancel() {
requestListener.cancel();
}
};
}
domain: domain || WILDCARD,
name: name
};
var requestListener = addRequestListener({ name: name, win: win, domain: domain }, listenerOptions);
if (options.once) {
var _handler = listenerOptions.handler;
listenerOptions.handler = onceFunction(function listenOnce() {
requestListener.cancel();
return _handler.apply(this, arguments);
});
}
if (listenerOptions.window && options.errorOnClose) {
var interval = safeInterval(function () {
if (win && (typeof win === 'undefined' ? 'undefined' : _typeof(win)) === 'object' && isWindowClosed(win)) {
interval.cancel();
listenerOptions.handleError(new Error('Post message target window is closed'));
}
}, 50);
}
return {
cancel: function cancel() {
requestListener.cancel();
}
};
}
const reqPromises = windowStore('requestPromises').getOrSet(win, () => []);
reqPromises.push(promise);
promise.catch(() => {
markResponseListenerErrored(hash);
deleteResponseListener(hash);
});
const totalAckTimeout = isWindowKnown(win) ? ACK_TIMEOUT_KNOWN : ACK_TIMEOUT;
const totalResTimeout = responseTimeout;
let ackTimeout = totalAckTimeout;
let resTimeout = totalResTimeout;
const interval = safeInterval(() => {
if (isWindowClosed(win)) {
return promise.reject(new Error(`Window closed for ${ name } before ${ responseListener.ack ? 'response' : 'ack' }`));
}
if (responseListener.cancelled) {
return promise.reject(new Error(`Response listener was cancelled for ${ name }`));
}
ackTimeout = Math.max(ackTimeout - RESPONSE_CYCLE_TIME, 0);
if (resTimeout !== -1) {
resTimeout = Math.max(resTimeout - RESPONSE_CYCLE_TIME, 0);
}
if (!responseListener.ack && ackTimeout === 0) {
return promise.reject(new Error(`No ack for postMessage ${ logName } in ${ getDomain() } in ${ totalAckTimeout }ms`));