Skip to content

Conversation

@marcin-bazyl
Copy link
Collaborator

@marcin-bazyl marcin-bazyl commented May 15, 2025

COMPLETES #SPARK-663300

This pull request addresses

Missing ipVersion in our metrics

by making the following changes

Added ipVersion to Amplitude metrics and CA event. It indicates what ip version was used for the media connection.
I've started using ts-sdp for SDP parsing in this PR, because we now have multiple places where we parse SDP in SDK and we've been using regex in them, once this PR lands, I'll update the other places to use ts-sdp in another PR.

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, e2e with web app - verified CA result, see correlationId=d5807698-bb5c-4a7a-a78e-a10286663e94

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 15, 2025

📝 Walkthrough

Walkthrough

The changes introduce IP version (IPv4 or IPv6) detection and reporting throughout the Webex meetings plugin. The @webex/ts-sdp dependency is added. In the MediaProperties class, new logic determines the IP version used in the WebRTC connection by analyzing RTC stats and parsing SDP when necessary, with robust error handling. The getCurrentConnectionInfo method is updated to include the IP version. The Meeting class's addMediaInternal method is modified to collect and report this IP version in metrics and client events. Corresponding unit tests are added and updated to verify correct handling and reporting of the IP version.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.1)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
(node:18861) [DEP0169] DeprecationWarning: url.parse() behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for url.parse() vulnerabilities.
(Use node --trace-deprecation ... to show where the warning was created)
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
warning [email protected]: Glob versions prior to v9 are no longer supported
warning intern > [email protected]: Glob versions prior to v9 are no longer supported
warning intern > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > jest-cli > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning [email protected]: 16.1.1
warning sinon > @sinonjs/samsam > [email protected]: This package is deprecated. Use the optional chaining (?.) operator instead.
warning wd > [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > [email protected]: request has been deprecated, see request/request#3142
warning wd > archiver > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > request > [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > request > [email protected]: this library is no longer supported
warning wd > archiver > archiver-utils > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/cli > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > [email protected]: 16.1.1
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-89bfbaa1-cad2-45fe-bc9e-307f6a9f0303 > @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "24.0.2"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f4efadd and 09f1e32.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (3 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
  • packages/@webex/plugin-meetings/src/meeting/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Initialize Project
  • GitHub Check: AWS Amplify Console Web Preview
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@aws-amplify-us-east-2
Copy link

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

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

@marcin-bazyl marcin-bazyl added the validated If the pull request is validated for automation. label May 19, 2025
@marcin-bazyl marcin-bazyl marked this pull request as ready for review May 19, 2025 18:30
@marcin-bazyl marcin-bazyl requested review from a team as code owners May 19, 2025 18:30
Copy link
Contributor

@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 comments (1)
packages/@webex/plugin-meetings/test/unit/spec/media/properties.ts (1)

76-84: ⚠️ Potential issue

getStats is no longer a function – this will throw immediately, defeating the timeout test

By overwriting mockMC.getStats with a Promise instance you turn the property from a callable function into a plain object.
MediaProperties#getCurrentConnectionInfo() subsequently calls this.webrtcMediaConnection.getStats(), causing a TypeError: getStats is not a function long before the 1-second timeout is reached, so the test never verifies what it intends to.

Proposed fix:

-// Promise that never resolves
-mockMC.getStats = new Promise(() => {});
+// Stub that returns a promise that never resolves
+mockMC.getStats.resetBehavior();
+mockMC.getStats.returns(new Promise(() => {}));

This keeps getStats callable while still simulating the hanging behaviour.

🧹 Nitpick comments (2)
packages/@webex/plugin-meetings/src/media/properties.ts (2)

219-226: isIPv6 heuristic may mis-classify unusual but valid IPv4 literals

The helper currently decides solely on the presence of ':'.
While perfectly fine for standard dotted-decimal vs. colon-hex notation, addresses such as IPv4-mapped IPv6 literals (::ffff:192.0.2.1) or future textual representations could be mis-categorised.

Not blocking, but if you need stricter accuracy consider a simple RegExp:

private isIPv6(ip: string): boolean {
  return /^[0-9a-fA-F:]+$/.test(ip) && ip.includes(':');
}

233-304: Repeated full-SDP parsing may be expensive – cache or short-circuit

getConnectionIpVersion parses the entire local SDP every time it is called and when the ICE stats are missing an address. In a busy stats-polling loop this could become non-trivial overhead.

Consider memoising the parsed SDP per RTCPeerConnection (e.g., store on a WeakMap) or parsing only once on first call.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 80e80da and f387e70.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • packages/@webex/plugin-meetings/package.json (1 hunks)
  • packages/@webex/plugin-meetings/src/media/properties.ts (6 hunks)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (3 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/media/properties.ts (3 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build Packages
  • GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (8)
packages/@webex/plugin-meetings/package.json (1)

78-78: Add SDP parsing library dependency
The new @webex/ts-sdp@^1.8.1 dependency is necessary for the IP version extraction via SDP parsing and aligns with the PR objective.

packages/@webex/plugin-meetings/src/meeting/index.ts (3)

7775-7776: Correctly extracting IP version information for metrics.

The code now extracts ipVersion along with other connection information, which will be used for logging network metrics about the media connection.


7786-7787: Added IP version to behavioral metrics payload.

Including ipVersion in the ADD_MEDIA_SUCCESS behavioral metric provides essential network connection information that can help with media connection diagnostics and analysis.


7799-7801: Added IP version to client event payload.

The IP version information is now also included in the client event for client.media-engine.ready, ensuring consistent reporting across different types of metrics. This change completes the implementation by making the IP version visible in Customer Analytics events.

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (4)

2050-2055: Test expectations correctly include the new ipVersion field

The test mock for getCurrentConnectionInfo now properly includes the ipVersion field with 'IPv6' value, correctly reflecting the implementation changes in the MediaProperties class.


3067-3069: Client event payload now includes IP version data

The test assertion for the 'client.media-engine.ready' event correctly verifies that the implementation now includes the IP version in client event payloads.


3126-3126: Updated metrics assertions for IP version reporting

Good job updating the metrics verification to include the new ipVersion field, ensuring that the connection information is properly reported in the metrics payload.


3280-3280: Consistent IP version reporting in all metrics assertions

The test consistently checks for the ipVersion field across different test scenarios, properly validating the implementation's IP version reporting across various connection cases.

* @returns {boolean} true if the address is IPv6, false otherwise
*/
private isIPv6(ip: string): boolean {
return ip.includes(':');
Copy link
Collaborator

Choose a reason for hiding this comment

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

this one makes me laugh !

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as long as it's called with an ip address, then it does the job :-) If it ever needs to be more robust to handle non-ip strings like urls, then it can be expanded when needed.

@marcin-bazyl marcin-bazyl merged commit 6a5834b into webex:next May 21, 2025
13 checks passed
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