Skip to content

feat: add useragent#341

Open
purplecabbage wants to merge 5 commits into
masterfrom
UserAgent
Open

feat: add useragent#341
purplecabbage wants to merge 5 commits into
masterfrom
UserAgent

Conversation

@purplecabbage

@purplecabbage purplecabbage commented Nov 16, 2024

Copy link
Copy Markdown
Member

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • 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)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@shazron

shazron commented Apr 7, 2026

Copy link
Copy Markdown
Member

oclif update already in #392

@shazron shazron changed the title add useragent, update oclif, jest feat: add useragent Apr 13, 2026
@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a richer OpenWhisk/User-Agent value for Runtime API calls by setting process.env.__OW_USER_AGENT during command initialization, and also bumps the Jest dev dependency.

Changes:

  • Set process.env.__OW_USER_AGENT in RuntimeBaseCommand.init() based on this.config.versionDetails.
  • Update Jest version from ^29.6.2 to ^29.7.0.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/RuntimeBaseCommand.js Adds logic in init() to set a runtime User-Agent env var for OpenWhisk calls.
package.json Bumps Jest devDependency version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/RuntimeBaseCommand.js Outdated
Comment thread src/RuntimeBaseCommand.js
}

// set User-Agent for runtime calls
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

The example UA in the comment doesn’t match what the code generates (example includes @adobe/aio-cli/... and a node-v... format, while the actual string is aio-cli-plugin-runtime/${vs?.cliVersion} (...)). Update the comment to reflect the real output so it stays useful as documentation.

Suggested change
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
// ex. aio-cli-plugin-runtime/10.3.1 (darwin-arm64; 18.20.4; zsh)

Copilot uses AI. Check for mistakes.
Comment thread src/RuntimeBaseCommand.js
Comment on lines +89 to +96
// set User-Agent for runtime calls
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
const vs = this.config.versionDetails
// console.log('init ', this.config.versionDetails)
process.env.__OW_USER_AGENT =
`aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})`

debug('init ', process.env.__OW_USER_AGENT)

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

New user-agent construction in init() isn’t asserted in unit tests (e.g., does not override a pre-set __OW_USER_AGENT, honors --useragent, and produces a string without "undefined" parts). Adding focused tests here would prevent regressions and clarify the intended precedence rules.

Copilot uses AI. Check for mistakes.
Comment thread src/RuntimeBaseCommand.js Outdated
purplecabbage and others added 2 commits April 16, 2026 17:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 PR Reviewer

The diff upgrades Jest to 29.7.0 and adds User-Agent construction logic in RuntimeBaseCommand. The logic is generally clear and safe, but there is a commented-out console.log left in the code that should be removed before merging.

📝 1 suggestion(s) - Please review inline comments below.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

Comment thread src/RuntimeBaseCommand.js
const userAgentDetails = [vs?.architecture, vs?.nodeVersion, vs?.shell]
.filter(detail => typeof detail === 'string' && detail.trim())
// console.log('init ', this.config.versionDetails)
process.env.__OW_USER_AGENT = userAgentDetails.length > 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Commented-out console.log debug statement should be removed before merging to keep the code clean.

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.

3 participants