segmentio / analytics-node

The hassle-free way to integrate analytics into any node application.

Home Page:https://segment.com/libraries/node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chrome extension background service worker + analytics-node = fail

rony-arnac opened this issue · comments

Hey!

there's an issue with using axios in the background service of chrome extensions with manifest v3.
the adapter isn't configured and axios requests fail.

adapter is not a function

is there a workaround to fix this issue?

I tried defining axios.defaults.adapter but it didn't take -- adapter is still undefined.

I have a workaround:

import fetchAdapter from '@vespaiach/axios-fetch-adapter';
...
...
analyticsProvider = new AnalyticsProvider(apiKey);
...
...
(analyticsProvider as any).axiosInstance.defaults.adapter = fetchAdapter;

https://github.com/vespaiach/axios-fetch-adapter