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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions chat-widget/src/components/livechatwidget/common/endChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

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?


// Use Case: If call is ongoing, end the call by simulating end call button click
endVoiceVideoCallIfOngoing(chatSDK, dispatch);

Expand Down