-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding authentication check to fetch new token before endchat #390
base: main
Are you sure you want to change the base?
Adding authentication check to fetch new token before endchat #390
Conversation
@@ -19,6 +19,9 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager"; | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
const prepareEndChat = async (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any) => { | |||
try { | |||
//Get new auth token again if chat continued for longer time, otherwise chatsdk throws 401 error for auth chats | |||
await handleAuthenticationIfEnabled(props, chatSDK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update CHANGE_LOG please
@@ -19,6 +19,9 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager"; | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
const prepareEndChat = async (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any) => { | |||
try { | |||
//Get new auth token again if chat continued for longer time, otherwise chatsdk throws 401 error for auth chats | |||
await handleAuthenticationIfEnabled(props, chatSDK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If token is not expired, will this hurt performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and No,
Yes - because it's making an additional call to get token.
No - because chat is already ending at this stage.
Should we allow this PR to fix the breaking functionality and have another tracking item for perf improvement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reviewing the code again, if performance is a problem, then instead of introducing a new handleAuthenticationIfEnabled
, maybe we should move the existing one from endChat
to this method in prepareEndChat
?
Thank you for your contribution. Before submitting this PR, please include:
Id of the task, bug, story or other reference.
Issue 3651972: [DFC] - Chat Survey return rate discrepancies in Consumer
Incident 436007411 : Post chat survey didn't load for long ongoing chats
Description
Include a description of the problem to be solved
Issue: The chat widget fails to return post-chat surveys for long-running chats, which has been reported by several SxG organization partners. This has resulted in a significant drop of approximately 25% in receiving feedback rates.
Investigation Findings: Upon investigating the issue, we identified that the problem is due to 401 unauthorized error returned from the
prepareEndChat
function.Consistency: The issue appears to be consistently reproducible in the context of long-running chats.
Solution Proposed
Detail what is the solution proposed, include links to design document if required or any other document required to support the solution
To address this issue, the recommendation is to implement a solution that ensures the
chatSDK
has a valid authentication token before executing the remaining code inprepareEndChat
function, in case of authenticated chats. The included fix will get a new token and allowchatSDK.getConversationDetails()
to run successfully, without encountering unauthorized errors, and subsequently, the survey can be rendered.Acceptance criteria
Define what are the conditions to consider the PR has achieved the intended goal
Test cases and evidence
Include what tests cases were considered, any evidence of testing for future references, to identify any corner cases, etc
Sanity Tests
A11y
Not required, as there is no change to UX.
Please provide justification if any of the validations has been skipped.