react-native-userleap 2.20.0 → 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/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
|
+
}
|