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

Cannot use Jitsu in a NextJs MIddleware #1103

Closed
thibaultleouay opened this issue May 6, 2024 · 2 comments
Closed

Cannot use Jitsu in a NextJs MIddleware #1103

thibaultleouay opened this issue May 6, 2024 · 2 comments

Comments

@thibaultleouay
Copy link

thibaultleouay commented May 6, 2024

We are using Jitsu to track analytics

But because of this it cannot be used in middleware

Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

The error was caused by importing '@jitsu/js/dist/jitsu.es.js' in   in '../../packages/analytics/src/index.ts' 

https://github.com/jitsucom/jitsu/blob/70fdf6a5000640ba46732331f65bea46e165e153/libs/jitsu-js/src/destination-plugins/tag.ts#L59C1-L73C14

@vklimontovich
Copy link
Contributor

You might want to look at next-collect. It works through middleware, and Jitsu is supported. Meanwhile, I'll check if the lib works directly, and apply the fix if necessary. The piece of code in question is never executed on in server environment

@vklimontovich
Copy link
Contributor

Upgrade to @jitsu/js 1.9.3 should solve the issue!

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

No branches or pull requests

2 participants