@screeb/react-native 2.1.18 → 2.2.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/README.md +24 -5
- package/{screeb-module.podspec → ScreebReactNative.podspec} +6 -4
- package/android/build.gradle +36 -86
- package/android/gradle.properties +5 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/app/screeb/reactnative/ScreebReactNativeModule.kt +258 -0
- package/android/src/main/java/app/screeb/reactnative/ScreebReactNativePackage.kt +33 -0
- package/ios/ScreebReactNative.m +63 -0
- package/ios/ScreebReactNative.swift +229 -0
- package/lib/module/NativeScreebReactNative.js +10 -0
- package/lib/module/NativeScreebReactNative.js.map +1 -0
- package/lib/module/index.js +170 -88
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeScreebReactNative.d.ts +49 -0
- package/lib/typescript/src/NativeScreebReactNative.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +25 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +153 -59
- package/src/NativeScreebReactNative.ts +81 -0
- package/src/index.tsx +255 -144
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/src/main/java/com/screebmodule/ScreebModuleModule.kt +0 -186
- package/android/src/main/java/com/screebmodule/ScreebModulePackage.kt +0 -17
- package/ios/ScreebModule-Bridging-Header.h +0 -3
- package/ios/ScreebModule.m +0 -24
- package/ios/ScreebModule.swift +0 -210
- package/ios/ScreebModule.xcodeproj/project.pbxproj +0 -293
- package/lib/commonjs/index.js +0 -130
- package/lib/typescript/index.d.ts +0 -13
package/android/gradlew.bat
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
@rem
|
|
2
|
-
@rem Copyright 2015 the original author or authors.
|
|
3
|
-
@rem
|
|
4
|
-
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
@rem you may not use this file except in compliance with the License.
|
|
6
|
-
@rem You may obtain a copy of the License at
|
|
7
|
-
@rem
|
|
8
|
-
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
@rem
|
|
10
|
-
@rem Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
@rem See the License for the specific language governing permissions and
|
|
14
|
-
@rem limitations under the License.
|
|
15
|
-
@rem
|
|
16
|
-
|
|
17
|
-
@if "%DEBUG%" == "" @echo off
|
|
18
|
-
@rem ##########################################################################
|
|
19
|
-
@rem
|
|
20
|
-
@rem Gradle startup script for Windows
|
|
21
|
-
@rem
|
|
22
|
-
@rem ##########################################################################
|
|
23
|
-
|
|
24
|
-
@rem Set local scope for the variables with windows NT shell
|
|
25
|
-
if "%OS%"=="Windows_NT" setlocal
|
|
26
|
-
|
|
27
|
-
set DIRNAME=%~dp0
|
|
28
|
-
if "%DIRNAME%" == "" set DIRNAME=.
|
|
29
|
-
set APP_BASE_NAME=%~n0
|
|
30
|
-
set APP_HOME=%DIRNAME%
|
|
31
|
-
|
|
32
|
-
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
33
|
-
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
34
|
-
|
|
35
|
-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
36
|
-
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
37
|
-
|
|
38
|
-
@rem Find java.exe
|
|
39
|
-
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
40
|
-
|
|
41
|
-
set JAVA_EXE=java.exe
|
|
42
|
-
%JAVA_EXE% -version >NUL 2>&1
|
|
43
|
-
if "%ERRORLEVEL%" == "0" goto execute
|
|
44
|
-
|
|
45
|
-
echo.
|
|
46
|
-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
47
|
-
echo.
|
|
48
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
49
|
-
echo location of your Java installation.
|
|
50
|
-
|
|
51
|
-
goto fail
|
|
52
|
-
|
|
53
|
-
:findJavaFromJavaHome
|
|
54
|
-
set JAVA_HOME=%JAVA_HOME:"=%
|
|
55
|
-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
56
|
-
|
|
57
|
-
if exist "%JAVA_EXE%" goto execute
|
|
58
|
-
|
|
59
|
-
echo.
|
|
60
|
-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
61
|
-
echo.
|
|
62
|
-
echo Please set the JAVA_HOME variable in your environment to match the
|
|
63
|
-
echo location of your Java installation.
|
|
64
|
-
|
|
65
|
-
goto fail
|
|
66
|
-
|
|
67
|
-
:execute
|
|
68
|
-
@rem Setup the command line
|
|
69
|
-
|
|
70
|
-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@rem Execute Gradle
|
|
74
|
-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
75
|
-
|
|
76
|
-
:end
|
|
77
|
-
@rem End local scope for the variables with windows NT shell
|
|
78
|
-
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
79
|
-
|
|
80
|
-
:fail
|
|
81
|
-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
82
|
-
rem the _cmd.exe /c_ return code!
|
|
83
|
-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
84
|
-
exit /b 1
|
|
85
|
-
|
|
86
|
-
:mainEnd
|
|
87
|
-
if "%OS%"=="Windows_NT" endlocal
|
|
88
|
-
|
|
89
|
-
:omega
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
package com.screebmodule
|
|
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 com.facebook.react.bridge.ReadableArray
|
|
9
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
10
|
-
import com.facebook.react.bridge.Arguments
|
|
11
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
12
|
-
import java.util.HashMap
|
|
13
|
-
import androidx.annotation.NonNull
|
|
14
|
-
import android.content.Context
|
|
15
|
-
import android.util.Log
|
|
16
|
-
import app.screeb.sdk.InitOptions
|
|
17
|
-
import app.screeb.sdk.Screeb
|
|
18
|
-
import android.os.Handler
|
|
19
|
-
import android.os.Looper
|
|
20
|
-
|
|
21
|
-
class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
22
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
23
|
-
|
|
24
|
-
override fun getName(): String {
|
|
25
|
-
return "ScreebModule"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@ReactMethod
|
|
29
|
-
fun initSdk(channelId: String, userId: String?, properties: ReadableMap?, hooks: ReadableMap?, initOptions: ReadableMap?, language: String?) {
|
|
30
|
-
Log.d("ScreebModule", "Called initSdk : $userId")
|
|
31
|
-
Screeb.setSecondarySDK("react-native", "2.1.18")
|
|
32
|
-
var mapHooks:HashMap<String, Any>? = null
|
|
33
|
-
if (hooks != null) {
|
|
34
|
-
mapHooks = hashMapOf<String, Any>()
|
|
35
|
-
val hooksKeys = hooks.keySetIterator()
|
|
36
|
-
while (hooksKeys.hasNextKey()) {
|
|
37
|
-
val key = hooksKeys.nextKey()
|
|
38
|
-
val value = hooks.getString(key)
|
|
39
|
-
if (key == "version"){
|
|
40
|
-
mapHooks[key] = value!!
|
|
41
|
-
} else {
|
|
42
|
-
mapHooks[key] = { payload:Any -> this.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java).emit("ScreebEvent", Arguments.createMap().apply {
|
|
43
|
-
putString("hookId", value!!)
|
|
44
|
-
putString("payload", payload.toString())
|
|
45
|
-
}) }
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
Handler(Looper.getMainLooper()).post {
|
|
51
|
-
Screeb.pluginInit(channelId, userId, this.fromReadableMap(properties), mapHooks, language)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@ReactMethod
|
|
56
|
-
fun setIdentity(userId: String, properties: ReadableMap?) {
|
|
57
|
-
Log.d("ScreebModule", "Called setIdentity : $userId")
|
|
58
|
-
Handler(Looper.getMainLooper()).post {
|
|
59
|
-
Screeb.setIdentity(userId, this.fromReadableMap(properties))
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@ReactMethod
|
|
64
|
-
fun setProperties(properties: ReadableMap?) {
|
|
65
|
-
if (properties == null) {
|
|
66
|
-
Log.d("ScreebModule", "Called setProperties with null properties")
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
Log.d("ScreebModule", "Called setProperties")
|
|
71
|
-
Handler(Looper.getMainLooper()).post {
|
|
72
|
-
Screeb.setVisitorProperties(this.fromReadableMap(properties)!!)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@ReactMethod
|
|
77
|
-
fun assignGroup(type: String? = null, name: String, properties: ReadableMap? = null) {
|
|
78
|
-
Log.d("ScreebModule", "Called assignGroup : $name")
|
|
79
|
-
Handler(Looper.getMainLooper()).post {
|
|
80
|
-
Screeb.assignGroup(type, name, this.fromReadableMap(properties))
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@ReactMethod
|
|
85
|
-
fun unassignGroup(type: String? = null, name: String, properties: ReadableMap? = null) {
|
|
86
|
-
Log.d("ScreebModule", "Called unassignGroup : $name")
|
|
87
|
-
Handler(Looper.getMainLooper()).post {
|
|
88
|
-
Screeb.unassignGroup(type, name, this.fromReadableMap(properties))
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@ReactMethod
|
|
93
|
-
fun trackEvent(eventId: String, properties: ReadableMap?) {
|
|
94
|
-
Log.d("ScreebModule", "Called trackEvent : $eventId")
|
|
95
|
-
Handler(Looper.getMainLooper()).post {
|
|
96
|
-
Screeb.trackEvent(eventId, this.fromReadableMap(properties))
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@ReactMethod
|
|
101
|
-
fun trackScreen(screen: String, properties: ReadableMap?) {
|
|
102
|
-
Log.d("ScreebModule", "Called trackScreen : $screen")
|
|
103
|
-
Handler(Looper.getMainLooper()).post {
|
|
104
|
-
Screeb.trackScreen(screen, this.fromReadableMap(properties))
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@ReactMethod
|
|
109
|
-
fun startSurvey(surveyId: String, allowMultipleResponses: Boolean? = true, hiddenFields: ReadableMap? = null, ignoreSurveyStatus: Boolean? = true, hooks: ReadableMap? = null, language: String? = null) {
|
|
110
|
-
Log.e("ScreebModule", "Called startSurvey : $surveyId")
|
|
111
|
-
var mapHooks:HashMap<String, Any>? = null
|
|
112
|
-
if (hooks != null) {
|
|
113
|
-
mapHooks = hashMapOf<String, Any>()
|
|
114
|
-
val hooksKeys = hooks.keySetIterator()
|
|
115
|
-
while (hooksKeys.hasNextKey()) {
|
|
116
|
-
val key = hooksKeys.nextKey()
|
|
117
|
-
val value = hooks.getString(key)
|
|
118
|
-
if (key == "version"){
|
|
119
|
-
mapHooks[key] = value!!
|
|
120
|
-
} else {
|
|
121
|
-
mapHooks[key] = { payload:Any -> this.reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java).emit("ScreebEvent", Arguments.createMap().apply {
|
|
122
|
-
putString("hookId", value!!)
|
|
123
|
-
putString("payload", payload.toString())
|
|
124
|
-
}) }
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
Handler(Looper.getMainLooper()).post {
|
|
129
|
-
Screeb.startSurvey(surveyId, allowMultipleResponses ?: true, this.fromReadableMap(hiddenFields), ignoreSurveyStatus ?: true, mapHooks, language)
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@ReactMethod
|
|
134
|
-
fun resetIdentity(){
|
|
135
|
-
Log.d("ScreebModule","Called resetIdentity")
|
|
136
|
-
Handler(Looper.getMainLooper()).post {
|
|
137
|
-
Screeb.resetIdentity()
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@ReactMethod
|
|
142
|
-
fun closeSdk(){
|
|
143
|
-
Log.d("ScreebModule","Called closeSdk")
|
|
144
|
-
Handler(Looper.getMainLooper()).post {
|
|
145
|
-
Screeb.closeSdk()
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@ReactMethod
|
|
150
|
-
fun closeSurvey(){
|
|
151
|
-
Log.d("ScreebModule","Called closeSurvey")
|
|
152
|
-
Handler(Looper.getMainLooper()).post {
|
|
153
|
-
Screeb.closeSurvey()
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@ReactMethod
|
|
158
|
-
fun onHookResult(hookId: String, payload: ReadableMap?){
|
|
159
|
-
if (payload != null) {
|
|
160
|
-
val result = this.fromReadableMap(payload!!)!!["result"] as Any?
|
|
161
|
-
Screeb.onHookResult(hookId, result)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
@ReactMethod
|
|
166
|
-
fun debug(){
|
|
167
|
-
Log.d("ScreebModule","Called debug")
|
|
168
|
-
Screeb.debug()
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@ReactMethod
|
|
172
|
-
fun debugTargeting(){
|
|
173
|
-
Log.d("ScreebModule","Called debugTargeting")
|
|
174
|
-
Handler(Looper.getMainLooper()).post {
|
|
175
|
-
Screeb.debugTargeting()
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private fun fromReadableMap(readableMap: ReadableMap?): HashMap<String, Any?>? {
|
|
180
|
-
if (readableMap == null) {
|
|
181
|
-
return null
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return readableMap!!.toHashMap() as HashMap<String, Any?>?
|
|
185
|
-
}
|
|
186
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package com.screebmodule
|
|
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 ScreebModulePackage : ReactPackage {
|
|
10
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
-
return listOf(ScreebModuleModule(reactContext))
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
-
return emptyList()
|
|
16
|
-
}
|
|
17
|
-
}
|
package/ios/ScreebModule.m
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
#import <React/RCTEventEmitter.h>
|
|
3
|
-
|
|
4
|
-
@interface RCT_EXTERN_MODULE(ScreebModule, RCTEventEmitter)
|
|
5
|
-
|
|
6
|
-
RCT_EXTERN_METHOD(initSdk:(NSString *)channelId userId:(NSString *)userId_ properties:(NSDictionary<NSString *, id> *)properties_ hooks:(NSDictionary<NSString *, id> *)hooks_ initOptions:(NSDictionary<NSString *, id> *)initOptions_ language:(NSString *)language_)
|
|
7
|
-
RCT_EXTERN_METHOD(setIdentity:(NSString *)userId properties:(NSDictionary<NSString *, id> *)properties_)
|
|
8
|
-
RCT_EXTERN_METHOD(setProperties:(NSDictionary<NSString *, id> *)properties)
|
|
9
|
-
RCT_EXTERN_METHOD(assignGroup:(NSString *)type name:(NSString *)name_ properties:(NSDictionary<NSString *, id> *)properties_)
|
|
10
|
-
RCT_EXTERN_METHOD(unassignGroup:(NSString *)type name:(NSString *)name_ properties:(NSDictionary<NSString *, id> *)properties_)
|
|
11
|
-
RCT_EXTERN_METHOD(trackEvent:(NSString *)eventId properties:(NSDictionary<NSString *, id> *)properties_)
|
|
12
|
-
RCT_EXTERN_METHOD(trackScreen:(NSString *)screen properties:(NSDictionary<NSString *, id> *)properties_)
|
|
13
|
-
RCT_EXTERN_METHOD(startSurvey:(NSString *)surveyId allowMultipleResponses:(BOOL)allowMultipleResponses_ hiddenFields:(NSDictionary<NSString *, id> *)hiddenFields_ ignoreSurveyStatus:(BOOL)ignoreSurveyStatus_ hooks:(NSDictionary<NSString *, id> *)hooks_ language:(NSString *)language_)
|
|
14
|
-
RCT_EXTERN_METHOD(onHookResult:(NSString *)hookId payload:(NSDictionary<NSString *, id> *)payload_)
|
|
15
|
-
RCT_EXTERN_METHOD(debug)
|
|
16
|
-
RCT_EXTERN_METHOD(debugTargeting)
|
|
17
|
-
RCT_EXTERN_METHOD(closeSdk)
|
|
18
|
-
RCT_EXTERN_METHOD(closeSurvey)
|
|
19
|
-
RCT_EXTERN_METHOD(resetIdentity)
|
|
20
|
-
+ (BOOL)requiresMainQueueSetup
|
|
21
|
-
{
|
|
22
|
-
return YES;
|
|
23
|
-
}
|
|
24
|
-
@end
|
package/ios/ScreebModule.swift
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import Screeb
|
|
2
|
-
import UIKit
|
|
3
|
-
import Foundation
|
|
4
|
-
|
|
5
|
-
@objc(ScreebModule)
|
|
6
|
-
class ScreebModule: RCTEventEmitter {
|
|
7
|
-
@objc(initSdk:userId:properties:hooks:initOptions:language:)
|
|
8
|
-
func initSdk(
|
|
9
|
-
_ channelId: String,
|
|
10
|
-
userId userId_: String?,
|
|
11
|
-
properties properties_: [String: Any]?,
|
|
12
|
-
hooks hooks_: [String: Any]?,
|
|
13
|
-
initOptions initOptions_: [String: Any]?,
|
|
14
|
-
language language_: String?
|
|
15
|
-
) {
|
|
16
|
-
Screeb.setSecondarySDK(name: "react-native", version: "2.1.18")
|
|
17
|
-
var map: [String: AnyEncodable?] = [:]
|
|
18
|
-
if (properties_ != nil) {
|
|
19
|
-
map = self.mapToAnyEncodable(map: properties_!)
|
|
20
|
-
}
|
|
21
|
-
var mapHooks: [String: Any?]? = nil
|
|
22
|
-
if (hooks_ != nil) {
|
|
23
|
-
mapHooks = [:]
|
|
24
|
-
hooks_?.forEach{ hook in
|
|
25
|
-
if (hook.key == "version") {
|
|
26
|
-
mapHooks![hook.key] = hook.value as? String
|
|
27
|
-
} else {
|
|
28
|
-
mapHooks![hook.key] = {(payload:Any) -> () in DispatchQueue.main.async {
|
|
29
|
-
guard let data = try? JSONEncoder().encode(self.toAnyEncodable(payload)) else {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let encoded = String(data: data, encoding: .utf8)!
|
|
34
|
-
self.sendEvent(withName: "ScreebEvent", body: ["hookId": hook.value, "payload": encoded])
|
|
35
|
-
}}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var initOptions = InitOptions()
|
|
41
|
-
initOptions_?.forEach{ option in
|
|
42
|
-
if (option.key == "isDebugMode") {
|
|
43
|
-
initOptions = InitOptions(isDebugMode: option.value as? Bool)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
DispatchQueue.main.async {
|
|
48
|
-
Screeb.initSdk(context: nil, channelId: channelId, identity: userId_, visitorProperty: map, initOptions: initOptions, hooks: mapHooks, language: language_)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@objc func setIdentity(_ userId: String, properties properties_: [String: Any]?) {
|
|
53
|
-
var map: [String: AnyEncodable?] = [:]
|
|
54
|
-
if (properties_ != nil) {
|
|
55
|
-
map = self.mapToAnyEncodable(map: properties_!)
|
|
56
|
-
}
|
|
57
|
-
DispatchQueue.main.async {
|
|
58
|
-
Screeb.setIdentity(uniqueVisitorId: userId, visitorProperty: map)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@objc func trackEvent(_ eventId: String, properties properties_: [String: Any]?) {
|
|
63
|
-
var map: [String: AnyEncodable?] = [:]
|
|
64
|
-
if (properties_ != nil) {
|
|
65
|
-
map = self.mapToAnyEncodable(map: properties_!)
|
|
66
|
-
}
|
|
67
|
-
DispatchQueue.main.async {
|
|
68
|
-
Screeb.trackEvent(name: eventId, trackingEventProperties: map)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@objc func trackScreen(_ screen: String, properties properties_: [String: Any]?) {
|
|
73
|
-
var map: [String: AnyEncodable?] = [:]
|
|
74
|
-
if (properties_ != nil) {
|
|
75
|
-
map = self.mapToAnyEncodable(map: properties_!)
|
|
76
|
-
}
|
|
77
|
-
DispatchQueue.main.async {
|
|
78
|
-
Screeb.trackScreen(name: screen, trackingEventProperties: map)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@objc(setProperties:)
|
|
83
|
-
func setVisitorPropertiesImpl(_ properties: [String: Any]) {
|
|
84
|
-
let map = self.mapToAnyEncodable(map: properties)
|
|
85
|
-
DispatchQueue.main.async {
|
|
86
|
-
Screeb.visitorProperty(visitorProperty: map)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@objc func startSurvey(_ surveyId: String, allowMultipleResponses allowMultipleResponses_: Bool, hiddenFields hiddenFields_: [String: Any]?,ignoreSurveyStatus ignoreSurveyStatus_: Bool, hooks hooks_: [String: Any]?, language language_: String?) {
|
|
91
|
-
var map: [String: AnyEncodable] = [:]
|
|
92
|
-
if (hiddenFields_ != nil) {
|
|
93
|
-
map = self.mapToAnyEncodable(map: hiddenFields_!).filter({ $0.value != nil }).mapValues({ $0! })
|
|
94
|
-
}
|
|
95
|
-
var mapHooks: [String: Any?]? = nil
|
|
96
|
-
if (hooks_ != nil) {
|
|
97
|
-
mapHooks = [:]
|
|
98
|
-
hooks_?.forEach{ hook in
|
|
99
|
-
if(hook.key == "version"){
|
|
100
|
-
mapHooks![hook.key] = hook.value as? String
|
|
101
|
-
} else {
|
|
102
|
-
mapHooks![hook.key] = {(payload:Any) -> () in DispatchQueue.main.async {
|
|
103
|
-
guard let data = try? JSONEncoder().encode(self.toAnyEncodable(payload)) else {
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let encoded = String(data: data, encoding: .utf8)!
|
|
108
|
-
self.sendEvent(withName: "ScreebEvent", body: ["hookId": hook.value, "payload": encoded])
|
|
109
|
-
}}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
DispatchQueue.main.async {
|
|
114
|
-
Screeb.startSurvey(surveyId: surveyId, allowMultipleResponses: allowMultipleResponses_, hiddenFields: map, ignoreSurveyStatus: ignoreSurveyStatus_, hooks: mapHooks, language: language_)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@objc func assignGroup(_ type: String?, name name_: String, properties properties_: [String: Any]?) {
|
|
119
|
-
var map: [String: AnyEncodable] = [:]
|
|
120
|
-
if (properties_ != nil) {
|
|
121
|
-
map = self.mapToAnyEncodable(map: properties_!).filter({ $0.value != nil }).mapValues({ $0! })
|
|
122
|
-
}
|
|
123
|
-
DispatchQueue.main.async {
|
|
124
|
-
Screeb.assignGroup(type: type, name: name_, properties: map)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@objc func unassignGroup(_ type: String?, name name_: String, properties properties_: [String: Any]?) {
|
|
129
|
-
var map: [String: AnyEncodable] = [:]
|
|
130
|
-
if (properties_ != nil) {
|
|
131
|
-
map = self.mapToAnyEncodable(map: properties_!).filter({ $0.value != nil }).mapValues({ $0! })
|
|
132
|
-
}
|
|
133
|
-
DispatchQueue.main.async {
|
|
134
|
-
Screeb.assignGroup(type: type, name: name_, properties: map)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@objc func resetIdentity(){
|
|
139
|
-
DispatchQueue.main.async {
|
|
140
|
-
Screeb.resetIdentity()
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
@objc func closeSdk(){
|
|
145
|
-
DispatchQueue.main.async {
|
|
146
|
-
Screeb.closeSdk()
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@objc func closeSurvey(){
|
|
151
|
-
DispatchQueue.main.async {
|
|
152
|
-
Screeb.closeSurvey()
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
@objc func onHookResult(_ hookId: String, payload: [String: Any]?) {
|
|
157
|
-
DispatchQueue.main.async {
|
|
158
|
-
if payload != nil {
|
|
159
|
-
let encoded = self.toAnyEncodable(payload!["result"])
|
|
160
|
-
Screeb.onHookResult(hookId, encoded)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
@objc func debug(){
|
|
166
|
-
DispatchQueue.main.async {
|
|
167
|
-
Screeb.debug()
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@objc func debugTargeting(){
|
|
172
|
-
DispatchQueue.main.async {
|
|
173
|
-
Screeb.debugTargeting()
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
private func toAnyEncodable(_ value: Any?) -> AnyEncodable? {
|
|
178
|
-
if let nsValue = value as? NSNumber {
|
|
179
|
-
if CFBooleanGetTypeID() == CFGetTypeID(nsValue) {
|
|
180
|
-
return AnyEncodable(nsValue.boolValue)
|
|
181
|
-
} else if let value = value as? Int {
|
|
182
|
-
return AnyEncodable(value)
|
|
183
|
-
} else if let value = value as? Double {
|
|
184
|
-
return AnyEncodable(value)
|
|
185
|
-
} else if let value = value as? Float {
|
|
186
|
-
return AnyEncodable(value)
|
|
187
|
-
} else {
|
|
188
|
-
return nil
|
|
189
|
-
}
|
|
190
|
-
} else if let value = value as? String {
|
|
191
|
-
return AnyEncodable(value)
|
|
192
|
-
} else if let value = value as? [String: Any?] {
|
|
193
|
-
return AnyEncodable(self.mapToAnyEncodable(map: value))
|
|
194
|
-
} else {
|
|
195
|
-
return nil
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private func mapToAnyEncodable(map: [String: Any?]?) -> [String: AnyEncodable?] {
|
|
200
|
-
var anyEncodableMap: [String: AnyEncodable?] = [:]
|
|
201
|
-
map?.forEach { key, value in
|
|
202
|
-
anyEncodableMap[key] = self.toAnyEncodable(value)
|
|
203
|
-
}
|
|
204
|
-
return anyEncodableMap
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
override func supportedEvents() -> [String]! {
|
|
208
|
-
return ["ScreebEvent"]
|
|
209
|
-
}
|
|
210
|
-
}
|