Skip to content

Commit 1c1ce3a

Browse files
authored
Merge pull request #8 from middleware-labs/init-fix
fix: 🐛 for throwing NPE during initializing middleware android sdk
2 parents b143a45 + 44f9fdc commit 1c1ce3a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ dependencies {
8484
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
8585
//noinspection GradleDynamicVersion
8686
implementation "com.facebook.react:react-native:+"
87-
implementation ('io.github.middleware-labs:android-sdk:2.0.4')
87+
implementation ('io.github.middleware-labs:android-sdk:2.0.5')
8888
implementation 'io.opentelemetry.android:instrumentation:+'
8989
implementation 'io.opentelemetry:opentelemetry-sdk:+'
9090
runtimeOnly 'io.opentelemetry:opentelemetry-semconv:1.30.1-alpha'

android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public void initialize(ReadableMap configMap, Promise promise) {
8080
.setGlobalAttributes(attributesFromMap(globalAttributes))
8181
.setDeploymentEnvironment(deploymentEnvironment)
8282
.disableActivityLifecycleMonitoring()
83-
.build(Objects.requireNonNull(getReactApplicationContext().getCurrentActivity()).getApplication());
83+
.build((Application) getReactApplicationContext().getApplicationContext());
8484

85-
if("true".equals(sessionRecording)) {
85+
if (Boolean.TRUE.toString().equals(sessionRecording)) {
8686
Middleware middleware = Middleware.getInstance();
8787
middleware.startNativeRecording(getCurrentActivity());
8888
}
@@ -103,7 +103,8 @@ public void nativeCrash() {
103103
new Thread(() -> {
104104
try {
105105
Thread.sleep(2000);
106-
} catch (InterruptedException e) {}
106+
} catch (InterruptedException e) {
107+
}
107108
throw new RuntimeException("test crash");
108109
}).start();
109110
}
@@ -242,7 +243,7 @@ private ReactSpanProperties propertiesFromMap(SpanMapReader mapReader) {
242243

243244
final ReadableArray readerEvents = mapReader.getEvents();
244245
final List<EventData> newEvents = new ArrayList<>();
245-
for(int index = 0; index < readerEvents.size(); index++) {
246+
for (int index = 0; index < readerEvents.size(); index++) {
246247
final ReadableMap readableMap = readerEvents.getMap(index);
247248
final EventData eventData = EventData.create(
248249
Long.parseLong(Objects.requireNonNull(readableMap.getString("time"))),

0 commit comments

Comments
 (0)