MCPcopy Index your code
hub / github.com/callstack/agent-device / withDiagnosticTimer

Function withDiagnosticTimer

src/utils/diagnostics.ts:146–173  ·  view source on GitHub ↗
(
  phase: string,
  fn: () => Promise<T> | T,
  data?: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

144}
145
146export async function withDiagnosticTimer<T>(
147 phase: string,
148 fn: () => Promise<T> | T,
149 data?: Record<string, unknown>,
150): Promise<T> {
151 const start = Date.now();
152 try {
153 const result = await fn();
154 emitDiagnostic({
155 level: 'info',
156 phase,
157 durationMs: Date.now() - start,
158 data,
159 });
160 return result;
161 } catch (error) {
162 emitDiagnostic({
163 level: 'error',
164 phase,
165 durationMs: Date.now() - start,
166 data: {
167 ...(data ?? {}),
168 error: error instanceof Error ? error.message : String(error),
169 },
170 });
171 throw error;
172 }
173}
174
175export function flushDiagnosticsToSessionFile(options: { force?: boolean } = {}): string | null {
176 const scope = diagnosticsStorage.getStore();

Callers 15

resolveTargetDeviceFunction · 0.90
dispatchCommandFunction · 0.90
createLinuxInteractorFunction · 0.90
createAndroidInteractorFunction · 0.90
createWebInteractorFunction · 0.90
sendToDaemonFunction · 0.90
finalizeRecordingOverlayFunction · 0.90

Calls 1

emitDiagnosticFunction · 0.85

Tested by

no test coverage detected