@logrocket/react-native 0.21.0 → 0.23.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.
package/README.md
CHANGED
|
@@ -37,10 +37,10 @@ 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
|
-
| Exceptions | :heavy_check_mark: | :
|
|
43
|
-
| Custom Events | :heavy_check_mark: | :
|
|
42
|
+
| Exceptions | :heavy_check_mark: | :heavy_check_mark: |
|
|
43
|
+
| Custom Events | :heavy_check_mark: | :heavy_check_mark: |
|
|
44
44
|
| getSessionURL | :heavy_check_mark: | :heavy_check_mark: |
|
|
45
45
|
| [Redux middleware][redux-middleware] | :heavy_check_mark: | :x: |
|
|
46
46
|
| Connection quality config | :heavy_check_mark: | :x: |
|
package/android/build.gradle
CHANGED
|
@@ -14,7 +14,7 @@ def DEFAULT_COMPILE_SDK_VERSION = 28
|
|
|
14
14
|
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
|
|
15
15
|
def DEFAULT_MIN_SDK_VERSION = 19
|
|
16
16
|
def DEFAULT_TARGET_SDK_VERSION = 28
|
|
17
|
-
def SDK_VERSION = "0.
|
|
17
|
+
def SDK_VERSION = "0.23.1"
|
|
18
18
|
|
|
19
19
|
def PACKAGE_ROOT_DIR = rootProject.name == 'LogRocket SDK' ? "$rootDir/../packages/@logrocket/react-native" : "$rootDir/..";
|
|
20
20
|
|
|
@@ -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;
|
|
@@ -22,11 +29,14 @@ import com.logrocket.core.util.logging.TaggedLogger;
|
|
|
22
29
|
import java.util.ArrayList;
|
|
23
30
|
import java.util.HashMap;
|
|
24
31
|
import java.util.Iterator;
|
|
32
|
+
import java.util.List;
|
|
25
33
|
import java.util.Map;
|
|
26
34
|
import java.util.Map.Entry;
|
|
35
|
+
import lr.core.Core.LogEvent;
|
|
27
36
|
import lr.redux.Redux.InitialState;
|
|
28
37
|
import lr.redux.Redux.ReduxAction;
|
|
29
38
|
import lr.utils.Utils;
|
|
39
|
+
import lr.utils.Utils.Value;
|
|
30
40
|
|
|
31
41
|
public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
32
42
|
|
|
@@ -37,6 +47,12 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
37
47
|
public LogRocketNativeModule(ReactApplicationContext reactContext) {
|
|
38
48
|
super(reactContext);
|
|
39
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);
|
|
40
56
|
}
|
|
41
57
|
|
|
42
58
|
@NonNull
|
|
@@ -45,6 +61,12 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
45
61
|
return "LogRocketNativeModule";
|
|
46
62
|
}
|
|
47
63
|
|
|
64
|
+
@ReactMethod
|
|
65
|
+
public void addListener(String eventName) {}
|
|
66
|
+
|
|
67
|
+
@ReactMethod
|
|
68
|
+
public void removeListeners(Integer count) {}
|
|
69
|
+
|
|
48
70
|
@Keep
|
|
49
71
|
@ReactMethod
|
|
50
72
|
public void initWithConfig(String appID, ReadableMap config, Promise promise) {
|
|
@@ -199,7 +221,36 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
199
221
|
@ReactMethod
|
|
200
222
|
public void addLog(String level, ReadableArray args) {
|
|
201
223
|
try {
|
|
202
|
-
|
|
224
|
+
List<Object> argsList = args.toArrayList();
|
|
225
|
+
LogRocketCore core = LogRocketCore.maybeGetInstance();
|
|
226
|
+
|
|
227
|
+
if (core != null) {
|
|
228
|
+
LogEvent.Builder logEvent = LogEvent.newBuilder();
|
|
229
|
+
|
|
230
|
+
switch (level) {
|
|
231
|
+
case "DEBUG":
|
|
232
|
+
logEvent.setLogLevel(LogEvent.LogLevel.DEBUG);
|
|
233
|
+
break;
|
|
234
|
+
case "INFO":
|
|
235
|
+
logEvent.setLogLevel(LogEvent.LogLevel.INFO);
|
|
236
|
+
break;
|
|
237
|
+
case "LOG":
|
|
238
|
+
logEvent.setLogLevel(LogEvent.LogLevel.LOG);
|
|
239
|
+
break;
|
|
240
|
+
case "WARN":
|
|
241
|
+
logEvent.setLogLevel(LogEvent.LogLevel.WARN);
|
|
242
|
+
break;
|
|
243
|
+
case "ERROR":
|
|
244
|
+
logEvent.setLogLevel(LogEvent.LogLevel.ERROR);
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
for (Object arg : argsList) {
|
|
249
|
+
logEvent.addArgs(Value.newBuilder().setArson((String) arg).build());
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
core.addEvent(EventType.LogEvent, logEvent);
|
|
253
|
+
}
|
|
203
254
|
} catch (Throwable th) {
|
|
204
255
|
this.logger.error("Error while adding log", th);
|
|
205
256
|
TelemetryReporter.sendErrorTelemetry(th);
|
|
@@ -359,4 +410,38 @@ public class LogRocketNativeModule extends ReactContextBaseJavaModule {
|
|
|
359
410
|
|
|
360
411
|
return formattedMap;
|
|
361
412
|
}
|
|
413
|
+
|
|
414
|
+
class LogRocketReceiver extends BroadcastReceiver {
|
|
415
|
+
private final ReactApplicationContext reactContext;
|
|
416
|
+
private final Logger logger = new TaggedLogger("logrocket-receiver");
|
|
417
|
+
|
|
418
|
+
public LogRocketReceiver(ReactApplicationContext reactContext) {
|
|
419
|
+
this.reactContext = reactContext;
|
|
420
|
+
}
|
|
421
|
+
|
|
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
|
+
}
|
|
434
|
+
|
|
435
|
+
params.putBoolean("shouldDisableAndFreeMemory", shouldDisableAndFreeMemory);
|
|
436
|
+
params.putBoolean("shouldWarnAboutReduxSize", shouldWarnAboutReduxSize);
|
|
437
|
+
|
|
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
|
+
}
|
|
446
|
+
}
|
|
362
447
|
}
|