How to use the belter/src.isBrowser function in belter

To help you get started, we’ve selected a few belter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krakenjs / beaver-logger / src / logger.js View on Github external
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
    }
github krakenjs / beaver-logger / src / logger.js View on Github external
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
github krakenjs / beaver-logger / dist / module / logger.js View on Github external
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
github krakenjs / beaver-logger / dist / module / logger.js View on Github external
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));
    }
github krakenjs / beaver-logger / dist / module / logger.js View on Github external
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) {
github krakenjs / beaver-logger / src / logger.js View on Github external
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 {
github krakenjs / beaver-logger / dist / module / logger.js View on Github external
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 = {};