Skip to content
Next Next commit
Check if appLaunchedInForeground and launch duration for native app s…
…tart
  • Loading branch information
antonis committed Oct 3, 2024
commit 2b596fa7b9a6e3c6ad4b711e53af06a783df4a07
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import io.sentry.Breadcrumb;
import io.sentry.DateUtils;
Expand Down Expand Up @@ -380,6 +381,13 @@ public void fetchNativeRelease(Promise promise) {
}

public void fetchNativeAppStart(Promise promise) {
AppStartMetrics appStartMetrics = AppStartMetrics.getInstance();
if (!appStartMetrics.isAppLaunchedInForeground() ||
appStartMetrics.getAppStartTimeSpan().getDurationMs() > TimeUnit.MINUTES.toMillis(1)) {
logger.log(SentryLevel.WARNING, "Invalid app start data: app not launched in foreground or app start took too long (>60s)");
promise.resolve(null);
}

final Map<String, Object> measurement = InternalSentrySdk.getAppStartMeasurement();

WritableMap mutableMeasurement = (WritableMap) RNSentryMapConverter.convertToWritable(measurement);
Expand Down