@screeb/react-native 0.8.7 → 0.8.9

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.
@@ -124,6 +124,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
124
124
  dependencies {
125
125
  // noinspection GradleDynamicVersion
126
126
  api 'com.facebook.react:react-native:+'
127
- implementation "app.screeb.sdk:survey:1.10.2"
127
+ implementation "app.screeb.sdk:survey:1.10.5"
128
128
  implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.0"
129
129
  }
@@ -22,13 +22,13 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
22
22
 
23
23
  @ReactMethod
24
24
  fun initSdk(channelId: String, userId: String?, properties: ReadableMap?) {
25
- Log.d("ScreebModule", "Called setIdentity : $userId")
25
+ Log.d("ScreebModule", "Called initSdk : $userId")
26
26
  var map: HashMap<String, Any?>? = null
27
27
  if (properties != null) {
28
28
  map = properties.toHashMap()
29
29
  }
30
30
  Handler(Looper.getMainLooper()).post {
31
- Screeb?.pluginInit(channelId, userId, map)
31
+ Screeb.pluginInit(channelId, userId, map)
32
32
  }
33
33
  }
34
34
 
@@ -40,66 +40,78 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
40
40
  map = properties.toHashMap()
41
41
  }
42
42
  Handler(Looper.getMainLooper()).post {
43
- Screeb?.setIdentity(userId, map)
43
+ Screeb.setIdentity(userId, map)
44
44
  }
45
45
  }
46
46
 
47
47
  @ReactMethod
