Skip to content

feat: add User-Agent header to all HTTP requests (DIS-41)#34

Open
ckorhonen wants to merge 2 commits intomainfrom
devin/1772484974-add-user-agent-header
Open

feat: add User-Agent header to all HTTP requests (DIS-41)#34
ckorhonen wants to merge 2 commits intomainfrom
devin/1772484974-add-user-agent-header

Conversation

@ckorhonen
Copy link

@ckorhonen ckorhonen commented Mar 2, 2026

Add User-Agent header to all HTTP requests

Summary

Adds a User-Agent: opensea-cli/<version> header to every HTTP request made by OpenSeaClient, enabling server-side traffic segmentation by channel (CLI vs MCP vs other consumers) in Datadog/analytics.

  • Reads the version dynamically from package.json at module load time using createRequire (standard ESM pattern to avoid rootDir issues with direct JSON imports)
  • Adds the header to both get() and post() methods
  • Updates existing test assertions to verify the header is present with a semver-format version

Confidence: 🟢 High — small, well-scoped change. Lint, type-check, and all 151 tests pass locally.

Review & Testing Checklist for Human

  • Verify createRequire("../package.json") resolves correctly after npm run build — the relative path ../package.json must resolve from dist/ at runtime, not just src/. Run: npm run build && node -e "import('./dist/index.js').then(m => console.log('ok'))" to confirm no runtime import error. This is the primary risk since tests mock fetch and don't exercise the actual createRequire path.
  • Confirm the User-Agent value appears in outgoing requests — e.g. make a verbose request and inspect headers, or add a quick log in a local test

Notes

  • Test assertions were changed from exact header matching to expect.objectContaining to accommodate the new header without breaking if header order changes. This is marginally less strict than before.
  • Test regex uses /^opensea-cli\/\d+\.\d+\.\d+/ to validate semver format rather than just a leading digit.
  • Linear ticket: DIS-41
  • Devin Session
  • Requested by: @ckorhonen

Open with Devin

Add User-Agent: opensea-cli/<version> header to all requests made by
OpenSeaClient. Version is dynamically read from package.json using
createRequire. Updates both get() and post() methods and corresponding
test assertions.

Co-Authored-By: Chris K <ckorhonen@gmail.com>
@devin-ai-integration
Copy link
Contributor

Original prompt from Chris K
Please work on ticket "[Tracking] Add User-Agent header to opensea-cli" ([DIS-41](https://linear.app/opensea/issue/DIS-41/tracking-add-user-agent-header-to-opensea-cli))

PLAYBOOK_md:
# Ticket to PR

## Overview

This playbook guides the process of taking a Linear ticket from initial scoping through implementation to final review. The workflow ensures proper context gathering, quality implementation, and thorough code review before delivery. The agent uses the Linear MCP to manage ticket status and communication throughout.

## What's Needed From User

- Linear ticket URL or ticket ID (e.g., `ENG-123` or `https://linear.app/team/issue/ENG-123/...`)
- Repository access for the codebase where changes will be made

<phase name="Disambiguation" id="1">
## Disambiguation Phase

Think about the full user intent. Tickets are sometimes sparse. Make sure you disambiguate to the full scope that the user intended.

1. Fetch the ticket details using the Linear MCP `get_issue` tool with the ticket ID
2. Before diving into code: use the devin MCP to get a high-level understanding of the relevant systems and architecture. Use `ask_question` to learn about the relevant systems – send queries for multiple repos that could be relevant to get the full picture. Use `read_wiki_contents` to then get a better understanding how different parts of the codebase connect to each other.
3. Gather additional context to understand what the ticket means and refers to:
   - Look at past tickets in the same project and from the same author to understand patterns and terminology
   - Search for related commits and PRs (by author and content) that may provide context on the affected systems
   - Check any linked documents, designs, or parent tickets
   - Investigate the actual code
4. Identify any ambiguity in what the ticket refers to or asks for, including jargon or project-specific terms and use all means necessary to answer this yourself
5. Consult your smart friend: pass in the raw content of the... (8092 chars truncated...)

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration bot marked this pull request as ready for review March 2, 2026 20:58
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Co-Authored-By: Chris K <ckorhonen@gmail.com>
@ckorhonen ckorhonen requested a review from CodySearsOS March 2, 2026 21:19
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