Skip to content
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

fix(replay): Capture JSON XHR response bodies #9623

Merged
merged 3 commits into from Dec 4, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Nov 21, 2023

This is stupid, now that I figured it out. Basically, if you set xhr.responseType = 'json', it will force xhr.response to be a POJO - which we can't parse right now.

We now handle this case specifically.

This also adds a new UNPARSEABLE_BODY_TYPE meta warning if we are not getting a body because it is not matching any of the known/parsed types.

Closes #9339

Copy link
Contributor

github-actions bot commented Nov 21, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 65.98 KB (+0.19% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 59.56 KB (+0.17% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.12 KB (0%)
@sentry/browser - Webpack (gzipped) 21.38 KB (-0.01% 🔽)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 62.93 KB (+0.35% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 29.61 KB (+0.28% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 21.68 KB (+0.37% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 198.2 KB (+0.38% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 89.63 KB (+0.35% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 64.61 KB (+0.5% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 32.27 KB (+0.18% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 66.36 KB (+0.17% 🔺)
@sentry/react - Webpack (gzipped) 21.42 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 83.07 KB (+0.14% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.21 KB (0%)
@sentry-internal/feedback - Webpack (gzipped) 16.17 KB (-0.13% 🔽)
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 74.62 KB (added)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 29.72 KB (added)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 71.18 KB (added)


__DEBUG_BUILD__ && logger.info('[Replay] Skipping network body because of body type', body);

return [undefined];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a NetworkMetaWarning for this case as well

body: XMLHttpRequest['response'],
responseType: XMLHttpRequest['responseType'],
): [string | undefined, NetworkMetaWarning?] {
logger.log(body, responseType, typeof body);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, oops!

Base automatically changed from fn/replay-network-body-error to develop November 22, 2023 08:43
@mydea mydea marked this pull request as ready for review November 22, 2023 08:45
@mydea
Copy link
Member Author

mydea commented Nov 22, 2023

OK, so I updated this to:

  1. add another new "UNPARSEABLE_BODY_TYPE" warning
  2. Add some more tests & actually handle empty bodies specifically

@mydea mydea requested a review from billyvg November 23, 2023 09:24
@mydea mydea merged commit 6a382a9 into develop Dec 4, 2023
86 checks passed
@mydea mydea deleted the fn/xhr-response-body branch December 4, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request getting filtered by Replay integration.
2 participants