MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / runCallback

Function runCallback

packages/core/src/exports.ts:219–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

217 upsertMonitorConfig?: MonitorConfig,
218): T {
219 function runCallback(): T {
220 const checkInId = captureCheckIn({ monitorSlug, status: 'in_progress' }, upsertMonitorConfig);
221 const now = timestampInSeconds();
222
223 function finishCheckIn(status: FinishedCheckIn['status']): void {
224 captureCheckIn({ monitorSlug, status, checkInId, duration: timestampInSeconds() - now });
225 }
226 // Default behavior without isolateTrace
227 let maybePromiseResult: T;
228 try {
229 maybePromiseResult = callback();
230 } catch (e) {
231 finishCheckIn('error');
232 throw e;
233 }
234
235 if (isThenable(maybePromiseResult)) {
236 return maybePromiseResult.then(
237 r => {
238 finishCheckIn('ok');
239 return r;
240 },
241 e => {
242 finishCheckIn('error');
243 throw e;
244 },
245 ) as T;
246 }
247 finishCheckIn('ok');
248
249 return maybePromiseResult;
250 }
251
252 return withIsolationScope(() => (upsertMonitorConfig?.isolateTrace ? startNewTrace(runCallback) : runCallback()));
253}

Callers 1

withMonitorFunction · 0.85

Calls 6

timestampInSecondsFunction · 0.90
isThenableFunction · 0.90
captureCheckInFunction · 0.85
finishCheckInFunction · 0.85
callbackFunction · 0.50
thenMethod · 0.45

Tested by

no test coverage detected