Skip to content

Commit

Permalink
feat(replay): Add url to replay hydration error breadcrumb type (#12521)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan953 committed Jun 18, 2024
1 parent a08335d commit 2c12022
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ErrorEvent, Event } from '@sentry/types';
import { getLocationHref } from '@sentry/utils';

import type { ReplayContainer } from '../types';
import { createBreadcrumb } from '../util/createBreadcrumb';
Expand Down Expand Up @@ -41,6 +42,9 @@ function handleHydrationError(replay: ReplayContainer, event: ErrorEvent): void
) {
const breadcrumb = createBreadcrumb({
category: 'replay.hydrate-error',
data: {
url: getLocationHref(),
},
});
addBreadcrumbEvent(replay, breadcrumb);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/replay-internal/src/types/replayFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ interface ReplayMutationFrame extends ReplayBaseBreadcrumbFrame {
data: ReplayMutationFrameData;
}

interface ReplayHydrationErrorFrameData {
url: string;
}
interface ReplayHydrationErrorFrame extends ReplayBaseBreadcrumbFrame {
category: 'replay.hydrate-error';
data: ReplayHydrationErrorFrameData;
}

interface ReplayKeyboardEventFrameData extends ReplayBaseDomFrameData {
metaKey: boolean;
shiftKey: boolean;
Expand Down Expand Up @@ -146,6 +154,7 @@ export type ReplayBreadcrumbFrame =
| ReplaySlowClickFrame
| ReplayMultiClickFrame
| ReplayMutationFrame
| ReplayHydrationErrorFrame
| ReplayFeedbackFrame
| ReplayBaseBreadcrumbFrame;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('Integration | coreHandlers | handleBeforeSendEvent', () => {
data: {
payload: {
category: 'replay.hydrate-error',
data: { url: 'http://localhost:3000/' },
timestamp: expect.any(Number),
type: 'default',
},
Expand Down Expand Up @@ -71,6 +72,7 @@ describe('Integration | coreHandlers | handleBeforeSendEvent', () => {
data: {
payload: {
category: 'replay.hydrate-error',
data: { url: 'http://localhost:3000/' },
timestamp: expect.any(Number),
type: 'default',
},
Expand Down

0 comments on commit 2c12022

Please sign in to comment.