Skip to content

Commit

Permalink
clear format
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-zimerman committed Aug 23, 2024
1 parent d0c0cf7 commit 1a52620
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/js/utils/sentryeventemitterfallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import { logger } from '@sentry/utils';
import type { EmitterSubscription } from 'react-native';
import { DeviceEventEmitter } from 'react-native';

import { NewFrameEventName } from './sentryeventemitter';
import { NewFrameEventName } from './sentryeventemitter';

export type FallBackNewFrameEvent = { newFrameTimestampInSeconds: number, isFallback?: boolean };
export type FallBackNewFrameEvent = { newFrameTimestampInSeconds: number; isFallback?: boolean };
export interface SentryEventEmitterFallback {
/**
* Initializes the fallback event emitter
* This method is synchronous in JS but the event emitter starts asynchronously
* https://github.com/facebook/react-native/blob/d09c02f9e2d468e4d0bde51890e312ae7003a3e6/packages/react-native/React/Modules/RCTEventEmitter.m#L95
* This method is synchronous in JS but the event emitter starts asynchronously.
*/
initAsync: () => void;
closeAllAsync: () => void;
closeAll: () => void;
startListenerAsync: () => void;
}

Expand All @@ -24,12 +23,11 @@ function timeNowNanosecond(): number {
* Creates emitter that allows to listen to UI Frame events when ready.
*/
export function createSentryFallbackEventEmitter(): SentryEventEmitterFallback {
let NativeEmitterCalled: boolean = false;
let NativeEmitterCalled: boolean = false;
let subscription: EmitterSubscription | undefined = undefined;
let isListening = false;
return {
initAsync() {

subscription = DeviceEventEmitter.addListener(NewFrameEventName, () => {
// Avoid noise from pages that we do not want to track.
if (isListening) {
Expand All @@ -56,7 +54,7 @@ export function createSentryFallbackEventEmitter(): SentryEventEmitterFallback {
if (NativeEmitterCalled) {
NativeEmitterCalled = false;
isListening = false;
return; // Native Repplied the bridge with a given timestamp.
return; // Native Replied the bridge with a given timestamp.
}

retries++;
Expand All @@ -65,18 +63,20 @@ export function createSentryFallbackEventEmitter(): SentryEventEmitterFallback {
} else {
logger.log('Native timestamp did not reply in time, using fallback.');
isListening = false;
DeviceEventEmitter.emit(NewFrameEventName, { newFrameTimestampInSeconds: timestampInSeconds, isFallback: true });
DeviceEventEmitter.emit(NewFrameEventName, {
newFrameTimestampInSeconds: timestampInSeconds,
isFallback: true,
});
}
};

// Start the retry process
retryCheck();

});
},

closeAllAsync() {
closeAll() {
subscription?.remove();
}
}
},
};
}

0 comments on commit 1a52620

Please sign in to comment.