-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(browser): Use proxy for XHR instrumentation #5843
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
feat(browser): Use proxy for XHR instrumentation #5843
Conversation
But I stuck in the testing. I am newbee about unit testing. I tried install dependancy both in the root dir and the package/browser. But after I ran yarn run v1.22.19
$ run-s test:unit
$ jest
FAIL test/unit/transports/xhr.test.ts
● Test suite failed to run
test/unit/transports/xhr.test.ts:1:42 - error TS2307: Cannot find module '@sentry/types'.
1 import { EventEnvelope, EventItem } from '@sentry/types';
~~~~~~~~~~~~~~~
test/unit/transports/xhr.test.ts:2:51 - error TS2307: Cannot find module '@sentry/utils'.
2 import { createEnvelope, serializeEnvelope } from '@sentry/utils';
~~~~~~~~~~~~~~~
test/unit/transports/xhr.test.ts:9:3 - error TS2322: Type '{ url: string; recordDroppedEvent: () => undefined; textEncoder: TextEncoder; }' is not assignable to type 'BrowserTransportOptions'.
Object literal may only specify known properties, and 'url' does not exist in type 'BrowserTransportOptions'.
9 url: 'https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/unit/transports/xhr.test.ts:67:85 - error TS2339: Property 'url' does not exist on type 'BrowserTransportOptions'.
67 expect(xhrMock.open).toHaveBeenCalledWith('POST', DEFAULT_XHR_TRANSPORT_OPTIONS.url); I have no idea how to fix these and let the test go on. PLEASE HELP. |
Hi, thanks for contributing! Can you summarize in the PR description what this PR is doing? Thank you! |
@lforst updated. |
Thank you! We will take a look and see if we can help with the tests! |
Hi, I am deeply sorry for taking so long to get back to you. I took some time to think about this PR - mainly about the bundle size impact vs. actual gain. For now, I've decided that it's not worth the effort + bundle size impact to go through with this, especially since newer versions of axios already work. Some additional reasons supporting this decision:
Anyhow, I still want to thank you for your contribution. If you still want to see this go through, I recommend opening a feature request issue and if enough people want to see something similar we might reconsider. |
the current implement of instrumentXHR can not cover:
axios
, in lower version,onreadystatechange = function(){...}
will cover theonreadystatechange
function of sentry causing the problem of Bug: no xhr breadcrumbs for error in onreadystatechange #1333 because of prototype chain mechanismonreadystatechange
function.to solve these two problem, I commit this pr.