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: added meetingJoinPhase to CA metrics #3954

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

Conversation

marcin-bazyl
Copy link
Collaborator

@marcin-bazyl marcin-bazyl commented Nov 5, 2024

COMPLETES #SPARK-576651

This pull request addresses

CA events sent by web app are missing metingJoinPhase

by making the following changes

Added metingJoinPhase to the new metrics plugin, the CallDiagnosticMetrics class that is responsible for CA events. Added a getter and setter so that both app and SDK can use and control the value. There is only 1 value, so this won't work if we ever want to join multiple meetings in parallel, but anyway SDK doesn't support that right now and there are other things in the metrics plugin that are done in the same way and assume only 1 meeting join at a time

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 where tested

unit tests and manually with the web app

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.

Summary by CodeRabbit

  • New Features

    • Introduced a new property for tracking the meeting join phase, allowing for better state management during meetings.
    • Added a specific type definition for the meeting join phase to enhance event handling.
  • Tests

    • Implemented new tests for the meeting join phase property to ensure correct functionality and state management.
    • Expanded existing tests to cover additional scenarios related to session identifiers.

@marcin-bazyl marcin-bazyl requested review from a team as code owners November 5, 2024 14:56
Copy link

coderabbitai bot commented Nov 5, 2024

Walkthrough

The changes involve modifications to the CallDiagnosticMetrics class in the call-diagnostic-metrics.ts file, including the introduction of a new private property joinMeetingPhase of type MeetingJoinPhase, initialized to 'pre-join'. This property has an associated getter and setter for external access. Additionally, a new type MeetingJoinPhase is defined in metrics.types.ts, enhancing the type system. A new test suite is added to verify the functionality of the meetingJoinPhase property, along with expanded existing tests for the getIdentifiers method.

Changes

File Change Summary
packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts - Added private property joinMeetingPhase: MeetingJoinPhase = 'pre-join'.
- Added getter get meetingJoinPhase().
- Added setter set meetingJoinPhase(joinMeetingPhase: MeetingJoinPhase).
packages/@webex/internal-plugin-metrics/src/metrics.types.ts - Introduced new type MeetingJoinPhase extracted from RawEvent type.
packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts - Added tests for meetingJoinPhase property to check default value and functionality of getter/setter.
- Expanded existing tests for getIdentifiers method.

Possibly related PRs

Suggested labels

validated

Suggested reviewers

  • edvujic
  • szotrabh

Poem

In the meadow, hops a rabbit bright,
With changes made, oh what a sight!
A phase for joining, set just right,
Encapsulated, a pure delight.
With tests to check, all day and night! 🐇✨


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.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3954.d3m3l2kee0btzx.amplifyapp.com

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
packages/@webex/internal-plugin-metrics/src/metrics.types.ts (1)

288-289: LGTM with minor formatting suggestions.

The type definition is well-structured and correctly extracts the type from the existing RawEvent. Consider removing the extra blank line before the type definition to maintain consistent spacing with other type definitions in the file.

-
export type MeetingJoinPhase = RawEvent['event']['meetingJoinPhase'];
+export type MeetingJoinPhase = RawEvent['event']['meetingJoinPhase'];
packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts (1)

123-137: Documentation needs improvement.

The getter and setter implementations have several documentation issues:

  1. Incorrect parameter name in setter's JSDoc (shows 'correlationId')
  2. Incorrect return type in getter's JSDoc (shows 'string')
  3. Missing clear descriptions of their purpose

Apply these documentation improvements:

 /**
-  * Getter - Returns current meetingJoinPhase value
-  * @returns {string}
+  * Gets the current phase of the meeting join process
+  * @returns {MeetingJoinPhase} The current meeting join phase
   */
  get meetingJoinPhase() {
    return this.joinMeetingPhase;
  }

  /**
-  * Setter - sets meetingJoinPhase value
-  * @param {string} correlationId
+  * Sets the current phase of the meeting join process
+  * @param {MeetingJoinPhase} joinMeetingPhase The new meeting join phase
   */
  set meetingJoinPhase(joinMeetingPhase: MeetingJoinPhase) {
    this.joinMeetingPhase = joinMeetingPhase;
  }
packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (1)

702-716: Test coverage could be enhanced.

The test suite for meetingJoinPhase provides good basic coverage. However, consider adding the following test cases to make it more robust:

  1. Validation of invalid values
  2. Edge cases (null, undefined)
  3. Error handling scenarios

Here's a suggested enhancement:

describe('#meetingJoinPhase', () => {
  it('should have a default value', () => {
    const res = cd.meetingJoinPhase;
    assert.equal(res, 'pre-join');
  });

  it('should have a getter and setter', () => {
    cd.meetingJoinPhase = 'join';
    assert.equal(cd.meetingJoinPhase, 'join');

    cd.meetingJoinPhase = 'in-meeting';
    assert.equal(cd.meetingJoinPhase, 'in-meeting');
  });

+ it('should handle invalid values', () => {
+   assert.throws(() => {
+     cd.meetingJoinPhase = 'invalid-phase';
+   }, /Invalid meeting join phase/);
+ });
+
+ it('should handle edge cases', () => {
+   assert.throws(() => {
+     cd.meetingJoinPhase = null;
+   }, /Invalid meeting join phase/);
+
+   assert.throws(() => {
+     cd.meetingJoinPhase = undefined;
+   }, /Invalid meeting join phase/);
+ });
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5408113 and e8b9c2e.

📒 Files selected for processing (3)
  • packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts (3 hunks)
  • packages/@webex/internal-plugin-metrics/src/metrics.types.ts (1 hunks)
  • packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (1 hunks)
🔇 Additional comments (3)
packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts (3)

43-43: LGTM: Import added correctly.

The MeetingJoinPhase type is properly imported from the metrics.types.ts file.


99-99: LGTM: Property declaration is well-structured.

The private property joinMeetingPhase is properly typed and initialized with a default value of 'pre-join'.


43-43: Verify the MeetingJoinPhase implementation.

The implementation looks good, but we should verify:

  1. The existence and correctness of the MeetingJoinPhase type
  2. The usage of this new property in the codebase

Also applies to: 99-99, 123-137

✅ Verification successful

Let me gather more information about the RawEvent type to understand the complete type definition.


Let me try a different approach to check the RawEvent definition.


MeetingJoinPhase implementation is properly integrated

The verification confirms:

  1. MeetingJoinPhase type is correctly defined in metrics.types.ts as RawEvent['event']['meetingJoinPhase']
  2. The implementation has proper test coverage showing valid values: 'pre-join' (default), 'join', and 'in-meeting'
  3. The getter and setter are properly implemented and tested in call-diagnostic-metrics.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify MeetingJoinPhase type definition and usage

# Test 1: Check if MeetingJoinPhase type exists and its definition
echo "Checking MeetingJoinPhase type definition..."
rg -p "type MeetingJoinPhase" --type ts

# Test 2: Find usage of meetingJoinPhase getter/setter
echo "Checking meetingJoinPhase usage..."
rg "meetingJoinPhase" --type ts

Length of output: 1909


Script:

#!/bin/bash
# Check the RawEvent type definition to understand meetingJoinPhase's type structure
ast-grep --pattern 'type RawEvent = {
  $$$
}'

# Also check for interface definition as an alternative
ast-grep --pattern 'interface RawEvent {
  $$$
}'

Length of output: 100


Script:

#!/bin/bash
# Search for RawEvent definition with context
rg -p "RawEvent" -B 2 -A 10 --type ts packages/@webex/internal-plugin-metrics/src/metrics.types.ts

# Also check the test file to understand valid values for meetingJoinPhase
rg -p "describe.*meetingJoinPhase" -B 2 -A 15 packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts

Length of output: 2781

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.

1 participant