Add custom User-Agent header to Octagon API requests#6
Conversation
WalkthroughAdded HTTP header "User-Agent": "Octagon-Excel-AddIn/1.2.0" to authenticated API requests in the OctagonApiService. The header is included alongside existing "Content-Type" and Authorization headers when making requests to the /v1/responses endpoint. No changes to API key handling, request body structure, error handling, or control flow. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/api/octagonApi.ts (1)
159-159: Extract the hardcoded version to prevent version drift.The version "1.2.0" is hardcoded in the User-Agent string at line 159. This creates a maintenance burden—every time the add-in version is updated in package.json, this line must be manually changed, risking version mismatches.
Consider extracting it as a constant at the file level or reading it dynamically from package.json.
Proposed refactor: Extract version as constant
Define a constant at the top of the file after imports:
import Logger from "../utils/logger"; import { getTextFormat, parseTextFormat } from "./format"; import { AgentRequest, AgentResponse, AgentType, OutputFormat } from "./types"; + +// Version for User-Agent header (should match package.json version) +const ADDIN_VERSION = "1.2.0";Then update line 159 to use the constant:
const headers = new Headers({ "Content-Type": "application/json", Authorization: `Bearer ${token}`, - "User-Agent": "Octagon-Excel-AddIn/1.2.0", + "User-Agent": `Octagon-Excel-AddIn/${ADDIN_VERSION}`, });
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.