feat(link): report agent-connected event after project linking#48
feat(link): report agent-connected event after project linking#48
Conversation
Call POST /tracking/v1/agent-connected after successful link to track agent connections. Supports both project_id (platform login) and app_key (OSS/self-hosted, parsed from api-base-url) payloads. Failures are silently ignored to avoid disrupting the link flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WalkthroughThe pull request adds best-effort event reporting following successful project linking. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/api/platform.ts`:
- Around line 112-129: reportAgentConnected currently always calls
getAccessToken() and may attach a stale JWT; change its signature to accept an
optional flag or token parameter (e.g. reportAgentConnected(payload, apiUrl?,
useAuth = true) or reportAgentConnected(payload, apiUrl?, token?: string)) and
only set the Authorization header when useAuth is true or a non-null token is
provided; update callers (notably link.ts) in the OSS/self-hosted path to pass
useAuth=false (or pass null token) so the tracking request is sent
unauthenticated, and ensure getAccessToken is not invoked when authentication is
disabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 44b760f0-02a0-4aa2-a88e-24a2b775c504
📒 Files selected for processing (2)
src/commands/projects/link.tssrc/lib/api/platform.ts
Summary
reportAgentConnectedAPI call toPOST /tracking/v1/agent-connectedafter successfulinsforge linkproject_idwith JWT authapp_keyfrom--api-base-url(must match{app_key}.{region}.insforge.appformat), reports without authTest plan
insforge link --api-url https://api-beta.insforge.dev --api-key ... --api-base-url https://vv6mjd5n.us-test.insforge.appsends request to/tracking/v1/agent-connectedwithapp_key: vv6mjd5nproject_idcorrectly*.insforge.dev) do not trigger reporting🤖 Generated with Claude Code
Note
Report agent-connected event after project linking
reportAgentConnectedfunction insrc/lib/api/platform.tsthat POSTs to/tracking/v1/agent-connectedwith an optional bearer token.reportAgentConnectedinsrc/commands/projects/link.tsafter both direct (OSS/self-hosted) and standard cloud linking flows complete successfully.app_keysubdomain fromopts.apiBaseUrl; for cloud linking, sends theproject_id.Macroscope summarized b14846c.
Summary by CodeRabbit