Blame view

lib/report.js 549 Bytes
dbcd2dae8   Adhidarma Hadiwinoto   Ready to test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  const MODULE_NAME = 'REPORT';
  
  const stringify = require('json-stringify-pretty-compact');
  
  const pull = require('komodo-sdk/gateway/pull');
  const logger = require('komodo-sdk/logger');
  
  module.exports = (xid, data) => {
      if (!data) return;
  
      logger.verbose(`${MODULE_NAME} BAACC918: Reporting to CORE`, {
          xid,
          data,
      });
  
      const reportMsg = JSON.parse(JSON.stringify(data));
      if (typeof reportMsg.message !== 'string') {
          reportMsg.message = stringify(reportMsg.message);
      }
  
      pull.report(reportMsg);
  };