48
- fun trackEvent(eventId: String, properties: ReadableMap?) {
49
- Log.d("ScreebModule", "Called trackEvent : $eventId")
48
+ fun setProperties(properties: ReadableMap) {
49
+ Log.d(
50
+ "ScreebModule",
51
+ "Called setVisitorProperties with " + properties.toHashMap().size + " properties"
52
+ )
53
+ Handler(Looper.getMainLooper()).post {
54
+ Screeb.setVisitorProperties(properties.toHashMap())
55
+ }
56
+ }
57
+
58
+ @ReactMethod
59
+ fun assignGroup(type: String? = null, name: String, properties: ReadableMap? = null) {
60
+ Log.d("ScreebModule", "Called assignGroup : $name")
50
61
  var map: HashMap<String, Any?>? = null
51
62
  if (properties != null) {
52
63
  map = properties.toHashMap()
53
64
  }
54
65
  Handler(Looper.getMainLooper()).post {
55
- Screeb?.trackEvent(eventId, map)
66
+ Screeb.assignGroup(type, name, map)
56
67
  }
57
68
  }
58
69
 
59
70
  @ReactMethod
60
- fun trackScreen(screen: String, properties: ReadableMap?) {
61
- Log.d("ScreebModule", "Called trackScreen : $screen")
71
+ fun unassignGroup(type: String? = null, name: String, properties: ReadableMap? = null) {
72
+ Log.d("ScreebModule", "Called unassignGroup : $name")
62
73
  var map: HashMap<String, Any?>? = null
63
74
  if (properties != null) {
64
75
  map = properties.toHashMap()
65
76
  }
66
77
  Handler(Looper.getMainLooper()).post {
67
- Screeb?.trackScreen(screen, map)
78
+ Screeb.unassignGroup(type, name, map)
68
79
  }
69
80
  }
70
81
 
71
82
  @ReactMethod
72
- fun setProperties(properties: ReadableMap) {
73
- Log.d(
74
- "ScreebModule",
75
- "Called setVisitorProperties with " + properties.toHashMap().size + " properties"
76
- )
83
+ fun trackEvent(eventId: String, properties: ReadableMap?) {
84
+ Log.d("ScreebModule", "Called trackEvent : $eventId")
85
+ var map: HashMap<String, Any?>? = null
86
+ if (properties != null) {
87
+ map = properties.toHashMap()
88
+ }
77
89
  Handler(Looper.getMainLooper()).post {
78
- Screeb?.setVisitorProperties(properties.toHashMap())
90
+ Screeb.trackEvent(eventId, map)
79
91
  }
80
92
  }
81
93
 
82
94
  @ReactMethod
83
- fun startSurvey(surveyId: String, allowMultipleResponses: Boolean, hiddenFields: ReadableMap? = null) {
84
- Log.e("ScreebModule", "Called startSurvey : $surveyId")
85
- var map: HashMap<String, Any>? = null
86
- if (hiddenFields != null) {
87
- map = hiddenFields.toHashMap()
95
+ fun trackScreen(screen: String, properties: ReadableMap?) {
96
+ Log.d("ScreebModule", "Called trackScreen : $screen")
97
+ var map: HashMap<String, Any?>? = null
98
+ if (properties != null) {
99
+ map = properties.toHashMap()
88
100
  }
89
101
  Handler(Looper.getMainLooper()).post {
90
- Screeb?.startSurvey(surveyId, allowMultipleResponses, map)
102
+ Screeb.trackScreen(screen, map)
91
103
  }
92
104
  }
93
105
 
94
106
  @ReactMethod
95
- fun assignGroup(type: String? = null, name: String, properties: ReadableMap? = null) {
96
- Log.d("ScreebModule", "Called assignGroup : $name")
107
+ fun startSurvey(surveyId: String, allowMultipleResponses: Boolean? = true, hiddenFields: ReadableMap? = null) {
108
+ Log.e("ScreebModule", "Called startSurvey : $surveyId")
97
109
  var map: HashMap<String, Any>? = null
98
- if (properties != null) {
99
- map = properties.toHashMap()
110
+ if (hiddenFields != null) {
111
+ map = hiddenFields.toHashMap()
100
112
  }
101
113
  Handler(Looper.getMainLooper()).post {
102
- Screeb?.assignGroup(type, name, map)
114
+ Screeb.startSurvey(surveyId, allowMultipleResponses, map)
103
115
  }
104
116
  }
105
117
 
@@ -107,9 +119,7 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
107
119
 
108
120
  @JvmStatic
109
121
  fun setAppContext(context: Context){
110
- Screeb.initSdkWithContextOnly(
111
- context
112
- )
122
+ Screeb.initSdkWithContextOnly(context)
113
123
  }
114
124
 
115
125
  }
@@ -4,11 +4,12 @@
4
4
 
5
5
  RCT_EXTERN_METHOD(initSdk:(NSString *)channelId userId:(NSString *)userId_ properties:(NSDictionary<NSString *, id> *)properties_)
6
6
  RCT_EXTERN_METHOD(setIdentity:(NSString *)userId properties:(NSDictionary<NSString *, id> *)properties_)
7
+ RCT_EXTERN_METHOD(setProperties:(NSDictionary<NSString *, id> *)properties)
8
+ RCT_EXTERN_METHOD(assignGroup:(NSString *)type name:(NSString *)name_ properties:(NSDictionary<NSString *, id> *)properties_)
9
+ RCT_EXTERN_METHOD(unassignGroup:(NSString *)type name:(NSString *)name_ properties:(NSDictionary<NSString *, id> *)properties_)
7
10
  RCT_EXTERN_METHOD(trackEvent:(NSString *)eventId properties:(NSDictionary<NSString *, id> *)properties_)
8
11
  RCT_EXTERN_METHOD(trackScreen:(NSString *)screen properties:(NSDictionary<NSString *, id> *)properties_)
9
- RCT_EXTERN_METHOD(setProperties:(NSDictionary<NSString *, id> *)properties)
10
12
  RCT_EXTERN_METHOD(startSurvey:(NSString *)surveyId allowMultipleResponses:(BOOL)allowMultipleResponses_ hiddenFields:(NSDictionary<NSString *, id> *)hiddenFields_)
11
- RCT_EXTERN_METHOD(assignGroup:(NSString *)type name:(NSString *)name_ properties:(NSDictionary<NSString *, id> *)properties_)
12
13
  + (BOOL)requiresMainQueueSetup
13
14
  {
14
15
  return YES;
@@ -23,7 +23,7 @@ class ScreebModule: NSObject {
23
23
  }
24
24
  }
25
25
 
26
- @objc func setIdentity(_ userId: String, properties properties_: [String: Any]?) {
26
+ @objc func setIdentity(_ userId: String, properties properties_: [String: Any?]?) {
27
27
  var map: [String: AnyEncodable?] = [:]
28
28
  if (properties_ != nil) {
29
29
  map = self.mapToAnyEncodable(map: properties_!)
@@ -33,7 +33,7 @@ class ScreebModule: NSObject {
33
33
  }
34
34
  }
35
35
 
36
- @objc func trackEvent(_ eventId: String, properties properties_: [String: Any]?) {
36
+ @objc func trackEvent(_ eventId: String, properties properties_: [String: Any?]?) {
37
37
  var map: [String: AnyEncodable?] = [:]
38
38
  if (properties_ != nil) {
39
39
  map = self.mapToAnyEncodable(map: properties_!)
@@ -43,7 +43,7 @@ class ScreebModule: NSObject {
43
43
  }
44
44
  }
45
45
 
46
- @objc func trackScreen(_ screen: String, properties properties_: [String: Any]?) {
46
+ @objc func trackScreen(_ screen: String, properties properties_: [String: Any?]?) {
47
47
  var map: [String: AnyEncodable?] = [:]
48
48
  if (properties_ != nil) {
49
49
  map = self.mapToAnyEncodable(map: properties_!)
@@ -54,7 +54,7 @@ class ScreebModule: NSObject {
54
54
  }
55
55
 
56
56
  @objc(setProperties:)
57
- func setVisitorPropertiesImpl(_ properties: [String: Any]) {
57
+ func setVisitorPropertiesImpl(_ properties: [String: Any?]) {
58
58
  let map = self.mapToAnyEncodable(map: properties)
59
59
  DispatchQueue.main.async {
60
60
  Screeb.visitorProperty(visitorProperty: map)
@@ -71,7 +71,17 @@ class ScreebModule: NSObject {
71
71
  }
72
72
  }
73
73
 
74
- @objc func assignGroup(_ type: String?, name name_: String, properties properties_: [String: Any]?) {
74
+ @objc func assignGroup(_ type: String?, name name_: String, properties properties_: [String: Any?]?) {
75
+ var map: [String: AnyEncodable] = [:]
76
+ if (properties_ != nil) {
77
+ map = self.mapToAnyEncodable(map: properties_!).filter({ $0.value != nil }).mapValues({ $0! })
78
+ }
79
+ DispatchQueue.main.async {
80
+ Screeb.assignGroup(type: type, name: name_, properties: map)
81
+ }
82
+ }
83
+
84
+ @objc func unassignGroup(_ type: String?, name name_: String, properties properties_: [String: Any?]?) {
75
85
  var map: [String: AnyEncodable] = [:]
76
86
  if (properties_ != nil) {
77
87
  map = self.mapToAnyEncodable(map: properties_!).filter({ $0.value != nil }).mapValues({ $0! })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screeb/react-native",
3
- "version": "0.8.7",
3
+ "version": "0.8.9",
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
+ }
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
17
 
18
18
  s.dependency "React-Core"
19
- s.dependency "Screeb", '~> 1.10.1'
19
+ s.dependency "Screeb", '~> 1.10.3'
20
20
  end
package/src/index.tsx CHANGED
@@ -31,18 +31,21 @@ export function initSdk(
31
31
  export function setIdentity(userId: string, properties?: Map<string, any>) {
32
32
  return ScreebModule.setIdentity(userId, properties);
33
33
  }
34
+ export function setProperties(properties?: Map<string, any>) {
35
+ return ScreebModule.setProperties(properties);
36
+ }
37
+ export function assignGroup(type: string | null, name: string, properties?: Map<string, any>) {
38
+ return ScreebModule.assignGroup(type, name, properties);
39
+ }
40
+ export function unassignGroup(type: string | null, name: string, properties?: Map<string, any>) {
41
+ return ScreebModule.unassignGroup(type, name, properties);
42
+ }
34
43
  export function trackEvent(name: string, properties?: Map<string, any>) {
35
44
  return ScreebModule.trackEvent(name, properties);
36
45
  }
37
46
  export function trackScreen(name: string, properties?: Map<string, any>) {
38
47
  return ScreebModule.trackScreen(name, properties);
39
48
  }
40
- export function setProperties(properties?: Map<string, any>) {
41
- return ScreebModule.setProperties(properties);
42
- }
43
49
  export function startSurvey(surveyId: string, allowMultipleResponses?: boolean, hiddenFields?: Map<string, any>) {
44
50
  return ScreebModule.startSurvey(surveyId, allowMultipleResponses ?? true, hiddenFields);
45
51
  }
46
- export function assignGroup(type: string | null, name: string, properties?: Map<string, any>) {
47
- return ScreebModule.assignGroup(name, type, properties);
48
- }