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

Replace axios with undici #283

Open
1 of 4 tasks
benmccann opened this issue Oct 11, 2024 · 1 comment
Open
1 of 4 tasks

Replace axios with undici #283

benmccann opened this issue Oct 11, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@benmccann
Copy link

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

  • All of them
  • posthog-web
  • posthog-node
  • posthog-react-native

Additional context

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

@benmccann benmccann added the enhancement New feature or request label Oct 11, 2024
@marandaneto
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants