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

[Feature] Allow providing your own implementation of fetch #159

Open
johnboxall opened this issue Jun 6, 2024 · 2 comments
Open

[Feature] Allow providing your own implementation of fetch #159

johnboxall opened this issue Jun 6, 2024 · 2 comments
Labels
ack Acknowledged

Comments

@johnboxall
Copy link
Contributor

Application Performance Monitoring frameworks often want to spy on HTTP requests being made.

To to this, they typically need to monkey patch / override fetch.

Currently its tricky to do this:

https://sfcc-unofficial.slack.com/archives/C01AWMT7GSZ/p1717714138887519

Ideally, we'd provide some way of providing fetch implementation, potentially as an additional param when creating an API client.

@clavery
Copy link

clavery commented Jun 7, 2024

This would also be useful for general request/response interception use cases (headers, logging, etc).

@opepin
Copy link

opepin commented Jun 8, 2024

followed @clavery suggestion

var myFetch: typeof globalObject.fetch; return function fetch() { if (!myFetch) { myFetch = globalObject.fetch; } // @ts-ignore return myFetch.apply(globalObject, arguments) }

Fetched can is now instrumented as expected and addressees missing requests https://docs.logrocket.com/docs/troubleshooting-sessions#network-requests-are-missing-or-not-being-recorded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Acknowledged
Projects
None yet
Development

No branches or pull requests

4 participants