@log-drop/react-native 1.0.1-beta8 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LogdropReactNative.podspec +1 -1
- package/README.md +28 -17
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/logdropreactnative/LogDropReactNative.kt +0 -3
- package/android/src/main/java/com/logdropreactnative/LogDropReactNativeConfig.kt +0 -15
- package/android/src/main/java/com/logdropreactnative/LogDropReactNativeModule.kt +5 -0
- package/ios/LogDropReactNative.swift +37 -49
- package/lib/module/LogDrop.js +1 -3
- package/lib/module/LogDrop.js.map +1 -1
- package/lib/module/LogDropConfig.js +1 -19
- package/lib/module/LogDropConfig.js.map +1 -1
- package/lib/module/LogDropReactNative.js.map +1 -1
- package/lib/module/utils/LogDropErrorTracking.js +18 -74
- package/lib/module/utils/LogDropErrorTracking.js.map +1 -1
- package/lib/module/utils/errorUtils.js +21 -20
- package/lib/module/utils/errorUtils.js.map +1 -1
- package/lib/module/utils/logdropDebugLogger.js +9 -0
- package/lib/module/utils/logdropDebugLogger.js.map +1 -0
- package/lib/typescript/src/LogDrop.d.ts.map +1 -1
- package/lib/typescript/src/LogDropConfig.d.ts +0 -9
- package/lib/typescript/src/LogDropConfig.d.ts.map +1 -1
- package/lib/typescript/src/LogDropReactNative.d.ts.map +1 -1
- package/lib/typescript/src/utils/LogDropErrorTracking.d.ts +0 -3
- package/lib/typescript/src/utils/LogDropErrorTracking.d.ts.map +1 -1
- package/lib/typescript/src/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/src/utils/logdropDebugLogger.d.ts +2 -0
- package/lib/typescript/src/utils/logdropDebugLogger.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/LogDrop.ts +1 -3
- package/src/LogDropConfig.ts +0 -24
- package/src/LogDropReactNative.ts +8 -9
- package/src/utils/LogDropErrorTracking.ts +25 -84
- package/src/utils/errorUtils.ts +27 -21
- package/src/utils/logdropDebugLogger.ts +7 -0
package/README.md
CHANGED
|
@@ -34,7 +34,6 @@ const config = new LogDropConfigBuilder()
|
|
|
34
34
|
.setApiKey('YOUR_API_KEY')
|
|
35
35
|
.setBaseUrl('YOUR_BASE_URL')
|
|
36
36
|
.setLoggingEnabled(true)
|
|
37
|
-
.setSensitiveInfoFilter(['^(?:\\d{4}[-\\s]?){3}\\d{4}$'])
|
|
38
37
|
.build();
|
|
39
38
|
|
|
40
39
|
LogDrop.init(config);
|
|
@@ -54,12 +53,39 @@ In `android/build.gradle`, add inside `allprojects.repositories`:
|
|
|
54
53
|
allprojects {
|
|
55
54
|
repositories {
|
|
56
55
|
google()
|
|
57
|
-
maven { url "https://
|
|
56
|
+
maven { url "https://artifactory.logdrop.io/repository/logdrop-android-sdk/" } // Add this line
|
|
57
|
+
maven { url "https://artifactory.logdrop.io/repository/logdrop-gradle-plugin/" } // Add this line
|
|
58
58
|
mavenCentral()
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
Then, add the following classpath dependencies to the buildscript section of `android/build.gradle`:
|
|
64
|
+
|
|
65
|
+
```gradle
|
|
66
|
+
classpath("io.logdrop.gradle:plugin:1.0.4")
|
|
67
|
+
classpath("io.logdrop.gradle:rnplugin:1.0.1")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To enable LogDrop integration, add the following plugins to your `android/app/build.gradle` file:
|
|
71
|
+
|
|
72
|
+
```gradle
|
|
73
|
+
apply plugin: "io.logdrop.gradle.plugin"
|
|
74
|
+
apply plugin: "io.logdrop.gradle.plugin.rn"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Create a file named logdrop-services.json under the `android/app` directory and add the following content:
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"base_url": "https://server.logdrop.io",
|
|
81
|
+
"projects": {
|
|
82
|
+
"com.example.app": {
|
|
83
|
+
"api_key": "YOUR_LOGDROP_API_KEY"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
63
89
|
### 2. Initialize LogDrop in `MainApplication.kt`
|
|
64
90
|
|
|
65
91
|
```kotlin
|
|
@@ -71,9 +97,6 @@ override fun onCreate() {
|
|
|
71
97
|
.apiKey("YOUR_API_KEY")
|
|
72
98
|
.baseUrl("YOUR_BASE_URL")
|
|
73
99
|
.logcatEnabled(true)
|
|
74
|
-
.sensitiveInfoFilter(
|
|
75
|
-
listOf(Regex("^(?:\\d{4}[-\\s]?){3}\\d{4}$"))
|
|
76
|
-
)
|
|
77
100
|
.build()
|
|
78
101
|
|
|
79
102
|
LogDropReactNative.initLogDrop(config)
|
|
@@ -151,18 +174,6 @@ LogDrop.onNewHmsPushToken(hmsToken);
|
|
|
151
174
|
|
|
152
175
|
---
|
|
153
176
|
|
|
154
|
-
## 🛡️ Sensitive Data Masking
|
|
155
|
-
|
|
156
|
-
Use regex patterns to filter out sensitive data before sending logs.
|
|
157
|
-
|
|
158
|
-
Example:
|
|
159
|
-
```ts
|
|
160
|
-
.setSensitiveInfoFilter(['^(?:\\d{4}[-\\s]?){3}\\d{4}$'])
|
|
161
|
-
```
|
|
162
|
-
This will mask any credit card-like patterns automatically.
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
177
|
## 🔑 API Keys
|
|
167
178
|
|
|
168
179
|
You can create and manage your API keys in the LogDrop Dashboard.
|
package/android/build.gradle
CHANGED
|
@@ -77,6 +77,6 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
77
77
|
dependencies {
|
|
78
78
|
implementation "com.facebook.react:react-android"
|
|
79
79
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
80
|
-
implementation "io.logdrop:sdk:1.0.
|
|
80
|
+
implementation "io.logdrop:sdk:1.0.7"
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -9,10 +9,7 @@ object LogDropReactNative {
|
|
|
9
9
|
config.apiKey?.let { apiKey(it) }
|
|
10
10
|
config.baseUrl?.let { baseUrl(it) }
|
|
11
11
|
config.isLoggingEnabled?.let { logcatEnabled(it) }
|
|
12
|
-
config.isCrashTrackingEnabled?.let { crashTrackingEnabled(it) }
|
|
13
12
|
config.initialIsSDKDisabledValue?.let { initialIsSDKDisabledValue(it) }
|
|
14
|
-
config.sensitiveInfoFilter?.let { sensitiveInfoFilter(it) }
|
|
15
|
-
config.isHttpLoggingEnabled?.let {httpLoggingEnabled(it)}
|
|
16
13
|
frameworkType(config.framework)
|
|
17
14
|
}.build())
|
|
18
15
|
}
|
|
@@ -7,22 +7,16 @@ class LogDropReactNativeConfig private constructor(
|
|
|
7
7
|
val apiKey: String?,
|
|
8
8
|
val baseUrl: String?,
|
|
9
9
|
val isLoggingEnabled: Boolean?,
|
|
10
|
-
val isCrashTrackingEnabled: Boolean?,
|
|
11
10
|
val initialIsSDKDisabledValue: Boolean?,
|
|
12
|
-
val sensitiveInfoFilter: List<Regex>?,
|
|
13
11
|
val context: Context,
|
|
14
12
|
val framework: FrameworkType,
|
|
15
|
-
val isHttpLoggingEnabled: Boolean?,
|
|
16
13
|
|
|
17
14
|
) {
|
|
18
15
|
class Builder(private val context: Context) {
|
|
19
16
|
private var apiKey: String? = null
|
|
20
17
|
private var baseUrl: String? = null
|
|
21
18
|
private var isLoggingEnabled: Boolean? = null
|
|
22
|
-
private var isCrashTrackingEnabled: Boolean? = null
|
|
23
|
-
private var isHttpLoggingEnabled: Boolean? = null
|
|
24
19
|
private var initialIsSDKDisabledValue: Boolean? = null
|
|
25
|
-
private var sensitiveInfoFilter: List<Regex>? = null
|
|
26
20
|
private var framework: FrameworkType = FrameworkType.REACT_NATIVE
|
|
27
21
|
|
|
28
22
|
fun apiKey(apiKey: String) = apply { this.apiKey = apiKey }
|
|
@@ -30,30 +24,21 @@ class LogDropReactNativeConfig private constructor(
|
|
|
30
24
|
fun logcatEnabled(isLoggingEnabled: Boolean) =
|
|
31
25
|
apply { this.isLoggingEnabled = isLoggingEnabled }
|
|
32
26
|
|
|
33
|
-
fun crashTrackingEnabled(isCrashTrackingEnabled: Boolean) =
|
|
34
|
-
apply { this.isCrashTrackingEnabled = isCrashTrackingEnabled }
|
|
35
27
|
|
|
36
28
|
fun initialIsSDKDisabledValue(initialIsSDKDisabledValue: Boolean) =
|
|
37
29
|
apply { this.initialIsSDKDisabledValue = initialIsSDKDisabledValue }
|
|
38
30
|
|
|
39
|
-
fun sensitiveInfoFilter(sensitiveInfoFilter: List<Regex>) =
|
|
40
|
-
apply { this.sensitiveInfoFilter = sensitiveInfoFilter }
|
|
41
31
|
|
|
42
32
|
fun framework(framework: FrameworkType) = apply { this.framework = framework }
|
|
43
33
|
|
|
44
|
-
fun httpLoggingEnabled(isHttpLoggingEnabled: Boolean?) = apply { this.isHttpLoggingEnabled = isHttpLoggingEnabled }
|
|
45
|
-
|
|
46
34
|
fun build(): LogDropReactNativeConfig {
|
|
47
35
|
return LogDropReactNativeConfig(
|
|
48
36
|
apiKey,
|
|
49
37
|
baseUrl,
|
|
50
38
|
isLoggingEnabled,
|
|
51
|
-
isCrashTrackingEnabled,
|
|
52
39
|
initialIsSDKDisabledValue,
|
|
53
|
-
sensitiveInfoFilter,
|
|
54
40
|
context,
|
|
55
41
|
framework,
|
|
56
|
-
isHttpLoggingEnabled,
|
|
57
42
|
)
|
|
58
43
|
}
|
|
59
44
|
}
|
|
@@ -64,6 +64,11 @@ class LogDropReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
64
64
|
LogDrop.w(tag, message, logFlowObject)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
@ReactMethod
|
|
68
|
+
fun saveCustomCrashReport(threadName: String, stackTrace: String, crashType: String) {
|
|
69
|
+
LogDrop.saveCrashReport(threadName, stackTrace, crashType)
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
companion object {
|
|
68
73
|
const val NAME = "LogDropReactNative"
|
|
69
74
|
}
|
|
@@ -2,85 +2,73 @@ import LogDropSDK
|
|
|
2
2
|
|
|
3
3
|
@objc(LogDropReactNative)
|
|
4
4
|
class LogDropReactNative: NSObject {
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
@objc
|
|
7
7
|
func initLogDrop(_ config: NSDictionary) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
builder.setFrameworkType(.reactNative)
|
|
32
|
-
|
|
33
|
-
if let crashTrackingEnabled = config["crashTrackingEnabled"] as? Bool {
|
|
34
|
-
builder.setCrashTrackingEnabled(crashTrackingEnabled)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if let httpLoggingEnabled = config["httpLoggingEnabled"] as? Bool {
|
|
38
|
-
builder.setIsHttpLoggingEnabled(httpLoggingEnabled)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let logDropConfig = builder.build()
|
|
42
|
-
LogDrop.initialize(with: logDropConfig)
|
|
8
|
+
let builder = LogDropConfig.Builder()
|
|
9
|
+
|
|
10
|
+
if let apiKey = config["apiKey"] as? String {
|
|
11
|
+
builder.setApiKey(apiKey)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if let baseUrl = config["baseUrl"] as? String {
|
|
15
|
+
builder.setBaseUrl(baseUrl)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if let defaultSDKDisabled = config["defaultSDKDisabled"] as? Bool {
|
|
19
|
+
builder.setDefaultSDKDisabledValue(defaultSDKDisabled)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if let isLoggingEnabled = config["isLoggingEnabled"] as? Bool {
|
|
23
|
+
builder.setLoggingEnabled(isLoggingEnabled)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
builder.setFrameworkType(.reactNative)
|
|
28
|
+
|
|
29
|
+
let logDropConfig = builder.build()
|
|
30
|
+
LogDrop.initialize(with: logDropConfig)
|
|
43
31
|
}
|
|
44
|
-
|
|
32
|
+
|
|
45
33
|
@objc
|
|
46
34
|
func i(_ tag: String, message: String, logFlow: NSDictionary?) {
|
|
47
35
|
let parsedFlow = LogFlowParser.from(dict: logFlow)
|
|
48
36
|
LogDrop.i(message, logFlow: parsedFlow, file: tag)
|
|
49
37
|
}
|
|
50
|
-
|
|
38
|
+
|
|
51
39
|
@objc
|
|
52
40
|
func d(_ tag: String, message: String, logFlow: NSDictionary?) {
|
|
53
41
|
let parsedFlow = LogFlowParser.from(dict: logFlow)
|
|
54
42
|
LogDrop.d(message, logFlow: parsedFlow, file: tag)
|
|
55
43
|
}
|
|
56
|
-
|
|
44
|
+
|
|
57
45
|
@objc
|
|
58
46
|
func w(_ tag: String, message: String, logFlow: NSDictionary?) {
|
|
59
47
|
let parsedFlow = LogFlowParser.from(dict: logFlow)
|
|
60
48
|
LogDrop.w(message, logFlow: parsedFlow, file: tag)
|
|
61
49
|
}
|
|
62
|
-
|
|
50
|
+
|
|
63
51
|
@objc
|
|
64
52
|
func e(_ tag: String, message: String, logFlow: NSDictionary?) {
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
let parsedFlow = LogFlowParser.from(dict: logFlow)
|
|
54
|
+
LogDrop.e(message, logFlow: parsedFlow, file: tag)
|
|
67
55
|
}
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
|
|
57
|
+
|
|
70
58
|
@objc
|
|
71
59
|
func userUpdate(_ userUuid: String) {
|
|
72
60
|
LogDrop.updateUser(userUuid: userUuid)
|
|
73
61
|
}
|
|
74
|
-
|
|
62
|
+
|
|
75
63
|
@objc
|
|
76
64
|
func sendLogs() {
|
|
77
65
|
LogDrop.sendLogs()
|
|
78
66
|
}
|
|
79
|
-
|
|
67
|
+
|
|
80
68
|
@objc
|
|
81
69
|
func saveCustomCrashReport(_ threadName: String, stackTrace: String, crashType: String) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
LogDrop.saveCustomCrashReport(threadName: threadName,
|
|
71
|
+
stackTrace: stackTrace,
|
|
72
|
+
crashType: crashType)
|
|
85
73
|
}
|
|
86
74
|
}
|
package/lib/module/LogDrop.js
CHANGED
|
@@ -11,9 +11,7 @@ export default class LogDrop {
|
|
|
11
11
|
static init = config => {
|
|
12
12
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
13
13
|
LogDropReactNative.initLogDrop?.(config);
|
|
14
|
-
|
|
15
|
-
LogDropErrorTracking.start();
|
|
16
|
-
}
|
|
14
|
+
LogDropErrorTracking.start();
|
|
17
15
|
}
|
|
18
16
|
};
|
|
19
17
|
static onRemoteMessageReceived = message => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","LogDropErrorTracking","LogDropReactNative","LogDrop","init","config","OS","initLogDrop","
|
|
1
|
+
{"version":3,"names":["Platform","LogDropErrorTracking","LogDropReactNative","LogDrop","init","config","OS","initLogDrop","start","onRemoteMessageReceived","message","onNewFcmPushToken","token","onNewHmsPushToken","sendLogs","userUpdate","userId","e","tag","logFlow","d","i","w"],"sourceRoot":"../../src","sources":["LogDrop.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,oBAAoB,QAAQ,iCAA8B;AAGnE,SAASC,kBAAkB,QAAQ,yBAAsB;AAEzD,eAAe,MAAMC,OAAO,CAAC;EAC3B,OAAOC,IAAI,GAAIC,MAAqB,IAAW;IAC7C,IAAIL,QAAQ,CAACM,EAAE,KAAK,KAAK,IAAIN,QAAQ,CAACM,EAAE,KAAK,SAAS,EAAE;MACtDJ,kBAAkB,CAACK,WAAW,GAAGF,MAAM,CAAC;MACxCJ,oBAAoB,CAACO,KAAK,CAAC,C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BAAkB,CAACoB,CAAC,CAACJ,GAAG,EAAER,OAAO,EAAES,OAAO,CAAC;EAC7C,CAAC;AACH","ignoreList":[]}
|
|
@@ -5,9 +5,6 @@ export class LogDropConfigBuilder {
|
|
|
5
5
|
baseUrl = '';
|
|
6
6
|
isLoggingEnabled = false;
|
|
7
7
|
defaultSDKDisabled = false;
|
|
8
|
-
sensitiveInfoFilter = [];
|
|
9
|
-
crashTrackingEnabled = true;
|
|
10
|
-
httpLoggingEnabled = false;
|
|
11
8
|
setApiKey(apiKey) {
|
|
12
9
|
this.apiKey = apiKey;
|
|
13
10
|
return this;
|
|
@@ -24,27 +21,12 @@ export class LogDropConfigBuilder {
|
|
|
24
21
|
this.defaultSDKDisabled = defaultSDKDisabled;
|
|
25
22
|
return this;
|
|
26
23
|
}
|
|
27
|
-
setSensitiveInfoFilter(sensitiveInfoFilter) {
|
|
28
|
-
this.sensitiveInfoFilter = sensitiveInfoFilter;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
setCrashTrackingEnabled(crashTrackingEnabled) {
|
|
32
|
-
this.crashTrackingEnabled = crashTrackingEnabled;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
setHttpLoggingEnabled(httpLoggingEnabled) {
|
|
36
|
-
this.httpLoggingEnabled = httpLoggingEnabled;
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
24
|
build() {
|
|
40
25
|
return {
|
|
41
26
|
apiKey: this.apiKey,
|
|
42
27
|
baseUrl: this.baseUrl,
|
|
43
28
|
isLoggingEnabled: this.isLoggingEnabled,
|
|
44
|
-
defaultSDKDisabled: this.defaultSDKDisabled
|
|
45
|
-
sensitiveInfoFilter: this.sensitiveInfoFilter,
|
|
46
|
-
crashTrackingEnabled: this.crashTrackingEnabled,
|
|
47
|
-
httpLoggingEnabled: this.httpLoggingEnabled
|
|
29
|
+
defaultSDKDisabled: this.defaultSDKDisabled
|
|
48
30
|
};
|
|
49
31
|
}
|
|
50
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LogDropConfigBuilder","apiKey","baseUrl","isLoggingEnabled","defaultSDKDisabled","
|
|
1
|
+
{"version":3,"names":["LogDropConfigBuilder","apiKey","baseUrl","isLoggingEnabled","defaultSDKDisabled","setApiKey","setBaseUrl","setLoggingEnabled","setDefaultSDKDisabledValue","build"],"sourceRoot":"../../src","sources":["LogDropConfig.ts"],"mappings":";;AAOA,OAAO,MAAMA,oBAAoB,CAAC;EACxBC,MAAM,GAAW,EAAE;EACnBC,OAAO,GAAW,EAAE;EACpBC,gBAAgB,GAAY,KAAK;EACjCC,kBAAkB,GAAY,KAAK;EAE3CC,SAASA,CAACJ,MAAc,EAAQ;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,OAAO,IAAI;EACb;EAEAK,UAAUA,CAACJ,OAAe,EAAQ;IAChC,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,OAAO,IAAI;EACb;EAEAK,iBAAiBA,CAACJ,gBAAyB,EAAQ;IACjD,IAAI,CAACA,gBAAgB,GAAGA,gBAAgB;IACxC,OAAO,IAAI;EACb;EAEAK,0BAA0BA,CAACJ,kBAA2B,EAAQ;IAC5D,IAAI,CAACA,kBAAkB,GAAGA,kBAAkB;IAC5C,OAAO,IAAI;EACb;EAEAK,KAAKA,CAAA,EAAkB;IACrB,OAAO;MACLR,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBC,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBC,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;MACvCC,kBAAkB,EAAE,IAAI,CAACA;IAC3B,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","LogDropReactNative","Proxy","get","Error"],"sourceRoot":"../../src","sources":["LogDropReactNative.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,+EAA+E,GAC/ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","LogDropReactNative","Proxy","get","Error"],"sourceRoot":"../../src","sources":["LogDropReactNative.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,+EAA+E,GAC/ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,kBAAkB,GAAGN,aAAa,CAACM,kBAAkB,GACvDN,aAAa,CAACM,kBAAkB,GAChC,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,SAASI,kBAAkB","ignoreList":[]}
|
|
@@ -1,122 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { NativeModules, Platform } from 'react-native';
|
|
4
|
-
import {
|
|
4
|
+
import { getErrorMessage, getErrorStackTrace } from "./errorUtils.js";
|
|
5
|
+
import { logdropDebugLogger } from "./logdropDebugLogger.js";
|
|
5
6
|
const {
|
|
6
7
|
LogDropReactNative
|
|
7
8
|
} = NativeModules;
|
|
8
9
|
const g = global;
|
|
9
10
|
export class LogDropErrorTracking {
|
|
10
11
|
static tracking = false;
|
|
11
|
-
static inDefaultHandler = false;
|
|
12
12
|
static defaultHandler = () => {};
|
|
13
|
-
static defaultConsoleError = (..._a) => {};
|
|
14
|
-
static lastSig = '';
|
|
15
13
|
static start() {
|
|
16
14
|
if (this.tracking) {
|
|
17
|
-
|
|
15
|
+
logdropDebugLogger('[LogDrop] ErrorTracking.start: already started');
|
|
18
16
|
return;
|
|
19
17
|
}
|
|
20
18
|
if (!g?.ErrorUtils) {
|
|
21
|
-
|
|
19
|
+
logdropDebugLogger('[LogDrop] ErrorTracking.start: ErrorUtils not available, skipping setup');
|
|
22
20
|
return;
|
|
23
21
|
}
|
|
24
22
|
const flushDelayMs = 50;
|
|
25
|
-
|
|
23
|
+
logdropDebugLogger('[LogDrop] ErrorTracking.start: installing global handlers');
|
|
26
24
|
this.defaultHandler = g.ErrorUtils.getGlobalHandler?.();
|
|
27
|
-
|
|
28
|
-
console.log('[LogDrop] ErrorTracking.start: captured original handlers');
|
|
25
|
+
logdropDebugLogger('[LogDrop] ErrorTracking.start: captured original handlers');
|
|
29
26
|
g.ErrorUtils.setGlobalHandler(async (error, isFatal) => {
|
|
30
27
|
const message = getErrorMessage(error);
|
|
31
28
|
const stack = getErrorStackTrace(error);
|
|
32
29
|
const top = (stack || '').split('\n')[0] || '';
|
|
33
|
-
|
|
30
|
+
logdropDebugLogger('[LogDrop] GlobalError captured', {
|
|
34
31
|
isFatal: !!isFatal,
|
|
35
32
|
message,
|
|
36
33
|
hasStack: !!stack,
|
|
37
34
|
topFrame: top
|
|
38
35
|
});
|
|
39
36
|
await this.report(message, stack, isFatal === true);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
await new Promise(r => setTimeout(r, flushDelayMs));
|
|
44
|
-
this.defaultHandler?.(error, isFatal);
|
|
45
|
-
} finally {
|
|
46
|
-
this.inDefaultHandler = false;
|
|
47
|
-
}
|
|
37
|
+
logdropDebugLogger('[LogDrop] GlobalError delegating to RN default handler');
|
|
38
|
+
await new Promise(r => setTimeout(r, flushDelayMs));
|
|
39
|
+
this.defaultHandler?.(error, isFatal);
|
|
48
40
|
});
|
|
49
|
-
console.error = (...params) => {
|
|
50
|
-
if (this.inDefaultHandler) return;
|
|
51
|
-
const {
|
|
52
|
-
stack,
|
|
53
|
-
name
|
|
54
|
-
} = pickStackAndNameFromParams(params);
|
|
55
|
-
const msg = params.map(p => typeof p === 'string' ? p : getErrorMessage(p)).join(' ');
|
|
56
|
-
const sig = `${msg}::${name}::${(stack || '').split('\n')[0] || ''}`;
|
|
57
|
-
const duplicate = sig === this.lastSig;
|
|
58
|
-
console.log('[LogDrop] ConsoleError captured', {
|
|
59
|
-
duplicate,
|
|
60
|
-
hasStack: stack !== EMPTY_STACK_TRACE,
|
|
61
|
-
name: name || DEFAULT_ERROR_NAME
|
|
62
|
-
});
|
|
63
|
-
if (!duplicate) {
|
|
64
|
-
this.lastSig = sig;
|
|
65
|
-
this.report(msg, stack || EMPTY_STACK_TRACE, false).finally(() => {
|
|
66
|
-
this.defaultConsoleError(...params);
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
this.defaultConsoleError(...params);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const hermes = g?.HermesInternal;
|
|
73
|
-
const hasTracker = !!hermes?.enablePromiseRejectionTracker && !!hermes?.hasPromise?.();
|
|
74
|
-
console.log('[LogDrop] Hermes promise rejection tracker', {
|
|
75
|
-
enabled: hasTracker
|
|
76
|
-
});
|
|
77
|
-
if (hasTracker) {
|
|
78
|
-
hermes.enablePromiseRejectionTracker({
|
|
79
|
-
allRejections: true,
|
|
80
|
-
onUnhandled: (_id, error) => {
|
|
81
|
-
const message = getErrorMessage(error);
|
|
82
|
-
const stack = getErrorStackTrace(error);
|
|
83
|
-
const top = (stack || '').split('\n')[0] || '';
|
|
84
|
-
console.log('[LogDrop] UnhandledPromiseRejection captured', {
|
|
85
|
-
message,
|
|
86
|
-
hasStack: !!stack,
|
|
87
|
-
topFrame: top
|
|
88
|
-
});
|
|
89
|
-
this.report(message, stack, false);
|
|
90
|
-
},
|
|
91
|
-
onHandled: _id => {}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
41
|
this.tracking = true;
|
|
95
|
-
|
|
42
|
+
logdropDebugLogger('[LogDrop] ErrorTracking.start: setup complete');
|
|
96
43
|
}
|
|
97
44
|
static async report(_message, stack, isFatal) {
|
|
98
45
|
try {
|
|
99
46
|
const thread = 'JS Thread';
|
|
100
47
|
const crashType = isFatal ? 'JSFatal' : 'JSNonFatal';
|
|
101
48
|
const body = `${stack || ''}`;
|
|
102
|
-
|
|
103
|
-
console.log('[LogDrop] Report to native', {
|
|
49
|
+
logdropDebugLogger('[LogDrop] Report to native', {
|
|
104
50
|
platform: Platform.OS,
|
|
105
|
-
crashType
|
|
106
|
-
hasBridge
|
|
51
|
+
crashType
|
|
107
52
|
});
|
|
108
53
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
109
|
-
if (
|
|
54
|
+
if (Platform.OS !== 'android') {
|
|
55
|
+
//Android SDK can catch React Native crashes using the Native module
|
|
110
56
|
LogDropReactNative.saveCustomCrashReport(thread, body, crashType);
|
|
111
|
-
console.log('[LogDrop] Report sent to native');
|
|
112
|
-
} else {
|
|
113
|
-
console.log('[LogDrop] Report skipped: native bridge method missing');
|
|
114
57
|
}
|
|
58
|
+
logdropDebugLogger('[LogDrop] Report sent to native');
|
|
115
59
|
} else {
|
|
116
|
-
|
|
60
|
+
logdropDebugLogger('[LogDrop] Report skipped: unsupported platform');
|
|
117
61
|
}
|
|
118
62
|
} catch (_e) {
|
|
119
|
-
|
|
63
|
+
logdropDebugLogger('[LogDrop] Report failed');
|
|
120
64
|
}
|
|
121
65
|
}
|
|
122
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","getErrorMessage","getErrorStackTrace","logdropDebugLogger","LogDropReactNative","g","global","LogDropErrorTracking","tracking","defaultHandler","start","ErrorUtils","flushDelayMs","getGlobalHandler","setGlobalHandler","error","isFatal","message","stack","top","split","hasStack","topFrame","report","Promise","r","setTimeout","_message","thread","crashType","body","platform","OS","saveCustomCrashReport","_e"],"sourceRoot":"../../../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} from "./logdropDebugLogger.js";
|
|
4
|
+
export const EMPTY_MESSAGE = 'Unknown Error';
|
|
5
|
+
export const EMPTY_STACK_TRACE = '';
|
|
6
|
+
export const DEFAULT_ERROR_NAME = 'Error';
|
|
6
7
|
export const getErrorMessage = error => {
|
|
7
8
|
if (error === undefined || error === null) return EMPTY_MESSAGE;
|
|
8
|
-
if (typeof error ===
|
|
9
|
+
if (typeof error === 'object' && 'message' in error) return String(error.message);
|
|
9
10
|
return String(error);
|
|
10
11
|
};
|
|
11
12
|
export const getErrorName = error => {
|
|
12
|
-
if (typeof error !==
|
|
13
|
+
if (typeof error !== 'object' || error === null) return DEFAULT_ERROR_NAME;
|
|
13
14
|
const n = error.name;
|
|
14
|
-
return typeof n ===
|
|
15
|
+
return typeof n === 'string' ? n : DEFAULT_ERROR_NAME;
|
|
15
16
|
};
|
|
16
17
|
export const getErrorStackTrace = error => {
|
|
17
18
|
try {
|
|
18
19
|
if (error === undefined || error === null) {
|
|
19
|
-
|
|
20
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: no error provided');
|
|
20
21
|
return EMPTY_STACK_TRACE;
|
|
21
22
|
}
|
|
22
|
-
if (typeof error ===
|
|
23
|
-
|
|
23
|
+
if (typeof error === 'string') {
|
|
24
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: string error has no stack');
|
|
24
25
|
return EMPTY_STACK_TRACE;
|
|
25
26
|
}
|
|
26
|
-
if (typeof error ===
|
|
27
|
-
if (
|
|
28
|
-
|
|
27
|
+
if (typeof error === 'object') {
|
|
28
|
+
if ('stacktrace' in error) {
|
|
29
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: using "stacktrace" field');
|
|
29
30
|
return String(error.stacktrace);
|
|
30
31
|
}
|
|
31
|
-
if (
|
|
32
|
-
|
|
32
|
+
if ('stack' in error) {
|
|
33
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: using "stack" field');
|
|
33
34
|
return String(error.stack);
|
|
34
35
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
36
|
+
if ('componentStack' in error) {
|
|
37
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: using "componentStack" field');
|
|
37
38
|
return String(error.componentStack);
|
|
38
39
|
}
|
|
39
|
-
if (
|
|
40
|
+
if ('sourceURL' in error && 'line' in error && 'column' in error) {
|
|
40
41
|
const s = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
41
|
-
|
|
42
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: synthesized from sourceURL/line/column');
|
|
42
43
|
return s;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
} catch (_e) {}
|
|
46
|
-
|
|
47
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: no stack extracted');
|
|
47
48
|
return EMPTY_STACK_TRACE;
|
|
48
49
|
};
|
|
49
50
|
export const pickStackAndNameFromParams = params => {
|
|
@@ -65,7 +66,7 @@ export const pickStackAndNameFromParams = params => {
|
|
|
65
66
|
}
|
|
66
67
|
if (stack !== EMPTY_STACK_TRACE && name !== DEFAULT_ERROR_NAME) break;
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
logdropDebugLogger('[LogDrop] pickStackAndNameFromParams:', {
|
|
69
70
|
name,
|
|
70
71
|
hasStack: stack !== EMPTY_STACK_TRACE,
|
|
71
72
|
stackFromParamIndex: foundStackAt,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","DEFAULT_ERROR_NAME","getErrorMessage","error","undefined","String","message","getErrorName","n","name","getErrorStackTrace","
|
|
1
|
+
{"version":3,"names":["logdropDebugLogger","EMPTY_MESSAGE","EMPTY_STACK_TRACE","DEFAULT_ERROR_NAME","getErrorMessage","error","undefined","String","message","getErrorName","n","name","getErrorStackTrace","stacktrace","stack","componentStack","s","sourceURL","line","column","_e","pickStackAndNameFromParams","params","foundStackAt","foundNameAt","i","length","p","hasStack","stackFromParamIndex","nameFromParamIndex"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IAAIqB,WAAW,KAAK,CAAC,CAAC,EAAE;MAClDb,IAAI,GAAGD,CAAC;MACRc,WAAW,GAAGC,CAAC;IACjB;IACA,IAAIX,KAAK,KAAKZ,iBAAiB,IAAIS,IAAI,KAAKR,kBAAkB,EAAE;EAClE;EACAH,kBAAkB,CAAC,uCAAuC,EAAE;IAC1DW,IAAI;IACJiB,QAAQ,EAAEd,KAAK,KAAKZ,iBAAiB;IACrC2B,mBAAmB,EAAEN,YAAY;IACjCO,kBAAkB,EAAEN;EACtB,CAAC,CAAC;EACF,OAAO;IAAEV,KAAK;IAAEH;EAAK,CAAC;AACxB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_consoleLogging","logdropDebugLogger","message","optionalParams","console","log"],"sourceRoot":"../../../src","sources":["utils/logdropDebugLogger.ts"],"mappings":";;AAAA,MAAMA,eAAe,GAAG,KAAK;AAE7B,OAAO,MAAMC,kBAAkB,GAAGA,CAACC,OAAa,EAAE,GAAGC,cAAqB,KAAK;EAC7E,IAAIH,eAAe,EAAE;IACnBI,OAAO,CAACC,GAAG,CAACH,OAAO,EAAEC,cAAc,CAAC;EACtC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogDrop.d.ts","sourceRoot":"","sources":["../../../src/LogDrop.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,OAAO,MAAM,WAAW,CAAC;AAGhC,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,MAAM,CAAC,IAAI,GAAI,QAAQ,aAAa,KAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"LogDrop.d.ts","sourceRoot":"","sources":["../../../src/LogDrop.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,OAAO,MAAM,WAAW,CAAC;AAGhC,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,MAAM,CAAC,IAAI,GAAI,QAAQ,aAAa,KAAG,IAAI,CAKzC;IAEF,MAAM,CAAC,uBAAuB,GAAI,SAAS;QACzC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,KAAG,IAAI,CAIN;IAEF,MAAM,CAAC,iBAAiB,GAAI,OAAO,MAAM,KAAG,IAAI,CAI9C;IAEF,MAAM,CAAC,iBAAiB,GAAI,OAAO,MAAM,KAAG,IAAI,CAI9C;IAEF,MAAM,CAAC,QAAQ,QAAO,IAAI,CAExB;IAEF,MAAM,CAAC,UAAU,GAAI,QAAQ,MAAM,KAAG,IAAI,CAExC;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;IAEF,MAAM,CAAC,CAAC,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,UAAU,OAAO,KAAG,IAAI,CAEhE;CACH"}
|
|
@@ -3,25 +3,16 @@ export interface LogDropConfig {
|
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
isLoggingEnabled: boolean;
|
|
5
5
|
defaultSDKDisabled: boolean;
|
|
6
|
-
sensitiveInfoFilter: string[];
|
|
7
|
-
crashTrackingEnabled: boolean;
|
|
8
|
-
httpLoggingEnabled: boolean;
|
|
9
6
|
}
|
|
10
7
|
export declare class LogDropConfigBuilder {
|
|
11
8
|
private apiKey;
|
|
12
9
|
private baseUrl;
|
|
13
10
|
private isLoggingEnabled;
|
|
14
11
|
private defaultSDKDisabled;
|
|
15
|
-
private sensitiveInfoFilter;
|
|
16
|
-
private crashTrackingEnabled;
|
|
17
|
-
private httpLoggingEnabled;
|
|
18
12
|
setApiKey(apiKey: string): this;
|
|
19
13
|
setBaseUrl(baseUrl: string): this;
|
|
20
14
|
setLoggingEnabled(isLoggingEnabled: boolean): this;
|
|
21
15
|
setDefaultSDKDisabledValue(defaultSDKDisabled: boolean): this;
|
|
22
|
-
setSensitiveInfoFilter(sensitiveInfoFilter: string[]): this;
|
|
23
|
-
setCrashTrackingEnabled(crashTrackingEnabled: boolean): this;
|
|
24
|
-
setHttpLoggingEnabled(httpLoggingEnabled: boolean): this;
|
|
25
16
|
build(): LogDropConfig;
|
|
26
17
|
}
|
|
27
18
|
//# sourceMappingURL=LogDropConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogDropConfig.d.ts","sourceRoot":"","sources":["../../../src/LogDropConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LogDropConfig.d.ts","sourceRoot":"","sources":["../../../src/LogDropConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,kBAAkB,CAAkB;IAE5C,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKjC,iBAAiB,CAAC,gBAAgB,EAAE,OAAO,GAAG,IAAI;IAKlD,0BAA0B,CAAC,kBAAkB,EAAE,OAAO,GAAG,IAAI;IAK7D,KAAK,IAAI,aAAa;CAQvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogDropReactNative.d.ts","sourceRoot":"","sources":["../../../src/LogDropReactNative.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LogDropReactNative.d.ts","sourceRoot":"","sources":["../../../src/LogDropReactNative.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,kBAAkB,KASnB,CAAC;AAEN,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogDropErrorTracking.d.ts","sourceRoot":"","sources":["../../../../src/utils/LogDropErrorTracking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LogDropErrorTracking.d.ts","sourceRoot":"","sources":["../../../../src/utils/LogDropErrorTracking.ts"],"names":[],"mappings":"AASA,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAO,CAAC,MAAM,CAAC,cAAc,CACW;IAExC,MAAM,CAAC,KAAK;mBA4CS,MAAM;CA4B5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/errorUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/errorUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,eAAO,MAAM,eAAe,GAAI,OAAO,GAAG,GAAG,SAAS,KAAG,MAKxD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,MAI7C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,GAAG,GAAG,SAAS,KAAG,MA0C3D,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,QAAQ,OAAO,EAAE;;;CA0B3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logdropDebugLogger.d.ts","sourceRoot":"","sources":["../../../../src/utils/logdropDebugLogger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,GAAI,UAAU,GAAG,EAAE,GAAG,gBAAgB,GAAG,EAAE,SAIzE,CAAC"}
|
package/package.json
CHANGED
package/src/LogDrop.ts
CHANGED
|
@@ -12,9 +12,7 @@ export default class LogDrop {
|
|
|
12
12
|
static init = (config: LogDropConfig): void => {
|
|
13
13
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
14
14
|
LogDropReactNative.initLogDrop?.(config);
|
|
15
|
-
|
|
16
|
-
LogDropErrorTracking.start();
|
|
17
|
-
}
|
|
15
|
+
LogDropErrorTracking.start();
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
18
|
|
package/src/LogDropConfig.ts
CHANGED
|
@@ -3,9 +3,6 @@ export interface LogDropConfig {
|
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
isLoggingEnabled: boolean;
|
|
5
5
|
defaultSDKDisabled: boolean;
|
|
6
|
-
sensitiveInfoFilter: string[];
|
|
7
|
-
crashTrackingEnabled: boolean;
|
|
8
|
-
httpLoggingEnabled: boolean;
|
|
9
6
|
}
|
|
10
7
|
|
|
11
8
|
export class LogDropConfigBuilder {
|
|
@@ -13,9 +10,6 @@ export class LogDropConfigBuilder {
|
|
|
13
10
|
private baseUrl: string = '';
|
|
14
11
|
private isLoggingEnabled: boolean = false;
|
|
15
12
|
private defaultSDKDisabled: boolean = false;
|
|
16
|
-
private sensitiveInfoFilter: string[] = [];
|
|
17
|
-
private crashTrackingEnabled: boolean = true;
|
|
18
|
-
private httpLoggingEnabled: boolean = false;
|
|
19
13
|
|
|
20
14
|
setApiKey(apiKey: string): this {
|
|
21
15
|
this.apiKey = apiKey;
|
|
@@ -37,30 +31,12 @@ export class LogDropConfigBuilder {
|
|
|
37
31
|
return this;
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
setSensitiveInfoFilter(sensitiveInfoFilter: string[]): this {
|
|
41
|
-
this.sensitiveInfoFilter = sensitiveInfoFilter;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setCrashTrackingEnabled(crashTrackingEnabled: boolean): this {
|
|
46
|
-
this.crashTrackingEnabled = crashTrackingEnabled;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
setHttpLoggingEnabled(httpLoggingEnabled: boolean): this {
|
|
51
|
-
this.httpLoggingEnabled = httpLoggingEnabled;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
34
|
build(): LogDropConfig {
|
|
56
35
|
return {
|
|
57
36
|
apiKey: this.apiKey,
|
|
58
37
|
baseUrl: this.baseUrl,
|
|
59
38
|
isLoggingEnabled: this.isLoggingEnabled,
|
|
60
39
|
defaultSDKDisabled: this.defaultSDKDisabled,
|
|
61
|
-
sensitiveInfoFilter: this.sensitiveInfoFilter,
|
|
62
|
-
crashTrackingEnabled: this.crashTrackingEnabled,
|
|
63
|
-
httpLoggingEnabled: this.httpLoggingEnabled,
|
|
64
40
|
};
|
|
65
41
|
}
|
|
66
42
|
}
|
|
@@ -6,16 +6,15 @@ const LINKING_ERROR =
|
|
|
6
6
|
'- You rebuilt the app after installing the package\n' +
|
|
7
7
|
'- You are not using Expo Go\n';
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
const LogDropReactNative = NativeModules.LogDropReactNative
|
|
11
10
|
? NativeModules.LogDropReactNative
|
|
12
11
|
: new Proxy(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get() {
|
|
15
|
+
throw new Error(LINKING_ERROR);
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
20
19
|
|
|
21
|
-
export {LogDropReactNative};
|
|
20
|
+
export { LogDropReactNative };
|
|
@@ -1,116 +1,59 @@
|
|
|
1
1
|
import { NativeModules, Platform } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
DEFAULT_ERROR_NAME,
|
|
5
|
-
getErrorMessage,
|
|
6
|
-
getErrorStackTrace,
|
|
7
|
-
pickStackAndNameFromParams,
|
|
8
|
-
} from './errorUtils';
|
|
2
|
+
import { getErrorMessage, getErrorStackTrace } from './errorUtils';
|
|
3
|
+
import { logdropDebugLogger } from './logdropDebugLogger';
|
|
9
4
|
|
|
10
5
|
type ErrorHandler = (e: any, isFatal?: boolean) => void;
|
|
11
|
-
type ConsoleError = (...args: any[]) => void;
|
|
12
6
|
|
|
13
7
|
const { LogDropReactNative } = NativeModules as any;
|
|
14
8
|
const g = global as any;
|
|
15
9
|
|
|
16
10
|
export class LogDropErrorTracking {
|
|
17
11
|
private static tracking = false;
|
|
18
|
-
private static inDefaultHandler = false;
|
|
19
12
|
private static defaultHandler: ErrorHandler =
|
|
20
13
|
(() => {}) as unknown as ErrorHandler;
|
|
21
|
-
private static defaultConsoleError: ConsoleError = ((
|
|
22
|
-
..._a: any[]
|
|
23
|
-
) => {}) as ConsoleError;
|
|
24
|
-
private static lastSig = '';
|
|
25
14
|
|
|
26
15
|
static start() {
|
|
27
16
|
if (this.tracking) {
|
|
28
|
-
|
|
17
|
+
logdropDebugLogger('[LogDrop] ErrorTracking.start: already started');
|
|
29
18
|
return;
|
|
30
19
|
}
|
|
31
20
|
if (!g?.ErrorUtils) {
|
|
32
|
-
|
|
21
|
+
logdropDebugLogger(
|
|
33
22
|
'[LogDrop] ErrorTracking.start: ErrorUtils not available, skipping setup'
|
|
34
23
|
);
|
|
35
24
|
return;
|
|
36
25
|
}
|
|
37
26
|
const flushDelayMs = 50;
|
|
38
|
-
|
|
27
|
+
logdropDebugLogger(
|
|
28
|
+
'[LogDrop] ErrorTracking.start: installing global handlers'
|
|
29
|
+
);
|
|
39
30
|
|
|
40
31
|
this.defaultHandler = g.ErrorUtils.getGlobalHandler?.() as ErrorHandler;
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
logdropDebugLogger(
|
|
33
|
+
'[LogDrop] ErrorTracking.start: captured original handlers'
|
|
34
|
+
);
|
|
43
35
|
|
|
44
36
|
g.ErrorUtils.setGlobalHandler(async (error: any, isFatal?: boolean) => {
|
|
45
37
|
const message = getErrorMessage(error);
|
|
46
38
|
const stack = getErrorStackTrace(error);
|
|
47
39
|
const top = (stack || '').split('\n')[0] || '';
|
|
48
|
-
|
|
40
|
+
logdropDebugLogger('[LogDrop] GlobalError captured', {
|
|
49
41
|
isFatal: !!isFatal,
|
|
50
42
|
message,
|
|
51
43
|
hasStack: !!stack,
|
|
52
44
|
topFrame: top,
|
|
53
45
|
});
|
|
54
46
|
await this.report(message, stack, isFatal === true);
|
|
55
|
-
this.inDefaultHandler = true;
|
|
56
|
-
try {
|
|
57
|
-
console.log('[LogDrop] GlobalError delegating to RN default handler');
|
|
58
|
-
await new Promise<void>((r) => setTimeout(r, flushDelayMs));
|
|
59
|
-
this.defaultHandler?.(error, isFatal);
|
|
60
|
-
} finally {
|
|
61
|
-
this.inDefaultHandler = false;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
console.error = ((...params: any[]) => {
|
|
66
|
-
if (this.inDefaultHandler) return;
|
|
67
|
-
const { stack, name } = pickStackAndNameFromParams(params);
|
|
68
|
-
const msg = params
|
|
69
|
-
.map((p) => (typeof p === 'string' ? p : getErrorMessage(p)))
|
|
70
|
-
.join(' ');
|
|
71
|
-
const sig = `${msg}::${name}::${(stack || '').split('\n')[0] || ''}`;
|
|
72
|
-
const duplicate = sig === this.lastSig;
|
|
73
|
-
console.log('[LogDrop] ConsoleError captured', {
|
|
74
|
-
duplicate,
|
|
75
|
-
hasStack: stack !== EMPTY_STACK_TRACE,
|
|
76
|
-
name: name || DEFAULT_ERROR_NAME,
|
|
77
|
-
});
|
|
78
|
-
if (!duplicate) {
|
|
79
|
-
this.lastSig = sig;
|
|
80
|
-
this.report(msg, stack || EMPTY_STACK_TRACE, false).finally(() => {
|
|
81
|
-
this.defaultConsoleError(...params);
|
|
82
|
-
});
|
|
83
|
-
} else {
|
|
84
|
-
this.defaultConsoleError(...params);
|
|
85
|
-
}
|
|
86
|
-
}) as ConsoleError;
|
|
87
47
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
48
|
+
logdropDebugLogger(
|
|
49
|
+
'[LogDrop] GlobalError delegating to RN default handler'
|
|
50
|
+
);
|
|
51
|
+
await new Promise<void>((r) => setTimeout(r, flushDelayMs));
|
|
52
|
+
this.defaultHandler?.(error, isFatal);
|
|
93
53
|
});
|
|
94
|
-
if (hasTracker) {
|
|
95
|
-
hermes.enablePromiseRejectionTracker({
|
|
96
|
-
allRejections: true,
|
|
97
|
-
onUnhandled: (_id: string, error: unknown) => {
|
|
98
|
-
const message = getErrorMessage(error as any);
|
|
99
|
-
const stack = getErrorStackTrace(error as any);
|
|
100
|
-
const top = (stack || '').split('\n')[0] || '';
|
|
101
|
-
console.log('[LogDrop] UnhandledPromiseRejection captured', {
|
|
102
|
-
message,
|
|
103
|
-
hasStack: !!stack,
|
|
104
|
-
topFrame: top,
|
|
105
|
-
});
|
|
106
|
-
this.report(message, stack, false);
|
|
107
|
-
},
|
|
108
|
-
onHandled: (_id: string) => {},
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
54
|
|
|
112
55
|
this.tracking = true;
|
|
113
|
-
|
|
56
|
+
logdropDebugLogger('[LogDrop] ErrorTracking.start: setup complete');
|
|
114
57
|
}
|
|
115
58
|
|
|
116
59
|
private static async report(
|
|
@@ -122,25 +65,23 @@ export class LogDropErrorTracking {
|
|
|
122
65
|
const thread = 'JS Thread';
|
|
123
66
|
const crashType = isFatal ? 'JSFatal' : 'JSNonFatal';
|
|
124
67
|
const body = `${stack || ''}`;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.log('[LogDrop] Report to native', {
|
|
68
|
+
|
|
69
|
+
logdropDebugLogger('[LogDrop] Report to native', {
|
|
128
70
|
platform: Platform.OS,
|
|
129
71
|
crashType,
|
|
130
|
-
hasBridge,
|
|
131
72
|
});
|
|
73
|
+
|
|
132
74
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
133
|
-
if (
|
|
75
|
+
if (Platform.OS !== 'android') {
|
|
76
|
+
//Android SDK can catch React Native crashes using the Native module
|
|
134
77
|
LogDropReactNative.saveCustomCrashReport(thread, body, crashType);
|
|
135
|
-
console.log('[LogDrop] Report sent to native');
|
|
136
|
-
} else {
|
|
137
|
-
console.log('[LogDrop] Report skipped: native bridge method missing');
|
|
138
78
|
}
|
|
79
|
+
logdropDebugLogger('[LogDrop] Report sent to native');
|
|
139
80
|
} else {
|
|
140
|
-
|
|
81
|
+
logdropDebugLogger('[LogDrop] Report skipped: unsupported platform');
|
|
141
82
|
}
|
|
142
83
|
} catch (_e) {
|
|
143
|
-
|
|
84
|
+
logdropDebugLogger('[LogDrop] Report failed');
|
|
144
85
|
}
|
|
145
86
|
}
|
|
146
87
|
}
|
package/src/utils/errorUtils.ts
CHANGED
|
@@ -1,57 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const
|
|
1
|
+
import { logdropDebugLogger } from './logdropDebugLogger';
|
|
2
|
+
|
|
3
|
+
export const EMPTY_MESSAGE = 'Unknown Error';
|
|
4
|
+
export const EMPTY_STACK_TRACE = '';
|
|
5
|
+
export const DEFAULT_ERROR_NAME = 'Error';
|
|
4
6
|
|
|
5
7
|
export const getErrorMessage = (error: any | undefined): string => {
|
|
6
8
|
if (error === undefined || error === null) return EMPTY_MESSAGE;
|
|
7
|
-
if (typeof error ===
|
|
9
|
+
if (typeof error === 'object' && 'message' in error)
|
|
8
10
|
return String(error.message);
|
|
9
11
|
return String(error);
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export const getErrorName = (error: unknown): string => {
|
|
13
|
-
if (typeof error !==
|
|
15
|
+
if (typeof error !== 'object' || error === null) return DEFAULT_ERROR_NAME;
|
|
14
16
|
const n = (error as any).name;
|
|
15
|
-
return typeof n ===
|
|
17
|
+
return typeof n === 'string' ? n : DEFAULT_ERROR_NAME;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
export const getErrorStackTrace = (error: any | undefined): string => {
|
|
19
21
|
try {
|
|
20
22
|
if (error === undefined || error === null) {
|
|
21
|
-
|
|
23
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: no error provided');
|
|
22
24
|
return EMPTY_STACK_TRACE;
|
|
23
25
|
}
|
|
24
|
-
if (typeof error ===
|
|
25
|
-
|
|
26
|
+
if (typeof error === 'string') {
|
|
27
|
+
logdropDebugLogger(
|
|
28
|
+
'[LogDrop] getErrorStackTrace: string error has no stack'
|
|
29
|
+
);
|
|
26
30
|
return EMPTY_STACK_TRACE;
|
|
27
31
|
}
|
|
28
|
-
if (typeof error ===
|
|
29
|
-
if (
|
|
30
|
-
|
|
32
|
+
if (typeof error === 'object') {
|
|
33
|
+
if ('stacktrace' in error) {
|
|
34
|
+
logdropDebugLogger(
|
|
35
|
+
'[LogDrop] getErrorStackTrace: using "stacktrace" field'
|
|
36
|
+
);
|
|
31
37
|
return String((error as any).stacktrace);
|
|
32
38
|
}
|
|
33
|
-
if (
|
|
34
|
-
|
|
39
|
+
if ('stack' in error) {
|
|
40
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: using "stack" field');
|
|
35
41
|
return String((error as any).stack);
|
|
36
42
|
}
|
|
37
|
-
if (
|
|
38
|
-
|
|
43
|
+
if ('componentStack' in error) {
|
|
44
|
+
logdropDebugLogger(
|
|
39
45
|
'[LogDrop] getErrorStackTrace: using "componentStack" field'
|
|
40
46
|
);
|
|
41
47
|
return String((error as any).componentStack);
|
|
42
48
|
}
|
|
43
|
-
if (
|
|
49
|
+
if ('sourceURL' in error && 'line' in error && 'column' in error) {
|
|
44
50
|
const s = `at ${(error as any).sourceURL}:${(error as any).line}:${
|
|
45
51
|
(error as any).column
|
|
46
52
|
}`;
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
logdropDebugLogger(
|
|
54
|
+
'[LogDrop] getErrorStackTrace: synthesized from sourceURL/line/column'
|
|
49
55
|
);
|
|
50
56
|
return s;
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
} catch (_e) {}
|
|
54
|
-
|
|
60
|
+
logdropDebugLogger('[LogDrop] getErrorStackTrace: no stack extracted');
|
|
55
61
|
return EMPTY_STACK_TRACE;
|
|
56
62
|
};
|
|
57
63
|
|
|
@@ -74,7 +80,7 @@ export const pickStackAndNameFromParams = (params: unknown[]) => {
|
|
|
74
80
|
}
|
|
75
81
|
if (stack !== EMPTY_STACK_TRACE && name !== DEFAULT_ERROR_NAME) break;
|
|
76
82
|
}
|
|
77
|
-
|
|
83
|
+
logdropDebugLogger('[LogDrop] pickStackAndNameFromParams:', {
|
|
78
84
|
name,
|
|
79
85
|
hasStack: stack !== EMPTY_STACK_TRACE,
|
|
80
86
|
stackFromParamIndex: foundStackAt,
|