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(consolidated-interstitial): add joinFlowVersion as CA event option #3991

Merged

Conversation

chburket
Copy link
Contributor

@chburket chburket commented Nov 19, 2024

COMPLETES #https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-576382

This pull request addresses

Added new joinFlowVersion CA event option that is needed for the consolidated interstitial feature.

https://sqbu-github.cisco.com/WebExSquared/event-dictionary/pull/1854

by making the following changes

  • bumped the "@webex/event-dictionary-ts" version
  • added MetricEventJoinFlowVersion type
  • pass through joinFlowVersion in createClientEventObjectInMeeting

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

Unit tests

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 parameter joinFlowVersion for enhanced event tracking in call diagnostics.
    • Added a new type MetricEventJoinFlowVersion to improve event categorization.
    • Enhanced event submission capabilities with additional identifiers in the submitClientEvent method.
  • Bug Fixes

    • Improved error handling and validation for client event submissions, ensuring more robust diagnostics.
  • Documentation

    • Updated method signatures and interfaces to reflect new parameters and types for better clarity and usability.

@chburket chburket requested review from a team as code owners November 19, 2024 19:01
Copy link

coderabbitai bot commented Nov 19, 2024

Walkthrough

The pull request introduces updates to the @webex/internal-plugin-metrics package, primarily enhancing the CallDiagnosticMetrics class and its methods. Key changes include the addition of a joinFlowVersion parameter in various method signatures, updates to the SubmitClientEventOptions interface to include a new type for joinFlowVersion, and improvements in error handling and identifier management within the metrics submission process. Additionally, the version of the @webex/event-dictionary-ts dependency is incremented.

Changes

File Change Summary
packages/@webex/internal-plugin-metrics/package.json Updated dependency version: @webex/event-dictionary-ts from ^1.0.1546 to ^1.0.1594.
packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts Added joinFlowVersion parameter to createClientEventObjectInMeeting and createClientEventObjectPreMeeting, refined error handling, and improved identifier management.
packages/@webex/internal-plugin-metrics/src/metrics.types.ts Introduced new type MetricEventJoinFlowVersion and updated SubmitClientEventOptions to include joinFlowVersion.
packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts Updated tests to reflect new parameters and error handling in submitClientEvent and buildClientEventFetchRequestOptions.

Possibly related PRs

Suggested reviewers

  • marcin-bazyl
  • adhmenon
  • Shreyas281299

Poem

In the meadow, hop and play,
Metrics dance the day away.
With joinFlowVersion in the mix,
Our events now do new tricks!
Error handling shines so bright,
Happy coding, what a sight! 🐇✨


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.

@chburket chburket added the validated If the pull request is validated for automation. label Nov 19, 2024
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/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (1)

2761-2778: Add a test case for when joinFlowVersion is undefined

Currently, there is a test verifying that joinFlowVersion is included in the event payload when provided. It's advisable to also test the scenario where joinFlowVersion is not provided to ensure the method handles undefined values correctly.

Consider adding the following test case:

+ it('does not include joinFlowVersion when not provided', async () => {
+   const options = {
+     meetingId: fakeMeeting.id,
+     preLoginId: 'myPreLoginId',
+     // 'joinFlowVersion' not included
+   };
+ 
+   const fetchOptions = await cd.buildClientEventFetchRequestOptions({
+     name: 'client.exit.app',
+     payload: {trigger: 'user-interaction', canProceed: false},
+     options,
+   });
+ 
+   expect(fetchOptions.body.metrics[0].eventPayload.event.joinFlowVersion).toBeUndefined();
+ });
packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts (2)

671-671: Consider adding type annotation for joinFlowVersion parameter

The joinFlowVersion parameter is added without a type annotation. While TypeScript can infer types from the SubmitClientEventOptions interface, explicit type annotations in method signatures improve code readability and maintainability.

-      joinFlowVersion,
+      joinFlowVersion: MetricEventJoinFlowVersion,

Line range hint 671-724: Consider adding JSDoc documentation for the new parameter

The joinFlowVersion parameter lacks documentation explaining its purpose and possible values. Adding JSDoc comments would help other developers understand when and how to use this parameter.

Add documentation above the method:

/**
 * Create client event object for in meeting events
 * @param arg - create args
 * @param arg.name - event key
 * @param arg.options - options
 * @param arg.options.joinFlowVersion - Version of the join flow (e.g., 'Other' or 'NewFTE')
 * @param arg.errors - errors
 * @returns object
 */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d5445fe and 550a229.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • packages/@webex/internal-plugin-metrics/package.json (1 hunks)
  • packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts (2 hunks)
  • packages/@webex/internal-plugin-metrics/src/metrics.types.ts (2 hunks)
  • packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (11 hunks)
🔇 Additional comments (4)
packages/@webex/internal-plugin-metrics/package.json (1)

