react-native-userleap 2.9.0 → 2.11.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.
Binary file
package/android/.project CHANGED
@@ -22,12 +22,12 @@
22
22
  </natures>
23
23
  <filteredResources>
24
24
  <filter>
25
- <id>0</id>
25
+ <id>1666118852606</id>
26
26
  <name></name>
27
27
  <type>30</type>
28
28
  <matcher>
29
29
  <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
- <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
30
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
31
  </matcher>
32
32
  </filter>
33
33
  </filteredResources>
@@ -1,11 +1,11 @@
1
- arguments=
1
+ arguments=--init-script /var/folders/sh/j278yjh97h71m1cnsl5kcwh00000gq/T/init7898332991690331628.gradle --init-script /var/folders/sh/j278yjh97h71m1cnsl5kcwh00000gq/T/init85421648644725063.gradle
2
2
  auto.sync=false
3
3
  build.scans.enabled=false
4
4
  connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5
5
  connection.project.dir=
6
6
  eclipse.preferences.version=1
7
7
  gradle.user.home=
8
- java.home=/Users/ghostr/.sdkman/candidates/java/8.0.312-zulu/zulu-8.jdk/Contents/Home
8
+ java.home=/Users/ghostr/.sdkman/candidates/java/11.0.13.8.1-amzn
9
9
  jvm.arguments=
10
10
  offline.mode=false
11
11
  override.workspace.settings=true
@@ -80,5 +80,5 @@ repositories {
80
80
  dependencies {
81
81
  //noinspection GradleDynamicVersion
82
82
  implementation 'com.facebook.react:react-native:+' // From node_modules
83
- implementation ("com.userleap:userleap-android-sdk:2.7.0") // update this version on android updates
83
+ implementation ("com.userleap:userleap-android-sdk:2.8.0") // update this version on android updates
84
84
  }
Binary file
Binary file
@@ -66,28 +66,39 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
66
66
 
67
67
  @ReactMethod
68
68
  public void track(String event, final Callback surveyStateCallback) {
69
- UserLeap.INSTANCE.track(event, new Function1<SurveyState, Unit>() {
70
- @Override
71
- public Unit invoke(SurveyState surveyState) {
72
- if (surveyStateCallback!=null) {
73
- surveyStateCallback.invoke(surveyState.name());
69
+ trackAndIdentify(event, null, null, surveyStateCallback);
70
+ }
71
+
72
+ @ReactMethod
73
+ public void trackWithProperties(String event, String userId, String partnerAnonymousId, ReadableMap properties, final Callback surveyStateCallback) {
74
+ if (surveyStateCallback == null) {
75
+ UserLeap.INSTANCE.track(event, userId, partnerAnonymousId, stringifyMap(properties));
76
+ } else {
77
+ UserLeap.INSTANCE.track(event, userId, partnerAnonymousId, stringifyMap(properties), new Function1<SurveyState, Unit>() {
78
+ @Override
79
+ public Unit invoke(SurveyState surveyState) {
80
+ if (surveyStateCallback!=null) {
81
+ surveyStateCallback.invoke(surveyState.name());
82
+ }
83
+ return null;
74
84
  }
75
- return null;
76
- }
77
- });
85
+ });
86
+ }
78
87
  }
79
88
 
80
89
  @ReactMethod
81
90
  public void trackAndIdentify(String event, String userId, String partnerAnonymousId, final Callback surveyStateCallback) {
82
- UserLeap.INSTANCE.track(event, userId, partnerAnonymousId, new Function1<SurveyState, Unit>() {
83
- @Override
84
- public Unit invoke(SurveyState surveyState) {
85
- if (surveyStateCallback!=null) {
91
+ if (surveyStateCallback == null) {
92
+ UserLeap.INSTANCE.track(event, userId, partnerAnonymousId);
93
+ } else {
94
+ UserLeap.INSTANCE.track(event, userId, partnerAnonymousId, new Function1<SurveyState, Unit>() {
95
+ @Override
96
+ public Unit invoke(SurveyState surveyState) {
86
97
  surveyStateCallback.invoke(surveyState.name());
98
+ return null;
87
99
  }
88
- return null;
89
- }
90
- });
100
+ });
101
+ }
91
102
  }
92
103
 
93
104
  @ReactMethod
@@ -156,7 +167,7 @@ public class UserLeapModule extends ReactContextBaseJavaModule {
156
167
  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
157
168
  stringifiedMap = map.toHashMap().entrySet().stream()
158
169
  .filter(m -> m.getKey() != null && m.getValue() !=null)
159
- .collect(Collectors.toMap(Map.Entry::getKey, e -> (String)e.getValue()));
170
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toString()));
160
171
  }
161
172
  return stringifiedMap;
162
173
  }
