influx-report.js 528 Bytes
const {logger} = require('./logger');

module.exports.sendMessage = (tick, time, type = 'ufo') => {
  if (!global.sender || !global.isProduction) {
    logger.error('[send-influx-message] error: sender not found or not in production');
    return;
  }

  try {
    global.sender.addMessage({
      measurement: 'spider_ufo_success_report',
      tags: {
        type
      },
      fields: {
        tick,
      },
      time
    });
  } catch (e) {
    logger.error(`[send-influx-message] error: ${JSON.stringify(e)}`);
  }
};