react-native-genius-sdk 1.0.5 → 1.0.6

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.
@@ -64,7 +64,7 @@ fun logEvent(eventName: String, eventValue: ReadableMap, promise: Promise) {
64
64
  // Run logging asynchronously on IO thread
65
65
  scope.launch {
66
66
  try {
67
- geniusSdk.logEvent(eventName = eventName, eventValue = dataMap)
67
+ geniusSdk.logEvent(eventName = GeniusSDK.EventName.Custom(eventName), eventValue = dataMap)
68
68
 
69
69
  // Resolve the JS promise on Main thread
70
70
  withContext(Dispatchers.Main) {
@@ -50,10 +50,24 @@ class GeniusSdk: RCTEventEmitter {
50
50
 
51
51
  @objc(logEvent:withEventValue:withResolver:withRejecter:)
52
52
  func logEvent(
53
- eventName: String, eventValue: [String: Any], resolve: @escaping RCTPromiseResolveBlock,
53
+ eventName: String,
54
+ eventValue: [String: Any],
55
+ resolve: @escaping RCTPromiseResolveBlock,
54
56
  reject: @escaping RCTPromiseRejectBlock
55
57
  ) {
56
- geniusSdk.logEvent(eventName: eventName, eventValue: eventValue)
58
+ // Run async code in a Swift concurrency Task
59
+ Task {
60
+ do {
61
+ // Await the async SDK method
62
+ await self.geniusSdk.logEvent(eventName: .custom(eventName), eventValue: eventValue)
63
+
64
+ // Resolve the JS promise after completion
65
+ resolve(true)
66
+ } catch {
67
+ // Reject the JS promise if an error occurs
68
+ reject("logEvent_ERROR", error.localizedDescription, error)
69
+ }
70
+ }
57
71
  }
58
72
 
59
73
  @objc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-genius-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A react native package for GeniusSDK",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",