t-comm
Version:
专业、稳定、纯粹的工具库
63 lines (56 loc) • 1.99 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var _typeof = require('@babel/runtime/helpers/typeof');
var tslib_es6 = require('../tslib.es6-01322ba9.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
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__default["default"](options) === 'object') {
innerOptions = options;
}
innerOptions = Object.keys(innerOptions).reduce(function (acc, item) {
var value = innerOptions[item];
acc[item] = _typeof__default["default"](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](tslib_es6.__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(tslib_es6.__assign({}, innerOptions));
} catch (err) {
console.log('[reportEvent] error', err);
}
}
exports.aegisReportErrorV2 = aegisReportErrorV2;
exports.aegisReportEventV2 = aegisReportEventV2;
exports.aegisReportInfoV2 = aegisReportInfoV2;
exports.aegisReportV2 = aegisReportV2;