Browse Source

fix(profiling): Use `ProfilerOnRenderCallback` type (#65761)

Scott Cooper 1 year ago
parent
commit
b0983f5c16
1 changed files with 3 additions and 7 deletions
  1. 3 7
      static/app/utils/performanceForSentry/index.tsx

+ 3 - 7
static/app/utils/performanceForSentry/index.tsx

@@ -1,4 +1,4 @@
-import type {ReactNode} from 'react';
+import type {ProfilerOnRenderCallback, ReactNode} from 'react';
 import {Fragment, Profiler, useEffect, useRef} from 'react';
 import type {IdleTransaction} from '@sentry/core';
 import {captureMessage, setExtra, setTag} from '@sentry/react';
@@ -35,11 +35,7 @@ export function getPerformanceTransaction(): IdleTransaction | Transaction | und
 /**
  * Callback for React Profiler https://reactjs.org/docs/profiler.html
  */
-export function onRenderCallback(
-  id: string,
-  phase: 'mount' | 'update',
-  actualDuration: number
-) {
+export const onRenderCallback: ProfilerOnRenderCallback = (id, phase, actualDuration) => {
   try {
     const transaction = getPerformanceTransaction();
     if (transaction && actualDuration > MIN_UPDATE_SPAN_TIME) {
@@ -54,7 +50,7 @@ export function onRenderCallback(
   } catch (_) {
     // Add defensive catch since this wraps all of App
   }
-}
+};
 
 export class PerformanceInteraction {
   private static interactionTransaction: Transaction | null = null;