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

feat(cc-sdk): added-device-type-for-agent-config #4006

Merged
merged 5 commits into from
Nov 27, 2024

Conversation

adhmenon
Copy link
Contributor

@adhmenon adhmenon commented Nov 26, 2024

COMPLETES #< SPARK-586282 >

This pull request addresses

  • Currently, as a part of the CC SDK, we are only updating the agent config isAgentLoggedIn flag.
  • As a result, whenever we are doing a relogin or a register (ie say, we reload the webpage), we only get the login state and not the device type the user has logged in with.
  • Further, we were not calling the mobius re-registration on browser relogin (this would cause problems later on).

by making the following changes

  • We now obtain the device type object from the response data of the reLogin method.
  • Using this, we populate the config data.
  • We also check for BROWSER device type and if it is present, we initiate a re-registration of WebexCallingService, ie create the lines again and send request to mobius,

Vidcast showing EXTENSION device type

https://app.vidcast.io/share/c9ae1f0e-53fc-4c85-ae5b-395cb5b163d3

Vidcast showing BROWSER device type

https://app.vidcast.io/share/b5142b97-df0a-46cc-a814-9ab2554d6243

Vidcast showing internet disconnect flow (same behaviour as before, not broken anything)

https://app.vidcast.io/share/3201f886-2536-4021-a366-6d65fee7bd93

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • Tested the device type of EXTENSION and reloaded the page to see if relogin worked
  • Tested the device type of BROWSER and reloaded the page to see if relogin worked and mobius registration has happened
  • Tested the device type of AGENT_DN and reloaded the page to see if dial number shows up
  • Tested the scenario when we get disconnected and we need to relogin. Observed that everything was working fine including agent status setting up.
  • Tested the scenario when relogin fails (ie agent is not logged in) and ensures it works correctly

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly


Make sure to have followed the contributing guidelines before submitting.

@adhmenon adhmenon requested a review from a team as a code owner November 26, 2024 15:13
Copy link

coderabbitai bot commented Nov 26, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -130,14 +130,15 @@ function register() {
});
const loginVoiceOptions = agentProfile.loginVoiceOptions;
agentLogin.innerHTML = '<option value="" selected>Choose Agent Login ...</option>'; // Clear previously selected option on agentLogin.
dialNumber.value = '';
dialNumber.disabled = true;
dialNumber.value = agentProfile.defaultDn ? agentProfile.defaultDn : '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we simply update the dial number if it exists (ie for EXTENSION and AGENT_DN relogin case).
Note that we disable it if the defaultDn is undefined.

I personally felt this approach was better (ie using the defaultDn of the agent config), however if there are some issues here, I am open to changing.

@@ -207,6 +208,7 @@ function logoutAgent() {

setTimeout(() => {
logoutAgentElm.classList.add('hidden');
agentLogin.selectedIndex = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed in order tor reset the login dropdown status as in the register we set one of the options, if the agent is already logged.

@@ -310,7 +310,8 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
};
await this.setAgentState(stateChangeData);
}
// Updating isAgentLoggedIn as true to indicate to the end user

await this.handleDeviceType(deviceType, dn);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have abstracted the logic to another method so we can handle errors there (if at all) more easily.

/**
* Handles the device type specific logic
*/
private async handleDeviceType(deviceType: string, dn: string): Promise<void> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this method, we simply run a switch case for all possible device types and based on them, we assign the config object deviceType.
Improtant thing to note is that for BROWSER we NEED to do a WebexCallingService re-register as otherwise we have no events sent to mobius (has missed this before).

this.agentConfig.defaultDn = dn;
break;
default:
LoggerProxy.error(`Unsupported device type: ${deviceType}`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should ideally never reach here, however we must account for all possibilites.

@@ -183,6 +183,8 @@ describe('webex.cc', () => {
data: {
auxCodeId: 'auxCodeId',
agentId: 'agentId',
deviceType: LoginOption.EXTENSION,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to mock this so we do not see any errors.

@@ -714,5 +719,38 @@ describe('webex.cc', () => {
{module: CC_FILE, method: 'silentRelogin'}
);
});

it('should handle errors during silent relogin', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few more tests so coverage is improved.

@adhmenon adhmenon added the validated If the pull request is validated for automation. label Nov 26, 2024
Copy link
Contributor

@Kesari3008 Kesari3008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving it with 2 comments. Please address them before merge

packages/@webex/plugin-cc/test/unit/spec/cc.ts Outdated Show resolved Hide resolved
packages/@webex/plugin-cc/src/cc.ts Outdated Show resolved Hide resolved
@Kesari3008
Copy link
Contributor

@CodeRabbit review

Copy link

coderabbitai bot commented Nov 26, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@adhmenon
Copy link
Contributor Author

Updated the PR. Tested all manual test cases as mentioned above and everything is working fine.

Copy link
Contributor

@Shreyas281299 Shreyas281299 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

packages/@webex/plugin-cc/src/cc.ts Outdated Show resolved Hide resolved
@adhmenon adhmenon merged commit 3fa2938 into webex:wxcc Nov 27, 2024
11 checks passed
@adhmenon adhmenon deleted the dev/adhmenon-SPARK-586282 branch November 27, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants