@log-drop/react-native 0.1.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.
Files changed (55) hide show
  1. package/LICENSE +20 -0
  2. package/LogdropReactNative.podspec +26 -0
  3. package/README.md +175 -0
  4. package/android/build.gradle +82 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/logdropreactnative/Extensions.kt +21 -0
  9. package/android/src/main/java/com/logdropreactnative/LogDropReactNative.kt +18 -0
  10. package/android/src/main/java/com/logdropreactnative/LogDropReactNativeConfig.kt +54 -0
  11. package/android/src/main/java/com/logdropreactnative/LogDropReactNativeModule.kt +70 -0
  12. package/android/src/main/java/com/logdropreactnative/LogDropReactNativePackage.kt +17 -0
  13. package/android/src/main/java/com/logdropreactnative/LogDropReactNativeUtils.kt +17 -0
  14. package/ios/LogDropReactNative-Bridging-Header.h +2 -0
  15. package/ios/LogDropReactNative.mm +21 -0
  16. package/ios/LogDropReactNative.swift +82 -0
  17. package/ios/LogFlowParser.swift +24 -0
  18. package/lib/module/LogDrop.js +53 -0
  19. package/lib/module/LogDrop.js.map +1 -0
  20. package/lib/module/LogDropConfig.js +45 -0
  21. package/lib/module/LogDropConfig.js.map +1 -0
  22. package/lib/module/LogDropReactNative.js +14 -0
  23. package/lib/module/LogDropReactNative.js.map +1 -0
  24. package/lib/module/LogFlow.js +10 -0
  25. package/lib/module/LogFlow.js.map +1 -0
  26. package/lib/module/index.js +7 -0
  27. package/lib/module/index.js.map +1 -0
  28. package/lib/module/package.json +1 -0
  29. package/lib/module/utils/LogDropErrorTracking.js +123 -0
  30. package/lib/module/utils/LogDropErrorTracking.js.map +1 -0
  31. package/lib/module/utils/errorUtils.js +79 -0
  32. package/lib/module/utils/errorUtils.js.map +1 -0
  33. package/lib/typescript/package.json +1 -0
  34. package/lib/typescript/src/LogDrop.d.ts +17 -0
  35. package/lib/typescript/src/LogDrop.d.ts.map +1 -0
  36. package/lib/typescript/src/LogDropConfig.d.ts +24 -0
  37. package/lib/typescript/src/LogDropConfig.d.ts.map +1 -0
  38. package/lib/typescript/src/LogDropReactNative.d.ts +3 -0
  39. package/lib/typescript/src/LogDropReactNative.d.ts.map +1 -0
  40. package/lib/typescript/src/LogFlow.d.ts +7 -0
  41. package/lib/typescript/src/LogFlow.d.ts.map +1 -0
  42. package/lib/typescript/src/index.d.ts +6 -0
  43. package/lib/typescript/src/index.d.ts.map +1 -0
  44. package/lib/typescript/src/utils/LogDropErrorTracking.d.ts +10 -0
  45. package/lib/typescript/src/utils/LogDropErrorTracking.d.ts.map +1 -0
  46. package/lib/typescript/src/utils/errorUtils.d.ts +11 -0
  47. package/lib/typescript/src/utils/errorUtils.d.ts.map +1 -0
  48. package/package.json +127 -0
  49. package/src/LogDrop.ts +64 -0
  50. package/src/LogDropConfig.ts +58 -0
  51. package/src/LogDropReactNative.ts +21 -0
  52. package/src/LogFlow.ts +15 -0
  53. package/src/index.tsx +6 -0
  54. package/src/utils/LogDropErrorTracking.ts +146 -0
  55. package/src/utils/errorUtils.ts +84 -0
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.2'
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.
@@ -0,0 +1,82 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['LogdropReactNative_' + name]
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
+ }
16
+ }
17
+
18
+
19
+ apply plugin: "com.android.library"
20
+ apply plugin: "kotlin-android"
21
+
22
+
23
+ def getExtOrIntegerDefault(name) {
24
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["LogdropReactNative_" + name]).toInteger()
25
+ }
26
+
27
+ def supportsNamespace() {
28
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
29
+ def major = parsed[0].toInteger()
30
+ def minor = parsed[1].toInteger()
31
+
32
+ // Namespace support was added in 7.3.0
33
+ return (major == 7 && minor >= 3) || major >= 8
34
+ }
35
+
36
+ android {
37
+ if (supportsNamespace()) {
38
+ namespace "com.logdropreactnative"
39
+
40
+ sourceSets {
41
+ main {
42
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
43
+ }
44
+ }
45
+ }
46
+
47
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
48
+
49
+ defaultConfig {
50
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
51
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
52
+ }
53
+
54
+ buildTypes {
55
+ release {
56
+ minifyEnabled false
57
+ }
58
+ }
59
+
60
+ lintOptions {
61
+ disable "GradleCompatible"
62
+ }
63
+
64
+ compileOptions {
65
+ sourceCompatibility JavaVersion.VERSION_1_8
66
+ targetCompatibility JavaVersion.VERSION_1_8
67
+ }
68
+ }
69
+
70
+ repositories {
71
+ mavenCentral()
72
+ google()
73
+ }
74
+
75
+ def kotlin_version = getExtOrDefault("kotlinVersion")
76
+
77
+ dependencies {
78
+ implementation "com.facebook.react:react-android"
79
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
80
+ implementation "io.logdrop:sdk:1.0.3"
81
+ }
82
+
@@ -0,0 +1,5 @@
1
+ LogdropReactNative_kotlinVersion=2.0.21
2
+ LogdropReactNative_minSdkVersion=24
3
+ LogdropReactNative_targetSdkVersion=34
4
+ LogdropReactNative_compileSdkVersion=35
5
+ LogdropReactNative_ndkVersion=27.1.12297006
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.logdropreactnative">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,21 @@
1
+ package com.logdropreactnative
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+ import com.facebook.react.bridge.ReadableType
5
+
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
+ }
19
+ }
20
+ return result
21
+ }
@@ -0,0 +1,18 @@
1
+ package com.logdropreactnative
2
+
3
+ import io.logdrop.sdk.LogDrop
4
+ import io.logdrop.sdk.LogDropConfig
5
+
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.isCrashTrackingEnabled?.let { crashTrackingEnabled(it) }
13
+ config.initialIsSDKDisabledValue?.let { initialIsSDKDisabledValue(it) }
14
+ config.sensitiveInfoFilter?.let { sensitiveInfoFilter(it) }
15
+ frameworkType(config.framework)
16
+ }.build())
17
+ }
18
+ }
@@ -0,0 +1,54 @@
1
+ package com.logdropreactnative
2
+
3
+ import android.content.Context
4
+ import io.logdrop.sdk.enums.FrameworkType
5
+
6
+ class LogDropReactNativeConfig private constructor(
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
15
+ ) {
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 }
32
+
33
+ fun initialIsSDKDisabledValue(initialIsSDKDisabledValue: Boolean) =
34
+ apply { this.initialIsSDKDisabledValue = initialIsSDKDisabledValue }
35
+
36
+ fun sensitiveInfoFilter(sensitiveInfoFilter: List<Regex>) =
37
+ apply { this.sensitiveInfoFilter = sensitiveInfoFilter }
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
+ }
@@ -0,0 +1,70 @@
1
+ package com.logdropreactnative
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.Promise
7
+ import com.facebook.react.bridge.ReadableMap
8
+ import io.logdrop.sdk.LogDrop
9
+
10
+ class LogDropReactNativeModule(reactContext: ReactApplicationContext) :
11
+ ReactContextBaseJavaModule(reactContext) {
12
+
13
+ override fun getName(): String {
14
+ return NAME
15
+ }
16
+
17
+ @ReactMethod
18
+ fun onRemoteMessageReceived(readableMap: ReadableMap) {
19
+ val data = readableMap.toHashMap().mapValues { it.value.toString() }.toMutableMap()
20
+ LogDrop.onRemoteMessageReceived(data)
21
+ }
22
+
23
+ @ReactMethod
24
+ fun onNewFcmPushToken(token: String) {
25
+ LogDrop.onNewFcmPushToken(token)
26
+ }
27
+
28
+ @ReactMethod
29
+ fun onNewHmsPushToken(token: String) {
30
+ LogDrop.onNewHmsPushToken(token)
31
+ }
32
+
33
+ @ReactMethod
34
+ fun sendLogs() {
35
+ LogDrop.sendLogs()
36
+ }
37
+
38
+ @ReactMethod
39
+ fun userUpdate(userId: String) {
40
+ LogDrop.userUpdate(userId)
41
+ }
42
+
43
+ @ReactMethod
44
+ fun e(tag: String, message: String, logFlow: ReadableMap?) {
45
+ val logFlowObject = readableMapToLogFlow(logFlow)
46
+ LogDrop.e(tag, message, logFlowObject)
47
+ }
48
+
49
+ @ReactMethod
50
+ fun d(tag: String, message: String, logFlow: ReadableMap?) {
51
+ val logFlowObject = readableMapToLogFlow(logFlow)
52
+ LogDrop.d(tag, message, logFlowObject)
53
+ }
54
+
55
+ @ReactMethod
56
+ fun i(tag: String, message: String, logFlow: ReadableMap?) {
57
+ val logFlowObject = readableMapToLogFlow(logFlow)
58
+ LogDrop.i(tag, message, logFlowObject)
59
+ }
60
+
61
+ @ReactMethod
62
+ fun w(tag: String, message: String, logFlow: ReadableMap?) {
63
+ val logFlowObject = readableMapToLogFlow(logFlow)
64
+ LogDrop.w(tag, message, logFlowObject)
65
+ }
66
+
67
+ companion object {
68
+ const val NAME = "LogDropReactNative"
69
+ }
70
+ }
@@ -0,0 +1,17 @@
1
+ package com.logdropreactnative
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+
9
+ class LogDropReactNativePackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return listOf(LogDropReactNativeModule(reactContext))
12
+ }
13
+
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
+ return emptyList()
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ package com.logdropreactnative
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+
5
+ import io.logdrop.sdk.LogFlow
6
+
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") ?: ""
10
+
11
+ val customAttributes: Map<String, String>? = logFlowMap
12
+ ?.takeIf { it.hasKey("customAttributes") && !it.isNull("customAttributes") }
13
+ ?.getMap("customAttributes")
14
+ ?.toStringMap()
15
+
16
+ return LogFlow(name = name, id = id, customAttributes = customAttributes)
17
+ }
@@ -0,0 +1,2 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTViewManager.h>
@@ -0,0 +1,21 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @interface RCT_EXTERN_MODULE(LogDropReactNative, NSObject)
4
+
5
+ RCT_EXTERN_METHOD(initLogDrop:(NSDictionary *)config)
6
+ RCT_EXTERN_METHOD(e:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
7
+ RCT_EXTERN_METHOD(i:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
8
+ RCT_EXTERN_METHOD(d:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
9
+ RCT_EXTERN_METHOD(w:(NSString *)tag message:(NSString *)message logFlow:(NSDictionary * _Nullable)logFlow)
10
+ RCT_EXTERN_METHOD(userUpdate:(NSString *)userUuid)
11
+ RCT_EXTERN_METHOD(sendLogs)
12
+ RCT_EXTERN_METHOD(saveCustomCrashReport:(NSString *)threadName
13
+ stackTrace:(NSString *)stackTrace
14
+ crashType:(NSString *)crashType)
15
+
16
+ + (BOOL)requiresMainQueueSetup
17
+ {
18
+ return NO;
19
+ }
20
+
21
+ @end
@@ -0,0 +1,82 @@
1
+ import LogDropSDK
2
+
3
+ @objc(LogDropReactNative)
4
+ class LogDropReactNative: NSObject {
5
+
6
+ @objc
7
+ func initLogDrop(_ config: NSDictionary) {
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
+ if let sensitiveInfoFilter = config["sensitiveInfoFilter"] as? [String] {
27
+ let regexList = sensitiveInfoFilter.compactMap { try? NSRegularExpression(pattern: $0) }
28
+ builder.setSensitiveInfoFilter(sensitiveInfoFilter: regexList)
29
+ }
30
+
31
+ builder.setFrameworkType(.reactNative)
32
+
33
+ if let crashTrackingEnabled = config["crashTrackingEnabled"] as? Bool {
34
+ builder.setCrashTrackingEnabled(crashTrackingEnabled)
35
+ }
36
+
37
+ let logDropConfig = builder.build()
38
+ LogDrop.initialize(with: logDropConfig)
39
+ }
40
+
41
+ @objc
42
+ func i(_ tag: String, message: String, logFlow: NSDictionary?) {
43
+ let parsedFlow = LogFlowParser.from(dict: logFlow)
44
+ LogDrop.i(message, logFlow: parsedFlow, file: tag)
45
+ }
46
+
47
+ @objc
48
+ func d(_ tag: String, message: String, logFlow: NSDictionary?) {
49
+ let parsedFlow = LogFlowParser.from(dict: logFlow)
50
+ LogDrop.d(message, logFlow: parsedFlow, file: tag)
51
+ }
52
+
53
+ @objc
54
+ func w(_ tag: String, message: String, logFlow: NSDictionary?) {
55
+ let parsedFlow = LogFlowParser.from(dict: logFlow)
56
+ LogDrop.w(message, logFlow: parsedFlow, file: tag)
57
+ }
58
+
59
+ @objc
60
+ func e(_ tag: String, message: String, logFlow: NSDictionary?) {
61
+ let parsedFlow = LogFlowParser.from(dict: logFlow)
62
+ LogDrop.e(message, logFlow: parsedFlow, file: tag)
63
+ }
64
+
65
+
66
+ @objc
67
+ func userUpdate(_ userUuid: String) {
68
+ LogDrop.updateUser(userUuid: userUuid)
69
+ }
70
+
71
+ @objc
72
+ func sendLogs() {
73
+ LogDrop.sendLogs()
74
+ }
75
+
76
+ @objc
77
+ func saveCustomCrashReport(_ threadName: String, stackTrace: String, crashType: String) {
78
+ LogDrop.saveCustomCrashReport(threadName: threadName,
79
+ stackTrace: stackTrace,
80
+ crashType: crashType)
81
+ }
82
+ }
@@ -0,0 +1,24 @@
1
+ //
2
+ // LogFlowParser.swift
3
+ // Pods
4
+ //
5
+ // Created by Initial Code
6
+ //
7
+
8
+ import Foundation
9
+ import LogDropSDK
10
+
11
+ struct LogFlowParser {
12
+ static func from(dict: NSDictionary?) -> LogFlow? {
13
+ guard
14
+ let dict = dict as? [String: Any],
15
+ let name = dict["name"] as? String,
16
+ let id = dict["id"] as? String
17
+ else {
18
+ return nil
19
+ }
20
+
21
+ let customAttributes = dict["customAttributes"] as? [String: String]
22
+ return LogFlow(name: name, id: id, customAttributes: customAttributes)
23
+ }
24
+ }