Skip to content

Commit

Permalink
fix android
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-zimerman committed Oct 17, 2024
1 parent 652a8dc commit 61b5835
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 51 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public void initNativeReactNavigationNewFrameTracking(Promise promise) {
}

public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
<<<<<<< HEAD
SentryAndroid.init(
this.getReactApplicationContext(),
options -> {
Expand Down Expand Up @@ -274,17 +273,6 @@ public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
}
} catch (Throwable ignored) { // NOPMD - We don't want to crash in any case
// We do nothing
=======
try {
SentryAndroid.init(
this.getReactApplicationContext(),
options -> {
@Nullable SdkVersion sdkVersion = options.getSdkVersion();
if (sdkVersion == null) {
sdkVersion = new SdkVersion(ANDROID_SDK_NAME, BuildConfig.VERSION_NAME);
} else {
sdkVersion.setName(ANDROID_SDK_NAME);
>>>>>>> 4ef0e98c (port navigation tracker #4042 to V6 / Todo: Fix tests)
}

options.setSentryClientName(sdkVersion.getName() + "/" + sdkVersion.getVersion());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.sentry.react;

import android.os.Handler;
import android.os.Looper;
import android.view.Choreographer;
import com.facebook.react.bridge.Promise;
import io.sentry.SentryDate;
import io.sentry.SentryDateProvider;

public class RNSentryTimeToDisplay {
public static void GetTimeToDisplay(Promise promise, SentryDateProvider dateProvider) {
Looper mainLooper = Looper.getMainLooper();

if (mainLooper == null) {
promise.reject(
"GetTimeToDisplay is not able to measure the time to display: Main looper not"
+ " available.");
return;
}

// Ensure the code runs on the main thread
new Handler(mainLooper)
.post(
() -> {
try {
Choreographer choreographer = Choreographer.getInstance();

// Invoke the callback after the frame is rendered
choreographer.postFrameCallback(
frameTimeNanos -> {
final SentryDate endDate = dateProvider.now();
promise.resolve(endDate.nanoTimestamp() / 1e9);
});
} catch (Exception exception) {
promise.reject("Failed to receive the instance of Choreographer", exception);
}
});
}
}

0 comments on commit 61b5835

Please sign in to comment.