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 <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Jake Macdonald
2026-04-06 10:24:43 -07:00
committed by Commit Queue
parent da2dc44dda
commit 527b05718c
+21 -8
View File
@@ -12,12 +12,25 @@ import 'package:dart_mcp_server/dart_mcp_server.dart';
import 'package:unified_analytics/unified_analytics.dart';
void main(List<String> 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);
}