MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / handleEntries

Function handleEntries

packages/browser-utils/src/metrics/inp.ts:223–258  ·  view source on GitHub ↗
({ entries }: { entries: PerformanceEntry[] })

Source from the content-addressed store, hash-verified

221 }
222
223 const handleEntries = ({ entries }: { entries: PerformanceEntry[] }): void => {
224 const activeSpan = getActiveSpan();
225 const activeRootSpan = activeSpan && getRootSpan(activeSpan);
226
227 entries.forEach(entry => {
228 if (!isPerformanceEventTiming(entry)) {
229 return;
230 }
231
232 const interactionId = entry.interactionId;
233 if (interactionId == null) {
234 return;
235 }
236
237 // If the interaction was already recorded before, nothing more to do
238 if (INTERACTIONS_SPAN_MAP.has(interactionId)) {
239 return;
240 }
241
242 const elementName = entry.target ? htmlTreeAsString(entry.target) : resolveElementNameFromEntry(entry);
243
244 // We keep max. 10 interactions in the list, then remove the oldest one & clean up
245 if (LAST_INTERACTIONS.length > 10) {
246 const last = LAST_INTERACTIONS.shift() as number;
247 INTERACTIONS_SPAN_MAP.delete(last);
248 }
249
250 // We add the interaction to the list of recorded interactions
251 // and store both the span and element name for this interaction
252 LAST_INTERACTIONS.push(interactionId);
253 INTERACTIONS_SPAN_MAP.set(interactionId, {
254 span: activeRootSpan,
255 elementName,
256 });
257 });
258 };
259
260 addPerformanceInstrumentationHandler('event', handleEntries);
261 addPerformanceInstrumentationHandler('first-input', handleEntries);

Callers

nothing calls this directly

Calls 11

getActiveSpanFunction · 0.90
isPerformanceEventTimingFunction · 0.90
htmlTreeAsStringFunction · 0.90
getRootSpanFunction · 0.85
shiftMethod · 0.80
pushMethod · 0.80
forEachMethod · 0.65
hasMethod · 0.65
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected