Our app is loaded into tickets sidebar, and among other things it has to get the ticket info and the contact info.
It’s done like this typically:
async get_contact_info() {
const data = await this.client.data.get("contact")
let contactName = data.contact.name
// etc.
}
Issue is that in about 35% of the time, this call to client.data.get("contact") fails in the context of an existing ticket and an existing contact (in new tickets or new emails that would be expected to have no contact info yet), and there is no reason I can see.
When we proceed to tests, it always works, but in our customers accounts, we get 35% of the time empty values here… I am sorry as I don’t have the error message to share here.
My question is: is there any possible expected reason the client.data.get("contact") would not return anything? like for example the current signed in agent authorizations, or some trick like that? The docs are not mentioning anything about any possible limitation here…
Sure we can try this, however we will need to republish it to see how it goes over time.
Just to make an additional check, about what you have in mind with this solution: do you think the fix could come from this specific part of your suggestion?
I am asking you this because we already do the client = await app.initialized(); part, and we can verify this client instance is valid as we can get the ticket details from it, it’s only the contact part that is missing (and missing randomly).
So question is: do you think there is a good chance the client.data.get(“contact”) will run more reliably if we wait for the onreadystatechange “complete” dom event?
Can you please share the exact error message from your browser console?
If the client object is not available when the code client.data.get("contact") is executed, then the contact payload will not be accessible. This usually happens when the app is rendered before the Freshdesk client is fully initialized.
I recommend adding a check to ensure the client is ready before calling client.data.get("contact"). Without seeing the actual error, I can only make general suggestions like this. Once you share the error message, I can help you debug it more accurately.
I totally understand it would be much better to have the error message, but it is actually only randomly happening to users. The only informations we can be certain are that the client is ready because it is used successfully prior to call the “contact”. For example client.data.get("ticket") is called before, and always works.
We tried to publish a new version with a backoff auto-retry mechanism - we will see if this can solve the issue.