40-40: Verify version compatibility and requirements

The significant version jump of @webex/event-dictionary-ts from 1546 to 1594 appears to be related to supporting the new joinFlowVersion feature.

Let's verify the version requirements:

✅ Verification successful

Version 1.0.1594 is appropriate for joinFlowVersion support

The version bump to 1.0.1594 is justified as this version includes the required joinFlowVersion type definition with supported values "NewFTE" | "Other". The type is properly integrated across multiple event interfaces in the package. The older version 1.0.1546 does not contain this field, confirming this is the correct version for the new feature.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version history and changes of @webex/event-dictionary-ts

# Check if this version is published and stable
curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts" | jq '.versions["1.0.1594"]'

# Look for any breaking changes or issues between these versions
curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts" | \
  jq -r '.versions | keys[]' | \
  awk -F. '$1=="1" && $2=="0" && $3>=1546 && $3<=1594' | \
  while read -r version; do
    echo "Checking version $version"
    curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts/$version" | \
      jq -r '.description + "\n" + (.dist.tarball // "")'
done

# Check if there are any versions between 1546 and 1594 that also support joinFlowVersion
# This helps determine if we're using the minimum required version
curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts" | \
  jq -r '.versions | keys[]' | \
  awk -F. '$1=="1" && $2=="0" && $3>=1546 && $3<=1594' | \
  while read -r version; do
    echo "Checking version $version for joinFlowVersion support"
    curl -s "$(curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts/$version" | \
      jq -r '.dist.tarball')" | \
      tar -xzO -f - package/dist/index.js 2>/dev/null | \
      grep -l "joinFlowVersion" >/dev/null && \
      echo "Version $version supports joinFlowVersion"
done

Length of output: 47624


Script:

#!/bin/bash
# Let's try a different approach to check for joinFlowVersion support
# by examining the package contents more directly

