-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
235 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { ErrorEvent, Event } from '@sentry/types'; | ||
|
||
import type { ReplayContainer } from '../types'; | ||
import { createBreadcrumb } from '../util/createBreadcrumb'; | ||
import { isErrorEvent } from '../util/eventUtils'; | ||
import { addBreadcrumbEvent } from './util/addBreadcrumbEvent'; | ||
|
||
type BeforeSendEventCallback = (event: Event) => void; | ||
|
||
/** | ||
* Returns a listener to be added to `client.on('afterSendErrorEvent, listener)`. | ||
*/ | ||
export function handleBeforeSendEvent(replay: ReplayContainer): BeforeSendEventCallback { | ||
return (event: Event) => { | ||
if (!replay.isEnabled() || !isErrorEvent(event)) { | ||
return; | ||
} | ||
|
||
handleHydrationError(replay, event); | ||
}; | ||
} | ||
|
||
function handleHydrationError(replay: ReplayContainer, event: ErrorEvent): void { | ||
const exceptionValue = event.exception && event.exception.values && event.exception.values[0].value; | ||
if (typeof exceptionValue !== 'string') { | ||
return; | ||
} | ||
|
||
if ( | ||
// Only matches errors in production builds of react-dom | ||
// Example https://reactjs.org/docs/error-decoder.html?invariant=423 | ||
exceptionValue.match(/reactjs\.org\/docs\/error-decoder\.html\?invariant=(418|419|422|423|425)/) || | ||
// Development builds of react-dom | ||
// Example Text: content did not match. Server: "A" Client: "B" | ||
exceptionValue.match(/(hydration|content does not match|did not match)/i) | ||
) { | ||
const breadcrumb = createBreadcrumb({ | ||
category: 'replay.hydrate-error', | ||
}); | ||
addBreadcrumbEvent(replay, breadcrumb); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.