Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds distinct analytics tagging for the bundled version of the CIO PLP component by setting a custom c param (cio-ui-plp-bundled-xxx) to differentiate bundled usage from normal library usage.
Changes:
- Modified bundled component to inject a custom version string into
cioClientOptions - Added test coverage for custom version handling in
useCioClienthook - Added comprehensive test suite for bundled component behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/bundled.jsx | Imports version number and passes custom bundled version string through cioClientOptions |
| spec/hooks/useCioClient/useCioClient.test.js | Added test to verify custom version option is respected by the hook |
| spec/bundled/bundled.test.jsx | New test file covering bundled version tagging, option preservation, and error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review ResultsStrengthsThe implementation correctly injects the bundled version tag via prop spreading with override, keeping the change minimal and well-tested with four targeted test cases. Critical Issues[File: src/bundled.jsx Lines: L36-L39] The version field is always overridden, even when the user explicitly provides one in cioClientOptions. The spread order (...rest.cioClientOptions first, then version:) silently discards the user-supplied value without any warning. The test titled 'should override user-provided version' confirms and enshrines this behavior. If the intent is to always enforce the bundled tag (as stated in the PR description), a console.warn should be emitted when a user-supplied version is detected and overridden, so developers are made aware. Important Issues[File: spec/hooks/useCioClient/useCioClient.test.js Lines: L67-L82] The new test passes version inside the options object, but the UseCioClientProps type explicitly excludes version from options via Omit (src/hooks/useCioClient.ts:12). This test works at runtime because JavaScript ignores the TypeScript constraint, but it tests a code path that is intentionally blocked by the public API types. The test should either: (a) verify that passing version in options is ignored or overridden (if that is the intended contract), or (b) better reflect the actual supported API where version override can only happen through the bundled wrapper and not by passing it directly to useCioClient. Suggestions[File: src/bundled.jsx Line: L6] The import alias versionNumber differs from the alias used in every other file that imports the same module (version in useCioClient.ts, spec/hooks/useCioClient/useCioClient.test.js, and spec/bundled/bundled.test.jsx). Renaming it to version would improve consistency across the codebase. Overall Assessment: Needs Work |
PR Description
We tag the bundle with a separate
cparamcio-ui-plp-bundled-xxxvs when the library is used normally.Note: We don't update the expected types in
useCioClientsince consumers of the library shouldn't be settingversionever.Pull Request Checklist
Before you submit a pull request, please make sure you have to following:
PR Type
What kind of change does this PR introduce?