Calling addEvent returns error UNAUTHORIZED_API_CALL

We are using Tawk Chat widget on our website which is a React application. If the visitor is authorized on the website we login the visitor in the widget. We have specific custom events that are triggered on different actions and we want to log them in the chat with addEvent() method. The problem is that addEvent() returns an UNAUTHORIZED_API_CALL error. There are some occasions in our dev environment that the error is not thrown and the event goes through and is correctly logged. But this never worked for out test or production environments. Are there any restrictions on the usage of addEvent? Our current setup of the widget is not restricted to domain.