From 527b05718c9d8f8e38f430dbf973700547b84333 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Mon, 6 Apr 2026 10:24:43 -0700 Subject: [PATCH] use the DASH__TOOL env var where given in the MCP server analytics Change-Id: I2e8e61d10cdbccdc1b36d14ad722f9663901c603 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493180 Commit-Queue: Brian Wilkerson Auto-Submit: Jake Macdonald Reviewed-by: Brian Wilkerson --- utils/dart_mcp_server/dart_mcp_server.dart | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/utils/dart_mcp_server/dart_mcp_server.dart b/utils/dart_mcp_server/dart_mcp_server.dart index 90becff8c74..ba17c565013 100644 --- a/utils/dart_mcp_server/dart_mcp_server.dart +++ b/utils/dart_mcp_server/dart_mcp_server.dart @@ -12,12 +12,25 @@ import 'package:dart_mcp_server/dart_mcp_server.dart'; import 'package:unified_analytics/unified_analytics.dart'; void main(List args) async { - exitCode = await DartMCPServer.run( - args, - analytics: Analytics( - tool: DashTool.dartTool, - // The actual version is part up to the first space. - dartVersion: Platform.version.split(' ').first, - ), - ); + DashTool? tool; + if (Platform.environment['DASH__TOOL'] case final toolEnv?) { + try { + tool = DashTool.fromLabel(toolEnv); + } catch (e) { + // Ignore errors, but don't track analytics for unrecognized tools. + } + } else { + // We default to the `dart` tool if none specified. + tool = DashTool.dartTool; + } + + final analytics = tool != null + ? Analytics( + tool: tool, + // The actual version is the part up to the first space. + dartVersion: Platform.version.split(' ').first, + ) + : null; + + exitCode = await DartMCPServer.run(args, analytics: analytics); }