@screeb/react-native 0.8.3 → 0.8.4

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.
@@ -10,6 +10,8 @@ import androidx.annotation.NonNull
10
10
  import android.content.Context
11
11
  import android.util.Log
12
12
  import app.screeb.sdk.Screeb
13
+ import android.os.Handler
14
+ import android.os.Looper
13
15
 
14
16
  class ScreebModuleModule(reactContext: ReactApplicationContext) :
15
17
  ReactContextBaseJavaModule(reactContext) {
@@ -25,7 +27,9 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
25
27
  if (properties != null) {
26
28
  map = properties.toHashMap()
27
29
  }
28
- screeb?.pluginInit(channelId, userId, map)
30
+ Handler(Looper.getMainLooper()).post {
31
+ screeb?.pluginInit(channelId, userId, map)
32
+ }
29
33
  }
30
34
 
31
35
  @ReactMethod
@@ -35,7 +39,9 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
35
39
  if (properties != null) {
36
40
  map = properties.toHashMap()
37
41
  }
38
- screeb?.setIdentity(userId, map)
42
+ Handler(Looper.getMainLooper()).post {
43
+ screeb?.setIdentity(userId, map)
44
+ }
39
45
  }
40
46
 
41
47
  @ReactMethod
@@ -45,7 +51,9 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
45
51
  if (properties != null) {
46
52
  map = properties.toHashMap()
47
53
  }
48
- screeb?.trackEvent(eventId, map)
54
+ Handler(Looper.getMainLooper()).post {
55
+ screeb?.trackEvent(eventId, map)
56
+ }
49
57
  }
50
58
 
51
59
  @ReactMethod
@@ -55,7 +63,9 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
55
63
  if (properties != null) {
56
64
  map = properties.toHashMap()
57
65
  }
58
- screeb?.trackScreen(screen, map)
66
+ Handler(Looper.getMainLooper()).post {
67
+ screeb?.trackScreen(screen, map)
68
+ }
59
69
  }
60
70
 
61
71
  @ReactMethod
@@ -64,7 +74,9 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
64
74
  "ScreebModule",
65
75
  "Called setVisitorProperties with " + properties.toHashMap().size + " properties"
66
76
  )
67
- screeb?.setVisitorProperties(properties.toHashMap())
77
+ Handler(Looper.getMainLooper()).post {
78
+ screeb?.setVisitorProperties(properties.toHashMap())
79
+ }
68
80
  }
69
81
 
70
82
  companion object {
@@ -1,5 +1,6 @@
1
1
  import Screeb
2
2
  import UIKit
3
+ import Foundation
3
4
 
4
5
  @objc(ScreebModule)
5
6
  class ScreebModule: NSObject {
@@ -14,7 +15,9 @@ class ScreebModule: NSObject {
14
15
  map = self.mapToAnyEncodable(map: properties_!)
15
16
  }
16
17
  if let controller = UIApplication.shared.keyWindow?.rootViewController {
17
- Screeb.initSdk(context: controller, channelId: channelId, identity: userId_, visitorProperty: map)
18
+ DispatchQueue.main.async {
19
+ Screeb.initSdk(context: controller, channelId: channelId, identity: userId_, visitorProperty: map)
20
+ }
18
21
  } else {
19
22
  print("Screeb : error init, could not find rootViewController")
20
23
  }
@@ -25,7 +28,9 @@ class ScreebModule: NSObject {
25
28
  if (properties_ != nil) {
26
29
  map = self.mapToAnyEncodable(map: properties_!)
27
30
  }
28
- Screeb.setIdentity(uniqueVisitorId: userId, visitorProperty: map)
31
+ DispatchQueue.main.async {
32
+ Screeb.setIdentity(uniqueVisitorId: userId, visitorProperty: map)
33
+ }
29
34
  }
30
35
 
31
36
  @objc func trackEvent(_ eventId: String, properties properties_: [String: Any]?) {
@@ -33,7 +38,9 @@ class ScreebModule: NSObject {
33
38
  if (properties_ != nil) {
34
39
  map = self.mapToAnyEncodable(map: properties_!)
35
40
  }
36
- Screeb.trackEvent(name: eventId, trackingEventProperties: map)
41
+ DispatchQueue.main.async {
42
+ Screeb.trackEvent(name: eventId, trackingEventProperties: map)
43
+ }
37
44
  }
38
45
 
39
46
  @objc func trackScreen(_ screen: String, properties properties_: [String: Any]?) {
@@ -41,13 +48,17 @@ class ScreebModule: NSObject {
41
48
  if (properties_ != nil) {
42
49
  map = self.mapToAnyEncodable(map: properties_!)
43
50
  }
44
- Screeb.trackScreen(name: screen, trackingEventProperties: map)
51
+ DispatchQueue.main.async {
52
+ Screeb.trackScreen(name: screen, trackingEventProperties: map)
53
+ }
45
54
  }
46
55
 
47
56
  @objc(setProperties:)
48
57
  func setVisitorPropertiesImpl(_ properties: [String: Any]) {
49
58
  let map = self.mapToAnyEncodable(map: properties)
50
- Screeb.visitorProperty(visitorProperty: map)
59
+ DispatchQueue.main.async {
60
+ Screeb.visitorProperty(visitorProperty: map)
61
+ }
51
62
  }
52
63
 
53
64
  private func mapToAnyEncodable(map: [String: Any]) -> [String: AnyEncodable?] {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screeb/react-native",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "A react-native module to integrate Screeb mobile sdk for Android and/or iOS.",
5
5
  "scripts": {
6
6
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
@@ -51,4 +51,4 @@
51
51
  "react": "*",
52
52
  "react-native": "*"
53
53
  }
54
- }
54
+ }