Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
"test:acceptance": "yarn pretest && mocha --forbid-only \"test/**/*.acceptance.test.ts\" && node ./bin/bats-test-runner",
"test:integration": "yarn pretest && mocha --forbid-only \"test/**/*.integration.test.ts\"",
"test:smoke": "yarn pretest && mocha --forbid-only \"test/**/smoke.acceptance.test.ts\"",
"test:unit:justTest:local": "nyc mocha \"test/**/*.unit.test.ts\"",
"test:unit:justTest:local": "mocha \"test/**/*.unit.test.ts\"",
"test:unit:justTest:ci": "nyc --reporter=lcov --reporter=text-summary mocha --forbid-only \"test/**/*.unit.test.ts\"",
"test": "yarn pretest && yarn test:unit:justTest:ci",
"test:local": "yarn pretest && yarn test:unit:justTest:local",
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default class AnalyticsCommand {

async record(opts: RecordOpts) {
await this.initialize
const mcpMode = process.env.HEROKU_MCP_MODE === 'true'
const mcpServerVersion = process.env.HEROKU_MCP_SERVER_VERSION || 'unknown'
const plugin = opts.Command.plugin
if (!plugin) {
debug('no plugin found for analytics')
Expand All @@ -63,7 +65,7 @@ export default class AnalyticsCommand {
cli: this.config.name,
command: opts.Command.id,
completion: await this._acAnalytics(opts.Command.id),
version: this.config.version,
version: `${this.config.version}${mcpMode ? ` (MCP ${mcpServerVersion})` : ''}`,
plugin: plugin.name,
plugin_version: plugin.version,
os: this.config.platform,
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/global_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ export function setupTelemetry(config: any, opts: any) {
const now = new Date()
const cmdStartTime = now.getTime()
const isRegularCmd = Boolean(opts.Command)
const mcpMode = process.env.HEROKU_MCP_MODE === 'true'
const mcpServerVersion = process.env.HEROKU_MCP_SERVER_VERSION || 'unknown'

const irregularTelemetryObject = {
command: opts.id,
os: config.platform,
version: config.version,
version: `${config.version}${mcpMode ? ` (MCP ${mcpServerVersion})` : ''}`,
exitCode: 0,
exitState: 'successful',
cliRunDuration: 0,
Expand Down
21 changes: 21 additions & 0 deletions packages/cli/test/unit/analytics.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ describe('analytics (backboard has an error) with authorizationToken', function
await runAnalyticsTest((d: AnalyticsInterface) => d.properties.install_id, 'abcde')
})

it('includes MCP version in version string when in MCP mode', async function () {
// Save original env vars
const originalMcpMode = process.env.HEROKU_MCP_MODE
const originalMcpVersion = process.env.HEROKU_MCP_SERVER_VERSION

// Set MCP mode and version
process.env.HEROKU_MCP_MODE = 'true'
process.env.HEROKU_MCP_SERVER_VERSION = '1.2.3'

try {
await runAnalyticsTest(
(d: AnalyticsInterface) => d.properties.version,
'1 (MCP 1.2.3)', // '1' is the version set in runAnalyticsTest
)
} finally {
// Restore original env vars
process.env.HEROKU_MCP_MODE = originalMcpMode
process.env.HEROKU_MCP_SERVER_VERSION = originalMcpVersion
}
})

after(function () {
sandbox.restore()
})
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/test/unit/global_telemetry.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ describe('telemetry', function () {
reportCmdNotFoundTest(mockConfig)
})

it('confirms version string includes MCP info when in MCP mode', function () {
// Mock MCP mode and version
const originalMcpMode = process.env.HEROKU_MCP_MODE
const originalMcpVersion = process.env.HEROKU_MCP_SERVER_VERSION
process.env.HEROKU_MCP_MODE = 'true'
process.env.HEROKU_MCP_SERVER_VERSION = '1.2.3'

const result = telemetry.setupTelemetry(mockConfig, mockOpts)
expect(result!.version).to.equal(`${version} (MCP 1.2.3)`)

// Restore original env vars
process.env.HEROKU_MCP_MODE = originalMcpMode
process.env.HEROKU_MCP_SERVER_VERSION = originalMcpVersion
})

it('confirms successful request to honeycomb', async function () {
const mockTelemetry = telemetry.setupTelemetry(mockConfig, mockOpts)
telemetry.initializeInstrumentation()
Expand Down
Loading