Open johnboxall opened 5 months ago
This would also be useful for general request/response interception use cases (headers, logging, etc).
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
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.