bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
60 lines (47 loc) • 1.45 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
function _requestify() {
const data = _interopRequireDefault(require("requestify"));
_requestify = function () {
return data;
};
return data;
}
function _globalConfig() {
const data = require("../api/consumer/lib/global-config");
_globalConfig = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../constants");
_constants = function () {
return data;
};
return data;
}
/* eslint no-console: 0 */
const ANALYTICS_DOMAIN = (0, _globalConfig().getSync)(_constants().CFG_ANALYTICS_DOMAIN_KEY) || _constants().DEFAULT_ANALYTICS_DOMAIN;
/**
* to debug errors here, first, change the parent to have { silent: false }, in analytics.js `fork` call.
*/
process.on('message', msg => {
// needed for the parent to make sure the child got the message
// without it, when the message is large, the parent exits before it totally sent
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
process.send('Got the message');
return _requestify().default.post(ANALYTICS_DOMAIN, msg, {
timeout: 1000
}).then(() => {
console.log('message has been sent');
process.exit();
}).fail(err => {
console.error('failed to send the message', err);
process.exit();
});
});
setTimeout(() => {
console.log('exit due to timeout');
process.exit();
}, 5000);
;