react-native-clarity 4.1.5 → 4.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ios/Clarity.m CHANGED
@@ -16,7 +16,7 @@ RCT_EXPORT_METHOD(initialize:(NSString *)projectId
16
16
  dispatch_async(dispatch_get_main_queue(), ^{
17
17
  ClarityConfig* config = [[ClarityConfig alloc] initWithProjectId:projectId];
18
18
 
19
- config.userId = userId;
19
+ config.userId = [self sanitizeBridgedValue:userId];
20
20
  config.logLevel = [self convertLogLevelToEnum:logLevel];
21
21
  config.applicationFramework = ApplicationFrameworkReactNative;
22
22
 
@@ -62,7 +62,7 @@ RCT_EXPORT_METHOD(setCustomUserId:(NSString *)customUserId
62
62
  rejecter:(RCTPromiseRejectBlock)reject)
63
63
  {
64
64
  dispatch_async(dispatch_get_main_queue(), ^{
65
- resolve(@([ClaritySDK setCustomUserId:customUserId]));
65
+ resolve(@([ClaritySDK setCustomUserId:[self sanitizeBridgedValue:customUserId]]));
66
66
  });
67
67
  }
68
68
 
@@ -71,7 +71,7 @@ RCT_EXPORT_METHOD(setCustomSessionId:(NSString *)customSessionId
71
71
  rejecter:(RCTPromiseRejectBlock)reject)
72
72
  {
73
73
  dispatch_async(dispatch_get_main_queue(), ^{
74
- resolve(@([ClaritySDK setCustomSessionId:customSessionId]));
74
+ resolve(@([ClaritySDK setCustomSessionId:[self sanitizeBridgedValue:customSessionId]]));
75
75
  });
76
76
  }
77
77
 
@@ -91,14 +91,15 @@ RCT_EXPORT_METHOD(setCustomTag:(NSString *)key value:(NSString *)value
91
91
  resolver:(RCTPromiseResolveBlock)resolve
92
92
  rejecter:(RCTPromiseRejectBlock)reject)
93
93
  {
94
- resolve(@([ClaritySDK setCustomTagWithKey:key value:value]));
94
+ resolve(@([ClaritySDK setCustomTagWithKey:[self sanitizeBridgedValue:key]
95
+ value:[self sanitizeBridgedValue:value]]));
95
96
  }
96
97
 
97
98
  RCT_EXPORT_METHOD(sendCustomEvent:(NSString *)value
98
99
  resolver:(RCTPromiseResolveBlock)resolve
99
100
  rejecter:(RCTPromiseRejectBlock)reject)
100
101
  {
101
- resolve(@([ClaritySDK sendCustomEventWithValue:value]));
102
+ resolve(@([ClaritySDK sendCustomEventWithValue:[self sanitizeBridgedValue:value]]));
102
103
  }
103
104
 
104
105
  RCT_EXPORT_METHOD(setCurrentScreenName:(NSString *)currentScreenName
@@ -106,7 +107,7 @@ RCT_EXPORT_METHOD(setCurrentScreenName:(NSString *)currentScreenName
106
107
  rejecter:(RCTPromiseRejectBlock)reject)
107
108
  {
108
109
  dispatch_async(dispatch_get_main_queue(), ^{
109
- resolve(@([ClaritySDK setCurrentScreenName:currentScreenName]));
110
+ resolve(@([ClaritySDK setCurrentScreenName:[self sanitizeBridgedValue:currentScreenName]]));
110
111
  });
111
112
  }
112
113
 
@@ -135,4 +136,23 @@ RCT_EXPORT_METHOD(setCurrentScreenName:(NSString *)currentScreenName
135
136
  return LogLevelNone;
136
137
  }
137
138
 
139
+ /**
140
+ * Ensures compatibility between React Native and the Swift-based Clarity modules.
141
+ *
142
+ * While newer versions of React Native automatically convert bridged values
143
+ * to valid Objective-C types, `NSNull` remains incompatible with Clarity's
144
+ * Swift-based interface. This method safely translates `NSNull` to `nil`
145
+ * to prevent unexpected crashes.
146
+ *
147
+ * @param value The bridged value from React Native, which may be `NSNull`.
148
+ * @return The original value if valid, or `nil` if the value is `NSNull`.
149
+ */
150
+ - (id)sanitizeBridgedValue:(id)value {
151
+ if ([value isKindOfClass:[NSNull class]]) {
152
+ return nil;
153
+ }
154
+
155
+ return value;
156
+ }
157
+
138
158
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-clarity",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
4
4
  "description": "A plugin to provide the Clarity experience for the React Native applications.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -163,4 +163,4 @@
163
163
  ]
164
164
  ]
165
165
  }
166
- }
166
+ }
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm}"
18
18
 
19
19
  s.dependency "React-Core"
20
- s.dependency "Clarity", '3.0.3'
20
+ s.dependency "Clarity", '3.0.5'
21
21
 
22
22
  # Don't install the dependencies when we run `pod install` in the old architecture.
23
23
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then