alc-aaron - Hi, is there a way to capture and r...
# dev-help
a
Hi, is there a way to capture and run logic when the following is emitted from the config?
loginFailedMessage
. I am trying to debug how my application is getting into this state where the FullAppEmbed is replaced with the text provided in the config.
a
message has been deleted
a
I was able to see in the SDK lib that this happens from the Logout callback I believe. If someone could confirm for me though.
p
cc: @Ruchi Anand
r
Hi @alc-aaron When authentication fails, SDK emits an AuthStatus.FAILURE event with the failureType. That failure is what causes the FullAppEmbed to be replaced with the loginFailedMessage UI. You can capture it by listening to the auth event emitter returned from init():
Copy code
const authEmitter = init({ ... });

authEmitter.on(AuthStatus.FAILURE, (payload) => {
  console.error("Auth failure", payload);
});
Ref : https://developers.thoughtspot.com/docs/Enumeration_AuthStatus#_success Let me know if that’s what you were looking for, or if you need more details.
a
I was looking at the SDK code and it appears that we emit the FAILURE and EXPIRY events even if it successfully recovers when getting a token? If this is true then should we have logic for retrying to fetch the sdk-token manually if that event is emitted or rely on the SDK to resolve that?
r
Could you tell us which authType you are using?
a
We are using cookieless authentication
The following code from the SDK: https://github.com/thoughtspot/visual-embed-sdk/blob/main/src/embed/ts-embed.ts#L563 It appears the SDK handles it internally and will always notify of Expiration regardless of if it is able to handle this expiration internally with success.
r
Yes, that is expected behavior. When a token expires, the SDK handles token expiration and regeneration internally. The EXPIRY / FAILURE events are emitted for notification purposes, even if the SDK successfully refreshes the token. No manual retry logic is needed on your side, you can rely on the SDK to resolve it automatically.