Hello
I'm using the Zendesk Web Widget in Web for chat and implemented the authentication as described in this guide:
https://developer.zendesk.com/api-reference/widget-messaging/web/authentication/
This works but I want to be able to track if there are errors in the loginUser callback, so I can monitor this and also prevent the chat widget from opening if that happened.
My code looks something like this:
zE("messenger", "loginUser", function (callback) {
const jwtToken = generateJWT()callback(jwtToken)
})
If my `generateJWT` function produces an invalid token I can see in the console that the Zendesk script is making a POST request to
https://<subdomain>.zendesk.com/sc/sdk/v2/apps/......../login
And this results in a 401 error. But I don't have any way to know this happened and take an action when it does.
I tried globally intercepting `fetch` but I can't see that call in my interceptor, so I guess you don't use fetch internally.
How can I intercept these calls and react to 40X errors? Is there a less hacky way to do this?
Thank you