index.uts 849 字节
Newer Older
M
mehaotian 已提交
1 2
import { Report, ReportOptions, ReportSuccess, ReportErrorCode } from './interface.uts'
import { ReportFailImpl } from "./unierror.uts"
M
mehaotian 已提交
3 4 5 6 7 8 9
import { Stat } from './common/core/stat.uts'
const stat = Stat.getInstance()


export const report : Report = function (options : ReportOptions) {
	const name = options.name
	const option = options.options
M
mehaotian 已提交
10 11
	stat.appEvent(name, option, (type : boolean, code : ReportErrorCode) => {
		if (type) {
M
mehaotian 已提交
12 13 14 15 16 17
			const res : ReportSuccess = {
				errMsg: 'report:ok',
			}
			options.success?.(res)
			options.complete?.(res)
		} else {
M
mehaotian 已提交
18
			let err = new ReportFailImpl(code);
M
mehaotian 已提交
19 20 21 22 23 24 25
			options.fail?.(err)
			options.complete?.(err)
		}
	})
}

export { Stat } from './common/core/stat.uts'
26
// --- 导出统计类型 ---
27
export { UniStatOptions, UniStatCollectItemsOptions, ReportFail } from './interface.uts'