UNPKG

t-comm

Version:

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

52 lines (49 loc) 1.57 kB
import _typeof from '@babel/runtime/helpers/typeof'; import { _ as __assign } from '../tslib.es6-096fffdd.js'; function parseOptions(options, key) { var _a; if (key === void 0) { key = 'msg'; } var innerOptions = {}; if (typeof options === 'string') { innerOptions = (_a = {}, _a[key] = options, _a); } else if (_typeof(options) === 'object') { innerOptions = options; } innerOptions = Object.keys(innerOptions).reduce(function (acc, item) { var value = innerOptions[item]; acc[item] = _typeof(value) === 'object' ? JSON.stringify(value) : value; return acc; }, {}); return innerOptions; } function aegisReportInfoV2(mAegisV2, options, method) { if (method === void 0) { method = 'info'; } if (!mAegisV2 || !options || !method) return; try { var innerOptions = parseOptions(options, 'msg'); mAegisV2[method](__assign({}, innerOptions)); } catch (err) { console.log('[reportInfo] error', err); } } function aegisReportErrorV2(mAegisV2, options) { return aegisReportInfoV2(mAegisV2, options, 'error'); } function aegisReportV2(mAegisV2, options) { return aegisReportInfoV2(mAegisV2, options, 'report'); } function aegisReportEventV2(mAegisV2, options) { if (!mAegisV2 || !options) return; try { var innerOptions = parseOptions(options, 'name'); if (!innerOptions.name) return; mAegisV2.reportEvent(__assign({}, innerOptions)); } catch (err) { console.log('[reportEvent] error', err); } } export { aegisReportErrorV2, aegisReportEventV2, aegisReportInfoV2, aegisReportV2 };