Skip to content

feat(cc-ui-logging): add PROPS_UPDATED event logging with propsToWatch filter#656

Closed
bhabalan wants to merge 2 commits intowebex:nextfrom
bhabalan:CAI-6890
Closed

feat(cc-ui-logging): add PROPS_UPDATED event logging with propsToWatch filter#656
bhabalan wants to merge 2 commits intowebex:nextfrom
bhabalan:CAI-6890

Conversation

@bhabalan
Copy link
Contributor

COMPLETES

https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6890

This pull request addresses

The widgets metrics system records mount and unmount events but does not track prop changes. We need to log a PROPS_UPDATED event when important props change, while filtering out noisy props like timers that would pollute the logs.

by making the following changes

  • metricsLogger.ts: Added getChangedWatchedProps() utility that compares previous and current props, checking only the specified propsToWatch keys, and returns a record of changed prop keys with their old/new values
  • withMetrics.tsx: Extended the withMetrics HOC to accept an optional propsToWatch parameter. Uses a useRef to track previous props and logs PROPS_UPDATED events only when watched props change. Backward compatible — existing usages without propsToWatch are unaffected
  • Tests: Added 6 new tests for getChangedWatchedProps and 3 new tests for withMetrics PROPS_UPDATED behavior

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 — all 22 ui-logging tests passing (9 new)
  • Unit tests — all 632 cc-components tests passing (backward compatibility)
  • Verified PROPS_UPDATED logs only for watched props
  • Verified no PROPS_UPDATED when unwatched props (e.g., timer) change
  • Verified no PROPS_UPDATED when propsToWatch is empty (backward compat)

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Claude Code
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the testing document
  • I have tested the functionality with amplify link

Make sure to have followed the contributing guidelines before submitting.

…h filter

Adds prop change tracking to the withMetrics HOC. A new optional
propsToWatch parameter allows components to specify which props should
trigger PROPS_UPDATED metric events, filtering out noisy props like
timers. Includes getChangedWatchedProps utility that reports old/new
values for changed watched props.

CAI-6890
@bhabalan bhabalan requested a review from a team as a code owner March 18, 2026 01:00
@@ -1,5 +1,5 @@
import store from '@webex/cc-store';
import {logMetrics, havePropsChanged, WidgetMetrics} from '../src/metricsLogger';
import {logMetrics, havePropsChanged, getChangedWatchedProps, WidgetMetrics} from '../src/metricsLogger';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add more comprehensive tests

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a215fab2ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


for (const key of propsToWatch) {
if (prev[key] !== next[key]) {
changes[key] = {oldValue: prev[key], newValue: next[key]};

Choose a reason for hiding this comment

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

P1 Badge Sanitize watched prop values before logging metrics

getChangedWatchedProps stores raw oldValue/newValue objects, and withMetrics forwards that payload to logMetrics, which serializes with JSON.stringify. If a watched prop contains a circular or otherwise non-serializable value (common for SDK/model objects), JSON.stringify throws inside the effect, causing runtime errors instead of emitting metrics. This new PROPS_UPDATED path should sanitize or safely serialize watched values before calling logMetrics.

Useful? React with 👍 / 👎.

@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-656.d1b38q61t1z947.amplifyapp.com

…thMetrics

Add edge case tests for havePropsChanged (same reference, null/object
transitions, empty objects, function references, undefined values) and
getChangedWatchedProps (undefined transitions, boolean/numeric props,
partial changes, null inputs). Add withMetrics tests for multiple
watched props, cross-render tracking, first-render behavior, and
different widget names.

CAI-6890
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a85385984

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +29 to +33
useEffect(() => {
if (prevPropsRef.current && propsToWatch.length > 0) {
const changes = getChangedWatchedProps(
prevPropsRef.current as Record<string, any>,
props as Record<string, any>,

Choose a reason for hiding this comment

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

P2 Badge Emit watched object prop changes even when memo skips render

This PROPS_UPDATED logic only runs inside an effect after the wrapped component renders, but withMetrics is still memoized with havePropsChanged, which treats object-to-object prop changes as unchanged. In practice, if a watched prop is an object (for example task or agent) and its reference changes between renders, React.memo can skip the render and this effect never runs, so the new feature silently misses updates for watched object props.

Useful? React with 👍 / 👎.

@bhabalan bhabalan closed this Mar 18, 2026
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