@log-drop/react-native 1.0.0 → 1.0.1-beta1

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.
Files changed (62) hide show
  1. package/LICENSE +20 -0
  2. package/LogdropReactNative.podspec +26 -0
  3. package/README.md +175 -0
  4. package/android/build.gradle +12 -1
  5. package/android/src/main/java/com/logdropreactnative/Extensions.kt +13 -13
  6. package/android/src/main/java/com/logdropreactnative/LogDropReactNative.kt +12 -10
  7. package/android/src/main/java/com/logdropreactnative/LogDropReactNativeConfig.kt +45 -31
  8. package/android/src/main/java/com/logdropreactnative/LogDropReactNativeModule.kt +50 -53
  9. package/android/src/main/java/com/logdropreactnative/LogDropReactNativeUtils.kt +8 -8
  10. package/ios/LogDropReactNative.mm +3 -0
  11. package/ios/LogDropReactNative.swift +12 -0
  12. package/lib/module/LogDrop.js +53 -0
  13. package/lib/module/LogDrop.js.map +1 -0
  14. package/lib/module/LogDropConfig.js +45 -0
  15. package/lib/module/LogDropConfig.js.map +1 -0
  16. package/lib/module/LogDropReactNative.js +14 -0
  17. package/lib/module/LogDropReactNative.js.map +1 -0
  18. package/lib/module/LogFlow.js +10 -0
  19. package/lib/module/LogFlow.js.map +1 -0
  20. package/lib/module/index.js +7 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/module/package.json +1 -0
  23. package/lib/module/utils/LogDropErrorTracking.js +123 -0
  24. package/lib/module/utils/LogDropErrorTracking.js.map +1 -0
  25. package/lib/module/utils/errorUtils.js +79 -0
  26. package/lib/module/utils/errorUtils.js.map +1 -0
  27. package/lib/typescript/package.json +1 -0
  28. package/lib/typescript/src/LogDrop.d.ts +17 -0
  29. package/lib/typescript/src/LogDrop.d.ts.map +1 -0
  30. package/lib/typescript/src/LogDropConfig.d.ts +24 -0
  31. package/lib/typescript/src/LogDropConfig.d.ts.map +1 -0
  32. package/lib/typescript/src/LogDropReactNative.d.ts +3 -0
  33. package/lib/typescript/src/LogDropReactNative.d.ts.map +1 -0
  34. package/lib/typescript/src/LogFlow.d.ts +7 -0
  35. package/lib/typescript/src/LogFlow.d.ts.map +1 -0
  36. package/lib/typescript/src/index.d.ts +6 -0
  37. package/lib/typescript/src/index.d.ts.map +1 -0
  38. package/lib/typescript/src/utils/LogDropErrorTracking.d.ts +10 -0
  39. package/lib/typescript/src/utils/LogDropErrorTracking.d.ts.map +1 -0
  40. package/lib/typescript/src/utils/errorUtils.d.ts +11 -0
  41. package/lib/typescript/src/utils/errorUtils.d.ts.map +1 -0
  42. package/package.json +111 -16
  43. package/src/LogDrop.ts +45 -43
  44. package/src/LogDropConfig.ts +53 -45
  45. package/src/LogDropReactNative.ts +21 -0
  46. package/src/LogFlow.ts +12 -12
  47. package/src/index.tsx +6 -0
  48. package/src/utils/LogDropErrorTracking.ts +146 -0
  49. package/src/utils/errorUtils.ts +84 -0
  50. package/.eslintignore +0 -6
  51. package/.gitattributes +0 -1
  52. package/.github/workflows/publish.yml +0 -45
  53. package/.idea/LogDrop-React-Native-SDK.iml +0 -12
  54. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  55. package/.idea/modules.xml +0 -8
  56. package/.idea/prettier.xml +0 -6
  57. package/.idea/vcs.xml +0 -6
  58. package/.prettierignore +0 -8
  59. package/LogDropReactNative.podspec +0 -23
  60. package/index.ts +0 -6
  61. package/scripts/yarn_rebuild.sh +0 -31
  62. package/tsconfig.json +0 -3
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Initial Code
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "LogdropReactNative"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported }
14
+ s.source = { :git => "https://github.com/initialcodess/LogDrop-React-Native-SDK.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+
18
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
19
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
20
+ if respond_to?(:install_modules_dependencies, true)
21
+ install_modules_dependencies(s)
22
+ else
23
+ s.dependency "React-Core"
24
+ end
25
+ s.dependency 'LogDrop', '1.0.5'
26
+ end
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # LogDrop React Native SDK
2
+
3
+ Official React Native SDK for [LogDrop](https://logdrop.io).
4
+ Capture logs, handle push messages, update user info, and send diagnostic data directly from your React Native app to LogDrop.
5
+
6
+ ---
7
+
8
+ ## 📦 Installation
9
+
10
+ ```bash
11
+ npm install @log-drop/react-native
12
+ # or
13
+ yarn add @log-drop/react-native
14
+ ```
15
+
16
+ ---
17
+
18
+ ## ⚙️ iOS Setup
19
+
20
+ ### 1. Install native dependencies
21
+
22
+ ```bash
23
+ cd ios && pod install && cd ..
24
+ ```
25
+
26
+ ### 2. Initialize LogDrop before your app starts
27
+
28
+ Add this code **before** `AppRegistry.registerComponent` in your `index.js` or `App.js`:
29
+
30
+ ```ts
31
+ import { LogDrop, LogDropConfigBuilder } from '@log-drop/react-native';
32
+
33
+ const config = new LogDropConfigBuilder()
34
+ .setApiKey('YOUR_API_KEY')
35
+ .setBaseUrl('YOUR_BASE_URL')
36
+ .setLoggingEnabled(true)
37
+ .setSensitiveInfoFilter(['^(?:\\d{4}[-\\s]?){3}\\d{4}$'])
38
+ .build();
39
+
40
+ LogDrop.init(config);
41
+ ```
42
+
43
+ > 💡 Make sure to initialize LogDrop **only once** during app startup.
44
+
45
+ ---
46
+
47
+ ## 🤖 Android Setup
48
+
49
+ ### 1. Add the LogDrop Maven repository
50
+
51
+ In `android/build.gradle`, add inside `allprojects.repositories`:
52
+
53
+ ```gradle
54
+ allprojects {
55
+ repositories {
56
+ google()
57
+ maven { url "https://nexus.logdrop.io/repository/logdrop-android-sdk/" } // Add this line
58
+ mavenCentral()
59
+ }
60
+ }
61
+ ```
62
+
63
+ ### 2. Initialize LogDrop in `MainApplication.kt`
64
+
65
+ ```kotlin
66
+ override fun onCreate() {
67
+ super.onCreate()
68
+ SoLoader.init(this, OpenSourceMergedSoMapping)
69
+
70
+ val config = LogDropReactNativeConfig.Builder(this)
71
+ .apiKey("YOUR_API_KEY")
72
+ .baseUrl("YOUR_BASE_URL")
73
+ .logcatEnabled(true)
74
+ .sensitiveInfoFilter(
75
+ listOf(Regex("^(?:\\d{4}[-\\s]?){3}\\d{4}$"))
76
+ )
77
+ .build()
78
+
79
+ LogDropReactNative.initLogDrop(config)
80
+ }
81
+ ```
82
+
83
+ ---
84
+
85
+ ## 🧠 API Reference
86
+
87
+ ### `LogDrop.init(config: LogDropConfig): void`
88
+ Initializes the LogDrop SDK with the provided configuration.
89
+ - **Required:** Call this before using any other method.
90
+ - **iOS only:** This method is used to initialize on iOS (Android handles it natively).
91
+
92
+ ---
93
+
94
+ ### `LogDrop.sendLogs(): void`
95
+ Forces the SDK to send any cached logs immediately.
96
+
97
+ ---
98
+
99
+ ### `LogDrop.userUpdate(userId: string): void`
100
+ Updates the current user identifier.
101
+ Use this when a user logs in or changes identity.
102
+
103
+ ```ts
104
+ LogDrop.userUpdate("user_123");
105
+ ```
106
+
107
+ ---
108
+
109
+ ### Logging Methods
110
+
111
+ These correspond to standard log levels.
112
+
113
+ | Method | Description | Example |
114
+ |----------------------------------|-------------|----------------------------------------------|
115
+ | `LogDrop.e(tag, message, flow?)` | Error log | `LogDrop.e("Auth", "Login failed")` |
116
+ | `LogDrop.w(tag, message, flow?)` | Warning log | `LogDrop.w("Network", "Slow response")` |
117
+ | `LogDrop.i(tag, message, flow?)` | Info log | `LogDrop.i("Init", "App started")` |
118
+ | `LogDrop.d(tag, message, flow?)` | Debug log | `LogDrop.d("Cache", "Fetching from memory")` |
119
+
120
+ > `flow` (optional) is a `LogFlow` instance to track grouped log events.
121
+
122
+ ---
123
+
124
+ ### `LogDrop.onRemoteMessageReceived(message: { [key: string]: string }): void`
125
+ Handles incoming push notification payloads.
126
+ - **Android only**
127
+
128
+ ```ts
129
+ LogDrop.onRemoteMessageReceived(remoteMessage.data);
130
+ ```
131
+
132
+ ---
133
+
134
+ ### `LogDrop.onNewFcmPushToken(token: string): void`
135
+ Registers a new **FCM** (Firebase Cloud Messaging) push token.
136
+ - **Android only**
137
+
138
+ ```ts
139
+ LogDrop.onNewFcmPushToken(fcmToken);
140
+ ```
141
+
142
+ ---
143
+
144
+ ### `LogDrop.onNewHmsPushToken(token: string): void`
145
+ Registers a new **HMS** (Huawei Mobile Services) push token.
146
+ - **Android only**
147
+
148
+ ```ts
149
+ LogDrop.onNewHmsPushToken(hmsToken);
150
+ ```
151
+
152
+ ---
153
+
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
+ ## 🔑 API Keys
167
+
168
+ You can create and manage your API keys in the LogDrop Dashboard.
169
+ Use these in your configuration examples.
170
+
171
+ ---
172
+
173
+ ## 📄 Notes
174
+ - Always initialize LogDrop before any other usage.
175
+ - Use `userUpdate` after authentication to bind logs to a specific user.
@@ -2,6 +2,17 @@ buildscript {
2
2
  ext.getExtOrDefault = {name ->
3
3
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['LogdropReactNative_' + name]
4
4
  }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
5
16
  }
6
17
 
7
18
 
@@ -66,6 +77,6 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
66
77
  dependencies {
67
78
  implementation "com.facebook.react:react-android"
68
79
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
69
- implementation "io.logdrop:sdk:1.0.0-beta13.test"
80
+ implementation "io.logdrop:sdk:1.0.6"
70
81
  }
71
82
 
@@ -4,18 +4,18 @@ import com.facebook.react.bridge.ReadableMap
4
4
  import com.facebook.react.bridge.ReadableType
5
5
 
6
6
  fun ReadableMap.toStringMap(): Map<String, String> {
7
- val result = mutableMapOf<String, String>()
8
- val iterator = this.keySetIterator()
9
- while (iterator.hasNextKey()) {
10
- val key = iterator.nextKey()
11
- if (!this.isNull(key)) {
12
- val value = this.getDynamic(key)
13
- if (value.type == ReadableType.String) {
14
- result[key] = value.asString()
15
- } else {
16
- result[key] = value.toString()
17
- }
18
- }
7
+ val result = mutableMapOf<String, String>()
8
+ val iterator = this.keySetIterator()
9
+ while (iterator.hasNextKey()) {
10
+ val key = iterator.nextKey()
11
+ if (!this.isNull(key)) {
12
+ val value = this.getDynamic(key)
13
+ if (value.type == ReadableType.String) {
14
+ result[key] = value.asString()
15
+ } else {
16
+ result[key] = value.toString()
17
+ }
19
18
  }
20
- return result
19
+ }
20
+ return result
21
21
  }
@@ -4,13 +4,15 @@ import io.logdrop.sdk.LogDrop
4
4
  import io.logdrop.sdk.LogDropConfig
5
5
 
6
6
  object LogDropReactNative {
7
- fun initLogDrop(config: LogDropReactNativeConfig) {
8
- LogDrop.init(config.context, LogDropConfig.Builder().apply {
9
- config.apiKey?.let { apiKey(it) }
10
- config.baseUrl?.let { baseUrl(it) }
11
- config.isLoggingEnabled?.let { logcatEnabled(it) }
12
- config.initialIsSDKDisabledValue?.let { initialIsSDKDisabledValue(it) }
13
- config.sensitiveInfoFilter?.let { sensitiveInfoFilter(it) }
14
- }.build())
15
- }
16
- }
7
+ fun initLogDrop(config: LogDropReactNativeConfig) {
8
+ LogDrop.init(config.context, LogDropConfig.Builder().apply {
9
+ config.apiKey?.let { apiKey(it) }
10
+ config.baseUrl?.let { baseUrl(it) }
11
+ config.isLoggingEnabled?.let { logcatEnabled(it) }
12
+ config.isCrashTrackingEnabled?.let { crashTrackingEnabled(it) }
13
+ config.initialIsSDKDisabledValue?.let { initialIsSDKDisabledValue(it) }
14
+ config.sensitiveInfoFilter?.let { sensitiveInfoFilter(it) }
15
+ frameworkType(config.framework)
16
+ }.build())
17
+ }
18
+ }
@@ -1,40 +1,54 @@
1
1
  package com.logdropreactnative
2
2
 
3
3
  import android.content.Context
4
+ import io.logdrop.sdk.enums.FrameworkType
4
5
 
5
6
  class LogDropReactNativeConfig private constructor(
6
- val apiKey: String?,
7
- val baseUrl: String?,
8
- val isLoggingEnabled: Boolean?,
9
- val initialIsSDKDisabledValue: Boolean?,
10
- val sensitiveInfoFilter: List<Regex>?,
11
- val context: Context
7
+ val apiKey: String?,
8
+ val baseUrl: String?,
9
+ val isLoggingEnabled: Boolean?,
10
+ val isCrashTrackingEnabled: Boolean?,
11
+ val initialIsSDKDisabledValue: Boolean?,
12
+ val sensitiveInfoFilter: List<Regex>?,
13
+ val context: Context,
14
+ val framework: FrameworkType
12
15
  ) {
13
- class Builder(private val context: Context) {
14
- private var apiKey: String? = null
15
- private var baseUrl: String? = null
16
- private var isLoggingEnabled: Boolean? = null
17
- private var initialIsSDKDisabledValue: Boolean? = null
18
- private var sensitiveInfoFilter: List<Regex>? = null
19
-
20
- fun apiKey(apiKey: String) = apply { this.apiKey = apiKey }
21
- fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
22
- fun logcatEnabled(isLoggingEnabled: Boolean) = apply { this.isLoggingEnabled = isLoggingEnabled }
23
- fun initialIsSDKDisabledValue(initialIsSDKDisabledValue: Boolean) = apply { this.initialIsSDKDisabledValue = initialIsSDKDisabledValue }
24
- fun sensitiveInfoFilter(sensitiveInfoFilter: List<Regex>) = apply { this.sensitiveInfoFilter = sensitiveInfoFilter }
25
-
26
- fun build(): LogDropReactNativeConfig {
27
- return LogDropReactNativeConfig(
28
- apiKey,
29
- baseUrl,
30
- isLoggingEnabled,
31
- initialIsSDKDisabledValue,
32
- sensitiveInfoFilter,
33
- context
34
- )
35
- }
36
- }
37
- }
16
+ class Builder(private val context: Context) {
17
+ private var apiKey: String? = null
18
+ private var baseUrl: String? = null
19
+ private var isLoggingEnabled: Boolean? = null
20
+ private var isCrashTrackingEnabled: Boolean? = null
21
+ private var initialIsSDKDisabledValue: Boolean? = null
22
+ private var sensitiveInfoFilter: List<Regex>? = null
23
+ private var framework: FrameworkType = FrameworkType.REACT_NATIVE
24
+
25
+ fun apiKey(apiKey: String) = apply { this.apiKey = apiKey }
26
+ fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl }
27
+ fun logcatEnabled(isLoggingEnabled: Boolean) =
28
+ apply { this.isLoggingEnabled = isLoggingEnabled }
29
+
30
+ fun crashTrackingEnabled(isCrashTrackingEnabled: Boolean) =
31
+ apply { this.isCrashTrackingEnabled = isCrashTrackingEnabled }
38
32
 
33
+ fun initialIsSDKDisabledValue(initialIsSDKDisabledValue: Boolean) =
34
+ apply { this.initialIsSDKDisabledValue = initialIsSDKDisabledValue }
39
35
 
36
+ fun sensitiveInfoFilter(sensitiveInfoFilter: List<Regex>) =
37
+ apply { this.sensitiveInfoFilter = sensitiveInfoFilter }
40
38
 
39
+ fun framework(framework: FrameworkType) = apply { this.framework = framework }
40
+
41
+ fun build(): LogDropReactNativeConfig {
42
+ return LogDropReactNativeConfig(
43
+ apiKey,
44
+ baseUrl,
45
+ isLoggingEnabled,
46
+ isCrashTrackingEnabled,
47
+ initialIsSDKDisabledValue,
48
+ sensitiveInfoFilter,
49
+ context,
50
+ framework
51
+ )
52
+ }
53
+ }
54
+ }
@@ -3,71 +3,68 @@ package com.logdropreactnative
3
3
  import com.facebook.react.bridge.ReactApplicationContext
