PostHog / posthog-js-lite

Reimplementation of posthog-js to be as light and modular as possible.
https://posthog.com/docs/libraries
MIT License
69 stars 36 forks source link

Replace `axios` with `undici` #283

Open benmccann opened 1 month ago

benmccann commented 1 month ago

Is your feature request related to a problem?

axios is a somewhat weighty dependency and doesn't adhere to the fetch standard

https://npmgraph.js.org/?q=axios

Describe the solution you'd like

Switch to undici. undici is the official fetch implementation bundled with Node.js. This should be an easy change as fetch is already used where available: https://github.com/PostHog/posthog-js-lite/blob/4fe4eb2aa5da5ec57f39481e57a712c6992991b4/posthog-node/src/fetch.ts#L17C10-L17C15

It also would make an eventual migration to Node's built-in fetch easy as you could simply drop the import and use the one from Node

Describe alternatives you've considered

It would be nice to use fetch directly from Node. However, doing so requires Node 18 and this library still supports Node 15. Could we drop support for EOL versions of Node?

Related sub-libraries

Additional context

Thank you for your feature request – we love each and every one!

marandaneto commented 1 month ago

@benmccann thanks for the suggestion. You can replace the fetch function to not use the global fetch nor axios by setting this function if you wish for now.