diff --git a/packages/session-replay-browser/src/session-replay.ts b/packages/session-replay-browser/src/session-replay.ts index 175a25780..2f369f763 100644 --- a/packages/session-replay-browser/src/session-replay.ts +++ b/packages/session-replay-browser/src/session-replay.ts @@ -633,8 +633,10 @@ export class SessionReplay implements AmplitudeSessionReplay { errorHandler: (error: unknown) => { const typedError = error as Error & { _external_?: boolean }; - // styled-components relies on this error being thrown and bubbled up, rrweb is otherwise suppressing it - if (typedError.message.includes('insertRule') && typedError.message.includes('CSSStyleSheet')) { + // CSS-in-JS libraries such as styled-components and stitches rely on this error being thrown and + // bubbled up, rrweb is otherwise suppressing it. The goal is to rethrow errors from + // `CSSStyleSheet.insertRule` and `CSSGroupingRule.insertRule`. + if (typedError.stack?.includes('insertRule')) { throw typedError; }