Skip to content

EPMRPP-117362 || Replace uniqid and uuid with built-in crypto.randomUUID#269

Merged
maria-hambardzumian merged 1 commit into
developfrom
feat/GH-CLJS-210
Jul 6, 2026
Merged

EPMRPP-117362 || Replace uniqid and uuid with built-in crypto.randomUUID#269
maria-hambardzumian merged 1 commit into
developfrom
feat/GH-CLJS-210

Conversation

@maria-hambardzumian

@maria-hambardzumian maria-hambardzumian commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses reportportal/agent-js-playwright#210 — the client shipped an outdated uuid@9.

The client previously depended on two id-generation libraries:

  • uniqid — used in lib/report-portal-client.js (getUniqId()) for internal tempIds
  • uuid — used in statistics/client-id.js for the anonymous analytics client_id

This consolidates id generation onto Node's built-in crypto.randomUUID(), removing both external packages. crypto.randomUUID() returns an RFC-4122 v4 UUID (the same thing uuid's v4() produces — modern uuid delegates to it internally on Node ≥18), so there is no functional change to the values produced.

Why not just bump uuid to v14?

uuid@14 is ESM-first (ships an exports map + modern .d.ts). While Node's require() resolves its CJS build fine at runtime, this repo's dev toolchain does not:

  • Jest resolves it to the ESM build and errors with Unexpected token 'export'.
  • TypeScript 4.9 rejects uuid@14's .d.ts (TS1383).
  • ESLint (import/no-unresolved) can't follow its exports map.

Keeping uuid would require a Jest shim, tsconfig skipLibCheck, and an ESLint rule change. Using the built-in avoids all of that and removes a dependency instead of adding config.

Changes

  • Remove uniqid and uuid from dependencies.
  • lib/report-portal-client.js + statistics/client-id.js: use crypto.randomUUID().
  • Update __tests__/client-id.spec.js accordingly.
  • Bump engines.node to >=14.17.0 (when crypto.randomUUID landed).
  • CHANGELOG entry.

Breaking change

Minimum Node.js is now 14.17.0 (was >=14.x, which allowed 14.0–14.16 that lack crypto.randomUUID). The internal tempId format changes from a uniqid hex string to a UUID v4 string; tempId is an opaque, client-internal correlation handle (never sent to the server as-is), so this is not observable to servers.

Verification

npm run lint, npm run build, and npm test all pass locally (9 suites, 175 tests).


🤖 Generated with Claude Code via the ai-workflow pipeline.

Summary by CodeRabbit

  • Bug Fixes

    • Improved client and statistics ID generation for more reliable unique identifiers.
    • Updated the minimum supported Node.js version to align with the new ID generation support.
  • Chores

    • Removed unused dependency requirements from the project.
    • Updated the changelog and tests to reflect the current ID generation approach.

Consolidates internal id generation onto Node's built-in
crypto.randomUUID(), removing both the uniqid and uuid dependencies.
Addresses reportportal/agent-js-playwright#210 (outdated uuid@9).

- lib/report-portal-client.js, statistics/client-id.js: use crypto.randomUUID()
- __tests__/client-id.spec.js: updated to match
- package.json: drop uniqid + uuid; bump engines.node to >=14.17.0
- CHANGELOG: note the change

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maria-hambardzumian maria-hambardzumian added the ai-workflow Generated by ai-workflow pipeline label Jul 6, 2026
@maria-hambardzumian

maria-hambardzumian commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR replaces the uniqid and uuid npm dependencies with Node's built-in crypto.randomUUID() for internal ID generation across the client and statistics modules, removes those dependencies from package.json, raises the minimum Node.js version to 14.17.0, updates tests accordingly, and documents the change in the changelog.

Changes

UUID generation migration

Layer / File(s) Summary
Client ID generation
lib/report-portal-client.js
Replaces uniqid import with crypto.randomUUID() and updates getUniqId() to return randomUUID().
Statistics client ID generation
statistics/client-id.js
Replaces uuid's v4 import with crypto.randomUUID() and updates the fallback assignment in getClientId().
Test expectations updated
__tests__/client-id.spec.js
Switches test-generated client IDs from uuidv4() to randomUUID() across three test cases.
Dependency and engine constraints
package.json, CHANGELOG.md
Removes uniqid/uuid dependencies, tightens engines.node to >=14.17.0, and documents the change in the changelog.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

Hop hop, out with the old ID scheme,
crypto.randomUUID() fuels the dream,
No more uniqid, no more uuid chase,
Just built-in magic, tidy and space-saved,
A rabbit cheers with a happy little leap! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing uniqid and uuid with built-in crypto.randomUUID.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/GH-CLJS-210

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

Comment @coderabbitai help to get the list of available commands.

@maria-hambardzumian maria-hambardzumian changed the title Replace uniqid and uuid with built-in crypto.randomUUID EPMRPP-117362 || Replace uniqid and uuid with built-in crypto.randomUUID Jul 6, 2026
@maria-hambardzumian

Copy link
Copy Markdown
Contributor Author

@maria-hambardzumian maria-hambardzumian merged commit 33dd20e into develop Jul 6, 2026
8 checks passed
@maria-hambardzumian maria-hambardzumian deleted the feat/GH-CLJS-210 branch July 6, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-workflow Generated by ai-workflow pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants