-
Notifications
You must be signed in to change notification settings - Fork 125
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: XHR req method capture #1527
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -280,6 +280,62 @@ describe('Session recording', () => { | |||
) | |||
}) | |||
}) | |||
|
|||
it('it captures XHR method correctly', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests have a lot of duplication now, but I want to get this fix out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is pretty convincing, how would it have failed before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method = POST assertion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep... it was always GET before (or at least overwhelmingly GET I didn't check which)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and for clarity I validated the test failed before the change 😊
@@ -386,7 +386,7 @@ function prepareRequest({ | |||
timeOrigin, | |||
timestamp, | |||
method: method, | |||
initiatorType: entry ? (entry.initiatorType as InitiatorType) : initiatorType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flips the choice here... if we're providing an initiator we should use it in preference to the detected one
they should always match
@@ -309,7 +309,7 @@ function initXhrObserver(cb: networkCallback, win: IWindow, options: Required<Ne | |||
.then((entry) => { | |||
const requests = prepareRequest({ | |||
entry, | |||
method: req.method, | |||
method: method, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the fix... the method is provided to the XHR function when it is called so we should use it
Size Change: +21 B (0%) Total Size: 3.11 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're deep within code I haven't looked at before so with that caveat:
- The bug itself makes sense
- The fix for it makes sense
- The test looks good
👍 👍 👍
We were using
req.method
before the request was used and so XHR was always captured as "GET"