UNPKG

t-comm

Version:

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

47 lines (44 loc) 1.65 kB
import _typeof from '@babel/runtime/helpers/typeof'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; function parseOptions(options) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'msg'; var innerOptions = {}; if (typeof options === 'string') { innerOptions = _defineProperty({}, key, options); } 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) { var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info'; if (!mAegisV2 || !options || !method) return; try { var innerOptions = parseOptions(options, 'msg'); mAegisV2[method](Object.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(Object.assign({}, innerOptions)); } catch (err) { console.log('[reportEvent] error', err); } } export { aegisReportErrorV2, aegisReportEventV2, aegisReportInfoV2, aegisReportV2 };