react-native-userleap 2.16.2 → 2.17.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.
@@ -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.17.3") // update this version on android updates
83
+ implementation ("com.userleap:userleap-android-sdk:2.17.4") // update this version on android updates
84
84
  }
package/index.d.ts CHANGED
@@ -21,5 +21,8 @@ declare namespace UserLeap {
21
21
  function logout(): void;
22
22
  function trackAndPresent(event: string): void;
23
23
  function trackIdentifyAndPresent(event: string, userId: string | undefined, partnerAnonymousId: string | undefined): void;
24
+ // Uncomment for UI testing
25
+ // function renderSnapshotForUITest(name: string, maskingLevel: string)
26
+
24
27
  }
25
28
  export default UserLeap;
package/index.js CHANGED
@@ -139,6 +139,13 @@ const trackIdentifyAndPresent = (event, userId, partnerAnonynmousId) => {
139
139
  }
140
140
  }
141
141
 
142
+ // Uncomment for UI testing
143
+ // const renderSnapshotForUITest = (name, maskingLevel) => {
144
+ // if (isValidPlatform()) {
145
+ // NativeModules.UserLeapBindings.renderSnapshotForUITest(name, maskingLevel);
146
+ // }
147
+ // }
148
+
142
149
  const UserLeap = {
143
150
  SurveyState,
144
151
  visitorIdentifier,
@@ -158,6 +165,8 @@ const UserLeap = {
158
165
  logout,
159
166
  trackAndPresent,
160
167
  trackIdentifyAndPresent,
168
+ // Uncomment for UI testing
169
+ // renderSnapshotForUITest,
161
170
  }
162
171
 
163
172
  export default UserLeap;
@@ -1,5 +1,10 @@
1
1
  #import <React/RCTBridgeModule.h>
2
+ @import UserLeapKit;
2
3
 
4
+ #if DEBUG
5
+ @interface UserLeapBindings : NSObject <RCTBridgeModule, SGRNTextExtractor>
6
+ #else
3
7
  @interface UserLeapBindings : NSObject <RCTBridgeModule>
4
-
8
+ #endif
9
+ @property (nonatomic, weak) RCTBridge *bridge;
5
10
  @end
@@ -1,9 +1,17 @@
1
1
  #import "UserLeapBindings.h"
2
2
  #import <React/RCTUtils.h>
3
- @import UserLeapKit;
3
+ #import <React/RCTTextView.h>
4
+ #import <React/RCTUIManager.h>
5
+ #import <React/RCTTextShadowView.h>
6
+ #import <React/RCTShadowView.h>
7
+ #import <React/RCTRawTextShadowView.h>
8
+ #import <React/RCTVirtualTextShadowView.h>
9
+ #import <React/RCTUIManagerUtils.h>
4
10
 
5
11
  @implementation UserLeapBindings
6
12
 
13
+ @synthesize bridge = _bridge;
14
+
7
15
  - (dispatch_queue_t)methodQueue
8
16
  {
9
17
  return dispatch_get_main_queue();
@@ -12,17 +20,17 @@
12
20
  - (NSString *)getSurveyState:(SurveyState)surveyState
13
21
  {
14
22
  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
- }
23
+ switch(surveyState) {
24
+ case SurveyStateDisabled:
25
+ surveyStateBinding = @"DISABLED";
26
+ break;
27
+ case SurveyStateReady:
28
+ surveyStateBinding = @"READY";
29
+ break;
30
+ case SurveyStateNoSurvey:
31
+ surveyStateBinding = @"NO_SURVEY";
32
+ break;
33
+ }
26
34
  return surveyStateBinding;
27
35
  }
28
36
 
@@ -46,6 +54,9 @@ RCT_EXPORT_METHOD(configure:(NSString *)environmentId)
46
54
  RCT_EXPORT_METHOD(configure:(NSString *)environmentId configuration:(NSDictionary *)configuration )
47
55
  {
48
56
  [[UserLeap shared] configureWithEnvironment:environmentId configuration:configuration];
57
+ #if DEBUG
58
+ [[UserLeap shared] passWithRnTextExtractor:self];
59
+ #endif
49
60
  }
50
61
 
51
62
  RCT_EXPORT_METHOD(setPreviewKey:(NSString *)previewKey)
@@ -157,4 +168,42 @@ RCT_EXPORT_METHOD(trackIdentifyAndPresent:(NSString *)eventName userId:(NSString
157
168
  [[UserLeap shared] trackAndPresentWithEventName:eventName userId:userId partnerAnonymousId:partnerAnonymousId from:RCTPresentedViewController()];
158
169
  }
159
170
 
171
+ #if DEBUG
172
+ RCT_EXPORT_METHOD(renderSnapshotForUITest:(NSString *)name maskingLevel: (NSString *) maskingLevel)
173
+ {
174
+ [[UserLeap shared] renderSnapshotForUITestWithName: name maskingLevel: maskingLevel];
175
+ }
176
+
177
+
178
+ - (SGRNTextProperties *)textPropertiesFromView:(UIView * _Nonnull)passedView {
179
+ if (![passedView isKindOfClass:[RCTTextView class]]) { return nil;}
180
+ RCTUIManager* uiManager = [self.bridge moduleForClass:[RCTUIManager class]];
181
+ RCTTextView *textView = (RCTTextView *)passedView;
182
+ __block SGRNTextProperties *textProperties = [[SGRNTextProperties alloc] init];
183
+ dispatch_sync(RCTGetUIManagerQueue(), ^{
184
+ RCTShadowView *shadowView = [uiManager shadowViewForReactTag:textView.reactTag];
185
+ if ([shadowView isKindOfClass:[RCTTextShadowView class]]) {
186
+ RCTTextShadowView *textShadowView = (RCTTextShadowView *)shadowView;
187
+ textProperties.text = [self extractText: textShadowView.reactSubviews];
188
+ textProperties.color = textShadowView.textAttributes.foregroundColor;
189
+ textProperties.alignment = textShadowView.textAttributes.alignment;
190
+ textProperties.font = textShadowView.textAttributes.effectiveFont;
191
+ }
192
+ });
193
+ return textProperties;
194
+ }
195
+
196
+ - (NSString * _Nullable)extractText:(NSArray<RCTShadowView *> * _Nonnull) subviews {
197
+ NSMutableString *text = [[NSMutableString alloc] init];
198
+ for (RCTShadowView *subview in subviews) {
199
+ if ([subview isKindOfClass:[RCTRawTextShadowView class]]) {
200
+ [text appendString:((RCTRawTextShadowView *)subview).text];
201
+ }
202
+ if ([subview isKindOfClass:[RCTVirtualTextShadowView class]]) {
203
+ return [self extractText: ((RCTVirtualTextShadowView *)subview).reactSubviews];
204
+ }
205
+ }
206
+ return text;
207
+ }
208
+ #endif
160
209
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-userleap",
3
- "version": "2.16.2",
3
+ "version": "2.17.0",
4
4
  "description": "React Native module for UserLeap",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,5 +19,5 @@ Pod::Spec.new do |s|
19
19
  s.requires_arc = true
20
20
 
21
21
  s.dependency "React"
22
- s.dependency "UserLeapKit", "4.22.1"
22
+ s.dependency "UserLeapKit", "4.23.0"
23
23
  end