@@ -117,8 +117,7 @@ public class RNSentryModuleImpl {
117117 private FrameMetricsAggregator frameMetricsAggregator = null ;
118118 private boolean androidXAvailable ;
119119
120- @ VisibleForTesting
121- static long lastStartTimestampMs = -1 ;
120+ @ VisibleForTesting static long lastStartTimestampMs = -1 ;
122121
123122 // 700ms to constitute frozen frames.
124123 private static final int FROZEN_FRAME_THRESHOLD = 700 ;
@@ -128,8 +127,7 @@ public class RNSentryModuleImpl {
128127 private static final int SCREENSHOT_TIMEOUT_SECONDS = 2 ;
129128
130129 /**
131- * Profiling traces rate. 101 hz means 101 traces in 1 second. Defaults to 101
132- * to avoid possible
130+ * Profiling traces rate. 101 hz means 101 traces in 1 second. Defaults to 101 to avoid possible
133131 * lockstep sampling. More on
134132 * https://stackoverflow.com/questions/45470758/what-is-lockstep-sampling
135133 */
@@ -174,29 +172,31 @@ private ReactApplicationContext getReactApplicationContext() {
174172 }
175173
176174 private void initFragmentInitialFrameTracking () {
177- final RNSentryReactFragmentLifecycleTracer fragmentLifecycleTracer = new RNSentryReactFragmentLifecycleTracer (
178- buildInfo , emitNewFrameEvent , logger );
175+ final RNSentryReactFragmentLifecycleTracer fragmentLifecycleTracer =
176+ new RNSentryReactFragmentLifecycleTracer ( buildInfo , emitNewFrameEvent , logger );
179177
180178 final @ Nullable FragmentActivity fragmentActivity = (FragmentActivity ) getCurrentActivity ();
181179 if (fragmentActivity != null ) {
182- final @ Nullable FragmentManager supportFragmentManager = fragmentActivity .getSupportFragmentManager ();
180+ final @ Nullable FragmentManager supportFragmentManager =
181+ fragmentActivity .getSupportFragmentManager ();
183182 if (supportFragmentManager != null ) {
184183 supportFragmentManager .registerFragmentLifecycleCallbacks (fragmentLifecycleTracer , true );
185184 }
186185 }
187186 }
188187
189188 private void initFragmentReplayTracking () {
190- final RNSentryReplayFragmentLifecycleTracer fragmentLifecycleTracer = new RNSentryReplayFragmentLifecycleTracer (
191- logger );
189+ final RNSentryReplayFragmentLifecycleTracer fragmentLifecycleTracer =
190+ new RNSentryReplayFragmentLifecycleTracer ( logger );
192191
193192 final @ Nullable Activity currentActivity = getCurrentActivity ();
194193 if (!(currentActivity instanceof FragmentActivity )) {
195194 return ;
196195 }
197196
198197 final @ NotNull FragmentActivity fragmentActivity = (FragmentActivity ) currentActivity ;
199- final @ Nullable FragmentManager supportFragmentManager = fragmentActivity .getSupportFragmentManager ();
198+ final @ Nullable FragmentManager supportFragmentManager =
199+ fragmentActivity .getSupportFragmentManager ();
200200 if (supportFragmentManager != null ) {
201201 supportFragmentManager .registerFragmentLifecycleCallbacks (fragmentLifecycleTracer , true );
202202 }
@@ -226,8 +226,7 @@ protected Context getApplicationContext() {
226226
227227 protected void getSentryAndroidOptions (
228228 @ NotNull SentryAndroidOptions options , @ NotNull ReadableMap rnOptions , ILogger logger ) {
229- @ Nullable
230- SdkVersion sdkVersion = options .getSdkVersion ();
229+ @ Nullable SdkVersion sdkVersion = options .getSdkVersion ();
231230 if (sdkVersion == null ) {
232231 sdkVersion = new SdkVersion (RNSentryVersion .ANDROID_SDK_NAME , BuildConfig .VERSION_NAME );
233232 } else {
@@ -329,7 +328,8 @@ protected void getSentryAndroidOptions(
329328 // Check if the replay integration is available on the classpath. It's already
330329 // kept from R8
331330 // shrinking by sentry-android-core
332- final boolean isReplayAvailable = loadClass .isClassAvailable ("io.sentry.android.replay.ReplayIntegration" , logger );
331+ final boolean isReplayAvailable =
332+ loadClass .isClassAvailable ("io.sentry.android.replay.ReplayIntegration" , logger );
333333 if (isReplayEnabled (replayOptions ) && isReplayAvailable ) {
334334 options .getReplayController ().setBreadcrumbConverter (new RNSentryReplayBreadcrumbConverter ());
335335 initFragmentReplayTracking ();
@@ -394,11 +394,13 @@ private boolean isReplayEnabled(SentryReplayOptions replayOptions) {
394394 }
395395
396396 private SentryReplayOptions getReplayOptions (@ NotNull ReadableMap rnOptions ) {
397- final SdkVersion replaySdkVersion = new SdkVersion (
398- RNSentryVersion .REACT_NATIVE_SDK_NAME ,
399- RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_VERSION );
397+ final SdkVersion replaySdkVersion =
398+ new SdkVersion (
399+ RNSentryVersion .REACT_NATIVE_SDK_NAME ,
400+ RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_VERSION );
400401 @ NotNull
401- final SentryReplayOptions androidReplayOptions = new SentryReplayOptions (false , replaySdkVersion );
402+ final SentryReplayOptions androidReplayOptions =
403+ new SentryReplayOptions (false , replaySdkVersion );
402404
403405 if (!(rnOptions .hasKey ("replaysSessionSampleRate" )
404406 || rnOptions .hasKey ("replaysOnErrorSampleRate" ))) {
@@ -423,8 +425,7 @@ private SentryReplayOptions getReplayOptions(@NotNull ReadableMap rnOptions) {
423425 if (!rnOptions .hasKey ("mobileReplayOptions" )) {
424426 return androidReplayOptions ;
425427 }
426- @ Nullable
427- final ReadableMap rnMobileReplayOptions = rnOptions .getMap ("mobileReplayOptions" );
428+ @ Nullable final ReadableMap rnMobileReplayOptions = rnOptions .getMap ("mobileReplayOptions" );
428429 if (rnMobileReplayOptions == null ) {
429430 return androidReplayOptions ;
430431 }
@@ -436,15 +437,17 @@ private SentryReplayOptions getReplayOptions(@NotNull ReadableMap rnOptions) {
436437 !rnMobileReplayOptions .hasKey ("maskAllImages" )
437438 || rnMobileReplayOptions .getBoolean ("maskAllImages" ));
438439
439- final boolean redactVectors = !rnMobileReplayOptions .hasKey ("maskAllVectors" )
440- || rnMobileReplayOptions .getBoolean ("maskAllVectors" );
440+ final boolean redactVectors =
441+ !rnMobileReplayOptions .hasKey ("maskAllVectors" )
442+ || rnMobileReplayOptions .getBoolean ("maskAllVectors" );
441443 if (redactVectors ) {
442444 androidReplayOptions .addMaskViewClass ("com.horcrux.svg.SvgView" ); // react-native-svg
443445 }
444446
445447 if (rnMobileReplayOptions .hasKey ("screenshotStrategy" )) {
446448 final String screenshotStrategyString = rnMobileReplayOptions .getString ("screenshotStrategy" );
447- final ScreenshotStrategyType screenshotStrategy = parseScreenshotStrategy (screenshotStrategyString );
449+ final ScreenshotStrategyType screenshotStrategy =
450+ parseScreenshotStrategy (screenshotStrategyString );
448451 androidReplayOptions .setScreenshotStrategy (screenshotStrategy );
449452 }
450453
@@ -484,13 +487,13 @@ private SentryReplayQuality parseReplayQuality(@Nullable String qualityString) {
484487 }
485488 }
486489
487- private void configureAndroidProfiling (@ NotNull SentryAndroidOptions options , @ NotNull ReadableMap rnOptions ) {
490+ private void configureAndroidProfiling (
491+ @ NotNull SentryAndroidOptions options , @ NotNull ReadableMap rnOptions ) {
488492 if (!rnOptions .hasKey ("_experiments" )) {
489493 return ;
490494 }
491495
492- @ Nullable
493- final ReadableMap experiments = rnOptions .getMap ("_experiments" );
496+ @ Nullable final ReadableMap experiments = rnOptions .getMap ("_experiments" );
494497 if (experiments == null || !experiments .hasKey ("androidProfilingOptions" )) {
495498 return ;
496499 }
@@ -503,7 +506,8 @@ private void configureAndroidProfiling(@NotNull SentryAndroidOptions options, @N
503506
504507 // Set profile session sample rate
505508 if (androidProfilingOptions .hasKey ("profileSessionSampleRate" )) {
506- final double profileSessionSampleRate = androidProfilingOptions .getDouble ("profileSessionSampleRate" );
509+ final double profileSessionSampleRate =
510+ androidProfilingOptions .getDouble ("profileSessionSampleRate" );
507511 options .setProfileSessionSampleRate (profileSessionSampleRate );
508512 logger .log (
509513 SentryLevel .INFO ,
@@ -592,10 +596,12 @@ protected void fetchNativeAppStart(
592596 return ;
593597 }
594598
595- WritableMap mutableMeasurement = (WritableMap ) RNSentryMapConverter .convertToWritable (metricsDataBag );
599+ WritableMap mutableMeasurement =
600+ (WritableMap ) RNSentryMapConverter .convertToWritable (metricsDataBag );
596601
597602 long currentStartTimestampMs = metrics .getAppStartTimeSpan ().getStartTimestampMs ();
598- boolean hasFetched = lastStartTimestampMs > 0 && lastStartTimestampMs == currentStartTimestampMs ;
603+ boolean hasFetched =
604+ lastStartTimestampMs > 0 && lastStartTimestampMs == currentStartTimestampMs ;
599605 mutableMeasurement .putBoolean ("has_fetched" , hasFetched );
600606
601607 if (lastStartTimestampMs < 0 ) {
@@ -728,11 +734,12 @@ public void captureScreenshot(Promise promise) {
728734
729735 private static byte [] takeScreenshotOnUiThread (Activity activity ) {
730736 CountDownLatch doneSignal = new CountDownLatch (1 );
731- final byte [][] bytesWrapper = { {} }; // wrapper to be able to set the value in the runnable
732- final Runnable runTakeScreenshot = () -> {
733- bytesWrapper [0 ] = takeScreenshot (activity , logger , buildInfo );
734- doneSignal .countDown ();
735- };
737+ final byte [][] bytesWrapper = {{}}; // wrapper to be able to set the value in the runnable
738+ final Runnable runTakeScreenshot =
739+ () -> {
740+ bytesWrapper [0 ] = takeScreenshot (activity , logger , buildInfo );
741+ doneSignal .countDown ();
742+ };
736743
737744 if (UiThreadUtil .isOnUiThread ()) {
738745 runTakeScreenshot .run ();
@@ -752,15 +759,17 @@ private static byte[] takeScreenshotOnUiThread(Activity activity) {
752759
753760 public void fetchViewHierarchy (Promise promise ) {
754761 final @ Nullable Activity activity = getCurrentActivity ();
755- final @ Nullable ViewHierarchy viewHierarchy = ViewHierarchyEventProcessor .snapshotViewHierarchy (activity , logger );
762+ final @ Nullable ViewHierarchy viewHierarchy =
763+ ViewHierarchyEventProcessor .snapshotViewHierarchy (activity , logger );
756764 if (viewHierarchy == null ) {
757765 logger .log (SentryLevel .ERROR , "Could not get ViewHierarchy." );
758766 promise .resolve (null );
759767 return ;
760768 }
761769
762770 ISerializer serializer = ScopesAdapter .getInstance ().getOptions ().getSerializer ();
763- final @ Nullable byte [] bytes = JsonSerializationUtils .bytesFrom (serializer , logger , viewHierarchy );
771+ final @ Nullable byte [] bytes =
772+ JsonSerializationUtils .bytesFrom (serializer , logger , viewHierarchy );
764773 if (bytes == null ) {
765774 logger .log (SentryLevel .ERROR , "Could not serialize ViewHierarchy." );
766775 promise .resolve (null );
@@ -970,7 +979,8 @@ public void getNewScreenTimeToDisplay(Promise promise) {
970979
971980 private String getProfilingTracesDirPath () {
972981 if (cacheDirPath == null ) {
973- cacheDirPath = new File (getReactApplicationContext ().getCacheDir (), "sentry/react" ).getAbsolutePath ();
982+ cacheDirPath =
983+ new File (getReactApplicationContext ().getCacheDir (), "sentry/react" ).getAbsolutePath ();
974984 }
975985 File profilingTraceDir = new File (cacheDirPath , "profiling_trace" );
976986 profilingTraceDir .mkdirs ();
@@ -983,12 +993,13 @@ private void initializeAndroidProfiler() {
983993 }
984994 final String tracesFilesDirPath = getProfilingTracesDirPath ();
985995
986- androidProfiler = new AndroidProfiler (
987- tracesFilesDirPath ,
988- (int ) SECONDS .toMicros (1 ) / profilingTracesHz ,
989- new SentryFrameMetricsCollector (reactApplicationContext , logger , buildInfo ),
990- executorService ,
991- logger );
996+ androidProfiler =
997+ new AndroidProfiler (
998+ tracesFilesDirPath ,
999+ (int ) SECONDS .toMicros (1 ) / profilingTracesHz ,
1000+ new SentryFrameMetricsCollector (reactApplicationContext , logger , buildInfo ),
1001+ executorService ,
1002+ logger );
9921003 }
9931004
9941005 public WritableMap startProfiling (boolean platformProfilers ) {
@@ -1022,8 +1033,9 @@ public WritableMap stopProfiling() {
10221033 }
10231034 HermesSamplingProfiler .disable ();
10241035
1025- output = File .createTempFile (
1026- "sampling-profiler-trace" , ".cpuprofile" , reactApplicationContext .getCacheDir ());
1036+ output =
1037+ File .createTempFile (
1038+ "sampling-profiler-trace" , ".cpuprofile" , reactApplicationContext .getCacheDir ());
10271039 if (isDebug ) {
10281040 logger .log (SentryLevel .INFO , "Profile saved to: " + output .getAbsolutePath ());
10291041 }
@@ -1033,8 +1045,10 @@ public WritableMap stopProfiling() {
10331045
10341046 if (end != null ) {
10351047 WritableMap androidProfile = new WritableNativeMap ();
1036- byte [] androidProfileBytes = FileUtils .readBytesFromFile (end .traceFile .getPath (), maxTraceFileSize );
1037- String base64AndroidProfile = Base64 .encodeToString (androidProfileBytes , NO_WRAP | NO_PADDING );
1048+ byte [] androidProfileBytes =
1049+ FileUtils .readBytesFromFile (end .traceFile .getPath (), maxTraceFileSize );
1050+ String base64AndroidProfile =
1051+ Base64 .encodeToString (androidProfileBytes , NO_WRAP | NO_PADDING );
10381052
10391053 androidProfile .putString ("sampled_profile" , base64AndroidProfile );
10401054 androidProfile .putInt ("android_api_level" , buildInfo .getSdkInfoVersion ());
@@ -1063,8 +1077,8 @@ public WritableMap stopProfiling() {
10631077 return proguardUuid ;
10641078 }
10651079 isProguardDebugMetaLoaded = true ;
1066- final @ Nullable List <Properties > debugMetaList = new AssetsDebugMetaLoader ( this . getReactApplicationContext (),
1067- logger ).loadDebugMeta ();
1080+ final @ Nullable List <Properties > debugMetaList =
1081+ new AssetsDebugMetaLoader ( this . getReactApplicationContext (), logger ).loadDebugMeta ();
10681082 if (debugMetaList == null ) {
10691083 return null ;
10701084 }
@@ -1082,7 +1096,7 @@ public WritableMap stopProfiling() {
10821096 }
10831097
10841098 private String readStringFromFile (File path ) throws IOException {
1085- try (BufferedReader br = new BufferedReader (new FileReader (path ));) {
1099+ try (BufferedReader br = new BufferedReader (new FileReader (path )); ) {
10861100
10871101 final StringBuilder text = new StringBuilder ();
10881102 String line ;
@@ -1132,8 +1146,8 @@ protected void fetchNativeDeviceContexts(
11321146 }
11331147 }
11341148
1135- final @ NotNull Map <String , Object > serialized = InternalSentrySdk . serializeScope ( context ,
1136- (SentryAndroidOptions ) options , currentScope );
1149+ final @ NotNull Map <String , Object > serialized =
1150+ InternalSentrySdk . serializeScope ( context , (SentryAndroidOptions ) options , currentScope );
11371151 final @ Nullable Object deviceContext = RNSentryMapConverter .convertToWritable (serialized );
11381152 promise .resolve (deviceContext );
11391153 }
@@ -1149,8 +1163,9 @@ protected void fetchNativeLogContexts(
11491163 return ;
11501164 }
11511165
1152- Object contextsObj = InternalSentrySdk .serializeScope (osContext , (SentryAndroidOptions ) options , currentScope )
1153- .get ("contexts" );
1166+ Object contextsObj =
1167+ InternalSentrySdk .serializeScope (osContext , (SentryAndroidOptions ) options , currentScope )
1168+ .get ("contexts" );
11541169
11551170 if (!(contextsObj instanceof Map )) {
11561171 promise .resolve (null );
@@ -1179,7 +1194,8 @@ protected void fetchNativeLogContexts(
11791194 }
11801195
11811196 public void fetchNativeSdkInfo (Promise promise ) {
1182- final @ Nullable SdkVersion sdkVersion = ScopesAdapter .getInstance ().getOptions ().getSdkVersion ();
1197+ final @ Nullable SdkVersion sdkVersion =
1198+ ScopesAdapter .getInstance ().getOptions ().getSdkVersion ();
11831199 if (sdkVersion == null ) {
11841200 promise .resolve (null );
11851201 } else {
@@ -1197,7 +1213,8 @@ public String fetchNativePackageName() {
11971213 public void getDataFromUri (String uri , Promise promise ) {
11981214 try {
11991215 Uri contentUri = Uri .parse (uri );
1200- try (InputStream is = getReactApplicationContext ().getContentResolver ().openInputStream (contentUri )) {
1216+ try (InputStream is =
1217+ getReactApplicationContext ().getContentResolver ().openInputStream (contentUri )) {
12011218 if (is == null ) {
12021219 String msg = "File not found for uri: " + uri ;
12031220 logger .log (SentryLevel .ERROR , msg );
0 commit comments