unsourced-dev / insights-js

The javascript client for Getinsights
https://getinsights.io
MIT License
26 stars 2 forks source link

'Error -Already initialized' on NextJS #8

Closed devphenom closed 2 years ago

devphenom commented 2 years ago

Hi, I receive Error - Already initialized whenever I initialized insights-js on my next-js application. How can I solve this? I just moved my application from create-react-app where it does work properly to next-js.

My _app.js


import {init, trackPages} from 'insights-js'

 init(myKey);
 trackPages();

Full console error:

Error: Already initialized!
    at Object.init (/node_modules/insights-js/dist/insights-js.cjs.js:366:15)
    at eval (webpack-internal:///./pages/_app.tsx:17:13)
    at Object../pages/_app.tsx (/.next/server/pages/_app.js:231:1)
    at __webpack_require__ (/.next/server/webpack-runtime.js:33:42)
    at __webpack_exec__ (/next/server/pages/_app.js:701:39)
    at /.next/server/pages/_app.js:702:28
    at Object.<anonymous> (/.next/server/pages/_app.js:705:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
error - Error: Already initialized!
Error: Already initialized!
    at Object.init (/node_modules/insights-js/dist/insights-js.cjs.js:366:15)
    at eval (webpack-internal:///./pages/_app.tsx:17:13)
    at Object../pages/_app.tsx (/.next/server/pages/_app.js:231:1)
    at __webpack_require__ (/.next/server/webpack-runtime.js:33:42)
    at __webpack_exec__ (/.next/server/pages/_app.js:701:39)
    at /.next/server/pages/_app.js:702:28
    at Object.<anonymous> (/.next/server/pages/_app.js:705:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
Mytrill commented 2 years ago

Hi there, sorry for the long delay.. I just published 1.2.11 which will fix this issue. Could you update any try again?

devphenom commented 2 years ago

The issue is now fixed with the new update.

Thanks