Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hi-bugly
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
hi-bugly
Commits
3a03bab4
提交
3a03bab4
authored
3月 21, 2024
作者:
jiangjun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增自定义异常上报
上级
53876ac0
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
97 行增加
和
12 行删除
+97
-12
HiBuglyPlugin.java
...oid/src/main/java/com/example/hi_bugly/HiBuglyPlugin.java
+7
-0
main.dart
example/lib/main.dart
+3
-2
HiBuglyPlugin.m
ios/Classes/HiBuglyPlugin.m
+28
-10
hi_bugly.dart
lib/hi_bugly.dart
+14
-0
hi_bugly_method_channel.dart
lib/hi_bugly_method_channel.dart
+30
-0
hi_bugly_platform_interface.dart
lib/hi_bugly_platform_interface.dart
+9
-0
hi_bugly_test.dart
test/hi_bugly_test.dart
+6
-0
没有找到文件。
android/src/main/java/com/example/hi_bugly/HiBuglyPlugin.java
浏览文件 @
3a03bab4
...
@@ -46,6 +46,13 @@ public class HiBuglyPlugin implements FlutterPlugin, MethodCallHandler {
...
@@ -46,6 +46,13 @@ public class HiBuglyPlugin implements FlutterPlugin, MethodCallHandler {
CrashReport
.
initCrashReport
(
flutterPluginBinding
.
getApplicationContext
(),
appID
,
debug
);
CrashReport
.
initCrashReport
(
flutterPluginBinding
.
getApplicationContext
(),
appID
,
debug
);
result
.
success
(
true
);
result
.
success
(
true
);
break
;
break
;
case
"postException"
:
String
message
=
""
;
if
(
call
.
hasArgument
(
"message"
))
{
message
=
call
.
argument
(
"message"
);
}
CrashReport
.
postCatchedException
(
new
Throwable
(
message
));
break
;
default
:
default
:
result
.
notImplemented
();
result
.
notImplemented
();
break
;
break
;
...
...
example/lib/main.dart
浏览文件 @
3a03bab4
...
@@ -30,8 +30,9 @@ class _MyAppState extends State<MyApp> {
...
@@ -30,8 +30,9 @@ class _MyAppState extends State<MyApp> {
body:
Column
(
body:
Column
(
children:
[
children:
[
MaterialButton
(
MaterialButton
(
onPressed:
()
{
onPressed:
()
async
{
HiBugly
.
initialize
(
appID:
'123456'
,
debug:
true
);
await
HiBugly
.
initialize
(
appID:
'123456'
,
debug:
true
);
HiBugly
.
postException
(
name:
'异常名'
,
reason:
'异常原因'
,
callStack:
'异常堆栈'
,
extraInfo:
'额外信息'
);
},
},
child:
const
Text
(
'初始化'
),
child:
const
Text
(
'初始化'
),
),
),
...
...
ios/Classes/HiBuglyPlugin.m
浏览文件 @
3a03bab4
...
@@ -11,16 +11,34 @@
...
@@ -11,16 +11,34 @@
}
}
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
([
@"initialize"
isEqualToString
:
call
.
method
])
{
NSString
*
method
=
call
.
method
;
NSString
*
appID
=
call
.
arguments
[
@"appID"
];
if
([
method
isEqualToString
:
@"initialize"
])
{
BOOL
debug
=
call
.
arguments
[
@"debug"
];
NSString
*
appID
=
call
.
arguments
[
@"appID"
];
BuglyConfig
*
config
=
[[
BuglyConfig
alloc
]
init
];
BOOL
debug
=
call
.
arguments
[
@"debug"
];
config
.
debugMode
=
debug
;
BuglyConfig
*
config
=
[[
BuglyConfig
alloc
]
init
];
[
Bugly
startWithAppId
:
appID
config
:
config
];
config
.
debugMode
=
debug
;
result
([
NSNumber
numberWithBool
:
YES
]);
[
Bugly
startWithAppId
:
appID
config
:
config
];
}
else
{
result
([
NSNumber
numberWithBool
:
YES
]);
result
(
FlutterMethodNotImplemented
);
}
}
else
if
([
method
isEqualToString
:
@"postException"
])
{
NSString
*
name
=
call
.
arguments
[
@"name"
];
NSString
*
reason
=
call
.
arguments
[
@"reason"
];
// 此调用栈为 dart 调用栈,放入扩展信息
NSString
*
callStack
=
call
.
arguments
[
@"callStack"
];
NSString
*
extraInfo
=
call
.
arguments
[
@"extraInfo"
];
[
Bugly
reportExceptionWithCategory
:
3
name
:
name
reason:
reason
callStack:
@[]
extraInfo:
@{
@"dartCallStack"
:
callStack
,
@"extraInfo"
:
extraInfo
,
}
terminateApp:
NO
];
}
else
{
result
(
FlutterMethodNotImplemented
);
}
}
}
@end
@end
lib/hi_bugly.dart
浏览文件 @
3a03bab4
...
@@ -10,4 +10,18 @@ class HiBugly {
...
@@ -10,4 +10,18 @@ class HiBugly {
debug:
debug
,
debug:
debug
,
);
);
}
}
static
postException
({
String
name
=
''
,
String
reason
=
''
,
String
callStack
=
''
,
String
extraInfo
=
''
,
})
{
HiBuglyPlatform
.
instance
.
postException
(
name:
name
,
reason:
reason
,
callStack:
callStack
,
extraInfo:
extraInfo
,
);
}
}
}
lib/hi_bugly_method_channel.dart
浏览文件 @
3a03bab4
import
'dart:io'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
...
@@ -22,4 +24,32 @@ class MethodChannelHiBugly extends HiBuglyPlatform {
...
@@ -22,4 +24,32 @@ class MethodChannelHiBugly extends HiBuglyPlatform {
},
},
);
);
}
}
@override
void
postException
({
String
name
=
''
,
String
reason
=
''
,
String
callStack
=
''
,
String
extraInfo
=
''
,
})
{
if
(
Platform
.
isAndroid
)
{
final
message
=
{
'name'
:
name
,
'reason'
:
reason
,
'callStack'
:
callStack
,
'extraInfo'
:
extraInfo
,
};
methodChannel
.
invokeMethod
(
'postException'
,
{
'message'
:
message
.
toString
()},
);
}
else
{
methodChannel
.
invokeMethod
(
'postException'
,
{
'name'
:
name
,
'reason'
:
reason
,
'callStack'
:
callStack
,
'extraInfo'
:
extraInfo
,
});
}
}
}
}
lib/hi_bugly_platform_interface.dart
浏览文件 @
3a03bab4
...
@@ -29,4 +29,13 @@ abstract class HiBuglyPlatform extends PlatformInterface {
...
@@ -29,4 +29,13 @@ abstract class HiBuglyPlatform extends PlatformInterface {
})
{
})
{
throw
UnimplementedError
(
'initialize() has not been implemented.'
);
throw
UnimplementedError
(
'initialize() has not been implemented.'
);
}
}
void
postException
({
String
name
=
''
,
String
reason
=
''
,
String
callStack
=
''
,
String
extraInfo
=
''
,
})
{
throw
UnimplementedError
(
'postException() has not been implemented.'
);
}
}
}
test/hi_bugly_test.dart
浏览文件 @
3a03bab4
...
@@ -14,6 +14,12 @@ class MockHiBuglyPlatform
...
@@ -14,6 +14,12 @@ class MockHiBuglyPlatform
// TODO: implement initialize
// TODO: implement initialize
throw
UnimplementedError
();
throw
UnimplementedError
();
}
}
@override
void
postException
({
String
name
=
''
,
String
reason
=
''
,
String
callStack
=
''
,
String
extraInfo
=
''
})
{
// TODO: implement postException
throw
UnimplementedError
();
}
}
}
void
main
(
)
{
void
main
(
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论