11import type { Span , StartSpanOptions } from '@sentry/core' ;
2- import { fill , getActiveSpan , getSpanDescendants , logger , SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN , SPAN_STATUS_ERROR , SPAN_STATUS_OK , spanToJSON , startInactiveSpan , uuid4 } from '@sentry/core' ;
2+ import { fill , getActiveSpan , getSpanDescendants , logger , SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN , SPAN_STATUS_ERROR , SPAN_STATUS_OK , spanToJSON , startInactiveSpan } from '@sentry/core' ;
33import * as React from 'react' ;
4+ import { useState } from 'react' ;
45
56import { isTurboModuleEnabled } from '../utils/environment' ;
67import { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY , SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from './origin' ;
78import { getRNSentryOnDrawReporter , nativeComponentExists } from './timetodisplaynative' ;
8- import type { RNSentryOnDrawNextFrameEvent } from './timetodisplaynative.types' ;
99import { setSpanDurationAsMeasurement , setSpanDurationAsMeasurementOnSpan } from './utils' ;
10- import { useState } from 'react' ;
1110
1211let nativeComponentMissingLogged = false ;
1312
@@ -288,22 +287,28 @@ function updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDispl
288287 setSpanDurationAsMeasurement ( 'time_to_full_display' , span ) ;
289288}
290289
290+ /**
291+ * Creates a new TimeToFullDisplay component which triggers the full display recording every time the component is focused.
292+ */
291293export function createTimeToFullDisplay ( {
292294 useFocusEffect,
293295} : {
294296 /**
295297 * `@react-navigation/native` useFocusEffect hook.
296298 */
297299 useFocusEffect : ( callback : ( ) => void ) => void
298- } ) {
300+ } ) : React . ComponentType < TimeToDisplayProps > {
299301 return createTimeToDisplay ( { useFocusEffect, Component : TimeToFullDisplay } ) ;
300302}
301303
304+ /**
305+ * Creates a new TimeToInitialDisplay component which triggers the initial display recording every time the component is focused.
306+ */
302307export function createTimeToInitialDisplay ( {
303308 useFocusEffect,
304309} : {
305310 useFocusEffect : ( callback : ( ) => void ) => void
306- } ) {
311+ } ) : React . ComponentType < TimeToDisplayProps > {
307312 return createTimeToDisplay ( { useFocusEffect, Component : TimeToInitialDisplay } ) ;
308313}
309314
@@ -316,8 +321,8 @@ function createTimeToDisplay({
316321 */
317322 useFocusEffect : ( callback : ( ) => void ) => void ;
318323 Component : typeof TimeToFullDisplay | typeof TimeToInitialDisplay ;
319- } ) {
320- return ( props : TimeToDisplayProps ) => {
324+ } ) : React . ComponentType < TimeToDisplayProps > {
325+ const TimeToDisplayWrapper = ( props : TimeToDisplayProps ) : React . ReactElement => {
321326 const [ focused , setFocused ] = useState ( false ) ;
322327
323328 useFocusEffect ( ( ) => {
@@ -329,4 +334,7 @@ function createTimeToDisplay({
329334
330335 return < Component { ...props } record = { focused && props . record } /> ;
331336 } ;
337+
338+ TimeToDisplayWrapper . displayName = `TimeToDisplayWrapper` ;
339+ return TimeToDisplayWrapper ;
332340}
0 commit comments