Sometimes register event twice in next.js
nnfans opened this issue · 4 comments
Sometimes the event that triggered appears twice in the clevertap activity tab
Screen.Recording.2022-12-02.at.10.05.57.mov
Step to reproduce
- clone https://github.com/nnfans/clevertap-repro
yarn
- create
.env.local
- add
NEXT_PUBLIC_CT_ID=
and fille with clevertap id yarn dev
Why don't we change the implementation to use fetch api or any http request library instead of appending script
tag inside head
tag and place the query inside it
clevertap-web-sdk/src/util/requestDispatcher.js
Lines 66 to 78 in 7680813
Hey @nnfans not from the clever tap team, but can it be because of the fact that you are using React 18 and use effect having double runs?
Maybe try to debug mode and check if requests are going twice.
hi @abhu-A-J, you can reproduce it. I already disable the restrict mode that make useEffect fired twice
https://github.com/nnfans/clevertap-repro/blob/main/next.config.js