Skip to content

Commit 9b35b98

Browse files
authored
Add events for dart mcp server tool invocations (#2112)
1 parent 1d55ee1 commit 9b35b98

File tree

6 files changed

+58
-3
lines changed

6 files changed

+58
-3
lines changed

pkgs/unified_analytics/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 8.0.2
2+
- Added `Event.dartMCPEvent` for events from the `dart mcp-server` command.
3+
14
## 8.0.1
25
- Added `Event.flutterInjectDarwinPlugins` event for plugins injected into an iOS/macOS project.
36

pkgs/unified_analytics/lib/src/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const int kMaxLogFileSize = 25 * (1 << 20);
8787
const String kLogFileName = 'dart-flutter-telemetry.log';
8888

8989
/// The current version of the package, should be in line with pubspec version.
90-
const String kPackageVersion = '8.0.1';
90+
const String kPackageVersion = '8.0.2';
9191

9292
/// The minimum length for a session.
9393
const int kSessionDurationMinutes = 30;

pkgs/unified_analytics/lib/src/enums.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ enum DashEvent {
5555
description: 'Pub package resolution details',
5656
toolOwner: DashTool.dartTool,
5757
),
58+
dartMCPEvent(
59+
label: 'dart_mcp_server',
60+
description: 'Information for a Dart MCP server event',
61+
toolOwner: DashTool.dartTool,
62+
),
5863

5964
// Events for Flutter devtools
6065

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,32 @@ final class Event {
905905
},
906906
);
907907

908+
/// An event that is sent from the Dart MCP server.
909+
///
910+
/// The [client] is the name of the client, as given when it connected to the
911+
/// MCP server, and [clientVersion] is the version of the client.
912+
///
913+
/// The [serverVersion] is the version of the Dart MCP server.
914+
///
915+
/// The [type] identifies the kind of event this is, and [additionalData] is
916+
/// the actual data for the event.
917+
Event.dartMCPEvent({
918+
required String client,
919+
required String clientVersion,
920+
required String serverVersion,
921+
required String type,
922+
CustomMetrics? additionalData,
923+
}) : this._(
924+
eventName: DashEvent.dartMCPEvent,
925+
eventData: {
926+
'client': client,
927+
'clientVersion': clientVersion,
928+
'serverVersion': serverVersion,
929+
'type': type,
930+
...?additionalData?.toMap(),
931+
},
932+
);
933+
908934
@override
909935
int get hashCode => Object.hash(eventName, jsonEncode(eventData));
910936

pkgs/unified_analytics/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: >-
55
# LINT.IfChange
66
# When updating this, keep the version consistent with the changelog and the
77
# value in lib/src/constants.dart.
8-
version: 8.0.1
8+
version: 8.0.2
99
# LINT.ThenChange(lib/src/constants.dart)
1010
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics
1111
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics

pkgs/unified_analytics/test/event_test.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,27 @@ void main() {
655655
expect(constructedEvent.eventData.length, 20);
656656
});
657657

658+
test('Event.dartMCPEvent constructed', () {
659+
final event = Event.dartMCPEvent(
660+
client: 'test client',
661+
clientVersion: '1.0.0',
662+
serverVersion: '1.1.0',
663+
type: 'some_event',
664+
additionalData:
665+
_TestMetrics(boolField: true, stringField: 'hello', intField: 1));
666+
expect(
667+
event.eventData,
668+
equals({
669+
'client': 'test client',
670+
'clientVersion': '1.0.0',
671+
'serverVersion': '1.1.0',
672+
'type': 'some_event',
673+
'boolField': true,
674+
'stringField': 'hello',
675+
'intField': 1,
676+
}));
677+
});
678+
658679
test('Confirm all constructors were checked', () {
659680
var constructorCount = 0;
660681
for (final declaration in reflectClass(Event).declarations.keys) {
@@ -667,7 +688,7 @@ void main() {
667688

668689
// Change this integer below if your PR either adds or removes
669690
// an Event constructor
670-
final eventsAccountedForInTests = 28;
691+
final eventsAccountedForInTests = 29;
671692
expect(eventsAccountedForInTests, constructorCount,
672693
reason: 'If you added or removed an event constructor, '
673694
'ensure you have updated '

0 commit comments

Comments
 (0)