react-native-userleap 2.19.2 → 2.21.0
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 +3 -2
- package/android/src/main/java/com/userleap/reactnative/UserLeapModule.java +293 -74
- package/index.d.ts +53 -3
- package/index.js +82 -12
- package/ios/UserLeapBindings.h +2 -1
- package/ios/UserLeapBindings.m +94 -17
- package/ios/UserLeapBindings.xcodeproj/project.xcworkspace/xcuserdata/kurt.hobson.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/package.json +2 -2
- package/react-native-userleap.podspec +1 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/android/gradlew +0 -251
- package/android/gradlew.bat +0 -94
- package/ios/UserLeapBindings.xcodeproj/project.xcworkspace/xcuserdata/shawnmckee.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/UserleapBindings.xcworkspace/xcuserdata/shawnmckee.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- /package/ios/UserLeapBindings.xcodeproj/xcuserdata/{shawnmckee.xcuserdatad → kurt.hobson.xcuserdatad}/xcschemes/xcschememanagement.plist +0 -0
package/android/build.gradle
CHANGED
|
@@ -70,11 +70,12 @@ repositories {
|
|
|
70
70
|
}
|
|
71
71
|
dependencies {
|
|
72
72
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
73
|
-
|
|
73
|
+
implementation "androidx.webkit:webkit:1.8.0"
|
|
74
|
+
|
|
74
75
|
// Use conditional logic for local vs Maven
|
|
75
76
|
if (findProject(':userleap-android-sdk') != null) {
|
|
76
77
|
implementation project(':userleap-android-sdk')
|
|
77
78
|
} else {
|
|
78
|
-
implementation ("com.userleap:userleap-android-sdk:2.
|
|
79
|
+
implementation ("com.userleap:userleap-android-sdk:2.23.0") // update this version on android updates
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
package com.userleap.reactnative;
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
|
+
import android.util.Log;
|
|
4
5
|
|
|
5
6
|
import androidx.fragment.app.FragmentActivity;
|
|
6
7
|
|
|
8
|
+
import com.facebook.react.bridge.Arguments;
|
|
7
9
|
import com.facebook.react.bridge.Callback;
|
|
8
10
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
11
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
10
12
|
import com.facebook.react.bridge.ReactMethod;
|
|
11
13
|
import com.facebook.react.bridge.ReadableArray;
|
|
12
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
|
+
import com.facebook.react.bridge.WritableMap;
|
|
16
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
13
17
|
|
|
18
|
+
import com.userleap.EventListener;
|
|
19
|
+
import com.userleap.EventName;
|
|
20
|
+
import com.userleap.EventPayload;
|
|
21
|
+
import com.userleap.SprigEvent;
|
|
22
|
+
import com.userleap.SprigSurveyResult;
|
|
14
23
|
import com.userleap.SurveyState;
|
|
15
24
|
import com.userleap.UserLeap;
|
|
16
25
|
|
|
26
|
+
import org.json.JSONException;
|
|
27
|
+
import org.json.JSONObject;
|
|
28
|
+
|
|
29
|
+
import java.util.EnumSet;
|
|
17
30
|
import java.util.HashMap;
|
|
31
|
+
import java.util.Iterator;
|
|
18
32
|
import java.util.List;
|
|
19
33
|
import java.util.Map;
|
|
20
34
|
import java.util.Objects;
|
|
35
|
+
import java.util.Set;
|
|
21
36
|
import java.util.stream.Collectors;
|
|
22
37
|
|
|
23
38
|
import javax.annotation.Nullable;
|
|
@@ -25,19 +40,38 @@ import javax.annotation.Nullable;
|
|
|
25
40
|
import kotlin.Unit;
|
|
26
41
|
import kotlin.jvm.functions.Function1;
|
|
27
42
|
|
|
28
|
-
import android.util.Log;
|
|
29
|
-
|
|
30
|
-
import com.userleap.EventListener;
|
|
31
|
-
import com.userleap.EventName;
|
|
32
|
-
import com.userleap.SprigEvent;
|
|
33
|
-
import com.userleap.SprigLoggingLevel;
|
|
34
|
-
import com.userleap.UserLeap;
|
|
35
|
-
|
|
36
|
-
import kotlin.Unit;
|
|
37
|
-
import kotlin.jvm.functions.Function1;
|
|
38
|
-
|
|
39
43
|
public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
40
44
|
|
|
45
|
+
private static final String TAG = "UserLeapModule";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Lifecycle events we forward to React Native via DeviceEventEmitter.
|
|
49
|
+
* Excluded:
|
|
50
|
+
* - LOGGING_EVENT: handled separately via logcat
|
|
51
|
+
* - REPLAY_CAPTURE: internal Web SDK plumbing, not meaningful to RN consumers
|
|
52
|
+
* - REPLAY_EVENTS_UPLOADED_COMPLETED: deprecated alias for REPLAY_EVENTS_UPLOAD_COMPLETED
|
|
53
|
+
*/
|
|
54
|
+
private static final Set<EventName> FORWARDED_EVENTS = EnumSet.of(
|
|
55
|
+
EventName.SDK_READY,
|
|
56
|
+
EventName.VISITOR_ID_UPDATED,
|
|
57
|
+
EventName.SURVEY_HEIGHT,
|
|
58
|
+
EventName.SURVEY_STATE_RETURNED,
|
|
59
|
+
EventName.SURVEY_WILL_PRESENT,
|
|
60
|
+
EventName.SURVEY_PRESENTED,
|
|
61
|
+
EventName.SURVEY_APPEARED,
|
|
62
|
+
EventName.QUESTION_ANSWERED,
|
|
63
|
+
EventName.SURVEY_CLOSE_REQUESTED,
|
|
64
|
+
EventName.SURVEY_WILL_CLOSE,
|
|
65
|
+
EventName.SURVEY_CLOSED,
|
|
66
|
+
EventName.SURVEY_COMPLETED,
|
|
67
|
+
EventName.REPLAY_CAPTURE_STARTED,
|
|
68
|
+
EventName.REPLAY_CAPTURE_STOPPED,
|
|
69
|
+
EventName.REPLAY_CAPTURE_COMPLETED,
|
|
70
|
+
EventName.REPLAY_RENDERING_COMPLETED,
|
|
71
|
+
EventName.REPLAY_UPLOAD_COMPLETED,
|
|
72
|
+
EventName.REPLAY_EVENTS_UPLOAD_COMPLETED
|
|
73
|
+
);
|
|
74
|
+
|
|
41
75
|
private final ReactApplicationContext reactContext;
|
|
42
76
|
|
|
43
77
|
public UserLeapModule(ReactApplicationContext reactContext) {
|
|
@@ -50,6 +84,157 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
50
84
|
return "UserLeapBindings";
|
|
51
85
|
}
|
|
52
86
|
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Required stubs for RN's NativeEventEmitter on the JS side.
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
@ReactMethod
|
|
92
|
+
public void addListener(String eventName) {
|
|
93
|
+
// No-op: listeners are registered once in configure() for the SDK lifetime.
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@ReactMethod
|
|
97
|
+
public void removeListeners(int count) {
|
|
98
|
+
// No-op: listeners are registered once in configure() for the SDK lifetime.
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Lifecycle event registration
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
private void registerForAllLifecycleEvents() {
|
|
106
|
+
for (EventName eventName : FORWARDED_EVENTS) {
|
|
107
|
+
UserLeap.INSTANCE.addEventListener(eventName, new EventListener() {
|
|
108
|
+
@Override
|
|
109
|
+
public void onEvent(SprigEvent event) {
|
|
110
|
+
sendSprigEvent(event);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private void sendSprigEvent(SprigEvent event) {
|
|
117
|
+
if (!reactContext.hasActiveCatalystInstance()) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
WritableMap params = jsonObjectToWritableMap(event.getData());
|
|
122
|
+
String eventName = toCamelCase(event.getName().name());
|
|
123
|
+
|
|
124
|
+
reactContext
|
|
125
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
126
|
+
.emit(eventName, params);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
// Bridge helpers
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Converts UPPER_SNAKE_CASE to camelCase to match the iOS event naming
|
|
135
|
+
* convention expected by the JS layer.
|
|
136
|
+
* e.g. "SURVEY_WILL_PRESENT" -> "surveyWillPresent"
|
|
137
|
+
*/
|
|
138
|
+
private String toCamelCase(String upperSnakeCase) {
|
|
139
|
+
String[] parts = upperSnakeCase.toLowerCase().split("_");
|
|
140
|
+
StringBuilder sb = new StringBuilder(parts[0]);
|
|
141
|
+
for (int i = 1; i < parts.length; i++) {
|
|
142
|
+
sb.append(Character.toUpperCase(parts[i].charAt(0)));
|
|
143
|
+
sb.append(parts[i].substring(1));
|
|
144
|
+
}
|
|
145
|
+
return sb.toString();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Shallow-converts a JSONObject to a WritableMap for passing across the RN bridge.
|
|
150
|
+
*/
|
|
151
|
+
private WritableMap jsonObjectToWritableMap(@Nullable JSONObject json) {
|
|
152
|
+
WritableMap map = Arguments.createMap();
|
|
153
|
+
if (json == null) {
|
|
154
|
+
return map;
|
|
155
|
+
}
|
|
156
|
+
Iterator<String> keys = json.keys();
|
|
157
|
+
while (keys.hasNext()) {
|
|
158
|
+
String key = keys.next();
|
|
159
|
+
try {
|
|
160
|
+
Object value = json.get(key);
|
|
161
|
+
if (value instanceof String) {
|
|
162
|
+
map.putString(key, (String) value);
|
|
163
|
+
} else if (value instanceof Boolean) {
|
|
164
|
+
map.putBoolean(key, (Boolean) value);
|
|
165
|
+
} else if (value instanceof Integer) {
|
|
166
|
+
map.putInt(key, (Integer) value);
|
|
167
|
+
} else if (value instanceof Double) {
|
|
168
|
+
map.putDouble(key, (Double) value);
|
|
169
|
+
} else if (value instanceof JSONObject) {
|
|
170
|
+
map.putMap(key, jsonObjectToWritableMap((JSONObject) value));
|
|
171
|
+
} else if (value == JSONObject.NULL) {
|
|
172
|
+
map.putNull(key);
|
|
173
|
+
} else {
|
|
174
|
+
map.putString(key, value.toString());
|
|
175
|
+
}
|
|
176
|
+
} catch (JSONException e) {
|
|
177
|
+
Log.w(TAG, "Failed to convert key '" + key + "' from SprigEvent data", e);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return map;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Converts a SprigSurveyResult to a WritableMap for passing across the RN bridge.
|
|
185
|
+
* Returns { surveyState: string, surveyId: int }
|
|
186
|
+
*/
|
|
187
|
+
private WritableMap surveyResultToWritableMap(SprigSurveyResult surveyResult) {
|
|
188
|
+
WritableMap resultMap = Arguments.createMap();
|
|
189
|
+
resultMap.putString("surveyState", surveyResult.getSurveyState().name());
|
|
190
|
+
if (surveyResult.getSurveyId() != null) {
|
|
191
|
+
resultMap.putInt("surveyId", surveyResult.getSurveyId());
|
|
192
|
+
} else {
|
|
193
|
+
resultMap.putInt("surveyId", 0);
|
|
194
|
+
}
|
|
195
|
+
return resultMap;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Wraps a RN Callback as a Function1<SprigSurveyResult, Unit> for the EventPayload API.
|
|
200
|
+
* Returns null if the callback is null.
|
|
201
|
+
*/
|
|
202
|
+
private @Nullable Function1<SprigSurveyResult, Unit> wrapResultCallback(@Nullable final Callback callback) {
|
|
203
|
+
if (callback == null) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
return new Function1<SprigSurveyResult, Unit>() {
|
|
207
|
+
@Override
|
|
208
|
+
public Unit invoke(SprigSurveyResult surveyResult) {
|
|
209
|
+
callback.invoke(surveyResultToWritableMap(surveyResult));
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private Map<String, String> stringifyMap(ReadableMap map) {
|
|
216
|
+
Map<String, String> stringifiedMap = new HashMap<>();
|
|
217
|
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
218
|
+
stringifiedMap = map.toHashMap().entrySet().stream()
|
|
219
|
+
.filter(m -> m.getKey() != null && m.getValue() != null)
|
|
220
|
+
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toString()));
|
|
221
|
+
}
|
|
222
|
+
return stringifiedMap;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private @Nullable FragmentActivity getFragmentActivity() {
|
|
226
|
+
Activity activity = getCurrentActivity();
|
|
227
|
+
if (activity instanceof FragmentActivity) {
|
|
228
|
+
return (FragmentActivity) activity;
|
|
229
|
+
} else {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ---------------------------------------------------------------------------
|
|
235
|
+
// SDK properties
|
|
236
|
+
// ---------------------------------------------------------------------------
|
|
237
|
+
|
|
53
238
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
54
239
|
public int visitorIdentifier() {
|
|
55
240
|
final Integer visitorIdentifierObject = UserLeap.INSTANCE.getVisitorIdentifier();
|
|
@@ -67,15 +252,16 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
67
252
|
return UserLeap.INSTANCE.getSdkVersion();
|
|
68
253
|
}
|
|
69
254
|
|
|
255
|
+
// ---------------------------------------------------------------------------
|
|
256
|
+
// Configuration
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
|
|
70
259
|
@ReactMethod
|
|
71
260
|
public void configure(String environment, ReadableMap configuration) {
|
|
72
|
-
|
|
73
261
|
UserLeap.INSTANCE.addEventListener(EventName.LOGGING_EVENT, new EventListener() {
|
|
74
262
|
@Override
|
|
75
263
|
public void onEvent(SprigEvent event) {
|
|
76
|
-
|
|
77
264
|
String tag = "SprigLoggingEvent";
|
|
78
|
-
|
|
79
265
|
switch (event.getLogLevel()) {
|
|
80
266
|
case INFO:
|
|
81
267
|
Log.i(tag, event.getLogMessage());
|
|
@@ -94,14 +280,20 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
94
280
|
}
|
|
95
281
|
});
|
|
96
282
|
|
|
283
|
+
registerForAllLifecycleEvents();
|
|
284
|
+
|
|
97
285
|
UserLeap.INSTANCE.configure(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
286
|
+
reactContext,
|
|
287
|
+
environment,
|
|
288
|
+
stringifyMap(configuration),
|
|
289
|
+
getFragmentActivity()
|
|
102
290
|
);
|
|
103
291
|
}
|
|
104
292
|
|
|
293
|
+
// ---------------------------------------------------------------------------
|
|
294
|
+
// Deprecated track methods (return SurveyState string)
|
|
295
|
+
// ---------------------------------------------------------------------------
|
|
296
|
+
|
|
105
297
|
@ReactMethod
|
|
106
298
|
public void track(String event, final Callback surveyStateCallback) {
|
|
107
299
|
trackAndIdentify(event, null, null, surveyStateCallback);
|
|
@@ -109,19 +301,17 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
109
301
|
|
|
110
302
|
@ReactMethod
|
|
111
303
|
public void trackWithProperties(String event, String userId, String partnerAnonymousId, ReadableMap properties, final Callback surveyStateCallback) {
|
|
112
|
-
|
|
304
|
+
if (surveyStateCallback == null) {
|
|
113
305
|
UserLeap.INSTANCE.track(event, userId, partnerAnonymousId, stringifyMap(properties));
|
|
114
|
-
|
|
306
|
+
} else {
|
|
115
307
|
UserLeap.INSTANCE.track(event, userId, partnerAnonymousId, stringifyMap(properties), new Function1<SurveyState, Unit>() {
|
|
116
308
|
@Override
|
|
117
309
|
public Unit invoke(SurveyState surveyState) {
|
|
118
|
-
|
|
119
|
-
surveyStateCallback.invoke(surveyState.name());
|
|
120
|
-
}
|
|
310
|
+
surveyStateCallback.invoke(surveyState.name());
|
|
121
311
|
return null;
|
|
122
312
|
}
|
|
123
|
-
});
|
|
124
|
-
|
|
313
|
+
});
|
|
314
|
+
}
|
|
125
315
|
}
|
|
126
316
|
|
|
127
317
|
@ReactMethod
|
|
@@ -139,50 +329,46 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
139
329
|
}
|
|
140
330
|
}
|
|
141
331
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@ReactMethod
|
|
148
|
-
public void setVisitorAttribute(String key, String value) {
|
|
149
|
-
UserLeap.INSTANCE.setVisitorAttribute(key, value);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
@ReactMethod
|
|
153
|
-
public void setVisitorAttributes(ReadableMap attributes) {
|
|
154
|
-
UserLeap.INSTANCE.setVisitorAttributes(stringifyMap(attributes));
|
|
155
|
-
}
|
|
332
|
+
// ---------------------------------------------------------------------------
|
|
333
|
+
// New track methods (return SprigSurveyResult via EventPayload)
|
|
334
|
+
// ---------------------------------------------------------------------------
|
|
156
335
|
|
|
157
336
|
@ReactMethod
|
|
158
|
-
public void
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
@ReactMethod
|
|
163
|
-
public void removeVisitorAttributes(ReadableArray attributes) {
|
|
164
|
-
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
165
|
-
List<String> attributeStrings = attributes.toArrayList().stream()
|
|
166
|
-
.map(object -> Objects.toString(object, null))
|
|
167
|
-
.collect(Collectors.toList());
|
|
168
|
-
UserLeap.INSTANCE.removeVisitorAttributes(attributeStrings);
|
|
169
|
-
}
|
|
337
|
+
public void trackEvent(String event, final Callback surveyStateCallback) {
|
|
338
|
+
trackEventAndIdentify(event, null, null, surveyStateCallback);
|
|
170
339
|
}
|
|
171
340
|
|
|
172
341
|
@ReactMethod
|
|
173
|
-
public void
|
|
174
|
-
|
|
342
|
+
public void trackEventWithProperties(String event, String userId, String partnerAnonymousId, ReadableMap properties, final Callback surveyStateCallback) {
|
|
343
|
+
EventPayload payload = new EventPayload(
|
|
344
|
+
event,
|
|
345
|
+
userId,
|
|
346
|
+
partnerAnonymousId,
|
|
347
|
+
stringifyMap(properties),
|
|
348
|
+
wrapResultCallback(surveyStateCallback),
|
|
349
|
+
null, // shouldShowSurveyCallback
|
|
350
|
+
null // deprecated callback
|
|
351
|
+
);
|
|
352
|
+
UserLeap.INSTANCE.track(payload);
|
|
175
353
|
}
|
|
176
354
|
|
|
177
355
|
@ReactMethod
|
|
178
|
-
public void
|
|
179
|
-
|
|
356
|
+
public void trackEventAndIdentify(String event, String userId, String partnerAnonymousId, final Callback surveyStateCallback) {
|
|
357
|
+
EventPayload payload = new EventPayload(
|
|
358
|
+
event,
|
|
359
|
+
userId,
|
|
360
|
+
partnerAnonymousId,
|
|
361
|
+
null, // properties
|
|
362
|
+
wrapResultCallback(surveyStateCallback),
|
|
363
|
+
null, // shouldShowSurveyCallback
|
|
364
|
+
null // deprecated callback
|
|
365
|
+
);
|
|
366
|
+
UserLeap.INSTANCE.track(payload);
|
|
180
367
|
}
|
|
181
368
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
369
|
+
// ---------------------------------------------------------------------------
|
|
370
|
+
// Track and present
|
|
371
|
+
// ---------------------------------------------------------------------------
|
|
186
372
|
|
|
187
373
|
@ReactMethod
|
|
188
374
|
public void trackAndPresent(String event) {
|
|
@@ -194,6 +380,10 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
194
380
|
UserLeap.INSTANCE.trackAndPresent(event, userId, partnerAnonymousId, getFragmentActivity());
|
|
195
381
|
}
|
|
196
382
|
|
|
383
|
+
// ---------------------------------------------------------------------------
|
|
384
|
+
// Survey presentation
|
|
385
|
+
// ---------------------------------------------------------------------------
|
|
386
|
+
|
|
197
387
|
@ReactMethod
|
|
198
388
|
public void presentSurvey() {
|
|
199
389
|
UserLeap.INSTANCE.presentSurvey(null);
|
|
@@ -214,23 +404,52 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
|
|
|
214
404
|
UserLeap.INSTANCE.unpauseDisplayingSurveys();
|
|
215
405
|
}
|
|
216
406
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
407
|
+
// ---------------------------------------------------------------------------
|
|
408
|
+
// User identity & attributes
|
|
409
|
+
// ---------------------------------------------------------------------------
|
|
410
|
+
|
|
411
|
+
@ReactMethod
|
|
412
|
+
public void setEmailAddress(String emailAddress) {
|
|
413
|
+
UserLeap.INSTANCE.setEmailAddress(emailAddress);
|
|
225
414
|
}
|
|
226
415
|
|
|
227
|
-
|
|
228
|
-
|
|
416
|
+
@ReactMethod
|
|
417
|
+
public void setVisitorAttribute(String key, String value) {
|
|
418
|
+
UserLeap.INSTANCE.setVisitorAttribute(key, value);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
@ReactMethod
|
|
422
|
+
public void setVisitorAttributes(ReadableMap attributes) {
|
|
423
|
+
UserLeap.INSTANCE.setVisitorAttributes(stringifyMap(attributes));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
@ReactMethod
|
|
427
|
+
public void setVisitorAttributesAndIdentify(ReadableMap attributes, String userId, String partnerAnonymousId) {
|
|
428
|
+
UserLeap.INSTANCE.setVisitorAttributes(stringifyMap(attributes), userId, partnerAnonymousId);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
@ReactMethod
|
|
432
|
+
public void removeVisitorAttributes(ReadableArray attributes) {
|
|
229
433
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
434
|
+
List<String> attributeStrings = attributes.toArrayList().stream()
|
|
435
|
+
.map(object -> Objects.toString(object, null))
|
|
436
|
+
.collect(Collectors.toList());
|
|
437
|
+
UserLeap.INSTANCE.removeVisitorAttributes(attributeStrings);
|
|
233
438
|
}
|
|
234
|
-
return stringifiedMap;
|
|
235
439
|
}
|
|
236
|
-
|
|
440
|
+
|
|
441
|
+
@ReactMethod
|
|
442
|
+
public void setPreviewKey(String previewKey) {
|
|
443
|
+
UserLeap.INSTANCE.setPreviewKey(previewKey);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
@ReactMethod
|
|
447
|
+
public void setUserIdentifier(String identifier) {
|
|
448
|
+
UserLeap.INSTANCE.setUserIdentifier(identifier);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
@ReactMethod
|
|
452
|
+
public void logout() {
|
|
453
|
+
UserLeap.INSTANCE.logout();
|
|
454
|
+
}
|
|
455
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -4,15 +4,68 @@ declare namespace UserLeap {
|
|
|
4
4
|
DISABLED: string;
|
|
5
5
|
NO_SURVEY: string;
|
|
6
6
|
};
|
|
7
|
+
|
|
8
|
+
const LifecycleEvent: {
|
|
9
|
+
sdkReady: number;
|
|
10
|
+
visitorIdUpdated: number;
|
|
11
|
+
surveyHeight: number;
|
|
12
|
+
surveyWillPresent: number;
|
|
13
|
+
surveyPresented: number;
|
|
14
|
+
surveyAppeared: number;
|
|
15
|
+
surveyCloseRequested: number;
|
|
16
|
+
surveyWillClose: number;
|
|
17
|
+
surveyClosed: number;
|
|
18
|
+
replayCapture: number;
|
|
19
|
+
replayCaptureStarted: number;
|
|
20
|
+
replayCaptureStopped: number;
|
|
21
|
+
replayCaptureCompleted: number;
|
|
22
|
+
replayRenderingCompleted: number;
|
|
23
|
+
replayUploadCompleted: number;
|
|
24
|
+
replayEventsUploadCompleted: number;
|
|
25
|
+
loggingEvent: number;
|
|
26
|
+
surveyCompleted: number;
|
|
27
|
+
surveyStateReturned: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Usage: UserLeap.EventEmitter.addListener('surveyPresented', callback)
|
|
31
|
+
const EventEmitter: any;
|
|
32
|
+
|
|
7
33
|
function visitorIdentifier(): number;
|
|
8
34
|
function visitorIdentifierString(): string;
|
|
9
35
|
function sdkVersion(): string;
|
|
10
36
|
function configure(environment: string, configuration?: {[key: string]: any}): void;
|
|
11
37
|
function setPreviewKey(previewKey: string): void;
|
|
12
38
|
function presentSurvey(): void;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated This function is outdated. Use `trackEvent()` instead.
|
|
41
|
+
*/
|
|
13
42
|
function track(event: string, surveyStateCallback: ((surveyState: string) => void)): void;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated This function is outdated. Use `trackEventWithProperties()` instead.
|
|
45
|
+
*/
|
|
14
46
|
function trackWithProperties(event: string, userId: string | undefined, partnerAnonymousId: string | undefined, properties: {[key: string]: any}, surveyStateCallback: ((surveyState: string) => void)): void;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated This function is outdated. Use `trackEventAndIdentify()` instead.
|
|
49
|
+
*/
|
|
15
50
|
function trackAndIdentify(event: string, userId: string | undefined, partnerAnonymousId: string | undefined, surveyStateCallback: ((surveyState: string) => void)): void;
|
|
51
|
+
function trackEvent(
|
|
52
|
+
event: string,
|
|
53
|
+
surveyResultCallback: (result: { surveyState: string; surveyId: number }) => void
|
|
54
|
+
): void;
|
|
55
|
+
function trackEventWithProperties(
|
|
56
|
+
event: string,
|
|
57
|
+
userId: string | undefined,
|
|
58
|
+
partnerAnonymousId: string | undefined,
|
|
59
|
+
properties: { [key: string]: any },
|
|
60
|
+
surveyResultCallback: (result: { surveyState: string; surveyId: number }) => void
|
|
61
|
+
): void;
|
|
62
|
+
|
|
63
|
+
function trackEventAndIdentify(
|
|
64
|
+
event: string,
|
|
65
|
+
userId: string | undefined,
|
|
66
|
+
partnerAnonymousId: string | undefined,
|
|
67
|
+
surveyResultCallback: (result: { surveyState: string; surveyId: number }) => void
|
|
68
|
+
): void;
|
|
16
69
|
function setEmailAddress(emailAddress: string): void;
|
|
17
70
|
function setVisitorAttribute(key: string, value: string): void;
|
|
18
71
|
function setVisitorAttributes(attributes: {[key: string]: string}): void;
|
|
@@ -25,8 +78,5 @@ declare namespace UserLeap {
|
|
|
25
78
|
function unpauseDisplayingSurveys(): void;
|
|
26
79
|
function trackAndPresent(event: string): void;
|
|
27
80
|
function trackIdentifyAndPresent(event: string, userId: string | undefined, partnerAnonymousId: string | undefined): void;
|
|
28
|
-
// Uncomment for UI testing
|
|
29
|
-
// function renderSnapshotForUITest(name: string, maskingLevel: string)
|
|
30
|
-
|
|
31
81
|
}
|
|
32
82
|
export default UserLeap;
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Platform, NativeModules } from "react-native";
|
|
1
|
+
import { Platform, NativeModules, NativeEventEmitter } from "react-native";
|
|
2
2
|
|
|
3
3
|
import { version } from "./package.json";
|
|
4
4
|
|
|
@@ -8,6 +8,30 @@ const SurveyState = {
|
|
|
8
8
|
NO_SURVEY: "NO_SURVEY",
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
const LifecycleEvent = {
|
|
12
|
+
sdkReady: 0,
|
|
13
|
+
visitorIdUpdated: 1,
|
|
14
|
+
surveyHeight: 2,
|
|
15
|
+
surveyWillPresent: 3,
|
|
16
|
+
surveyPresented: 4,
|
|
17
|
+
surveyAppeared: 5,
|
|
18
|
+
surveyCloseRequested: 6,
|
|
19
|
+
surveyWillClose: 7,
|
|
20
|
+
surveyClosed: 8,
|
|
21
|
+
replayCapture: 9,
|
|
22
|
+
replayCaptureStarted: 10,
|
|
23
|
+
replayCaptureStopped: 11,
|
|
24
|
+
replayCaptureCompleted: 12,
|
|
25
|
+
replayRenderingCompleted: 13,
|
|
26
|
+
replayUploadCompleted: 14,
|
|
27
|
+
replayEventsUploadCompleted: 15,
|
|
28
|
+
loggingEvent: 16,
|
|
29
|
+
surveyCompleted: 17,
|
|
30
|
+
surveyStateReturned: 18
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const UserLeapEventEmitter = new NativeEventEmitter(NativeModules.UserLeapBindings);
|
|
34
|
+
|
|
11
35
|
const stringifyAttributes = (attributes) => {
|
|
12
36
|
if (!(attributes instanceof Object && attributes.constructor === Object))
|
|
13
37
|
return {};
|
|
@@ -35,7 +59,7 @@ const visitorIdentifier = () => {
|
|
|
35
59
|
|
|
36
60
|
const sdkVersion = () => {
|
|
37
61
|
if (Platform.OS === "ios") {
|
|
38
|
-
if (String(Platform.Version) >= "
|
|
62
|
+
if (String(Platform.Version) >= "15.0") {
|
|
39
63
|
return NativeModules.UserLeapBindings.sdkVersion();
|
|
40
64
|
}
|
|
41
65
|
} else {
|
|
@@ -81,12 +105,18 @@ const presentSurvey = () => {
|
|
|
81
105
|
}
|
|
82
106
|
};
|
|
83
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated This function is outdated. Use `trackEvent()` instead.
|
|
110
|
+
*/
|
|
84
111
|
const track = (event, surveyStateCallback) => {
|
|
85
112
|
if (isValidPlatform()) {
|
|
86
113
|
NativeModules.UserLeapBindings.track(event, surveyStateCallback);
|
|
87
114
|
}
|
|
88
115
|
};
|
|
89
116
|
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated This function is outdated. Use `trackEventWithProperties()` instead.
|
|
119
|
+
*/
|
|
90
120
|
const trackWithProperties = (
|
|
91
121
|
event,
|
|
92
122
|
userId,
|
|
@@ -105,6 +135,9 @@ const trackWithProperties = (
|
|
|
105
135
|
}
|
|
106
136
|
};
|
|
107
137
|
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated This function is outdated. Use `trackEventAndIdentify()` instead.
|
|
140
|
+
*/
|
|
108
141
|
const trackAndIdentify = (
|
|
109
142
|
event,
|
|
110
143
|
userId,
|
|
@@ -121,6 +154,46 @@ const trackAndIdentify = (
|
|
|
121
154
|
}
|
|
122
155
|
};
|
|
123
156
|
|
|
157
|
+
const trackEvent = (event, surveyResultCallback) => {
|
|
158
|
+
if (isValidPlatform()) {
|
|
159
|
+
NativeModules.UserLeapBindings.trackEvent(event, surveyResultCallback);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const trackEventWithProperties = (
|
|
164
|
+
event,
|
|
165
|
+
userId,
|
|
166
|
+
partnerAnonymousId,
|
|
167
|
+
properties,
|
|
168
|
+
surveyResultCallback
|
|
169
|
+
) => {
|
|
170
|
+
if (isValidPlatform()) {
|
|
171
|
+
NativeModules.UserLeapBindings.trackEventWithProperties(
|
|
172
|
+
event,
|
|
173
|
+
userId,
|
|
174
|
+
partnerAnonymousId,
|
|
175
|
+
properties,
|
|
176
|
+
surveyResultCallback
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const trackEventAndIdentify = (
|
|
182
|
+
event,
|
|
183
|
+
userId,
|
|
184
|
+
partnerAnonynmousId,
|
|
185
|
+
surveyResultCallback
|
|
186
|
+
) => {
|
|
187
|
+
if (isValidPlatform()) {
|
|
188
|
+
NativeModules.UserLeapBindings.trackEventAndIdentify(
|
|
189
|
+
event,
|
|
190
|
+
userId,
|
|
191
|
+
partnerAnonynmousId,
|
|
192
|
+
surveyResultCallback
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
124
197
|
const setEmailAddress = (emailAddress) => {
|
|
125
198
|
if (isValidPlatform()) {
|
|
126
199
|
NativeModules.UserLeapBindings.setEmailAddress(emailAddress);
|
|
@@ -207,15 +280,7 @@ const trackIdentifyAndPresent = (event, userId, partnerAnonynmousId) => {
|
|
|
207
280
|
}
|
|
208
281
|
};
|
|
209
282
|
|
|
210
|
-
// Uncomment for UI testing
|
|
211
|
-
// const renderSnapshotForUITest = (name, maskingLevel) => {
|
|
212
|
-
// if (isValidPlatform()) {
|
|
213
|
-
// NativeModules.UserLeapBindings.renderSnapshotForUITest(name, maskingLevel);
|
|
214
|
-
// }
|
|
215
|
-
// }
|
|
216
|
-
|
|
217
283
|
const UserLeap = {
|
|
218
|
-
SurveyState,
|
|
219
284
|
visitorIdentifier,
|
|
220
285
|
visitorIdentifierString,
|
|
221
286
|
sdkVersion,
|
|
@@ -225,6 +290,9 @@ const UserLeap = {
|
|
|
225
290
|
track,
|
|
226
291
|
trackWithProperties,
|
|
227
292
|
trackAndIdentify,
|
|
293
|
+
trackEvent,
|
|
294
|
+
trackEventWithProperties,
|
|
295
|
+
trackEventAndIdentify,
|
|
228
296
|
setEmailAddress,
|
|
229
297
|
setVisitorAttribute,
|
|
230
298
|
setVisitorAttributes,
|
|
@@ -237,8 +305,10 @@ const UserLeap = {
|
|
|
237
305
|
dismissActiveSurvey,
|
|
238
306
|
pauseDisplayingSurveys,
|
|
239
307
|
unpauseDisplayingSurveys,
|
|
240
|
-
// Uncomment for UI testing
|
|
241
|
-
// renderSnapshotForUITest,
|
|
242
308
|
};
|
|
243
309
|
|
|
310
|
+
UserLeap.LifecycleEvent = LifecycleEvent;
|
|
311
|
+
UserLeap.SurveyState = SurveyState;
|
|
312
|
+
UserLeap.EventEmitter = UserLeapEventEmitter;
|
|
313
|
+
|
|
244
314
|
export default UserLeap;
|
package/ios/UserLeapBindings.h
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
2
3
|
@import UserLeapKit;
|
|
3
4
|
|
|
4
|
-
@interface UserLeapBindings :
|
|
5
|
+
@interface UserLeapBindings : RCTEventEmitter <RCTBridgeModule, _SGRNExtractor>
|
|
5
6
|
@property (nonatomic, weak) RCTBridge *bridge;
|
|
6
7
|
@end
|
package/ios/UserLeapBindings.m
CHANGED
|
@@ -18,6 +18,13 @@
|
|
|
18
18
|
return dispatch_get_main_queue();
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
-(NSDictionary *) parseSurveyResult:(SprigSurveyResult *)result {
|
|
22
|
+
SurveyState state = [result surveyState];
|
|
23
|
+
NSString *surveyStateString = [self getSurveyState:state];
|
|
24
|
+
NSInteger surveyId = [result surveyId];
|
|
25
|
+
return @{@"surveyState": surveyStateString, @"surveyId": @(surveyId)};
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
- (NSString *)getSurveyState:(SurveyState)surveyState
|
|
22
29
|
{
|
|
23
30
|
NSString *surveyStateBinding = @"NO_SURVEY";
|
|
@@ -31,10 +38,18 @@
|
|
|
31
38
|
case SurveyStateNoSurvey:
|
|
32
39
|
surveyStateBinding = @"NO_SURVEY";
|
|
33
40
|
break;
|
|
41
|
+
case SurveyStatePreviousSurveyReady:
|
|
42
|
+
surveyStateBinding = @"PREVIOUS_SURVEY_READY";
|
|
43
|
+
break;
|
|
34
44
|
}
|
|
35
45
|
return surveyStateBinding;
|
|
36
46
|
}
|
|
37
47
|
|
|
48
|
+
/// These are required by RCTEventEmitter.
|
|
49
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
50
|
+
return [LifecycleEventUtil allNameStrings];
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
RCT_EXPORT_MODULE()
|
|
39
54
|
|
|
40
55
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(visitorIdentifier)
|
|
@@ -56,8 +71,35 @@ RCT_EXPORT_METHOD(configure:(NSString *)environmentId configuration:(NSDictionar
|
|
|
56
71
|
{
|
|
57
72
|
[[UserLeap shared] configureWithEnvironment:environmentId configuration:configuration];
|
|
58
73
|
[[UserLeap shared] _passWithRnExtractor:self];
|
|
74
|
+
|
|
75
|
+
/// Register for all the LifeCycle events.
|
|
76
|
+
[self registerForAllLifecycleEvents];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void)registerForAllLifecycleEvents {
|
|
80
|
+
|
|
81
|
+
for (NSNumber *eventVal in [LifecycleEventUtil all]) {
|
|
82
|
+
[[UserLeap shared] registerEventListenerFor:[eventVal intValue] listener:^(NSDictionary<NSString *,id> * eventData) {
|
|
83
|
+
|
|
84
|
+
NSString *type = eventData[LifecycleEventDataKey.eventType];
|
|
85
|
+
if (!type) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
LifecycleEvent lifecycleEvent = [LifecycleEventUtil fromString:type];
|
|
90
|
+
if (lifecycleEvent != LifecycleEventUnknown) {
|
|
91
|
+
|
|
92
|
+
/// Always make sure the type exists in the supportedEvents; sending an unsupported event will crash the app.
|
|
93
|
+
NSString *lifecycleEventName = [LifecycleEventUtil stringName:lifecycleEvent];
|
|
94
|
+
if ([[self supportedEvents] containsObject: lifecycleEventName]) {
|
|
95
|
+
[self sendEventWithName:lifecycleEventName body:eventData];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}];
|
|
99
|
+
}
|
|
59
100
|
}
|
|
60
101
|
|
|
102
|
+
|
|
61
103
|
RCT_EXPORT_METHOD(setPreviewKey:(NSString *)previewKey)
|
|
62
104
|
{
|
|
63
105
|
[[UserLeap shared] setPreviewKey:previewKey];
|
|
@@ -68,6 +110,7 @@ RCT_EXPORT_METHOD(presentSurvey)
|
|
|
68
110
|
[[UserLeap shared] presentSurveyFrom:RCTPresentedViewController()];
|
|
69
111
|
}
|
|
70
112
|
|
|
113
|
+
/// Use trackEvent instead of track
|
|
71
114
|
RCT_EXPORT_METHOD(track:(NSString *)eventName
|
|
72
115
|
surveyStateCallback:(RCTResponseSenderBlock)callback)
|
|
73
116
|
{
|
|
@@ -80,33 +123,50 @@ RCT_EXPORT_METHOD(track:(NSString *)eventName
|
|
|
80
123
|
}
|
|
81
124
|
}
|
|
82
125
|
|
|
126
|
+
RCT_EXPORT_METHOD(trackEvent:(NSString *)eventName
|
|
127
|
+
surveyResultCallback:(RCTResponseSenderBlock)callback)
|
|
128
|
+
{
|
|
129
|
+
EventPayload *payload = [[EventPayload alloc] initWithEventName:eventName userId:nil partnerAnonymousId:nil properties:nil handler:nil resultHandler:^(SprigSurveyResult * result) {
|
|
130
|
+
if (callback != nil) {
|
|
131
|
+
callback(@[[self parseSurveyResult:result]]);
|
|
132
|
+
}
|
|
133
|
+
}];
|
|
134
|
+
[[UserLeap shared] trackWithPayload: payload];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// Use trackEventWithProperties instead of trackWithProperties
|
|
83
138
|
RCT_EXPORT_METHOD(trackWithProperties:(NSString *)eventName
|
|
84
139
|
userId:(NSString * _Nullable)userId
|
|
85
140
|
partnerAnonymousId:(NSString * _Nullable)partnerAnonymousId
|
|
86
141
|
properties: (NSDictionary *)properties
|
|
87
142
|
surveyStateCallback:(RCTResponseSenderBlock)callback)
|
|
88
143
|
{
|
|
89
|
-
if (callback != nil) {
|
|
90
144
|
[[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId properties:properties handler:^(enum SurveyState surveyState) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
145
|
+
callback(@[[self getSurveyState:surveyState]]);
|
|
146
|
+
}];
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
RCT_EXPORT_METHOD(trackEventWithProperties:(NSString *)eventName
|
|
151
|
+
userId:(NSString * _Nullable)userId
|
|
152
|
+
partnerAnonymousId:(NSString * _Nullable)partnerAnonymousId
|
|
153
|
+
properties: (NSDictionary *)properties
|
|
154
|
+
surveyResultCallback:(RCTResponseSenderBlock)callback)
|
|
155
|
+
{
|
|
156
|
+
EventPayload *payload = [[EventPayload alloc] initWithEventName:eventName
|
|
157
|
+
userId:userId
|
|
158
|
+
partnerAnonymousId:partnerAnonymousId
|
|
159
|
+
properties:properties
|
|
160
|
+
handler:nil
|
|
161
|
+
resultHandler:^(SprigSurveyResult * result) {
|
|
162
|
+
if (callback != nil) {
|
|
163
|
+
callback(@[[self parseSurveyResult:result]]);
|
|
102
164
|
}
|
|
103
|
-
callback(@[surveyStateBinding]);
|
|
104
165
|
}];
|
|
105
|
-
|
|
106
|
-
[[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId properties:properties handler:nil];
|
|
107
|
-
}
|
|
166
|
+
[[UserLeap shared] trackWithPayload: payload];
|
|
108
167
|
}
|
|
109
168
|
|
|
169
|
+
/// Use trackEventAndIdentify instead of trackAndIdentify
|
|
110
170
|
RCT_EXPORT_METHOD(trackAndIdentify:(NSString *)eventName
|
|
111
171
|
userId:(NSString *)userId
|
|
112
172
|
partnerAnonymousId:(NSString *)partnerAnonymousId
|
|
@@ -119,7 +179,24 @@ RCT_EXPORT_METHOD(trackAndIdentify:(NSString *)eventName
|
|
|
119
179
|
} else {
|
|
120
180
|
[[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId handler:nil];
|
|
121
181
|
}
|
|
122
|
-
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
RCT_EXPORT_METHOD(trackEventAndIdentify:(NSString *)eventName
|
|
185
|
+
userId:(NSString *)userId
|
|
186
|
+
partnerAnonymousId:(NSString *)partnerAnonymousId
|
|
187
|
+
surveyResultCallback:(RCTResponseSenderBlock)callback)
|
|
188
|
+
{
|
|
189
|
+
EventPayload *payload = [[EventPayload alloc] initWithEventName:eventName
|
|
190
|
+
userId:userId
|
|
191
|
+
partnerAnonymousId:partnerAnonymousId
|
|
192
|
+
properties:nil
|
|
193
|
+
handler:nil
|
|
194
|
+
resultHandler:^(SprigSurveyResult * result) {
|
|
195
|
+
if (callback != nil) {
|
|
196
|
+
callback(@[[self parseSurveyResult:result]]);
|
|
197
|
+
}
|
|
198
|
+
}];
|
|
199
|
+
[[UserLeap shared] trackWithPayload: payload];
|
|
123
200
|
}
|
|
124
201
|
|
|
125
202
|
RCT_EXPORT_METHOD(setEmailAddress:(NSString *)emailAddress)
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-userleap",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"description": "React Native module for UserLeap",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
"react-native": "0.74.7",
|
|
44
44
|
"react-test-renderer": "18.2.0"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|
|
Binary file
|
package/android/gradlew
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
# Copyright © 2015-2021 the original authors.
|
|
5
|
-
#
|
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
# you may not use this file except in compliance with the License.
|
|
8
|
-
# You may obtain a copy of the License at
|
|
9
|
-
#
|
|
10
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
# See the License for the specific language governing permissions and
|
|
16
|
-
# limitations under the License.
|
|
17
|
-
#
|
|
18
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
##############################################################################
|
|
22
|
-
#
|
|
23
|
-
# Gradle start up script for POSIX generated by Gradle.
|
|
24
|
-
#
|
|
25
|
-
# Important for running:
|
|
26
|
-
#
|
|
27
|
-
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
28
|
-
# noncompliant, but you have some other compliant shell such as ksh or
|
|
29
|
-
# bash, then to run this script, type that shell name before the whole
|
|
30
|
-
# command line, like:
|
|
31
|
-
#
|
|
32
|
-
# ksh Gradle
|
|
33
|
-
#
|
|
34
|
-
# Busybox and similar reduced shells will NOT work, because this script
|
|
35
|
-
# requires all of these POSIX shell features:
|
|
36
|
-
# * functions;
|
|
37
|
-
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
38
|
-
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
39
|
-
# * compound commands having a testable exit status, especially «case»;
|
|
40
|
-
# * various built-in commands including «command», «set», and «ulimit».
|
|
41
|
-
#
|
|
42
|
-
# Important for patching:
|
|
43
|
-
#
|
|
44
|
-
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
45
|
-
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
46
|
-
#
|
|
47
|
-
# The "traditional" practice of packing multiple parameters into a
|
|
48
|
-
# space-separated string is a well documented source of bugs and security
|
|
49
|
-
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
50
|
-
# options in "$@", and eventually passing that to Java.
|
|
51
|
-
#
|
|
52
|
-
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
53
|
-
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
54
|
-
# see the in-line comments for details.
|
|
55
|
-
#
|
|
56
|
-
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
57
|
-
# Darwin, MinGW, and NonStop.
|
|
58
|
-
#
|
|
59
|
-
# (3) This script is generated from the Groovy template
|
|
60
|
-
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
61
|
-
# within the Gradle project.
|
|
62
|
-
#
|
|
63
|
-
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
64
|
-
#
|
|
65
|
-
##############################################################################
|
|
66
|
-
|
|
67
|
-
# Attempt to set APP_HOME
|
|
68
|
-
|
|
69
|
-
# Resolve links: $0 may be a link
|
|
70
|
-
app_path=$0
|
|
71
|
-
|
|
72
|
-
# Need this for daisy-chained symlinks.
|
|
73
|
-
while
|
|
74
|
-
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
75
|
-
[ -h "$app_path" ]
|
|
76
|
-
do
|
|
77
|
-
ls=$( ls -ld "$app_path" )
|
|
78
|
-
link=${ls#*' -> '}
|
|
79
|
-
case $link in #(
|
|
80
|
-
/*) app_path=$link ;; #(
|
|
81
|
-
*) app_path=$APP_HOME$link ;;
|
|
82
|
-
esac
|
|
83
|
-
done
|
|
84
|
-
|
|
85
|
-
# This is normally unused
|
|
86
|
-
# shellcheck disable=SC2034
|
|
87
|
-
APP_BASE_NAME=${0##*/}
|
|
88
|
-
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
89
|
-
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
|
90
|
-
|
|
91
|
-
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
92
|
-
MAX_FD=maximum
|
|
93
|
-
|
|
94
|
-
warn () {
|
|
95
|
-
echo "$*"
|
|
96
|
-
} >&2
|
|
97
|
-
|
|
98
|
-
die () {
|
|
99
|
-
echo
|
|
100
|
-
echo "$*"
|
|
101
|
-
echo
|
|
102
|
-
exit 1
|
|
103
|
-
} >&2
|
|
104
|
-
|
|
105
|
-
# OS specific support (must be 'true' or 'false').
|
|
106
|
-
cygwin=false
|
|
107
|
-
msys=false
|
|
108
|
-
darwin=false
|
|
109
|
-
nonstop=false
|
|
110
|
-
case "$( uname )" in #(
|
|
111
|
-
CYGWIN* ) cygwin=true ;; #(
|
|
112
|
-
Darwin* ) darwin=true ;; #(
|
|
113
|
-
MSYS* | MINGW* ) msys=true ;; #(
|
|
114
|
-
NONSTOP* ) nonstop=true ;;
|
|
115
|
-
esac
|
|
116
|
-
|
|
117
|
-
CLASSPATH="\\\"\\\""
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# Determine the Java command to use to start the JVM.
|
|
121
|
-
if [ -n "$JAVA_HOME" ] ; then
|
|
122
|
-
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
123
|
-
# IBM's JDK on AIX uses strange locations for the executables
|
|
124
|
-
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
125
|
-
else
|
|
126
|
-
JAVACMD=$JAVA_HOME/bin/java
|
|
127
|
-
fi
|
|
128
|
-
if [ ! -x "$JAVACMD" ] ; then
|
|
129
|
-
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
130
|
-
|
|
131
|
-
Please set the JAVA_HOME variable in your environment to match the
|
|
132
|
-
location of your Java installation."
|
|
133
|
-
fi
|
|
134
|
-
else
|
|
135
|
-
JAVACMD=java
|
|
136
|
-
if ! command -v java >/dev/null 2>&1
|
|
137
|
-
then
|
|
138
|
-
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
139
|
-
|
|
140
|
-
Please set the JAVA_HOME variable in your environment to match the
|
|
141
|
-
location of your Java installation."
|
|
142
|
-
fi
|
|
143
|
-
fi
|
|
144
|
-
|
|
145
|
-
# Increase the maximum file descriptors if we can.
|
|
146
|
-
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
147
|
-
case $MAX_FD in #(
|
|
148
|
-
max*)
|
|
149
|
-
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
150
|
-
# shellcheck disable=SC2039,SC3045
|
|
151
|
-
MAX_FD=$( ulimit -H -n ) ||
|
|
152
|
-
warn "Could not query maximum file descriptor limit"
|
|
153
|
-
esac
|
|
154
|
-
case $MAX_FD in #(
|
|
155
|
-
'' | soft) :;; #(
|
|
156
|
-
*)
|
|
157
|
-
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
158
|
-
# shellcheck disable=SC2039,SC3045
|
|
159
|
-
ulimit -n "$MAX_FD" ||
|
|
160
|
-
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
161
|
-
esac
|
|
162
|
-
fi
|
|
163
|
-
|
|
164
|
-
# Collect all arguments for the java command, stacking in reverse order:
|
|
165
|
-
# * args from the command line
|
|
166
|
-
# * the main class name
|
|
167
|
-
# * -classpath
|
|
168
|
-
# * -D...appname settings
|
|
169
|
-
# * --module-path (only if needed)
|
|
170
|
-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
171
|
-
|
|
172
|
-
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
173
|
-
if "$cygwin" || "$msys" ; then
|
|
174
|
-
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
175
|
-
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
176
|
-
|
|
177
|
-
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
178
|
-
|
|
179
|
-
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
180
|
-
for arg do
|
|
181
|
-
if
|
|
182
|
-
case $arg in #(
|
|
183
|
-
-*) false ;; # don't mess with options #(
|
|
184
|
-
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
185
|
-
[ -e "$t" ] ;; #(
|
|
186
|
-
*) false ;;
|
|
187
|
-
esac
|
|
188
|
-
then
|
|
189
|
-
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
190
|
-
fi
|
|
191
|
-
# Roll the args list around exactly as many times as the number of
|
|
192
|
-
# args, so each arg winds up back in the position where it started, but
|
|
193
|
-
# possibly modified.
|
|
194
|
-
#
|
|
195
|
-
# NB: a `for` loop captures its iteration list before it begins, so
|
|
196
|
-
# changing the positional parameters here affects neither the number of
|
|
197
|
-
# iterations, nor the values presented in `arg`.
|
|
198
|
-
shift # remove old arg
|
|
199
|
-
set -- "$@" "$arg" # push replacement arg
|
|
200
|
-
done
|
|
201
|
-
fi
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
205
|
-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
206
|
-
|
|
207
|
-
# Collect all arguments for the java command:
|
|
208
|
-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
209
|
-
# and any embedded shellness will be escaped.
|
|
210
|
-
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
211
|
-
# treated as '${Hostname}' itself on the command line.
|
|
212
|
-
|
|
213
|
-
set -- \
|
|
214
|
-
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
215
|
-
-classpath "$CLASSPATH" \
|
|
216
|
-
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
|
217
|
-
"$@"
|
|
218
|
-
|
|
219
|
-
# Stop when "xargs" is not available.
|
|
220
|
-
if ! command -v xargs >/dev/null 2>&1
|
|
221
|
-
then
|
|
222
|
-
die "xargs is not available"
|
|
223
|
-
fi
|
|
224
|
-
|
|
225
|
-
# Use "xargs" to parse quoted args.
|
|
226
|
-
#
|
|
227
|
-
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
228
|
-
#
|
|
229
|
-
# In Bash we could simply go:
|
|
230
|
-
#
|
|
231
|
-
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
232
|
-
# set -- "${ARGS[@]}" "$@"
|
|
233
|
-
#
|
|
234
|
-
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
235
|
-
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
236
|
-
# character that might be a shell metacharacter, then use eval to reverse
|
|
237
|
-
# that process (while maintaining the separation between arguments), and wrap
|
|
238
|
-
# the whole thing up as a single "set" statement.
|
|
239
|
-
#
|
|
240
|
-
# This will of course break if any of these variables contains a newline or
|
|
241
|
-
# an unmatched quote.
|
|
242
|
-
#
|
|
243
|
-
|
|
244
|
-
eval "set -- $(
|
|
245
|
-
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
246
|
-
xargs -n1 |
|
|
247
|
-
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
248
|
-
tr '\n' ' '
|
|
249
|
-
)" '"$@"'
|
|
250
|
-
|
|
251
|
-
exec "$JAVACMD" "$@"
|
package/android/gradlew.bat
DELETED
|
@@ -1,94 +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
|
-
@rem SPDX-License-Identifier: Apache-2.0
|
|
17
|
-
@rem
|
|
18
|
-
|
|
19
|
-
@if "%DEBUG%"=="" @echo off
|
|
20
|
-
@rem ##########################################################################
|
|
21
|
-
@rem
|
|
22
|
-
@rem Gradle startup script for Windows
|
|
23
|
-
@rem
|
|
24
|
-
@rem ##########################################################################
|
|
25
|
-
|
|
26
|
-
@rem Set local scope for the variables with windows NT shell
|
|
27
|
-
if "%OS%"=="Windows_NT" setlocal
|
|
28
|
-
|
|
29
|
-
set DIRNAME=%~dp0
|
|
30
|
-
if "%DIRNAME%"=="" set DIRNAME=.
|
|
31
|
-
@rem This is normally unused
|
|
32
|
-
set APP_BASE_NAME=%~n0
|
|
33
|
-
set APP_HOME=%DIRNAME%
|
|
34
|
-
|
|
35
|
-
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
36
|
-
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
37
|
-
|
|
38
|
-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
39
|
-
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
40
|
-
|
|
41
|
-
@rem Find java.exe
|
|
42
|
-
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
43
|
-
|
|
44
|
-
set JAVA_EXE=java.exe
|
|
45
|
-
%JAVA_EXE% -version >NUL 2>&1
|
|
46
|
-
if %ERRORLEVEL% equ 0 goto execute
|
|
47
|
-
|
|
48
|
-
echo. 1>&2
|
|
49
|
-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
50
|
-
echo. 1>&2
|
|
51
|
-
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
52
|
-
echo location of your Java installation. 1>&2
|
|
53
|
-
|
|
54
|
-
goto fail
|
|
55
|
-
|
|
56
|
-
:findJavaFromJavaHome
|
|
57
|
-
set JAVA_HOME=%JAVA_HOME:"=%
|
|
58
|
-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
59
|
-
|
|
60
|
-
if exist "%JAVA_EXE%" goto execute
|
|
61
|
-
|
|
62
|
-
echo. 1>&2
|
|
63
|
-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
64
|
-
echo. 1>&2
|
|
65
|
-
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
66
|
-
echo location of your Java installation. 1>&2
|
|
67
|
-
|
|
68
|
-
goto fail
|
|
69
|
-
|
|
70
|
-
:execute
|
|
71
|
-
@rem Setup the command line
|
|
72
|
-
|
|
73
|
-
set CLASSPATH=
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
@rem Execute Gradle
|
|
77
|
-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
|
78
|
-
|
|
79
|
-
:end
|
|
80
|
-
@rem End local scope for the variables with windows NT shell
|
|
81
|
-
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
82
|
-
|
|
83
|
-
:fail
|
|
84
|
-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
85
|
-
rem the _cmd.exe /c_ return code!
|
|
86
|
-
set EXIT_CODE=%ERRORLEVEL%
|
|
87
|
-
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
88
|
-
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
89
|
-
exit /b %EXIT_CODE%
|
|
90
|
-
|
|
91
|
-
:mainEnd
|
|
92
|
-
if "%OS%"=="Windows_NT" endlocal
|
|
93
|
-
|
|
94
|
-
:omega
|
|
Binary file
|
|
Binary file
|