4
4
  import com.facebook.react.bridge.ReactContextBaseJavaModule
5
5
  import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.Promise
6
7
  import com.facebook.react.bridge.ReadableMap
7
-
8
8
  import io.logdrop.sdk.LogDrop
9
9
 
10
- class LogDropReactNativeModule(private val reactContext: ReactApplicationContext) :
11
- ReactContextBaseJavaModule(reactContext) {
12
-
13
- companion object {
14
- const val NAME = "LogDropReactNative"
15
- }
10
+ class LogDropReactNativeModule(reactContext: ReactApplicationContext) :
11
+ ReactContextBaseJavaModule(reactContext) {
16
12
 
17
- override fun getName(): String {
18
- return NAME
19
- }
13
+ override fun getName(): String {
14
+ return NAME
15
+ }
20
16
 
21
- @ReactMethod
22
- fun onRemoteMessageReceived(readableMap: ReadableMap) {
23
- val data = readableMap.toHashMap()
24
- .mapValues { it.value.toString() }
25
- .toMutableMap()
26
- LogDrop.onRemoteMessageReceived(data)
27
- }
17
+ @ReactMethod
18
+ fun onRemoteMessageReceived(readableMap: ReadableMap) {
19
+ val data = readableMap.toHashMap().mapValues { it.value.toString() }.toMutableMap()
20
+ LogDrop.onRemoteMessageReceived(data)
21
+ }
28
22
 
29
- @ReactMethod
30
- fun onNewFcmPushToken(token: String) {
31
- LogDrop.onNewFcmPushToken(token)
32
- }
23
+ @ReactMethod
24
+ fun onNewFcmPushToken(token: String) {
25
+ LogDrop.onNewFcmPushToken(token)
26
+ }
33
27
 
34
- @ReactMethod
35
- fun onNewHmsPushToken(token: String) {
36
- LogDrop.onNewHmsPushToken(token)
37
- }
28
+ @ReactMethod
29
+ fun onNewHmsPushToken(token: String) {
30
+ LogDrop.onNewHmsPushToken(token)
31
+ }
38
32
 
39
- @ReactMethod
40
- fun sendLogs() {
41
- LogDrop.sendLogs()
42
- }
33
+ @ReactMethod
34
+ fun sendLogs() {
35
+ LogDrop.sendLogs()
36
+ }
43
37
 
44
- @ReactMethod
45
- fun userUpdate(userId: String) {
46
- LogDrop.userUpdate(userId)
47
- }
38
+ @ReactMethod
39
+ fun userUpdate(userId: String) {
40
+ LogDrop.userUpdate(userId)
41
+ }
48
42
 
49
- @ReactMethod
50
- fun e(tag: String, message: String, logFlow: ReadableMap?) {
51
- val logFlowObject = readableMapToLogFlow(logFlow)
52
- LogDrop.e(tag, message, logFlowObject)
53
- }
43
+ @ReactMethod
44
+ fun e(tag: String, message: String, logFlow: ReadableMap?) {
45
+ val logFlowObject = readableMapToLogFlow(logFlow)
46
+ LogDrop.e(tag, message, logFlowObject)
47
+ }
54
48
 
55
- @ReactMethod
56
- fun d(tag: String, message: String, logFlow: ReadableMap?) {
57
- val logFlowObject = readableMapToLogFlow(logFlow)
58
- LogDrop.d(tag, message, logFlowObject)
59
- }
49
+ @ReactMethod
50
+ fun d(tag: String, message: String, logFlow: ReadableMap?) {
51
+ val logFlowObject = readableMapToLogFlow(logFlow)
52
+ LogDrop.d(tag, message, logFlowObject)
53
+ }
60
54
 
61
- @ReactMethod
62
- fun i(tag: String, message: String, logFlow: ReadableMap?) {
63
- val logFlowObject = readableMapToLogFlow(logFlow)
64
- LogDrop.i(tag, message, logFlowObject)
65
- }
55
+ @ReactMethod
56
+ fun i(tag: String, message: String, logFlow: ReadableMap?) {
57
+ val logFlowObject = readableMapToLogFlow(logFlow)
58
+ LogDrop.i(tag, message, logFlowObject)
59
+ }
66
60
 
67
- @ReactMethod
68
- fun w(tag: String, message: String, logFlow: ReadableMap?) {
69
- val logFlowObject = readableMapToLogFlow(logFlow)
70
- LogDrop.w(tag, message, logFlowObject)
71
- }
61
+ @ReactMethod
62
+ fun w(tag: String, message: String, logFlow: ReadableMap?) {
63
+ val logFlowObject = readableMapToLogFlow(logFlow)
64
+ LogDrop.w(tag, message, logFlowObject)
65
+ }
72
66
 
67
+ companion object {
68
+ const val NAME = "LogDropReactNative"
69
+ }
73
70
  }
@@ -5,13 +5,13 @@ import com.facebook.react.bridge.ReadableMap
5
5
  import io.logdrop.sdk.LogFlow
6
6
 
7
7
  fun readableMapToLogFlow(logFlowMap: ReadableMap?): LogFlow {
8
- val name = logFlowMap?.takeIf { it.hasKey("name") && !it.isNull("name") }?.getString("name") ?: ""
9
- val id = logFlowMap?.takeIf { it.hasKey("id") && !it.isNull("id") }?.getString("id") ?: ""
8
+ val name = logFlowMap?.takeIf { it.hasKey("name") && !it.isNull("name") }?.getString("name") ?: ""
9
+ val id = logFlowMap?.takeIf { it.hasKey("id") && !it.isNull("id") }?.getString("id") ?: ""
10
10
 
11
- val customAttributes: Map<String, String>? = logFlowMap
12
- ?.takeIf { it.hasKey("customAttributes") && !it.isNull("customAttributes") }
13
- ?.getMap("customAttributes")
14
- ?.toStringMap()
11
+ val customAttributes: Map<String, String>? = logFlowMap
12
+ ?.takeIf { it.hasKey("customAttributes") && !it.isNull("customAttributes") }
13
+ ?.getMap("customAttributes")
14
+ ?.toStringMap()
15
15
 
16
- return LogFlow(name = name, id = id, customAttributes = customAttributes)
17
- }
16
+ return LogFlow(name = name, id = id, customAttributes = customAttributes)
17
+ }
@@ -9,6 +9,9 @@ RCT_EXTERN_METHOD(d:(NSString *)tag message:(NSString *)message logFlow:(NSDicti
9
9
  RCT_EXTERN_METHOD(w:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
10
10
  RCT_EXTERN_METHOD(userUpdate:(NSString *)userUuid)
11
11
  RCT_EXTERN_METHOD(sendLogs)
12
+ RCT_EXTERN_METHOD(saveCustomCrashReport:(NSString *)threadName
13
+ stackTrace:(NSString *)stackTrace
14
+ crashType:(NSString *)crashType)
12
15
 
13
16
  + (BOOL)requiresMainQueueSetup
14
17
  {
@@ -28,6 +28,12 @@ class LogDropReactNative: NSObject {
28
28
  builder.setSensitiveInfoFilter(sensitiveInfoFilter: regexList)
29
29
  }
30
30
 
31
+ builder.setFrameworkType(.reactNative)
32
+
33
+ if let crashTrackingEnabled = config["crashTrackingEnabled"] as? Bool {
34
+ builder.setCrashTrackingEnabled(crashTrackingEnabled)
35
+ }
36
+
31
37
  let logDropConfig = builder.build()
32
38
  LogDrop.initialize(with: logDropConfig)
33
39
  }
@@ -67,4 +73,10 @@ class LogDropReactNative: NSObject {
67
73
  LogDrop.sendLogs()
68
74
  }
69
75
 
76
+ @objc
77
+ func saveCustomCrashReport(_ threadName: String, stackTrace: String, crashType: String) {
78
+ LogDrop.saveCustomCrashReport(threadName: threadName,
79
+ stackTrace: stackTrace,
80
+ crashType: crashType)
81
+ }
70
82
  }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2025 Initial Code
5
+ */
6
+
7
+ import { Platform } from 'react-native';
8
+ import { LogDropErrorTracking } from "./utils/LogDropErrorTracking.js";
9
+ import { LogDropReactNative } from "./LogDropReactNative.js";
10
+ export default class LogDrop {
11
+ static init = config => {
12
+ if (Platform.OS === 'ios' || Platform.OS === 'android') {
13
+ LogDropReactNative.initLogDrop?.(config);
14
+ if (config.crashTrackingEnabled) {
15
+ LogDropErrorTracking.start();
16
+ }
17
+ }
18
+ };
19
+ static onRemoteMessageReceived = message => {
20
+ if (Platform.OS === 'android') {
21
+ LogDropReactNative.onRemoteMessageReceived(message);
22
+ }
23
+ };
24
+ static onNewFcmPushToken = token => {
25
+ if (Platform.OS === 'android') {
26
+ LogDropReactNative.onNewFcmPushToken(token);
27
+ }
28
+ };
29
+ static onNewHmsPushToken = token => {
30
+ if (Platform.OS === 'android') {
31
+ LogDropReactNative.onNewHmsPushToken(token);
32
+ }
33
+ };
34
+ static sendLogs = () => {
35
+ LogDropReactNative.sendLogs();
36
+ };
37
+ static userUpdate = userId => {
38
+ LogDropReactNative.userUpdate(userId);
39
+ };
40
+ static e = (tag, message, logFlow) => {
41
+ LogDropReactNative.e(tag, message, logFlow);
42
+ };
43
+ static d = (tag, message, logFlow) => {
44
+ LogDropReactNative.d(tag, message, logFlow);
45
+ };
46
+ static i = (tag, message, logFlow) => {
47
+ LogDropReactNative.i(tag, message, logFlow);
48
+ };
49
+ static w = (tag, message, logFlow) => {
50
+ LogDropReactNative.w(tag, message, logFlow);
51
+ };
52
+ }
53
+ //# sourceMappingURL=LogDrop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","LogDropErrorTracking","LogDropReactNative","LogDrop","init","config","OS","initLogDrop","crashTrackingEnabled","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;MACxC,IAAIA,MAAM,CAACG,oBAAoB,EAAE;QAC/BP,oBAAoB,CAACQ,KAAK,CAAC,CAAC;MAC9B;IACF;EACF,CAAC;EAED,OAAOC,uBAAuB,GAAIC,OAEjC,IAAW;IACV,IAAIX,QAAQ,CAACM,EAAE,KAAK,SAAS,EAAE;MAC7BJ,kBAAkB,CAACQ,uBAAuB,CAACC,OAAO,CAAC;IACrD;EACF,CAAC;EAED,OAAOC,iBAAiB,GAAIC,KAAa,IAAW;IAClD,IAAIb,QAAQ,CAACM,EAAE,KAAK,SAAS,EAAE;MAC7BJ,kBAAkB,CAACU,iBAAiB,CAACC,KAAK,CAAC;IAC7C;EACF,CAAC;EAED,OAAOC,iBAAiB,GAAID,KAAa,IAAW;IAClD,IAAIb,QAAQ,CAACM,EAAE,KAAK,SAAS,EAAE;MAC7BJ,kBAAkB,CAACY,iBAAiB,CAACD,KAAK,CAAC;IAC7C;EACF,CAAC;EAED,OAAOE,QAAQ,GAAGA,CAAA,KAAY;IAC5Bb,kBAAkB,CAACa,QAAQ,CAAC,CAAC;EAC/B,CAAC;EAED,OAAOC,UAAU,GAAIC,MAAc,IAAW;IAC5Cf,kBAAkB,CAACc,UAAU,CAACC,MAAM,CAAC;EACvC,CAAC;EAED,OAAOC,CAAC,GAAGA,CAACC,GAAW,EAAER,OAAe,EAAES,OAAiB,KAAW;IACpElB,kBAAkB,CAACgB,CAAC,CAACC,GAAG,EAAER,OAAO,EAAES,OAAO,CAAC;EAC7C,CAAC;EAED,OAAOC,CAAC,GAAGA,CAACF,GAAW,EAAER,OAAe,EAAES,OAAiB,KAAW;IACpElB,kBAAkB,CAACmB,CAAC,CAACF,GAAG,EAAER,OAAO,EAAES,OAAO,CAAC;EAC7C,CAAC;EAED,OAAOE,CAAC,GAAGA,CAACH,GAAW,EAAER,OAAe,EAAES,OAAiB,KAAW;IACpElB,kBAAkB,CAACoB,CAAC,CAACH,GAAG,EAAER,OAAO,EAAES,OAAO,CAAC;EAC7C,CAAC;EAED,OAAOG,CAAC,GAAGA,CAACJ,GAAW,EAAER,OAAe,EAAES,OAAiB,KAAW;IACpElB,kBAAkB,CAACqB,CAAC,CAACJ,GAAG,EAAER,OAAO,EAAES,OAAO,CAAC;EAC7C,CAAC;AACH","ignoreList":[]}