algolia / search-insights.js

Library for reporting click, conversion and view metrics using the Algolia Insights API
MIT License
53 stars 18 forks source link

feat: introduce native fetch fallback when http-module is not supported #515

Closed Jeffrey-Zutt closed 1 year ago

Jeffrey-Zutt commented 1 year ago

First of all, thank you for maintaining the great library!

As described in issue #444, importing search-insights on an 'edge-runtime' results in the following error: [Error: Could not find a supported HTTP request client in this environment.]

The edge runtime however, does support fetch (and is added to node per version 18).

This PR adds a fallback to the native fetch method when nodeHttpRequest is not available.

Please let me know if you'd like to see anything changed :-).

Kind regards.

codesandbox-ci[bot] commented 1 year ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e948f84998bf7935c4e6fc74a58165a46cb88558:

Sandbox Source
Vanilla Configuration