package/index.d.ts CHANGED
@@ -9,6 +9,7 @@ declare namespace UserLeap {
9
9
  function configure(environment: string): void;
10
10
  function presentSurvey(): void;
11
11
  function track(event: string, surveyStateCallback: ((surveyState: string) => void)): void;
12
+ function trackWithProperties(event: string, userId: string | undefined, partnerAnonymousId: string | undefined, properties: {[key: string]: any}, surveyStateCallback: ((surveyState: string) => void)): void;
12
13
  function trackAndIdentify(event: string, userId: string | undefined, partnerAnonymousId: string | undefined, surveyStateCallback: ((surveyState: string) => void)): void;
13
14
  function setEmailAddress(emailAddress: string): void;
14
15
  function setVisitorAttribute(key: string, value: string): void;
package/index.js CHANGED
@@ -4,104 +4,117 @@ const SurveyState = {
4
4
  READY: 'READY',
5
5
  DISABLED: 'DISABLED',
6
6
  NO_SURVEY: 'NO_SURVEY'
7
+ };
8
+
9
+ const stringifyAttributes = ( attributes ) => {
10
+ if (!(attributes instanceof Object && attributes.constructor === Object)) return {};
11
+ Object.keys(attributes).forEach(function(key, index) {
12
+ attributes[key] = String(attributes[key]);
13
+ });
7
14
  }
8
15
 
9
16
  const isValidPlatform = () => {
10
17
  //Platform.Version is a number for android and string for ios
11
- return (Platform.OS === 'android' && String(Platform.Version) >= '21') || (Platform.OS === 'ios' && String(Platform.Version) >= '10.3')
18
+ return (Platform.OS === 'android' && String(Platform.Version) >= '21') || (Platform.OS === 'ios' && String(Platform.Version) >= '10.3');
12
19
  }
13
20
 
14
21
  const visitorIdentifier = () => {
15
22
  if (isValidPlatform()) {
16
- return NativeModules.UserLeapBindings.visitorIdentifier()
23
+ return NativeModules.UserLeapBindings.visitorIdentifier();
17
24
  } else {
18
- return 0
25
+ return 0;
19
26
  }
20
27
  }
21
28
 
22
29
  const visitorIdentifierString = () => {
23
30
  if (isValidPlatform()) {
24
- return NativeModules.UserLeapBindings.visitorIdentifierString()
31
+ return NativeModules.UserLeapBindings.visitorIdentifierString();
25
32
  } else {
26
- return ""
33
+ return "";
27
34
  }
28
35
  }
29
36
 
30
37
  const configure = (environment) => {
31
38
  if (isValidPlatform()) {
32
- NativeModules.UserLeapBindings.configure(environment)
39
+ NativeModules.UserLeapBindings.configure(environment);
33
40
  }
34
41
  }
35
42
 
36
43
  const presentSurvey = () => {
37
44
  if (isValidPlatform()) {
38
- NativeModules.UserLeapBindings.presentSurvey()
45
+ NativeModules.UserLeapBindings.presentSurvey();
39
46
  }
40
47
  }
41
48
 
42
49
  const track = (event, surveyStateCallback) => {
43
50
  if (isValidPlatform()) {
44
- NativeModules.UserLeapBindings.track(event, surveyStateCallback)
51
+ NativeModules.UserLeapBindings.track(event, surveyStateCallback);
52
+ }
53
+ }
54
+
55
+ const trackWithProperties = (event, userId, partnerAnonymousId, properties, surveyStateCallback) => {
56
+ if (isValidPlatform()) {
57
+ NativeModules.UserLeapBindings.trackWithProperties(event, userId, partnerAnonymousId, properties, surveyStateCallback);
45
58
  }
46
59
  }
47
60
 
48
61
  const trackAndIdentify = (event, userId, partnerAnonynmousId, surveyStateCallback) => {
49
62
  if (isValidPlatform()) {
50
- NativeModules.UserLeapBindings.trackAndIdentify(event, userId, partnerAnonynmousId, surveyStateCallback)
63
+ NativeModules.UserLeapBindings.trackAndIdentify(event, userId, partnerAnonynmousId, surveyStateCallback);
51
64
  }
52
65
  }
53
66
 
54
67
  const setEmailAddress = (emailAddress) => {
55
68
  if (isValidPlatform()) {
56
- NativeModules.UserLeapBindings.setEmailAddress(emailAddress)
69
+ NativeModules.UserLeapBindings.setEmailAddress(emailAddress);
57
70
  }
58
71
  }
59
72
 
60
73
  const setVisitorAttribute = (key, value) => {
61
74
  if (isValidPlatform()) {
62
- NativeModules.UserLeapBindings.setVisitorAttribute(key, value)
75
+ NativeModules.UserLeapBindings.setVisitorAttribute(key, value);
63
76
  }
64
77
  }
65
78
 
66
79
  const setVisitorAttributes = (attributes) => {
67
80
  if (isValidPlatform()) {
68
- NativeModules.UserLeapBindings.setVisitorAttributes(attributes)
81
+ NativeModules.UserLeapBindings.setVisitorAttributes(stringifyAttributes(attributes));
69
82
  }
70
83
  }
71
84
 
72
85
  const removeVisitorAttributes = (keys) => {
73
86
  if (isValidPlatform()) {
74
- NativeModules.UserLeapBindings.removeVisitorAttributes(keys)
87
+ NativeModules.UserLeapBindings.removeVisitorAttributes(keys);
75
88
  }
76
89
  }
77
90
 
78
91
  const setVisitorAttributesAndIdentify = (attributes, userId, partnerAnonynmousId) => {
79
92
  if (isValidPlatform()) {
80
- NativeModules.UserLeapBindings.setVisitorAttributesAndIdentify(attributes, userId, partnerAnonynmousId)
93
+ NativeModules.UserLeapBindings.setVisitorAttributesAndIdentify(stringifyAttributes(attributes), userId, partnerAnonynmousId);
81
94
  }
82
95
  }
83
96
 
84
97
  const setUserIdentifier = (identifier) => {
85
98
  if (isValidPlatform()) {
86
- NativeModules.UserLeapBindings.setUserIdentifier(identifier)
99
+ NativeModules.UserLeapBindings.setUserIdentifier(identifier);
87
100
  }
88
101
  }
89
102
 
90
103
  const logout = () => {
91
104
  if (isValidPlatform()) {
92
- NativeModules.UserLeapBindings.logout()
105
+ NativeModules.UserLeapBindings.logout();
93
106
  }
94
107
  }
95
108
 
96
109
  const trackAndPresent = (event) => {
97
110
  if (isValidPlatform()) {
98
- NativeModules.UserLeapBindings.trackAndPresent(event)
111
+ NativeModules.UserLeapBindings.trackAndPresent(event);
99
112
  }
100
113
  }
101
114
 
102
115
  const trackIdentifyAndPresent = (event, userId, partnerAnonynmousId) => {
103
116
  if (isValidPlatform()) {
104
- NativeModules.UserLeapBindings.trackIdentifyAndPresent(event, userId, partnerAnonynmousId)
117
+ NativeModules.UserLeapBindings.trackIdentifyAndPresent(event, userId, partnerAnonynmousId);
105
118
  }
106
119
  }
107
120
 
@@ -112,6 +125,7 @@ const UserLeap = {
112
125
  configure,
113
126
  presentSurvey,
114
127
  track,
128
+ trackWithProperties,
115
129
  trackAndIdentify,
116
130
  setEmailAddress,
117
131
  setVisitorAttribute,
package/ios/.DS_Store ADDED
Binary file
@@ -9,6 +9,23 @@
9
9
  return dispatch_get_main_queue();
10
10
  }
11
11
 
12
+ - (NSString *)getSurveyState:(SurveyState)surveyState
13
+ {
14
+ NSString *surveyStateBinding = @"NO_SURVEY";
15
+ switch(surveyState) {
16
+ case SurveyStateDisabled:
17
+ surveyStateBinding = @"DISABLED";
18
+ break;
19
+ case SurveyStateReady:
20
+ surveyStateBinding = @"READY";
21
+ break;
22
+ case SurveyStateNoSurvey:
23
+ surveyStateBinding = @"NO_SURVEY";
24
+ break;
25
+ }
26
+ return surveyStateBinding;
27
+ }
28
+
12
29
  RCT_EXPORT_MODULE()
13
30
 
14
31
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(visitorIdentifier)
@@ -34,22 +51,40 @@ RCT_EXPORT_METHOD(presentSurvey)
34
51
  RCT_EXPORT_METHOD(track:(NSString *)eventName
35
52
  surveyStateCallback:(RCTResponseSenderBlock)callback)
36
53
  {
37
- [[UserLeap shared] trackWithEventName:eventName handler:^(enum SurveyState surveyState) {
38
- NSString *surveyStateBinding = @"NO_SURVEY";
54
+ if (callback != nil) {
55
+ [[UserLeap shared] trackWithEventName:eventName handler:^(enum SurveyState surveyState) {
56
+ callback(@[[self getSurveyState:surveyState]]);
57
+ }];
58
+ } else {
59
+ [[UserLeap shared] trackWithEventName:eventName handler:nil];
60
+ }
61
+ }
39
62
 
40
- switch(surveyState) {
41
- case SurveyStateDisabled:
42
- surveyStateBinding = @"DISABLED";
43
- break;
44
- case SurveyStateReady:
45
- surveyStateBinding = @"READY";
46
- break;
47
- case SurveyStateNoSurvey:
48
- surveyStateBinding = @"NO_SURVEY";
49
- break;
50
- }
51
- callback(@[surveyStateBinding]);
52
- }];
63
+ RCT_EXPORT_METHOD(trackWithProperties:(NSString *)eventName
64
+ userId:(NSString * _Nullable)userId
65
+ partnerAnonymousId:(NSString * _Nullable)partnerAnonymousId
66
+ properties: (NSDictionary *)properties
67
+ surveyStateCallback:(RCTResponseSenderBlock)callback)
68
+ {
69
+ if (callback != nil) {
70
+ [[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId properties:properties handler:^(enum SurveyState surveyState) {
71
+ NSString *surveyStateBinding = @"NO_SURVEY";
72
+ switch(surveyState) {
73
+ case SurveyStateDisabled:
74
+ surveyStateBinding = @"DISABLED";
75
+ break;
76
+ case SurveyStateReady:
77
+ surveyStateBinding = @"READY";
78
+ break;
79
+ case SurveyStateNoSurvey:
80
+ surveyStateBinding = @"NO_SURVEY";
81
+ break;
82
+ }
83
+ callback(@[surveyStateBinding]);
84
+ }];
85
+ } else {
86
+ [[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId properties:properties handler:nil];
87
+ }
53
88
  }
54
89
 
55
90
  RCT_EXPORT_METHOD(trackAndIdentify:(NSString *)eventName
@@ -57,22 +92,14 @@ RCT_EXPORT_METHOD(trackAndIdentify:(NSString *)eventName
57
92
  partnerAnonymousId:(NSString *)partnerAnonymousId
58
93
  handler:(RCTResponseSenderBlock)callback)
59
94
  {
60
- [[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId handler:^(enum SurveyState surveyState) {
61
- NSString *surveyStateBinding = @"NO_SURVEY";
62
-
63
- switch(surveyState) {
64
- case SurveyStateDisabled:
65
- surveyStateBinding = @"DISABLED";
66
- break;
67
- case SurveyStateReady:
68
- surveyStateBinding = @"READY";
69
- break;
70
- case SurveyStateNoSurvey:
71
- surveyStateBinding = @"NO_SURVEY";
72
- break;
73
- }
74
- callback(@[surveyStateBinding]);
75
- }];
95
+ if (callback != nil) {
96
+ [[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId handler:^(enum SurveyState surveyState) {
97
+ callback(@[[self getSurveyState:surveyState]]);
98
+ }];
99
+ } else {
100
+ [[UserLeap shared] trackWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId handler:nil];
101
+ }
102
+
76
103
  }
77
104
 
78
105
  RCT_EXPORT_METHOD(setEmailAddress:(NSString *)emailAddress)
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>UserLeapBindings.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-userleap",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
4
4
  "description": "React Native module for UserLeap",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,6 +19,6 @@ Pod::Spec.new do |s|
19
19
  s.requires_arc = true
20
20
 
21
21
  s.dependency "React"
22
- s.dependency "UserLeapKit", "4.9.0"
22
+ s.dependency "UserLeapKit", "4.11.0"
23
23
  end
24
24