Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sarojkpr
Copy link
Contributor

@sarojkpr sarojkpr commented Nov 6, 2023

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 in prepareEndChat function, in case of authenticated chats. The included fix will get a new token and allow chatSDK.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

  1. Ensure unauthenticated chats is working as expected.
  2. Ensure authenitcated chats are working as expected without causing any regression
  3. Ensure post chat survey is rendered successfully even for long running chats.

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

  • You have tested all changes in Popout mode
  • You have tested all changes in cross browsers i.e Edge, Chrome, Firefox, Safari and mobile devices(iOS and Android)
  • Your changes are included in the CHANGELOG

A11y

Please provide justification if any of the validations has been skipped.

@sarojkpr sarojkpr requested a review from a team as a code owner November 6, 2023 19:58
@@ -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);
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants