The current version of Axios fixes a security issue but has other issues regarding environments like Cloudflare.
Tried to look for a general fix here but the world of polyfilled Fetch is a mess to say the least... In the end, the workaround that made most sense was to simply use fetch if it is defined (which it is in custom environments like Cloudflare workers.
Also added an example project for testing this - managed to recreate the issue and this PR fixes it.
Release info Sub-libraries affected
Bump level
[ ] Major
[x] Minor
[ ] Patch
Libraries affected
[ ] All of them
[ ] posthog-web
[x] posthog-node
[ ] posthog-react-native
Changelog notes
Fixes issues with Axios imports for non-node environments like Cloudflare workers
Uses the globally defined fetch if available, otherwise imports and uses axios as a polyfill
Problem
Hopefully fixes https://github.com/PostHog/posthog-js-lite/issues/127 And also https://github.com/PostHog/posthog-js-lite/issues/129
Changes
The current version of Axios fixes a security issue but has other issues regarding environments like Cloudflare. Tried to look for a general fix here but the world of polyfilled Fetch is a mess to say the least... In the end, the workaround that made most sense was to simply use fetch if it is defined (which it is in custom environments like Cloudflare workers.
Also added an example project for testing this - managed to recreate the issue and this PR fixes it.
Release info Sub-libraries affected
Bump level
Libraries affected
Changelog notes
fetch
if available, otherwise imports and uses axios as a polyfill