metricsHelper.prototype.sendAnonymousMetric = function()

in source/lambda/services/limitreport/lib/metrics-helper.js [40:84]


  metricsHelper.prototype.sendAnonymousMetric = function(metric, cb) {
    let _options = {
      hostname: 'metrics.awssolutionsbuilder.com',
      port: 443,
      path: '/generic',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
    };

    let request = https.request(_options, function(response) {
      // data is streamed in chunks from the server
      // so we have to handle the "data" event
      let buffer;
      let data;
      let route;

      response.on('data', function(chunk) {
        buffer += chunk;
      });

      response.on('end', function(err) {
        data = buffer;
        cb(null, data);
      });
    });

    if (metric) {
      request.write(JSON.stringify(metric));
    }

    request.end();

    request.on('error', e => {
      LOGGER.log('ERROR', e);
      cb(
        [
          'Error occurred when sending metric request.',
          JSON.stringify(_payload),
        ].join(' '),
        null
      );
    });
  };