posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

React SDK - Session Recorder - Original fetch args is modified causing application to crash

Open samuellawerentz opened this issue 1 year ago • 18 comments

Bug description

We use the React SDK to initialize posthog. We have a fetch interceptor which modifies the request before the API call is made.

After integrating with posthog, the fetch API is already modified and the args are not passed properly, because of this our interceptor is not able to function properly. The issue is with the recorder.js file.

TLDR; you are modifying the original fetch and not forwarding all the args in this format ...args . And hence our fetch interceptor which expects two args, receive only one causing the app to crash.

How to reproduce

  1. Load react posthog
  2. modify the fetch API like window.fetch = ...
  3. App crashes

Please let me know, how to resolve this or what is the next step.

I'm attaching a screenshot of the recorder.js file for reference, where you are overriding the default fetch. FreezeFrame 2024-07-16 at 9 29 28 PM

I have already sent an email, but was not able to track it.

Debug info

No response

samuellawerentz avatar Jul 29 '24 16:07 samuellawerentz