-
Notifications
You must be signed in to change notification settings - Fork 7
/
FlutterInternalInterfaceImpl.kt
79 lines (72 loc) · 2.28 KB
/
FlutterInternalInterfaceImpl.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package io.embrace.android.embracesdk
import io.embrace.android.embracesdk.capture.metadata.HostedSdkVersionInfo
import io.embrace.android.embracesdk.internal.EmbraceInternalInterface
import io.embrace.android.embracesdk.logging.EmbLogger
internal class FlutterInternalInterfaceImpl(
private val embrace: EmbraceImpl,
private val impl: EmbraceInternalInterface,
private val hostedSdkVersionInfo: HostedSdkVersionInfo,
private val logger: EmbLogger
) : EmbraceInternalInterface by impl, FlutterInternalInterface {
override fun setEmbraceFlutterSdkVersion(version: String?) {
if (embrace.isStarted()) {
if (version != null) {
hostedSdkVersionInfo.hostedSdkVersion = version
}
} else {
logger.logSdkNotInitialized("setEmbraceFlutterSdkVersion")
}
}
override fun setDartVersion(version: String?) {
if (embrace.isStarted()) {
if (version != null) {
hostedSdkVersionInfo.hostedPlatformVersion = version
}
} else {
logger.logSdkNotInitialized("setDartVersion")
}
}
override fun logHandledDartException(
stack: String?,
name: String?,
message: String?,
context: String?,
library: String?
) {
logDartException(stack, name, message, context, library, LogExceptionType.HANDLED)
}
override fun logUnhandledDartException(
stack: String?,
name: String?,
message: String?,
context: String?,
library: String?
) {
logDartException(stack, name, message, context, library, LogExceptionType.UNHANDLED)
}
private fun logDartException(
stack: String?,
name: String?,
message: String?,
context: String?,
library: String?,
exceptionType: LogExceptionType
) {
if (embrace.isStarted()) {
embrace.logMessage(
EventType.ERROR_LOG,
"Dart error",
null,
null,
stack,
exceptionType,
context,
library,
name,
message
)
} else {
logger.logSdkNotInitialized("logDartError")
}
}
}