index.uts 824 B

123456789101112131415161718192021222324252627
  1. import { Report, ReportOptions, ReportSuccess, ReportErrorCode } from './interface.uts'
  2. import { ReportFailImpl } from "./unierror.uts"
  3. import { Stat } from './common/core/stat.uts'
  4. const stat = Stat.getInstance()
  5. export const report : Report = function (options : ReportOptions) {
  6. const name = options.name
  7. const option = options.options
  8. stat.appEvent(name, option, (type : boolean, code : ReportErrorCode) => {
  9. if (type) {
  10. const res : ReportSuccess = {
  11. errMsg: 'report:ok',
  12. }
  13. options.success?.(res)
  14. options.complete?.(res)
  15. } else {
  16. let err = new ReportFailImpl(code);
  17. options.fail?.(err)
  18. options.complete?.(err)
  19. }
  20. })
  21. }
  22. export { Stat } from './common/core/stat.uts'
  23. // --- 导出统计类型 ---
  24. export { UniStatOptions, UniStatCollectItemsOptions, ReportFail } from './interface.uts'