Skip to content

fix(lib): record success events for 9 tools misusing trackMCP - #424

Merged
gaurav-singh-9227 merged 2 commits into
browserstack:mainfrom
SavioBS629:fix/trackmcp-success-events
Sep 17, 2026
Merged

gaurav-singh-9227 merged 2 commits into
browserstack:mainfrom
SavioBS629:fix/trackmcp-success-events

Conversation

@SavioBS629

@SavioBS629 SavioBS629 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Nine tools call trackMCP(name, clientInfo, config) on the success path, dropping the error argument. trackMCP's signature is (toolName, clientInfo, error?, config?), so on every successful call:

  • config lands in the error slot → success=false
  • config itself is undefined → no Authorization header → the event is never stored

Result: 30 days of MCPInstrumentation data contain zero success=true rows for these tools, so analytics show them failing 100% of the time (see #proj-mcp thread from Bharti on fetchBuildInsights / runTestsOnBrowserStack). Correctly instrumented tools (getFailureLogs, listSessions, …) show both outcomes in the same window.

Affected call sites:

  • src/tools/build-insights.tsfetchBuildInsights
  • src/tools/bstack-sdk.tssetupBrowserStackAutomateTests
  • src/tools/percy-sdk.ts — all seven Percy tools (including the single-line listTestFiles and runPercyScan calls flagged in review)

Changes

  • Pass undefined explicitly as the error argument at the nine success-path call sites.
  • Align tracked names with registered tool names (drifted after renames):
    • runTestsOnBrowserStacksetupBrowserStackAutomateTests
    • VisualTestIntegrationAgentpercyVisualTestIntegrationAgent
    • setupPercyVisualTestingexpandPercyVisualTesting

No behavioural change for end users; telemetry only.

Heads-up for analytics

Dashboards/sheets keyed on the three old names will see the new names from the release that ships this. Historic success counts for these tools cannot be backfilled.

Test plan

  • npm run build (lint + format + test + tsc) green on Node 22: 47 files / 649 tests
  • Verified no remaining trackMCP( calls pass config in the third position
  • Verified registered name == tracked name == handleMCPError name for every tool in the three files

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 7bbbfd07-d54a-4abd-a37b-19ad487872dd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@SavioBS629 SavioBS629 changed the title fix: record success events for 7 tools misusing trackMCP fix(lib): record success events for 9 tools misusing trackMCP Sep 17, 2026
…n trackMCP calls

Same misuse as the other seven call sites, missed because these two were
single-line calls. Sweep of src/ confirms no trackMCP call now passes
config in the error slot.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@gaurav-singh-9227
gaurav-singh-9227 merged commit 75d0bf9 into browserstack:main Sep 17, 2026
2 checks passed
gaurav-singh-9227 pushed a commit that referenced this pull request Sep 17, 2026
…d createTestCasesFromFile

Two tools were invisible in MCPInstrumentation:

- setupBrowserStackAppAutomateTests never called trackMCP on either path.
  Add the standard entry (success) and catch (failure) calls.
- createTestCasesFromFile called trackMCP without config, so the event
  went out with no Authorization header and Rails dropped it. Pass config
  on both paths.

Tests assert both paths call trackMCP with the tool name, client info,
error slot, and config, so a regression to the config-in-error-slot
shape (PR #424) is caught.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

2 participants