({ entries }: { entries: PerformanceEntry[] })
| 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); |
nothing calls this directly
no test coverage detected