t-comm
Version:
专业、稳定、纯粹的工具库
67 lines (60 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var tslib_es6 = require('../tslib.es6-01322ba9.js');
var axios = require('axios');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
var ReportType;
(function (ReportType) {
ReportType[ReportType["PERFORMANCE"] = 1] = "PERFORMANCE";
ReportType[ReportType["BUNDLE"] = 2] = "BUNDLE";
ReportType[ReportType["AUTO_TEST"] = 3] = "AUTO_TEST";
ReportType[ReportType["BUNDLE_MP"] = 4] = "BUNDLE_MP";
})(ReportType || (ReportType = {}));
var ReportPlatform;
(function (ReportPlatform) {
ReportPlatform[ReportPlatform["NOT_KNOWN"] = 0] = "NOT_KNOWN";
ReportPlatform[ReportPlatform["H5"] = 1] = "H5";
ReportPlatform[ReportPlatform["MP"] = 2] = "MP";
})(ReportPlatform || (ReportPlatform = {}));
/**
* 上报数据到研发平台
* @param {object} param 参数
* @param {object} param.data 上报数据
* @param {string} param.host 请求域名
* @param {ReportType} param.type 上报类型
* @param {ReportPlatform} param.platform 上报平台
* @returns 上报结果
*/
function reportToRdPlatform(_a) {
var data = _a.data,
host = _a.host,
_b = _a.type,
type = _b === void 0 ? 1 : _b,
_c = _a.platform,
platform = _c === void 0 ? 1 : _c;
return tslib_es6.__awaiter(this, void 0, void 0, function () {
var url, res;
return tslib_es6.__generator(this, function (_d) {
switch (_d.label) {
case 0:
url = host.includes('localhost:') ? "".concat(host, "/performance-report") : "".concat(host, "/rd-platform-cgi/performance-report");
return [4 /*yield*/, axios__default["default"]({
method: 'POST',
url: url,
data: {
data: data,
type: type,
platform: platform
}
})["catch"](function (err) {
console.log('[reportToRdPlatform] err', err);
})];
case 1:
res = _d.sent();
return [2 /*return*/, res.data];
}
});
});
}
exports.reportToRdPlatform = reportToRdPlatform;