Skip to content

Commit

Permalink
misc(ttd): Add Android Logger when new frame event is not emitted (#4081
Browse files Browse the repository at this point in the history
)
  • Loading branch information
krystofwoldrich authored Sep 12, 2024
1 parent d43a46b commit 3aff6fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

### Changes

- Add Android Logger when new frame event is not emitted ([#4081](https://github.com/getsentry/sentry-react-native/pull/4081))
- React Native Tracing Deprecations ([#4073](https://github.com/getsentry/sentry-react-native/pull/4073))
- `new ReactNativeTracing` to `reactNativeTracingIntegration()`
- `new ReactNavigationInstrumentation` to `reactNativeTracingIntegration()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import java.util.Map;

import io.sentry.ILogger;
import io.sentry.SentryDate;
import io.sentry.SentryDateProvider;
import io.sentry.SentryLevel;
import io.sentry.android.core.AndroidLogger;
import io.sentry.android.core.BuildInfoProvider;
import io.sentry.android.core.SentryAndroidDateProvider;
Expand Down Expand Up @@ -68,6 +70,8 @@ public Map getExportedCustomBubblingEventTypeConstants() {

public static class RNSentryOnDrawReporterView extends View {

private static final ILogger logger = new AndroidLogger("RNSentryOnDrawReporterView");

private final @Nullable ReactApplicationContext reactContext;
private final @NotNull SentryDateProvider dateProvider = new SentryAndroidDateProvider();
private final @Nullable Runnable emitInitialDisplayEvent;
Expand Down Expand Up @@ -96,6 +100,7 @@ public void setFullDisplay(boolean fullDisplay) {
return;
}

logger.log(SentryLevel.DEBUG, "[TimeToDisplay] Register full display event emitter.");
registerForNextDraw(emitFullDisplayEvent);
}

Expand All @@ -104,16 +109,27 @@ public void setInitialDisplay(boolean initialDisplay) {
return;
}

logger.log(SentryLevel.DEBUG, "[TimeToDisplay] Register initial display event emitter.");
registerForNextDraw(emitInitialDisplayEvent);
}

private void registerForNextDraw(@Nullable Runnable emitter) {
if (emitter == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, emitter is null.");
return;
}
if (buildInfo == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, buildInfo is null.");
return;
}
if (reactContext == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, reactContext is null.");
return;
}

@Nullable Activity activity = reactContext.getCurrentActivity();
if (activity == null || emitter == null || buildInfo == null) {
if (activity == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, reactContext is null.");
return;
}

Expand All @@ -129,6 +145,7 @@ private void emitDisplayEvent(String type) {
event.putDouble("newFrameTimestampInSeconds", endDate.nanoTimestamp() / 1e9);

if (reactContext == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Recorded next frame draw but can't emit the event, reactContext is null.");
return;
}
reactContext
Expand Down

0 comments on commit 3aff6fa

Please sign in to comment.