@screeb/react-native 2.1.0 → 2.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.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/screebmodule/ScreebModuleModule.kt +20 -15
- package/ios/ScreebModule.swift +44 -33
- package/lib/commonjs/index.js +10 -5
- package/lib/module/index.js +10 -5
- package/package.json +3 -3
- package/screeb-module.podspec +1 -1
- package/src/index.tsx +10 -5
package/android/build.gradle
CHANGED
|
@@ -123,6 +123,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
123
123
|
dependencies {
|
|
124
124
|
// noinspection GradleDynamicVersion
|
|
125
125
|
api 'com.facebook.react:react-native:+'
|
|
126
|
-
implementation "app.screeb.sdk:survey:2.
|
|
126
|
+
implementation "app.screeb.sdk:survey:2.1.2"
|
|
127
127
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
|
|
128
128
|
}
|
|
@@ -28,7 +28,7 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
28
28
|
@ReactMethod
|
|
29
29
|
fun initSdk(channelId: String, userId: String?, properties: ReadableMap?, hooks: ReadableMap?, initOptions: ReadableMap?) {
|
|
30
30
|
Log.d("ScreebModule", "Called initSdk : $userId")
|
|
31
|
-
Screeb.setSecondarySDK("react-native", "2.1.
|
|
31
|
+
Screeb.setSecondarySDK("react-native", "2.1.1")
|
|
32
32
|
var map: HashMap<String, Any?>? = null
|
|
33
33
|
if (properties != null) {
|
|
34
34
|
map = properties.toHashMap()
|
|
@@ -164,20 +164,6 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
@ReactMethod
|
|
168
|
-
fun debug(){
|
|
169
|
-
Log.d("ScreebModule","Called debug")
|
|
170
|
-
Screeb.debug()
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
@ReactMethod
|
|
174
|
-
fun debugTargeting(){
|
|
175
|
-
Log.d("ScreebModule","Called debugTargeting")
|
|
176
|
-
Handler(Looper.getMainLooper()).post {
|
|
177
|
-
Screeb.debugTargeting()
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
167
|
@ReactMethod
|
|
182
168
|
fun resetIdentity(){
|
|
183
169
|
Log.d("ScreebModule","Called resetIdentity")
|
|
@@ -201,4 +187,23 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
201
187
|
Screeb.closeSurvey()
|
|
202
188
|
}
|
|
203
189
|
}
|
|
190
|
+
|
|
191
|
+
@ReactMethod
|
|
192
|
+
fun onHookResult(hookId: String, result: Any?){
|
|
193
|
+
Screeb.onHookResult(hookId, result)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@ReactMethod
|
|
197
|
+
fun debug(){
|
|
198
|
+
Log.d("ScreebModule","Called debug")
|
|
199
|
+
Screeb.debug()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@ReactMethod
|
|
203
|
+
fun debugTargeting(){
|
|
204
|
+
Log.d("ScreebModule","Called debugTargeting")
|
|
205
|
+
Handler(Looper.getMainLooper()).post {
|
|
206
|
+
Screeb.debugTargeting()
|
|
207
|
+
}
|
|
208
|
+
}
|
|
204
209
|
}
|
package/ios/ScreebModule.swift
CHANGED
|
@@ -11,7 +11,7 @@ class ScreebModule: RCTEventEmitter {
|
|
|
11
11
|
properties properties_: [String: Any]?,
|
|
12
12
|
hooks hooks_: [String: Any]?,
|
|
13
13
|
initOptions initOptions_: [String: Any]?) {
|
|
14
|
-
Screeb.setSecondarySDK(name: "react-native", version: "2.1.
|
|
14
|
+
Screeb.setSecondarySDK(name: "react-native", version: "2.1.1")
|
|
15
15
|
var map: [String: AnyEncodable?] = [:]
|
|
16
16
|
if (properties_ != nil) {
|
|
17
17
|
map = self.mapToAnyEncodable(map: properties_!)
|
|
@@ -119,60 +119,71 @@ class ScreebModule: RCTEventEmitter {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
@objc func
|
|
122
|
+
@objc func resetIdentity(){
|
|
123
123
|
DispatchQueue.main.async {
|
|
124
|
-
Screeb.
|
|
124
|
+
Screeb.resetIdentity()
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
@objc func
|
|
128
|
+
@objc func closeSdk(){
|
|
129
129
|
DispatchQueue.main.async {
|
|
130
|
-
Screeb.
|
|
130
|
+
Screeb.closeSdk()
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
@objc func
|
|
134
|
+
@objc func closeSurvey(){
|
|
135
135
|
DispatchQueue.main.async {
|
|
136
|
-
Screeb.
|
|
136
|
+
Screeb.closeSurvey()
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
@objc func
|
|
140
|
+
@objc func onHookResult(_ hookId: String, result: Any?) {
|
|
141
141
|
DispatchQueue.main.async {
|
|
142
|
-
|
|
142
|
+
let encoded = self.toAnyEncodable(result)
|
|
143
|
+
Screeb.onHookResult(hookId, encoded)
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
@objc func
|
|
147
|
+
@objc func debug(){
|
|
147
148
|
DispatchQueue.main.async {
|
|
148
|
-
Screeb.
|
|
149
|
+
Screeb.debug()
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
anyEncodableMap[key] = AnyEncodable(value)
|
|
169
|
-
} else if let value = value as? [String: Any?] {
|
|
170
|
-
anyEncodableMap[key] = AnyEncodable(self.mapToAnyEncodable(map: value))
|
|
153
|
+
@objc func debugTargeting(){
|
|
154
|
+
DispatchQueue.main.async {
|
|
155
|
+
Screeb.debugTargeting()
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private func toAnyEncodable(_ value: Any?) -> AnyEncodable? {
|
|
160
|
+
if let nsValue = value as? NSNumber {
|
|
161
|
+
if CFBooleanGetTypeID() == CFGetTypeID(nsValue) {
|
|
162
|
+
return AnyEncodable(nsValue.boolValue)
|
|
163
|
+
} else if let value = value as? Int {
|
|
164
|
+
return AnyEncodable(value)
|
|
165
|
+
} else if let value = value as? Double {
|
|
166
|
+
return AnyEncodable(value)
|
|
167
|
+
} else if let value = value as? Float {
|
|
168
|
+
return AnyEncodable(value)
|
|
171
169
|
} else {
|
|
172
|
-
|
|
170
|
+
return nil
|
|
173
171
|
}
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
} else if let value = value as? String {
|
|
173
|
+
return AnyEncodable(value)
|
|
174
|
+
} else if let value = value as? [String: Any?] {
|
|
175
|
+
return AnyEncodable(self.mapToAnyEncodable(map: value))
|
|
176
|
+
} else {
|
|
177
|
+
return nil
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private func mapToAnyEncodable(map: [String: Any?]?) -> [String: AnyEncodable?] {
|
|
182
|
+
var anyEncodableMap: [String: AnyEncodable?] = [:]
|
|
183
|
+
map?.forEach { key, value in
|
|
184
|
+
anyEncodableMap[key] = self.toAnyEncodable(value)
|
|
185
|
+
}
|
|
186
|
+
return anyEncodableMap
|
|
176
187
|
}
|
|
177
188
|
|
|
178
189
|
override func supportedEvents() -> [String]! {
|
package/lib/commonjs/index.js
CHANGED
|
@@ -27,8 +27,7 @@ function initSdk(androidChannelId, iosChannelId, userId, properties, hooks, isDe
|
|
|
27
27
|
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
|
|
31
|
-
let uuid = Date.now().toString() + Math.random().toString();
|
|
30
|
+
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
32
31
|
hooksRegistry.set(uuid, hooks[key]);
|
|
33
32
|
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
34
33
|
}
|
|
@@ -75,8 +74,7 @@ function startSurvey(surveyId, allowMultipleResponses, hiddenFields, ignoreSurve
|
|
|
75
74
|
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
76
75
|
}
|
|
77
76
|
else {
|
|
78
|
-
|
|
79
|
-
let uuid = Date.now().toString() + Math.random().toString();
|
|
77
|
+
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
80
78
|
hooksRegistry.set(uuid, hooks[key]);
|
|
81
79
|
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
82
80
|
}
|
|
@@ -106,10 +104,17 @@ function closeSurvey() {
|
|
|
106
104
|
}
|
|
107
105
|
exports.closeSurvey = closeSurvey;
|
|
108
106
|
function handleEvent(event) {
|
|
107
|
+
console.log(event);
|
|
109
108
|
if (event?.hookId != null) {
|
|
110
109
|
let hook = hooksRegistry.get(event.hookId);
|
|
111
110
|
if (hook != null) {
|
|
112
|
-
hook(event.payload);
|
|
111
|
+
const result = hook(event.payload);
|
|
112
|
+
console.log("Hook result: ", result);
|
|
113
|
+
console.log(event.payload);
|
|
114
|
+
const originalHookId = event?.payload?.hook_id;
|
|
115
|
+
if (originalHookId) {
|
|
116
|
+
ScreebModule.onHookResult(originalHookId, result);
|
|
117
|
+
}
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
}
|
package/lib/module/index.js
CHANGED
|
@@ -24,8 +24,7 @@ export function initSdk(androidChannelId, iosChannelId, userId, properties, hook
|
|
|
24
24
|
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
|
|
28
|
-
let uuid = Date.now().toString() + Math.random().toString();
|
|
27
|
+
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
29
28
|
hooksRegistry.set(uuid, hooks[key]);
|
|
30
29
|
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
31
30
|
}
|
|
@@ -65,8 +64,7 @@ export function startSurvey(surveyId, allowMultipleResponses, hiddenFields, igno
|
|
|
65
64
|
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
66
65
|
}
|
|
67
66
|
else {
|
|
68
|
-
|
|
69
|
-
let uuid = Date.now().toString() + Math.random().toString();
|
|
67
|
+
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
70
68
|
hooksRegistry.set(uuid, hooks[key]);
|
|
71
69
|
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
72
70
|
}
|
|
@@ -90,10 +88,17 @@ export function closeSurvey() {
|
|
|
90
88
|
return ScreebModule.closeSurvey();
|
|
91
89
|
}
|
|
92
90
|
function handleEvent(event) {
|
|
91
|
+
console.log(event);
|
|
93
92
|
if (event?.hookId != null) {
|
|
94
93
|
let hook = hooksRegistry.get(event.hookId);
|
|
95
94
|
if (hook != null) {
|
|
96
|
-
hook(event.payload);
|
|
95
|
+
const result = hook(event.payload);
|
|
96
|
+
console.log("Hook result: ", result);
|
|
97
|
+
console.log(event.payload);
|
|
98
|
+
const originalHookId = event?.payload?.hook_id;
|
|
99
|
+
if (originalHookId) {
|
|
100
|
+
ScreebModule.onHookResult(originalHookId, result);
|
|
101
|
+
}
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@screeb/react-native",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Continuous Product Discovery",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rm -rf lib/",
|
|
7
7
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
8
8
|
"build": "npm run clean ; tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json"
|
|
9
9
|
},
|
|
10
|
-
"react-native": "src/index",
|
|
10
|
+
"react-native": "src/index.tsx",
|
|
11
11
|
"main": "lib/commonjs/index.js",
|
|
12
12
|
"module": "lib/module/index.js",
|
|
13
|
-
"source": "src/index",
|
|
13
|
+
"source": "src/index.tsx",
|
|
14
14
|
"keywords": [
|
|
15
15
|
"react-native",
|
|
16
16
|
"ios",
|
package/screeb-module.podspec
CHANGED
package/src/index.tsx
CHANGED
|
@@ -44,8 +44,7 @@ export function initSdk(
|
|
|
44
44
|
if (key == "version") {
|
|
45
45
|
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
46
46
|
} else {
|
|
47
|
-
|
|
48
|
-
let uuid = Date.now().toString() + Math.random().toString();
|
|
47
|
+
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
49
48
|
hooksRegistry.set(uuid, hooks[key]);
|
|
50
49
|
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
51
50
|
}
|
|
@@ -109,8 +108,7 @@ export function startSurvey(
|
|
|
109
108
|
if (key == "version") {
|
|
110
109
|
mapHooksId = { ...mapHooksId, version: hooks[key] };
|
|
111
110
|
} else {
|
|
112
|
-
|
|
113
|
-
let uuid = Date.now().toString() + Math.random().toString();
|
|
111
|
+
let uuid = Date.now().toString() + Math.random().toString() + key;
|
|
114
112
|
hooksRegistry.set(uuid, hooks[key]);
|
|
115
113
|
mapHooksId = { ...mapHooksId, [key]: uuid };
|
|
116
114
|
}
|
|
@@ -141,10 +139,17 @@ export function closeSurvey() {
|
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
function handleEvent(event: any) {
|
|
142
|
+
console.log(event);
|
|
144
143
|
if (event?.hookId != null) {
|
|
145
144
|
let hook = hooksRegistry.get(event.hookId);
|
|
146
145
|
if (hook != null) {
|
|
147
|
-
hook(event.payload);
|
|
146
|
+
const result = hook(event.payload);
|
|
147
|
+
console.log("Hook result: ", result);
|
|
148
|
+
console.log(event.payload);
|
|
149
|
+
const originalHookId = event?.payload?.hook_id;
|
|
150
|
+
if (originalHookId) {
|
|
151
|
+
ScreebModule.onHookResult(originalHookId, result);
|
|
152
|
+
}
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
155
|
}
|