@logrocket/react-native 1.39.2 → 1.40.1

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.
@@ -6,13 +6,12 @@
6
6
 
7
7
  RCT_EXPORT_MODULE();
8
8
 
9
- static NSMutableDictionary<NSString *, LROResponseBuilder *> *capturedRequests;
9
+ static NSMutableArray *fullMessageArray = nil;
10
10
 
11
11
  - (id)init {
12
12
  self = [super init];
13
13
 
14
14
  if (self) {
15
- capturedRequests = [[NSMutableDictionary alloc] init];
16
15
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleError:) name:@"LogRocketSDKError" object:nil];
17
16
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSessionAccepted:) name:@"LogRocketSDKSessionAccepted" object:nil];
18
17
  }
@@ -164,119 +163,6 @@ static NSMutableDictionary<NSString *, LROResponseBuilder *> *capturedRequests;
164
163
  return configuration;
165
164
  }
166
165
 
167
-
168
- RCT_EXPORT_METHOD(addLog:(NSString *)level args:(NSArray *)args)
169
- {
170
- @try {
171
- [LROSDK addLogWithLevel:level args:args];
172
- }
173
- @catch (NSException *e) {
174
- NSLog(@"Failed to add log");
175
- }
176
- }
177
-
178
- RCT_EXPORT_METHOD(captureException:(NSString *)message
179
- errorType:(NSString *)errorType
180
- exceptionType:(NSString *)exceptionType
181
- stackTrace:(NSString *)stackTrace)
182
- {
183
- @try {
184
- [LROSDK captureExceptionWithErrorMessage:message errorType:errorType exceptionType:exceptionType stackTrace:stackTrace];
185
- }
186
- @catch (NSException *e) {
187
- NSLog(@"Failed to capture exception");
188
- }
189
- }
190
-
191
- RCT_EXPORT_METHOD(captureReduxAction:(NSDictionary *)data)
192
- {
193
- @try {
194
- NSNumber *storeId = data[@"storeId"];
195
- NSNumber *count = [data objectForKey:@"count"] ? data[@"count"] : 0;
196
- NSNumber *duration = data[@"duration"];
197
- NSString *stateDelta = data[@"stateDelta"];
198
- NSString *action = data[@"action"];
199
-
200
- [LROSDK captureReduxActionWithAction:action storeId:storeId duration:duration stateDelta:stateDelta count:count];
201
- }
202
- @catch (NSException *e) {
203
- NSLog(@"Failed to capture redux action");
204
- }
205
- }
206
-
207
- RCT_EXPORT_METHOD(captureReduxInitialState:(NSDictionary *)data)
208
- {
209
- @try {
210
- NSNumber *storeId = data[@"storeId"];
211
- NSString *state = data[@"state"];
212
-
213
- [LROSDK captureReduxInitialStateWithState:state storeId:storeId];
214
- }
215
- @catch (NSException *e) {
216
- NSLog(@"Failed to capture initial redux state");
217
- }
218
- }
219
-
220
- RCT_EXPORT_METHOD(captureRequest:(NSString *)reqID request:(NSDictionary *)request)
221
- {
222
- @try {
223
- LRORequestBuilder *builder = [LROSDK newRequestBuilder];
224
- builder.url = request[@"url"];
225
-
226
- if ([request objectForKey:@"body"]) {
227
- NSDictionary *arson = [request objectForKey:@"body"];
228
- if (arson && [arson objectForKey:@"arson"]) {
229
- builder.arsonBody = [arson objectForKey:@"arson"];
230
- }
231
- }
232
-
233
- if ([request objectForKey:@"method"]) {
234
- builder.method = [request objectForKey:@"method"];
235
- }
236
-
237
- if ([request objectForKey:@"headers"]) {
238
- builder.headers = [request objectForKey:@"headers"];
239
- }
240
-
241
- capturedRequests[reqID] = [builder capture];
242
- }
243
- @catch (NSException *e) {
244
- NSLog(@"Failed to capture request");
245
- }
246
- }
247
-
248
- RCT_EXPORT_METHOD(captureResponse:(NSString *)reqID response:(NSDictionary *)response)
249
- {
250
- @try {
251
- LROResponseBuilder *builder = capturedRequests[reqID];
252
-
253
- if (builder) {
254
- if ([response objectForKey:@"body"]) {
255
- NSDictionary *arson = [response objectForKey:@"body"];
256
- if (arson && [arson objectForKey:@"arson"]) {
257
- builder.arsonBody = [arson objectForKey:@"arson"];
258
- }
259
- }
260
-
261
- if ([response objectForKey:@"statusCode"]) {
262
- NSNumber *statusCode = (NSNumber *) [response objectForKey:@"statusCode"];
263
- builder.status = [statusCode longValue];
264
- }
265
-
266
- if ([response objectForKey:@"headers"]) {
267
- builder.headers = [response objectForKey:@"headers"];
268
- }
269
-
270
- [builder capture];
271
- }
272
-
273
- [capturedRequests removeObjectForKey:reqID];
274
- }
275
- @catch (NSException *e) {
276
- NSLog(@"Failed to capture response");
277
- }
278
- }
279
-
280
166
  RCT_EXPORT_METHOD(initWithConfig:(NSString *)appID
281
167
  config:(NSDictionary *)config
282
168
  resolver:(RCTPromiseResolveBlock)resolve
@@ -351,32 +237,6 @@ RCT_EXPORT_METHOD(track:(NSString *)customEventName eventProperties:(NSDictionar
351
237
  }
352
238
  }
353
239
 
354
- RCT_EXPORT_METHOD(captureMessage:(NSString *)message options:(NSDictionary *)options)
355
- {
356
- @try {
357
- LROCaptureMessageBuilder *builder = [[LROCaptureMessageBuilder alloc] init:message];
358
-
359
- for (NSString *key in options) {
360
- if ([key isEqualToString:@"tags"] || [key isEqualToString:@"extra"]) {
361
- NSDictionary *tagsOrExtras = [options objectForKey:key];
362
-
363
- for (NSString *tagKey in tagsOrExtras) {
364
- NSString *tagValue = [tagsOrExtras objectForKey:tagKey];
365
- if ([key isEqualToString:@"tags"]) {
366
- [builder putTagString:tagKey value:tagValue];
367
- } else {
368
- [builder putExtraString:tagKey value:tagValue];
369
- }
370
- }
371
- }
372
- }
373
- [LROSDK captureMessage:builder];
374
- }
375
- @catch (NSException *e) {
376
- NSLog(@"Failed to capture message");
377
- }
378
- }
379
-
380
240
  RCT_EXPORT_METHOD(pauseViewCapture)
381
241
  {
382
242
  @try {
@@ -409,4 +269,26 @@ RCT_EXPORT_METHOD(tagPage:(NSString *)relativePage)
409
269
  }
410
270
  }
411
271
 
272
+ RCT_EXPORT_METHOD(postMessage:(NSArray *) message)
273
+ {
274
+ if (!fullMessageArray) {
275
+ fullMessageArray = [NSMutableArray arrayWithArray:message];
276
+ } else {
277
+ [fullMessageArray addObjectsFromArray: message];
278
+ }
279
+ }
280
+
281
+ RCT_EXPORT_METHOD(donePostingMessage)
282
+ {
283
+ if (fullMessageArray) {
284
+ [LROSDK rebuildMessage:fullMessageArray];
285
+ // Set array to nil so that it get replaced with a new array when another event
286
+ // is captured. This array instance could still be getting processed by the
287
+ // native SDK when another event comes in.
288
+ fullMessageArray = nil;
289
+ } else {
290
+ NSLog(@"Received donePostingMessage without posting any message");
291
+ }
292
+ }
293
+
412
294
  @end
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,c,m,swift}"
17
17
  s.requires_arc = true
