Dubhe
Committed by GitHub

feat: 添加错误上报功能并引入错误模型类

1 import 'package:auto_track/auto_track/config/queue.dart'; 1 import 'package:auto_track/auto_track/config/queue.dart';
2 import 'package:auto_track/auto_track/drag/drag_info.dart'; 2 import 'package:auto_track/auto_track/drag/drag_info.dart';
  3 +import 'package:auto_track/auto_track/utils/error_model.dart';
3 import 'package:auto_track/auto_track/utils/track_model.dart'; 4 import 'package:auto_track/auto_track/utils/track_model.dart';
4 5
5 import '../click/click_info.dart'; 6 import '../click/click_info.dart';
@@ -99,6 +100,10 @@ class Track { @@ -99,6 +100,10 @@ class Track {
99 _TrackPlugin.customEvent(type, params); 100 _TrackPlugin.customEvent(type, params);
100 AutoTrackLogger.getInstance().debug('track custom_event => $params'); 101 AutoTrackLogger.getInstance().debug('track custom_event => $params');
101 } 102 }
  103 +
  104 + void reportError(Object error, StackTrace stack) {
  105 + _TrackPlugin.customEvent('error', ErrorModel(error: error, stack: stack).toMap());
  106 + }
102 } 107 }
103 108
104 class _TrackPlugin { 109 class _TrackPlugin {
  1 +class ErrorModel {
  2 + final Object error;
  3 + final StackTrace stack;
  4 +
  5 + ErrorModel({required this.error, required this.stack});
  6 +
  7 + Map<String, dynamic> toMap() {
  8 + return {
  9 + 'error': error.toString(),
  10 + 'stack': stack.toString(),
  11 + 'key': error.runtimeType.toString()
  12 + };
  13 + }
  14 +}
1 name: auto_track 1 name: auto_track
2 description: "Auto Track Plugin" 2 description: "Auto Track Plugin"
3 -version: 0.0.3 3 +version: 0.0.4
4 homepage: https://github.com/epoll-j/auto_track_plugin 4 homepage: https://github.com/epoll-j/auto_track_plugin
5 5
6 environment: 6 environment: