mixpanel / mixpanel-node

A node.js API for mixpanel
http://www.mixpanel.com
MIT License
476 stars 161 forks source link

Is there anyway to get this to work in the Next.js edge environment? #215

Open jmcannon opened 1 year ago

jmcannon commented 1 year ago

On init, it throws an error Error: The edge runtime does not support Node.js 'http' module.

tdumitrescu commented 1 year ago

Judging by the restrictions listed here: https://nextjs.org/docs/api-reference/edge-runtime#unsupported-apis it would probably take a ton of work to make this lib usable in that environment (no require statements, all deps in node_modules must use ES modules and not call any native Node.js APIs).

jmcannon commented 1 year ago

Yes, I think you're right. I just fell back to the default Next serverless environment.

stephenasuncionDEV commented 1 year ago

Yes, I think you're right. I just feel back to the default Next serverless environment.

As an alternative, you can just call via mixpanel's HTTP API using fetch in the edge.

GorvGoyl commented 10 months ago

looking for same. If it's too much work, would be easier for you guys to port mixpanel-js library for edge?

tdumitrescu commented 9 months ago

would be easier for you guys to port mixpanel-js library for edge?

That seems like it would also be a big project, since the browser lib relies on a lot of browser APIs to function correctly.

astanciu commented 3 months ago

It's a shame there's been no movement on this in a year. Making the lib edge ready shouldn't be that hard. Any plans to do this?

tdumitrescu commented 3 months ago

No, there are no plans to. The right move is probably to use whichever native HTTP APIs the Next edge environment offers you.

filipwiniarski commented 1 month ago

I'm surprised this is not a high-priority issue. Mixpanel is losing big time in my opinion. A lot of front-end projects are moving to Edge for all the benefits. Serving from servers is odd in 2024. I'd choose Mixpanel for a couple of projects, but writing your own integration is too much of a commitment, especially for small teams.