react-native-userleap 2.18.5 → 2.18.7
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
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// android/build.gradle
|
|
2
|
-
|
|
3
2
|
// based on:
|
|
4
3
|
//
|
|
5
4
|
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
|
|
@@ -9,16 +8,13 @@
|
|
|
9
8
|
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
|
|
10
9
|
// original location:
|
|
11
10
|
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
|
-
|
|
13
11
|
def DEFAULT_COMPILE_SDK_VERSION = 28
|
|
14
12
|
def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2'
|
|
15
13
|
def DEFAULT_MIN_SDK_VERSION = 16
|
|
16
14
|
def DEFAULT_TARGET_SDK_VERSION = 28
|
|
17
|
-
|
|
18
15
|
def safeExtGet(prop, fallback) {
|
|
19
16
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
buildscript {
|
|
23
19
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
24
20
|
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
@@ -34,15 +30,13 @@ buildscript {
|
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
apply plugin: 'com.android.library'
|
|
39
|
-
|
|
40
34
|
android {
|
|
41
35
|
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
42
36
|
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
43
37
|
compileOptions {
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
39
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
46
40
|
}
|
|
47
41
|
defaultConfig {
|
|
48
42
|
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
@@ -54,7 +48,6 @@ android {
|
|
|
54
48
|
abortOnError false
|
|
55
49
|
}
|
|
56
50
|
}
|
|
57
|
-
|
|
58
51
|
repositories {
|
|
59
52
|
// ref: https://www.baeldung.com/maven-local-repository
|
|
60
53
|
maven {
|
|
@@ -65,7 +58,6 @@ repositories {
|
|
|
65
58
|
// Android JSC is installed from npm
|
|
66
59
|
url "$rootDir/../node_modules/jsc-android/dist"
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
mavenCentral {
|
|
70
62
|
// We don't want to fetch react-native from Maven Central as there are
|
|
71
63
|
// older versions over there.
|
|
@@ -76,9 +68,13 @@ repositories {
|
|
|
76
68
|
google()
|
|
77
69
|
maven { url 'https://www.jitpack.io' }
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
dependencies {
|
|
81
|
-
//noinspection GradleDynamicVersion
|
|
82
72
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
|
|
74
|
+
// Use conditional logic for local vs Maven
|
|
75
|
+
if (findProject(':userleap-android-sdk') != null) {
|
|
76
|
+
implementation project(':userleap-android-sdk')
|
|
77
|
+
} else {
|
|
78
|
+
implementation ("com.userleap:userleap-android-sdk:2.19.0") // update this version on android updates
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -51,6 +51,11 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
51
51
|
return visitorIdentifierObject == null ? "" : visitorIdentifierObject;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
55
|
+
public String getSdkVersion() {
|
|
56
|
+
return UserLeap.INSTANCE.getSdkVersion();
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
@ReactMethod
|
|
55
60
|
public void configure(String environment, ReadableMap configuration) {
|
|
56
61
|
UserLeap.INSTANCE.configure(reactContext, environment, stringifyMap(configuration), getFragmentActivity());
|
package/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare namespace UserLeap {
|
|
|
6
6
|
};
|
|
7
7
|
function visitorIdentifier(): number;
|
|
8
8
|
function visitorIdentifierString(): string;
|
|
9
|
+
function sdkVersion(): string;
|
|
9
10
|
function configure(environment: string, configuration?: {[key: string]: any}): void;
|
|
10
11
|
function setPreviewKey(previewKey: string): void;
|
|
11
12
|
function presentSurvey(): void;
|
package/index.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { Platform, NativeModules } from
|
|
1
|
+
import { Platform, NativeModules } from "react-native";
|
|
2
2
|
|
|
3
|
-
import { version } from
|
|
3
|
+
import { version } from "./package.json";
|
|
4
4
|
|
|
5
5
|
const SurveyState = {
|
|
6
|
-
READY:
|
|
7
|
-
DISABLED:
|
|
8
|
-
NO_SURVEY:
|
|
6
|
+
READY: "READY",
|
|
7
|
+
DISABLED: "DISABLED",
|
|
8
|
+
NO_SURVEY: "NO_SURVEY",
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const stringifyAttributes = (
|
|
12
|
-
if (!(attributes instanceof Object && attributes.constructor === Object))
|
|
13
|
-
|
|
11
|
+
const stringifyAttributes = (attributes) => {
|
|
12
|
+
if (!(attributes instanceof Object && attributes.constructor === Object))
|
|
13
|
+
return {};
|
|
14
|
+
Object.keys(attributes).forEach(function (key, index) {
|
|
14
15
|
attributes[key] = String(attributes[key]);
|
|
15
16
|
});
|
|
16
17
|
return attributes;
|
|
17
|
-
}
|
|
18
|
+
};
|
|
18
19
|
|
|
19
20
|
const isValidPlatform = () => {
|
|
20
21
|
//Platform.Version is a number for android and string for ios
|
|
21
|
-
return (
|
|
22
|
-
|
|
22
|
+
return (
|
|
23
|
+
(Platform.OS === "android" && String(Platform.Version) >= "21") ||
|
|
24
|
+
(Platform.OS === "ios" && String(Platform.Version) >= "10.3")
|
|
25
|
+
);
|
|
26
|
+
};
|
|
23
27
|
|
|
24
28
|
const visitorIdentifier = () => {
|
|
25
29
|
if (isValidPlatform()) {
|
|
@@ -27,7 +31,18 @@ const visitorIdentifier = () => {
|
|
|
27
31
|
} else {
|
|
28
32
|
return 0;
|
|
29
33
|
}
|
|
30
|
-
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const sdkVersion = () => {
|
|
37
|
+
if (Platform.OS === "ios") {
|
|
38
|
+
if (String(Platform.Version) >= "10.3") {
|
|
39
|
+
return NativeModules.UserLeapBindings.sdkVersion();
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
return NativeModules.UserLeapBindings.getSdkVersion();
|
|
43
|
+
}
|
|
44
|
+
return "0.0.0";
|
|
45
|
+
};
|
|
31
46
|
|
|
32
47
|
const visitorIdentifierString = () => {
|
|
33
48
|
if (isValidPlatform()) {
|
|
@@ -35,109 +50,144 @@ const visitorIdentifierString = () => {
|
|
|
35
50
|
} else {
|
|
36
51
|
return "";
|
|
37
52
|
}
|
|
38
|
-
}
|
|
53
|
+
};
|
|
39
54
|
|
|
40
55
|
const configure = (environment, configuration = {}) => {
|
|
41
|
-
const source =
|
|
42
|
-
configuration.source ===
|
|
43
|
-
?
|
|
44
|
-
:
|
|
45
|
-
const packageVersion =
|
|
46
|
-
configuration.packageVersion
|
|
47
|
-
|
|
48
|
-
: version;
|
|
56
|
+
const source =
|
|
57
|
+
configuration.source === "react-native-segment"
|
|
58
|
+
? "react-native-segment"
|
|
59
|
+
: "react-native";
|
|
60
|
+
const packageVersion = configuration.packageVersion
|
|
61
|
+
? configuration.packageVersion
|
|
62
|
+
: version;
|
|
49
63
|
const defaultConfiguration = {
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
"x-ul-installation-method": `${Platform.OS}-${source}`,
|
|
65
|
+
"x-ul-package-version": packageVersion,
|
|
52
66
|
};
|
|
53
67
|
if (isValidPlatform()) {
|
|
54
68
|
NativeModules.UserLeapBindings.configure(environment, defaultConfiguration);
|
|
55
69
|
}
|
|
56
|
-
}
|
|
70
|
+
};
|
|
57
71
|
|
|
58
72
|
const setPreviewKey = (previewKey) => {
|
|
59
73
|
if (isValidPlatform()) {
|
|
60
74
|
NativeModules.UserLeapBindings.setPreviewKey(previewKey);
|
|
61
75
|
}
|
|
62
|
-
}
|
|
76
|
+
};
|
|
63
77
|
|
|
64
78
|
const presentSurvey = () => {
|
|
65
79
|
if (isValidPlatform()) {
|
|
66
80
|
NativeModules.UserLeapBindings.presentSurvey();
|
|
67
81
|
}
|
|
68
|
-
}
|
|
82
|
+
};
|
|
69
83
|
|
|
70
84
|
const track = (event, surveyStateCallback) => {
|
|
71
85
|
if (isValidPlatform()) {
|
|
72
86
|
NativeModules.UserLeapBindings.track(event, surveyStateCallback);
|
|
73
87
|
}
|
|
74
|
-
}
|
|
88
|
+
};
|
|
75
89
|
|
|
76
|
-
const trackWithProperties = (
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
const trackWithProperties = (
|
|
91
|
+
event,
|
|
92
|
+
userId,
|
|
93
|
+
partnerAnonymousId,
|
|
94
|
+
properties,
|
|
95
|
+
surveyStateCallback
|
|
96
|
+
) => {
|
|
97
|
+
if (isValidPlatform()) {
|
|
98
|
+
NativeModules.UserLeapBindings.trackWithProperties(
|
|
99
|
+
event,
|
|
100
|
+
userId,
|
|
101
|
+
partnerAnonymousId,
|
|
102
|
+
properties,
|
|
103
|
+
surveyStateCallback
|
|
104
|
+
);
|
|
79
105
|
}
|
|
80
|
-
}
|
|
106
|
+
};
|
|
81
107
|
|
|
82
|
-
const trackAndIdentify = (
|
|
108
|
+
const trackAndIdentify = (
|
|
109
|
+
event,
|
|
110
|
+
userId,
|
|
111
|
+
partnerAnonynmousId,
|
|
112
|
+
surveyStateCallback
|
|
113
|
+
) => {
|
|
83
114
|
if (isValidPlatform()) {
|
|
84
|
-
NativeModules.UserLeapBindings.trackAndIdentify(
|
|
115
|
+
NativeModules.UserLeapBindings.trackAndIdentify(
|
|
116
|
+
event,
|
|
117
|
+
userId,
|
|
118
|
+
partnerAnonynmousId,
|
|
119
|
+
surveyStateCallback
|
|
120
|
+
);
|
|
85
121
|
}
|
|
86
|
-
}
|
|
122
|
+
};
|
|
87
123
|
|
|
88
124
|
const setEmailAddress = (emailAddress) => {
|
|
89
125
|
if (isValidPlatform()) {
|
|
90
126
|
NativeModules.UserLeapBindings.setEmailAddress(emailAddress);
|
|
91
127
|
}
|
|
92
|
-
}
|
|
128
|
+
};
|
|
93
129
|
|
|
94
130
|
const setVisitorAttribute = (key, value) => {
|
|
95
131
|
if (isValidPlatform()) {
|
|
96
132
|
NativeModules.UserLeapBindings.setVisitorAttribute(key, value);
|
|
97
133
|
}
|
|
98
|
-
}
|
|
134
|
+
};
|
|
99
135
|
|
|
100
136
|
const setVisitorAttributes = (attributes) => {
|
|
101
137
|
if (isValidPlatform()) {
|
|
102
|
-
NativeModules.UserLeapBindings.setVisitorAttributes(
|
|
138
|
+
NativeModules.UserLeapBindings.setVisitorAttributes(
|
|
139
|
+
stringifyAttributes(attributes)
|
|
140
|
+
);
|
|
103
141
|
}
|
|
104
|
-
}
|
|
142
|
+
};
|
|
105
143
|
|
|
106
144
|
const removeVisitorAttributes = (keys) => {
|
|
107
145
|
if (isValidPlatform()) {
|
|
108
146
|
NativeModules.UserLeapBindings.removeVisitorAttributes(keys);
|
|
109
147
|
}
|
|
110
|
-
}
|
|
148
|
+
};
|
|
111
149
|
|
|
112
|
-
const setVisitorAttributesAndIdentify = (
|
|
150
|
+
const setVisitorAttributesAndIdentify = (
|
|
151
|
+
attributes,
|
|
152
|
+
userId,
|
|
153
|
+
partnerAnonynmousId
|
|
154
|
+
) => {
|
|
113
155
|
if (isValidPlatform()) {
|
|
114
|
-
NativeModules.UserLeapBindings.setVisitorAttributesAndIdentify(
|
|
156
|
+
NativeModules.UserLeapBindings.setVisitorAttributesAndIdentify(
|
|
157
|
+
stringifyAttributes(attributes),
|
|
158
|
+
userId,
|
|
159
|
+
partnerAnonynmousId
|
|
160
|
+
);
|
|
115
161
|
}
|
|
116
|
-
}
|
|
162
|
+
};
|
|
117
163
|
|
|
118
164
|
const setUserIdentifier = (identifier) => {
|
|
119
165
|
if (isValidPlatform()) {
|
|
120
166
|
NativeModules.UserLeapBindings.setUserIdentifier(identifier);
|
|
121
167
|
}
|
|
122
|
-
}
|
|
168
|
+
};
|
|
123
169
|
|
|
124
170
|
const logout = () => {
|
|
125
171
|
if (isValidPlatform()) {
|
|
126
172
|
NativeModules.UserLeapBindings.logout();
|
|
127
173
|
}
|
|
128
|
-
}
|
|
174
|
+
};
|
|
129
175
|
|
|
130
176
|
const trackAndPresent = (event) => {
|
|
131
177
|
if (isValidPlatform()) {
|
|
132
178
|
NativeModules.UserLeapBindings.trackAndPresent(event);
|
|
133
179
|
}
|
|
134
|
-
}
|
|
180
|
+
};
|
|
135
181
|
|
|
136
182
|
const trackIdentifyAndPresent = (event, userId, partnerAnonynmousId) => {
|
|
137
183
|
if (isValidPlatform()) {
|
|
138
|
-
NativeModules.UserLeapBindings.trackIdentifyAndPresent(
|
|
184
|
+
NativeModules.UserLeapBindings.trackIdentifyAndPresent(
|
|
185
|
+
event,
|
|
186
|
+
userId,
|
|
187
|
+
partnerAnonynmousId
|
|
188
|
+
);
|
|
139
189
|
}
|
|
140
|
-
}
|
|
190
|
+
};
|
|
141
191
|
|
|
142
192
|
// Uncomment for UI testing
|
|
143
193
|
// const renderSnapshotForUITest = (name, maskingLevel) => {
|
|
@@ -147,26 +197,27 @@ const trackIdentifyAndPresent = (event, userId, partnerAnonynmousId) => {
|
|
|
147
197
|
// }
|
|
148
198
|
|
|
149
199
|
const UserLeap = {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
200
|
+
SurveyState,
|
|
201
|
+
visitorIdentifier,
|
|
202
|
+
visitorIdentifierString,
|
|
203
|
+
sdkVersion,
|
|
204
|
+
configure,
|
|
205
|
+
presentSurvey,
|
|
206
|
+
setPreviewKey,
|
|
207
|
+
track,
|
|
208
|
+
trackWithProperties,
|
|
209
|
+
trackAndIdentify,
|
|
210
|
+
setEmailAddress,
|
|
211
|
+
setVisitorAttribute,
|
|
212
|
+
setVisitorAttributes,
|
|
213
|
+
removeVisitorAttributes,
|
|
214
|
+
setVisitorAttributesAndIdentify,
|
|
215
|
+
setUserIdentifier,
|
|
216
|
+
logout,
|
|
217
|
+
trackAndPresent,
|
|
218
|
+
trackIdentifyAndPresent,
|
|
219
|
+
// Uncomment for UI testing
|
|
220
|
+
// renderSnapshotForUITest,
|
|
221
|
+
};
|
|
171
222
|
|
|
172
223
|
export default UserLeap;
|
package/ios/UserLeapBindings.m
CHANGED
|
@@ -47,6 +47,11 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(visitorIdentifierString)
|
|
|
47
47
|
return [[UserLeap shared] visitorIdentifierString];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(sdkVersion)
|
|
51
|
+
{
|
|
52
|
+
return [[UserLeap shared] sdkVersion];
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
RCT_EXPORT_METHOD(configure:(NSString *)environmentId configuration:(NSDictionary *)configuration )
|
|
51
56
|
{
|
|
52
57
|
[[UserLeap shared] configureWithEnvironment:environmentId configuration:configuration];
|
package/package.json
CHANGED