@screeb/react-native 0.8.4 → 0.8.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.
- package/README.md +2 -130
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/screebmodule/ScreebModuleModule.kt +32 -10
- package/ios/ScreebModule.m +2 -0
- package/ios/ScreebModule.swift +20 -0
- package/lib/commonjs/index.js +48 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +31 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/package.json +2 -2
- package/screeb-module.podspec +1 -1
- package/src/index.tsx +17 -11
package/README.md
CHANGED
|
@@ -9,137 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
A react-native module to integrate Screeb mobile sdk for Android and/or iOS.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## How to install the React-Native SDK in your app ?
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
npm install @screeb/react-native
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## iOS specific configuration
|
|
19
|
-
|
|
20
|
-
Your Podfile needs the instruction **use_frameworks!** to correctly import Screeb dependencies.
|
|
21
|
-
Then you should set IOS target build configuration `BUILD_LIBRARY_FOR_DISTRIBUTION` to `YES` in your `Podfile` to avoid runtime crash:
|
|
22
|
-
```ruby
|
|
23
|
-
use_frameworks!
|
|
24
|
-
...
|
|
25
|
-
post_install do |installer|
|
|
26
|
-
...
|
|
27
|
-
installer.pods_project.targets.each do |target|
|
|
28
|
-
...
|
|
29
|
-
|
|
30
|
-
target.build_configurations.each do |config|
|
|
31
|
-
...
|
|
32
|
-
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
When upgrading a Screeb sdk-reactnative version, it can be useful to run in /ios directory :
|
|
39
|
-
```sh
|
|
40
|
-
pod update Screeb
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Android specific configuration
|
|
44
|
-
|
|
45
|
-
First, you should use MultidexApplication if not yet to avoid compilation issues.
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
defaultConfig {
|
|
49
|
-
(...)
|
|
50
|
-
multiDexEnabled true
|
|
51
|
-
}
|
|
52
|
-
(...)
|
|
53
|
-
dependencies {
|
|
54
|
-
(...)
|
|
55
|
-
implementation 'androidx.multidex:multidex:2.0.1'
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Then, the Android sdk needs to be notified of activities lifecycle changes to be correctly started.
|
|
60
|
-
|
|
61
|
-
It is mandatory to pass the Application context to the module in your custom Application class
|
|
62
|
-
in the `onCreate` function :
|
|
63
|
-
|
|
64
|
-
```kotlin
|
|
65
|
-
override fun onCreate() {
|
|
66
|
-
super.onCreate()
|
|
67
|
-
ScreebModuleModule.setAppContext(this)
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
NB : Your android app needs to use AGP minimum 7.1.3
|
|
72
|
-
|
|
73
|
-
```groovy
|
|
74
|
-
classpath("com.android.tools.build:gradle:7.1.3")
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Usage
|
|
78
|
-
|
|
79
|
-
```js
|
|
80
|
-
import { initSdk, trackScreen, trackEvent, setProperties, setIdentity } from "@screeb/react-native";
|
|
81
|
-
|
|
82
|
-
// Init the sdk at app start (useEffect hook used here, but componentDidMount is fine)
|
|
83
|
-
React.useEffect(() => {
|
|
84
|
-
initSdk(
|
|
85
|
-
"<android-channel-id>",
|
|
86
|
-
"<ios-channel-id>",
|
|
87
|
-
"<user-identity>",
|
|
88
|
-
{
|
|
89
|
-
'example-prop1': false,
|
|
90
|
-
'example-prop2': 29,
|
|
91
|
-
'example-prop3' : 'iPhone 13',
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
}, []);
|
|
95
|
-
|
|
96
|
-
(...)
|
|
97
|
-
|
|
98
|
-
// SetIdentity command :
|
|
99
|
-
setIdentity(
|
|
100
|
-
'<user-identity>',
|
|
101
|
-
{
|
|
102
|
-
'example-prop1': false,
|
|
103
|
-
'example-prop2': 29,
|
|
104
|
-
'example-prop3' : 'iPhone 13',
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
(...)
|
|
109
|
-
|
|
110
|
-
// trackEvent command :
|
|
111
|
-
trackEvent(
|
|
112
|
-
'<event-name>',
|
|
113
|
-
{
|
|
114
|
-
'example-prop1': false,
|
|
115
|
-
'example-prop2': 29,
|
|
116
|
-
'example-prop3' : 'iPhone 13',
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
(...)
|
|
121
|
-
|
|
122
|
-
// trackScreen command :
|
|
123
|
-
trackScreen(
|
|
124
|
-
'<screen-name>',
|
|
125
|
-
{
|
|
126
|
-
'example-prop1': false,
|
|
127
|
-
'example-prop2': 29,
|
|
128
|
-
'example-prop3' : 'iPhone 13',
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
(...)
|
|
133
|
-
|
|
134
|
-
// setProperties command :
|
|
135
|
-
setProperties(
|
|
136
|
-
{
|
|
137
|
-
'example-prop1': false,
|
|
138
|
-
'example-prop2': 29,
|
|
139
|
-
'example-prop3' : 'iPhone 13',
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
```
|
|
14
|
+
[See here.](https://github.com/ScreebApp/developers/wiki/React-Native-SDK-install)
|
|
143
15
|
|
|
144
16
|
## Run example
|
|
145
17
|
|
package/android/build.gradle
CHANGED
|
@@ -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.
|
|
127
|
+
implementation "app.screeb.sdk:survey:1.10.1"
|
|
128
128
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.0"
|
|
129
129
|
}
|
|
@@ -28,7 +28,7 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
28
28
|
map = properties.toHashMap()
|
|
29
29
|
}
|
|
30
30
|
Handler(Looper.getMainLooper()).post {
|
|
31
|
-
|
|
31
|
+
Screeb?.pluginInit(channelId, userId, map)
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -40,7 +40,7 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
40
40
|
map = properties.toHashMap()
|
|
41
41
|
}
|
|
42
42
|
Handler(Looper.getMainLooper()).post {
|
|
43
|
-
|
|
43
|
+
Screeb?.setIdentity(userId, map)
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
52
52
|
map = properties.toHashMap()
|
|
53
53
|
}
|
|
54
54
|
Handler(Looper.getMainLooper()).post {
|
|
55
|
-
|
|
55
|
+
Screeb?.trackEvent(eventId, map)
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -64,7 +64,7 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
64
64
|
map = properties.toHashMap()
|
|
65
65
|
}
|
|
66
66
|
Handler(Looper.getMainLooper()).post {
|
|
67
|
-
|
|
67
|
+
Screeb?.trackScreen(screen, map)
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -75,19 +75,41 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
|
|
|
75
75
|
"Called setVisitorProperties with " + properties.toHashMap().size + " properties"
|
|
76
76
|
)
|
|
77
77
|
Handler(Looper.getMainLooper()).post {
|
|
78
|
-
|
|
78
|
+
Screeb?.setVisitorProperties(properties.toHashMap())
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@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()
|
|
88
|
+
}
|
|
89
|
+
Handler(Looper.getMainLooper()).post {
|
|
90
|
+
Screeb?.startSurvey(surveyId, allowMultipleResponses, map)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@ReactMethod
|
|
95
|
+
fun assignGroup(type: String? = null, name: String, properties: ReadableMap? = null) {
|
|
96
|
+
Log.d("ScreebModule", "Called assignGroup : $name")
|
|
97
|
+
var map: HashMap<String, Any>? = null
|
|
98
|
+
if (properties != null) {
|
|
99
|
+
map = properties.toHashMap()
|
|
100
|
+
}
|
|
101
|
+
Handler(Looper.getMainLooper()).post {
|
|
102
|
+
Screeb?.assignGroup(type, name, map)
|
|
79
103
|
}
|
|
80
104
|
}
|
|
81
105
|
|
|
82
106
|
companion object {
|
|
83
|
-
var screeb: Screeb? = null
|
|
84
107
|
|
|
85
108
|
@JvmStatic
|
|
86
109
|
fun setAppContext(context: Context){
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.build()
|
|
110
|
+
Screeb.initSdkWithContextOnly(
|
|
111
|
+
context
|
|
112
|
+
)
|
|
91
113
|
}
|
|
92
114
|
|
|
93
115
|
}
|
package/ios/ScreebModule.m
CHANGED
|
@@ -7,6 +7,8 @@ RCT_EXTERN_METHOD(setIdentity:(NSString *)userId properties:(NSDictionary<NSStri
|
|
|
7
7
|
RCT_EXTERN_METHOD(trackEvent:(NSString *)eventId properties:(NSDictionary<NSString *, id> *)properties_)
|
|
8
8
|
RCT_EXTERN_METHOD(trackScreen:(NSString *)screen properties:(NSDictionary<NSString *, id> *)properties_)
|
|
9
9
|
RCT_EXTERN_METHOD(setProperties:(NSDictionary<NSString *, id> *)properties)
|
|
10
|
+
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_)
|
|
10
12
|
+ (BOOL)requiresMainQueueSetup
|
|
11
13
|
{
|
|
12
14
|
return YES;
|
package/ios/ScreebModule.swift
CHANGED
|
@@ -61,6 +61,26 @@ class ScreebModule: NSObject {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
@objc func startSurvey(_ surveyId: String, allowMultipleResponses allowMultipleResponses_: Bool, hiddenFields hiddenFields_: [String: Any]?) {
|
|
65
|
+
var map: [String: AnyEncodable] = [:]
|
|
66
|
+
if (hiddenFields_ != nil) {
|
|
67
|
+
map = self.mapToAnyEncodable(map: hiddenFields_!).filter({ $0.value != nil }).mapValues({ $0! })
|
|
68
|
+
}
|
|
69
|
+
DispatchQueue.main.async {
|
|
70
|
+
Screeb.startSurvey(surveyId: surveyId, allowMultipleResponses: allowMultipleResponses_, hiddenFields: map)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
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
|
+
|
|
64
84
|
private func mapToAnyEncodable(map: [String: Any]) -> [String: AnyEncodable?] {
|
|
65
85
|
return map.mapValues{
|
|
66
86
|
value in
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initSdk = initSdk;
|
|
7
|
+
exports.setIdentity = setIdentity;
|
|
8
|
+
exports.setProperties = setProperties;
|
|
9
|
+
exports.trackEvent = trackEvent;
|
|
10
|
+
exports.trackScreen = trackScreen;
|
|
11
|
+
|
|
12
|
+
var _reactNative = require("react-native");
|
|
13
|
+
|
|
14
|
+
const LINKING_ERROR = `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
15
|
+
ios: "- You have run 'pod install'\n",
|
|
16
|
+
default: ''
|
|
17
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
18
|
+
const ScreebModule = _reactNative.NativeModules.ScreebModule ? _reactNative.NativeModules.ScreebModule : new Proxy({}, {
|
|
19
|
+
get() {
|
|
20
|
+
throw new Error(LINKING_ERROR);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
function initSdk(androidChannelId, iosChannelId, userId, properties) {
|
|
26
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
27
|
+
return ScreebModule.initSdk(iosChannelId, userId, properties);
|
|
28
|
+
} else {
|
|
29
|
+
return ScreebModule.initSdk(androidChannelId, userId, properties);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function setIdentity(userId, properties) {
|
|
34
|
+
return ScreebModule.setIdentity(userId, properties);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function trackEvent(name, properties) {
|
|
38
|
+
return ScreebModule.trackEvent(name, properties);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function trackScreen(name, properties) {
|
|
42
|
+
return ScreebModule.trackScreen(name, properties);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function setProperties(properties) {
|
|
46
|
+
return ScreebModule.setProperties(properties);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["LINKING_ERROR","Platform","select","ios","default","ScreebModule","NativeModules","Proxy","get","Error","initSdk","androidChannelId","iosChannelId","userId","properties","OS","setIdentity","trackEvent","name","trackScreen","setProperties"],"mappings":";;;;;;;;;;;AAAA;;AAEA,MAAMA,aAAa,GAChB,+EAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,YAAY,GAAGC,2BAAcD,YAAd,GACjBC,2BAAcD,YADG,GAEjB,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;;AAWO,SAASU,OAAT,CACHC,gBADG,EAEHC,YAFG,EAGHC,MAHG,EAIHC,UAJG,EAI4B;AACjC,MAAIb,sBAASc,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOV,YAAY,CAACK,OAAb,CAAqBE,YAArB,EAAmCC,MAAnC,EAA2CC,UAA3C,CAAP;AACD,GAFD,MAEO;AACL,WAAOT,YAAY,CAACK,OAAb,CAAqBC,gBAArB,EAAuCE,MAAvC,EAA+CC,UAA/C,CAAP;AACD;AACF;;AACM,SAASE,WAAT,CAAqBH,MAArB,EAAqCC,UAArC,EAAoE;AACzE,SAAOT,YAAY,CAACW,WAAb,CAAyBH,MAAzB,EAAiCC,UAAjC,CAAP;AACD;;AACM,SAASG,UAAT,CAAoBC,IAApB,EAAkCJ,UAAlC,EAAiE;AACtE,SAAOT,YAAY,CAACY,UAAb,CAAwBC,IAAxB,EAA8BJ,UAA9B,CAAP;AACD;;AACM,SAASK,WAAT,CAAqBD,IAArB,EAAmCJ,UAAnC,EAAkE;AACvE,SAAOT,YAAY,CAACc,WAAb,CAAyBD,IAAzB,EAA+BJ,UAA/B,CAAP;AACD;;AACM,SAASM,aAAT,CAAuBN,UAAvB,EAAsD;AAC3D,SAAOT,YAAY,CAACe,aAAb,CAA2BN,UAA3B,CAAP;AACD","sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst ScreebModule = NativeModules.ScreebModule\n ? NativeModules.ScreebModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport function initSdk(\n androidChannelId: string,\n iosChannelId: string,\n userId?: string,\n properties?: Map<string, any>) {\n if (Platform.OS === 'ios') {\n return ScreebModule.initSdk(iosChannelId, userId, properties);\n } else {\n return ScreebModule.initSdk(androidChannelId, userId, properties);\n }\n}\nexport function setIdentity(userId: string, properties?: Map<string, any>) {\n return ScreebModule.setIdentity(userId, properties);\n}\nexport function trackEvent(name: string, properties?: Map<string, any>) {\n return ScreebModule.trackEvent(name, properties);\n}\nexport function trackScreen(name: string, properties?: Map<string, any>) {\n return ScreebModule.trackScreen(name, properties);\n}\nexport function setProperties(properties?: Map<string, any>) {\n return ScreebModule.setProperties(properties);\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
const LINKING_ERROR = `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
+
ios: "- You have run 'pod install'\n",
|
|
4
|
+
default: ''
|
|
5
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
6
|
+
const ScreebModule = NativeModules.ScreebModule ? NativeModules.ScreebModule : new Proxy({}, {
|
|
7
|
+
get() {
|
|
8
|
+
throw new Error(LINKING_ERROR);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
});
|
|
12
|
+
export function initSdk(androidChannelId, iosChannelId, userId, properties) {
|
|
13
|
+
if (Platform.OS === 'ios') {
|
|
14
|
+
return ScreebModule.initSdk(iosChannelId, userId, properties);
|
|
15
|
+
} else {
|
|
16
|
+
return ScreebModule.initSdk(androidChannelId, userId, properties);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function setIdentity(userId, properties) {
|
|
20
|
+
return ScreebModule.setIdentity(userId, properties);
|
|
21
|
+
}
|
|
22
|
+
export function trackEvent(name, properties) {
|
|
23
|
+
return ScreebModule.trackEvent(name, properties);
|
|
24
|
+
}
|
|
25
|
+
export function trackScreen(name, properties) {
|
|
26
|
+
return ScreebModule.trackScreen(name, properties);
|
|
27
|
+
}
|
|
28
|
+
export function setProperties(properties) {
|
|
29
|
+
return ScreebModule.setProperties(properties);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","ScreebModule","Proxy","get","Error","initSdk","androidChannelId","iosChannelId","userId","properties","OS","setIdentity","trackEvent","name","trackScreen","setProperties"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAEA,MAAMC,aAAa,GAChB,+EAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,YAAY,GAAGN,aAAa,CAACM,YAAd,GACjBN,aAAa,CAACM,YADG,GAEjB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA,OAAO,SAASQ,OAAT,CACHC,gBADG,EAEHC,YAFG,EAGHC,MAHG,EAIHC,UAJG,EAI4B;AACjC,MAAIb,QAAQ,CAACc,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOT,YAAY,CAACI,OAAb,CAAqBE,YAArB,EAAmCC,MAAnC,EAA2CC,UAA3C,CAAP;AACD,GAFD,MAEO;AACL,WAAOR,YAAY,CAACI,OAAb,CAAqBC,gBAArB,EAAuCE,MAAvC,EAA+CC,UAA/C,CAAP;AACD;AACF;AACD,OAAO,SAASE,WAAT,CAAqBH,MAArB,EAAqCC,UAArC,EAAoE;AACzE,SAAOR,YAAY,CAACU,WAAb,CAAyBH,MAAzB,EAAiCC,UAAjC,CAAP;AACD;AACD,OAAO,SAASG,UAAT,CAAoBC,IAApB,EAAkCJ,UAAlC,EAAiE;AACtE,SAAOR,YAAY,CAACW,UAAb,CAAwBC,IAAxB,EAA8BJ,UAA9B,CAAP;AACD;AACD,OAAO,SAASK,WAAT,CAAqBD,IAArB,EAAmCJ,UAAnC,EAAkE;AACvE,SAAOR,YAAY,CAACa,WAAb,CAAyBD,IAAzB,EAA+BJ,UAA/B,CAAP;AACD;AACD,OAAO,SAASM,aAAT,CAAuBN,UAAvB,EAAsD;AAC3D,SAAOR,YAAY,CAACc,aAAb,CAA2BN,UAA3B,CAAP;AACD","sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package '@screeb/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst ScreebModule = NativeModules.ScreebModule\n ? NativeModules.ScreebModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport function initSdk(\n androidChannelId: string,\n iosChannelId: string,\n userId?: string,\n properties?: Map<string, any>) {\n if (Platform.OS === 'ios') {\n return ScreebModule.initSdk(iosChannelId, userId, properties);\n } else {\n return ScreebModule.initSdk(androidChannelId, userId, properties);\n }\n}\nexport function setIdentity(userId: string, properties?: Map<string, any>) {\n return ScreebModule.setIdentity(userId, properties);\n}\nexport function trackEvent(name: string, properties?: Map<string, any>) {\n return ScreebModule.trackEvent(name, properties);\n}\nexport function trackScreen(name: string, properties?: Map<string, any>) {\n return ScreebModule.trackScreen(name, properties);\n}\nexport function setProperties(properties?: Map<string, any>) {\n return ScreebModule.setProperties(properties);\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function initSdk(androidChannelId: string, iosChannelId: string, userId?: string, properties?: Map<string, any>): any;
|
|
2
|
+
export declare function setIdentity(userId: string, properties?: Map<string, any>): any;
|
|
3
|
+
export declare function trackEvent(name: string, properties?: Map<string, any>): any;
|
|
4
|
+
export declare function trackScreen(name: string, properties?: Map<string, any>): any;
|
|
5
|
+
export declare function setProperties(properties?: Map<string, any>): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@screeb/react-native",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
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
|
+
}
|
package/screeb-module.podspec
CHANGED
package/src/index.tsx
CHANGED
|
@@ -9,19 +9,19 @@ const LINKING_ERROR =
|
|
|
9
9
|
const ScreebModule = NativeModules.ScreebModule
|
|
10
10
|
? NativeModules.ScreebModule
|
|
11
11
|
: new Proxy(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get() {
|
|
15
|
+
throw new Error(LINKING_ERROR);
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
19
|
|
|
20
20
|
export function initSdk(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
androidChannelId: string,
|
|
22
|
+
iosChannelId: string,
|
|
23
|
+
userId?: string,
|
|
24
|
+
properties?: Map<string, any>) {
|
|
25
25
|
if (Platform.OS === 'ios') {
|
|
26
26
|
return ScreebModule.initSdk(iosChannelId, userId, properties);
|
|
27
27
|
} else {
|
|
@@ -40,3 +40,9 @@ export function trackScreen(name: string, properties?: Map<string, any>) {
|
|
|
40
40
|
export function setProperties(properties?: Map<string, any>) {
|
|
41
41
|
return ScreebModule.setProperties(properties);
|
|
42
42
|
}
|
|
43
|
+
export function startSurvey(surveyId: string, allowMultipleResponses?: boolean, hiddenFields?: Map<string, any>) {
|
|
44
|
+
return ScreebModule.startSurvey(surveyId, allowMultipleResponses ?? true, hiddenFields);
|
|
45
|
+
}
|
|
46
|
+
export function assignGroup(type: string | null, name: string, properties?: Map<string, any>) {
|
|
47
|
+
return ScreebModule.assignGroup(name, type, properties);
|
|
48
|
+
}
|