# 1. Get the tarball URL for version 1.0.1594
TARBALL_URL=$(curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts/1.0.1594" | jq -r '.dist.tarball')

# 2. Download and examine the package contents for joinFlowVersion
curl -s "$TARBALL_URL" | tar -xzO -f - package/generated/typescript/index.d.ts 2>/dev/null | grep -A 5 -B 5 "joinFlowVersion"

# 3. Also check the same for version 1.0.1546 to compare
OLD_TARBALL_URL=$(curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts/1.0.1546" | jq -r '.dist.tarball')
echo -e "\nChecking old version 1.0.1546:"
curl -s "$OLD_TARBALL_URL" | tar -xzO -f - package/generated/typescript/index.d.ts 2>/dev/null | grep -A 5 -B 5 "joinFlowVersion"

# 4. Check the changelog or commit history if available
curl -s "https://registry.npmjs.org/@webex/event-dictionary-ts/1.0.1594" | jq -r '.gitHead' | while read -r commit; do
  echo -e "\nChecking commit message for version 1.0.1594 ($commit):"
  curl -s "https://api.github.com/repos/webex/webex-js-sdk/commits/$commit" | jq -r '.commit.message' 2>/dev/null
done

Length of output: 4407

packages/@webex/internal-plugin-metrics/src/metrics.types.ts (2)

113-114: LGTM! Well-structured type definition.

The new MetricEventJoinFlowVersion type follows the existing naming conventions and provides clear, descriptive values.


128-128: LGTM! Clean interface extension.

The joinFlowVersion property is properly integrated into the SubmitClientEventOptions interface as an optional field.

Let's verify the usage of this new option:

✅ Verification successful

Property is properly integrated and actively used in the codebase

The verification shows that joinFlowVersion is:

  • Correctly defined in the interface
  • Actively used in call-diagnostic-metrics.ts for client event handling
  • Has test coverage verifying its functionality with the 'NewFTE' value
  • Properly propagated to the client event object when present
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of joinFlowVersion in client events
# Expected: Find references to joinFlowVersion in related files

# Search for direct usage of joinFlowVersion
rg -t typescript "joinFlowVersion" --no-filename

# Search for SubmitClientEventOptions usage to ensure proper typing
ast-grep --pattern 'SubmitClientEventOptions'

Length of output: 337


Script:

#!/bin/bash
# Let's try with ripgrep's default behavior for text files and check the actual content
rg "joinFlowVersion" -A 3 -B 3

# Also check the files that import SubmitClientEventOptions to see their usage
rg "import.*SubmitClientEventOptions" -A 5

Length of output: 4657

packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts (1)

722-724: LGTM! Conditional addition of joinFlowVersion

The implementation correctly adds the joinFlowVersion to the clientEventObject only when it's provided, maintaining backward compatibility with existing calls.

Copy link

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

Access this pull request here: https://pr-3991.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: 1

🧹 Outside diff range and nitpick comments (1)
packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (1)

2761-2778: Test case needs additional assertions

The test case for joinFlowVersion only verifies the presence of the field but doesn't validate the complete event payload structure.

Consider adding assertions to verify:

  1. The complete event payload structure remains valid
  2. Edge cases like undefined/null joinFlowVersion
  3. Invalid joinFlowVersion values

Example:

it('includes expected joinFlowVersion', async () => {
  const options = {
    meetingId: fakeMeeting.id,
    preLoginId: 'myPreLoginId',
    joinFlowVersion: 'NewFTE' 
  };

  const fetchOptions = await cd.buildClientEventFetchRequestOptions({
    name: 'client.exit.app',
    payload: {trigger: 'user-interaction', canProceed: false},
    options,
  });

  // Verify joinFlowVersion
  assert.equal(
    fetchOptions.body.metrics[0].eventPayload.event.joinFlowVersion,
    options.joinFlowVersion
  );

  // Verify payload structure remains valid
  assert.hasAllKeys(fetchOptions.body.metrics[0].eventPayload.event, [
    'canProceed',
    'eventData',
    'identifiers',
    'loginType',
    'name',
    'trigger',
    'joinFlowVersion'
  ]);
});

it('handles undefined joinFlowVersion', async () => {
  const options = {
    meetingId: fakeMeeting.id,
    preLoginId: 'myPreLoginId'
  };

  const fetchOptions = await cd.buildClientEventFetchRequestOptions({
    name: 'client.exit.app',
    payload: {trigger: 'user-interaction', canProceed: false},
    options,
  });

  assert.isUndefined(
    fetchOptions.body.metrics[0].eventPayload.event.joinFlowVersion
  );
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 550a229 and 7ece0a8.

📒 Files selected for processing (1)
  • packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (11 hunks)

@@ -718,6 +719,10 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
webexSubServiceType: this.getSubServiceType(meeting),
};

if (joinFlowVersion) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't this need to be added to the preMeeting function and all the other functions in this file? similar to sessionCorrelationId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just preMeeting function, I think. Good catch. Added.

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 (1)
packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (1)

2760-2779: LGTM - Test coverage for joinFlowVersion, consider additional test cases

Good test coverage for the new joinFlowVersion feature. The test properly validates that the joinFlowVersion is included in the metrics payload.

Consider adding test cases for:

  • Invalid joinFlowVersion values
  • Missing joinFlowVersion
  • Edge cases in the joinFlowVersion handling

Example additional test:

it('handles missing joinFlowVersion gracefully', async () => {
  const options = {
    meetingId: fakeMeeting.id,
    preLoginId: 'myPreLoginId'
  };

  const fetchOptions = await cd.buildClientEventFetchRequestOptions({
    name: 'client.exit.app',
    payload: {trigger: 'user-interaction', canProceed: false},
    options,
  });

  assert.isUndefined(
    fetchOptions.body.metrics[0].eventPayload.event.joinFlowVersion
  );
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7ece0a8 and c944b1e.

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

59-59: LGTM - Comma addition for object property


1078-1078: LGTM - Enhanced test coverage for sessionCorrelationId

The changes appropriately add test coverage for sessionCorrelationId handling in different scenarios.

Also applies to: 1172-1172, 1185-1185


1465-1465: LGTM - Enhanced error reporting

Good addition of errorName to errorData for more detailed error reporting.

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 (1)
packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (1)

2759-2800: Consider adding edge case tests for joinFlowVersion.

While the current test coverage is good, consider adding tests for:

  1. Invalid/unexpected joinFlowVersion values
  2. Undefined/null joinFlowVersion scenarios
  3. Interaction with other options
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c944b1e and cde767b.

📒 Files selected for processing (2)
  • packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts (2 hunks)
  • packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.ts
🔇 Additional comments (3)
packages/@webex/internal-plugin-metrics/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts (3)

2759-2800: LGTM! The new tests for joinFlowVersion look good.

The added test cases thoroughly verify the joinFlowVersion functionality:

  1. Tests the in-meeting scenario by verifying joinFlowVersion is included when meetingId is present
  2. Tests the pre-join scenario by verifying joinFlowVersion is included when only correlationId is present
  3. Follows the existing test patterns and assertions

The test coverage is comprehensive and the implementation is correct.


1077-1077: LGTM! The sessionCorrelationId additions are consistent.

The changes correctly add sessionCorrelationId to the test options objects across different test cases, maintaining consistency with the existing test patterns.

Also applies to: 1171-1171, 1184-1184, 1295-1295


1464-1464: LGTM! The errorName additions are consistent.

The changes consistently add errorName to the error data objects across different test cases for error handling.

Also applies to: 1538-1538, 2253-2253

@chburket chburket enabled auto-merge (squash) November 19, 2024 21:34
Copy link
Contributor

@sreenara sreenara left a comment

Choose a reason for hiding this comment

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

Approved with a single question

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.

3 participants