@logrocket/react-native 0.22.0 → 0.24.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/README.md +3 -3
- package/android/build.gradle +4 -4
- package/android/src/main/java/com/logrocket/plugins/react/LogRocketNativeModule.java +78 -25
- package/dist/build.js +2 -2
- package/ios/LogRocketNativeModule.h +2 -1
- package/ios/LogRocketNativeModule.m +122 -0
- package/logrocket-react-native.podspec +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,12 +37,12 @@ Now you can build your app with [EAS Build](https://docs.expo.io/build/introduct
|
|
|
37
37
|
| View Redaction | :heavy_check_mark: | :heavy_check_mark: |
|
|
38
38
|
| Touch Events | :heavy_check_mark: | :heavy_check_mark: |
|
|
39
39
|
| Identify and User Traits | :heavy_check_mark: | :heavy_check_mark: |
|
|
40
|
-
| Network Requests & Responses | :heavy_check_mark: | :
|
|
40
|
+
| Network Requests & Responses | :heavy_check_mark: | :heavy_check_mark: |
|
|
41
41
|
| Console Logs | :heavy_check_mark: | :heavy_check_mark: |
|
|
42
42
|
| Exceptions | :heavy_check_mark: | :heavy_check_mark: |
|
|
43
|
-
| Custom Events | :heavy_check_mark: | :
|
|
43
|
+
| Custom Events | :heavy_check_mark: | :heavy_check_mark: |
|
|
44
44
|
| getSessionURL | :heavy_check_mark: | :heavy_check_mark: |
|
|
45
|
-
| [Redux middleware][redux-middleware] | :heavy_check_mark: | :
|
|
45
|
+
| [Redux middleware][redux-middleware] | :heavy_check_mark: | :heavy_check_mark: |
|
|
46
46
|
| Connection quality config | :heavy_check_mark: | :x: |
|
|
47
47
|
|
|
48
48
|
LogRocket instruments the XmlHttpRequest and fetch APIs to capture network requests and responses.
|
package/android/build.gradle
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
def DEFAULT_COMPILE_SDK_VERSION = 28
|
|
14
14
|
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
|
|
15
|
-
def DEFAULT_MIN_SDK_VERSION =
|
|
15
|
+
def DEFAULT_MIN_SDK_VERSION = 21
|
|
16
16
|
def DEFAULT_TARGET_SDK_VERSION = 28
|
|
17
|
-
def SDK_VERSION = "0.
|
|
17
|
+
def SDK_VERSION = "0.24.0"
|
|
18
18
|
|
|
19
19
|
def PACKAGE_ROOT_DIR = rootProject.name == 'LogRocket SDK' ? "$rootDir/../packages/@logrocket/react-native" : "$rootDir/..";
|
|
20
20
|
|
|
@@ -33,7 +33,7 @@ buildscript {
|
|
|
33
33
|
if (project == rootProject) {
|
|
34
34
|
repositories {
|
|
35
35
|
google()
|
|
36
|
-
|
|
36
|
+
mavenCentral()
|
|
37
37
|
}
|
|
38
38
|
dependencies {
|
|
39
39
|
classpath 'com.android.tools.build:gradle:3.4.1'
|
|
@@ -74,7 +74,7 @@ repositories {
|
|
|
74
74
|
url "$PACKAGE_ROOT_DIR/node_modules/jsc-android/dist"
|
|
75
75
|
}
|
|
76
76
|
google()
|
|
77
|
-
|
|
77
|
+
mavenCentral()
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
dependencies {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
package com.logrocket.plugins.react;
|
|
2
2
|
|
|
3
|
+
import android.content.BroadcastReceiver;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.Intent;
|
|
6
|
+
import android.content.IntentFilter;
|
|
3
7
|
import androidx.annotation.Keep;
|
|
4
8
|
import androidx.annotation.NonNull;
|
|
9
|
+
import com.facebook.react.bridge.Arguments;
|
|
5
10
|
import com.facebook.react.bridge.Callback;
|
|
6
11
|
import com.facebook.react.bridge.Promise;
|
|
7
12
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -9,6 +14,8 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
9
14
|
import com.facebook.react.bridge.ReactMethod;
|
|
10
15
|
import com.facebook.react.bridge.ReadableArray;
|
|
11
16
|
import com.facebook.react.bridge.ReadableMap;
|
|
17
|
+
import com.facebook.react.bridge.WritableMap;
|
|
18
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
12
19
|
import com.logrocket.core.CustomEventBuilder;
|
|
13
20
|
import com.logrocket.core.EventType;
|
|
14
21
|
import com.logrocket.core.IdentifyHelper;
|
|
@@ -40,6 +47,29 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
40
47
|
public LogRocketNativeModule(ReactApplicationContext reactContext) {
|
|
41
48
|
super(reactContext);
|
|
42
49
|
this.reactContext = reactContext;
|
|
50
|
+
LogRocketReceiver receiver = new LogRocketReceiver(this.reactContext);
|
|
51
|
+
|
|
52
|
+
IntentFilter filter = new IntentFilter();
|
|
53
|
+
filter.addAction("LogRocketSDK.Error");
|
|
54
|
+
|
|
55
|
+
this.reactContext.registerReceiver(receiver, filter);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private static Map<String, String> formatReadableMap(ReadableMap map) {
|
|
59
|
+
Map<String, String> formattedMap = new HashMap<>();
|
|
60
|
+
|
|
61
|
+
if (map == null) {
|
|
62
|
+
return formattedMap;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Iterator<Map.Entry<String, Object>> iterator = map.getEntryIterator();
|
|
66
|
+
|
|
67
|
+
while (iterator.hasNext()) {
|
|
68
|
+
Map.Entry<String, Object> entry = iterator.next();
|
|
69
|
+
formattedMap.put(entry.getKey(), entry.getValue().toString());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return formattedMap;
|
|
43
73
|
}
|
|
44
74
|
|
|
45
75
|
@NonNull
|
|
@@ -48,6 +78,12 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
48
78
|
return "LogRocketNativeModule";
|
|
49
79
|
}
|
|
50
80
|
|
|
81
|
+
@ReactMethod
|
|
82
|
+
public void addListener(String eventName) {}
|
|
83
|
+
|
|
84
|
+
@ReactMethod
|
|
85
|
+
public void removeListeners(Integer count) {}
|
|
86
|
+
|
|
51
87
|
@Keep
|
|
52
88
|
@ReactMethod
|
|
53
89
|
public void initWithConfig(String appID, ReadableMap config, Promise promise) {
|
|
@@ -275,32 +311,32 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
275
311
|
if (protobufVariant.hasKey("doubleVal")) {
|
|
276
312
|
ReadableArray readableArray = protobufVariant.getArray("doubleVal");
|
|
277
313
|
if (readableArray != null) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
list.add((Double) arrayIterator.next());
|
|
314
|
+
Double[] list = new Double[readableArray.size()];
|
|
315
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
316
|
+
list[i] = readableArray.getDouble(i);
|
|
282
317
|
}
|
|
283
|
-
|
|
318
|
+
|
|
319
|
+
builder.put(keyString, list);
|
|
284
320
|
}
|
|
285
321
|
} else if (protobufVariant.hasKey("boolVal")) {
|
|
286
322
|
ReadableArray readableArray = protobufVariant.getArray("boolVal");
|
|
287
323
|
if (readableArray != null) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
list.add((Boolean) arrayIterator.next());
|
|
324
|
+
Boolean[] list = new Boolean[readableArray.size()];
|
|
325
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
326
|
+
list[i] = readableArray.getBoolean(i);
|
|
292
327
|
}
|
|
293
|
-
|
|
328
|
+
|
|
329
|
+
builder.put(keyString, list);
|
|
294
330
|
}
|
|
295
331
|
} else if (protobufVariant.hasKey("stringVal")) {
|
|
296
332
|
ReadableArray readableArray = protobufVariant.getArray("stringVal");
|
|
297
333
|
if (readableArray != null) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
list.add((String) arrayIterator.next());
|
|
334
|
+
String[] list = new String[readableArray.size()];
|
|
335
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
336
|
+
list[i] = readableArray.getString(i);
|
|
302
337
|
}
|
|
303
|
-
|
|
338
|
+
|
|
339
|
+
builder.put(keyString, list);
|
|
304
340
|
}
|
|
305
341
|
}
|
|
306
342
|
}
|
|
@@ -375,20 +411,37 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
375
411
|
}
|
|
376
412
|
}
|
|
377
413
|
|
|
378
|
-
|
|
379
|
-
|
|
414
|
+
class LogRocketReceiver extends BroadcastReceiver {
|
|
415
|
+
private final ReactApplicationContext reactContext;
|
|
416
|
+
private final Logger logger = new TaggedLogger("logrocket-receiver");
|
|
380
417
|
|
|
381
|
-
|
|
382
|
-
|
|
418
|
+
public LogRocketReceiver(ReactApplicationContext reactContext) {
|
|
419
|
+
this.reactContext = reactContext;
|
|
383
420
|
}
|
|
384
421
|
|
|
385
|
-
|
|
422
|
+
@Override
|
|
423
|
+
public void onReceive(Context context, Intent intent) {
|
|
424
|
+
try {
|
|
425
|
+
String errorMessage = intent.getStringExtra("errorMessage");
|
|
426
|
+
boolean shouldDisableAndFreeMemory =
|
|
427
|
+
intent.getBooleanExtra("shouldDisableAndFreeMemory", false);
|
|
428
|
+
boolean shouldWarnAboutReduxSize =
|
|
429
|
+
intent.getBooleanExtra("shouldWarnAboutReduxSize", false);
|
|
430
|
+
WritableMap params = Arguments.createMap();
|
|
431
|
+
if (errorMessage.length() > 0) {
|
|
432
|
+
params.putString("errorMessage", errorMessage);
|
|
433
|
+
}
|
|
386
434
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
formattedMap.put(entry.getKey(), entry.getValue().toString());
|
|
390
|
-
}
|
|
435
|
+
params.putBoolean("shouldDisableAndFreeMemory", shouldDisableAndFreeMemory);
|
|
436
|
+
params.putBoolean("shouldWarnAboutReduxSize", shouldWarnAboutReduxSize);
|
|
391
437
|
|
|
392
|
-
|
|
438
|
+
this.reactContext
|
|
439
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
440
|
+
.emit("LogRocketSDKOnError", params);
|
|
441
|
+
} catch (Throwable th) {
|
|
442
|
+
this.logger.error("Error while sending event from Native Module", th);
|
|
443
|
+
TelemetryReporter.sendErrorTelemetry(th);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
393
446
|
}
|
|
394
447
|
}
|