18
18
 
19
- s.dependency "LogRocket", "1.39.2"
19
+ s.dependency "LogRocket", "1.40.1"
20
20
  s.dependency "React"
21
21
  end
22
22
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@logrocket/react-native",
3
3
  "title": "Logrocket Native Module",
4
- "version": "1.39.2",
4
+ "version": "1.40.1",
5
5
  "description": "LogRocket SDK for react-native",
6
6
  "typings": "types.d.ts",
7
7
  "files": [
@@ -45,6 +45,7 @@
45
45
  "@logrocket/custom-events": "^0.0.85",
46
46
  "@logrocket/redux": "^0.0.85",
47
47
  "@logrocket/diffpatch": "^0.0.85",
48
+ "@logrocket/post-message": "^0.0.85",
48
49
  "jest": "^26.6.3",
49
50
  "react-native": "0.66.4",
50
51
  "@babel/core": "^7.13.15",
package/types.d.ts CHANGED
@@ -128,6 +128,7 @@ interface ILogRocket {
128
128
  registerWebView(view: any): void;
129
129
  startNewSession(appID?: string, config?: IOptions): Promise<boolean>;
130
130
  startNewSessionSameConfig(): Promise<boolean>;
131
+ log(args: any[]): void;
131
132
  }
132
133
 
133
134
  export function LRAllowProps(allowTag: string = 'lr-show');