UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

59 lines (56 loc) 1.91 kB
import { b as __awaiter, c as __generator } from '../tslib.es6-096fffdd.js'; import axios from '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 __awaiter(this, void 0, void 0, function () { var url, res; return __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({ 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]; } }); }); } export { reportToRdPlatform };