Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(replay): use live click attributes in breadcrumbs#20262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
e7747b346af45618f89cce9ec66d87e886be5bbdb0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,17 @@ | ||
| import { EventType } from '@sentry-internal/rrweb'; | ||
| import { EventType, IncrementalSource, record } from '@sentry-internal/rrweb'; | ||
| import { NodeType } from '@sentry-internal/rrweb-snapshot'; | ||
| import { updateClickDetectorForRecordingEvent } from '../coreHandlers/handleClick'; | ||
| import { DEBUG_BUILD } from '../debug-build'; | ||
| import { saveSession } from '../session/saveSession'; | ||
| import type { RecordingEvent, ReplayContainer, ReplayOptionFrameEvent } from '../types'; | ||
| import { addEventSync } from './addEvent'; | ||
| import { debug } from './logger'; | ||
| type MutationAttributeData = { | ||
| id: number; | ||
| attributes: Record<string, string | number | true | null>; | ||
| }; | ||
| type RecordingEmitCallback = (event: RecordingEvent, isCheckout?: boolean) => void; | ||
| /** | ||
| @@ -29,6 +35,8 @@ export function getHandleRecordingEmit(replay: ReplayContainer): RecordingEmitCa | ||
| const isCheckout = _isCheckout || !hadFirstEvent; | ||
| hadFirstEvent = true; | ||
| syncMirrorAttributesFromMutationEvent(event); | ||
| if (replay.clickDetector) { | ||
| updateClickDetectorForRecordingEvent(replay.clickDetector, event); | ||
| } | ||
| @@ -112,6 +120,40 @@ export function getHandleRecordingEmit(replay: ReplayContainer): RecordingEmitCa | ||
| }; | ||
| } | ||
| export function syncMirrorAttributesFromMutationEvent(event: RecordingEvent): void { | ||
| const data = event.data; | ||
| if ( | ||
| event.type !== EventType.IncrementalSnapshot || | ||
| !data || | ||
| typeof data !== 'object' || | ||
| !('source' in data) || | ||
| data.source !== IncrementalSource.Mutation || | ||
| !('attributes' in data) || | ||
| !Array.isArray(data.attributes) | ||
logaretm marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ) { | ||
| return; | ||
| } | ||
| for (const mutation of data.attributes as MutationAttributeData[]) { | ||
| const node = record.mirror.getNode(mutation.id); | ||
| const meta = node && record.mirror.getMeta(node); | ||
| if (meta?.type !== NodeType.Element) { | ||
| continue; | ||
| } | ||
| for (const [attributeName, value] of Object.entries(mutation.attributes)) { | ||
| if (value === null) { | ||
| // oxlint-disable-next-line typescript/no-dynamic-delete | ||
| delete meta.attributes[attributeName]; | ||
| } else { | ||
| meta.attributes[attributeName] = value; | ||
| } | ||
| } | ||
sentry[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| } | ||
| /** | ||
| * Exported for tests | ||
| */ | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.