diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index 3d4c4f278..e5c26c902 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -1,3 +1,6 @@ +## 8.0.2 +- Added `Event.dartMCPEvent` for events from the `dart mcp-server` command. + ## 8.0.1 - Added `Event.flutterInjectDarwinPlugins` event for plugins injected into an iOS/macOS project. diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index c6ba7496e..3d472ea0e 100644 --- a/pkgs/unified_analytics/lib/src/constants.dart +++ b/pkgs/unified_analytics/lib/src/constants.dart @@ -87,7 +87,7 @@ const int kMaxLogFileSize = 25 * (1 << 20); const String kLogFileName = 'dart-flutter-telemetry.log'; /// The current version of the package, should be in line with pubspec version. -const String kPackageVersion = '8.0.1'; +const String kPackageVersion = '8.0.2'; /// The minimum length for a session. const int kSessionDurationMinutes = 30; diff --git a/pkgs/unified_analytics/lib/src/enums.dart b/pkgs/unified_analytics/lib/src/enums.dart index eff8205a5..b051e8487 100644 --- a/pkgs/unified_analytics/lib/src/enums.dart +++ b/pkgs/unified_analytics/lib/src/enums.dart @@ -55,6 +55,11 @@ enum DashEvent { description: 'Pub package resolution details', toolOwner: DashTool.dartTool, ), + dartMCPEvent( + label: 'dart_mcp_server', + description: 'Information for a Dart MCP server event', + toolOwner: DashTool.dartTool, + ), // Events for Flutter devtools diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index 0071ebd84..7fcaad6f2 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart @@ -905,6 +905,32 @@ final class Event { }, ); + /// An event that is sent from the Dart MCP server. + /// + /// The [client] is the name of the client, as given when it connected to the + /// MCP server, and [clientVersion] is the version of the client. + /// + /// The [serverVersion] is the version of the Dart MCP server. + /// + /// The [type] identifies the kind of event this is, and [additionalData] is + /// the actual data for the event. + Event.dartMCPEvent({ + required String client, + required String clientVersion, + required String serverVersion, + required String type, + CustomMetrics? additionalData, + }) : this._( + eventName: DashEvent.dartMCPEvent, + eventData: { + 'client': client, + 'clientVersion': clientVersion, + 'serverVersion': serverVersion, + 'type': type, + ...?additionalData?.toMap(), + }, + ); + @override int get hashCode => Object.hash(eventName, jsonEncode(eventData)); diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index 8bba46243..94b3fe901 100644 --- a/pkgs/unified_analytics/pubspec.yaml +++ b/pkgs/unified_analytics/pubspec.yaml @@ -5,7 +5,7 @@ description: >- # LINT.IfChange # When updating this, keep the version consistent with the changelog and the # value in lib/src/constants.dart. -version: 8.0.1 +version: 8.0.2 # LINT.ThenChange(lib/src/constants.dart) repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics diff --git a/pkgs/unified_analytics/test/event_test.dart b/pkgs/unified_analytics/test/event_test.dart index e8a9f5696..9c4a99c0b 100644 --- a/pkgs/unified_analytics/test/event_test.dart +++ b/pkgs/unified_analytics/test/event_test.dart @@ -655,6 +655,27 @@ void main() { expect(constructedEvent.eventData.length, 20); }); + test('Event.dartMCPEvent constructed', () { + final event = Event.dartMCPEvent( + client: 'test client', + clientVersion: '1.0.0', + serverVersion: '1.1.0', + type: 'some_event', + additionalData: + _TestMetrics(boolField: true, stringField: 'hello', intField: 1)); + expect( + event.eventData, + equals({ + 'client': 'test client', + 'clientVersion': '1.0.0', + 'serverVersion': '1.1.0', + 'type': 'some_event', + 'boolField': true, + 'stringField': 'hello', + 'intField': 1, + })); + }); + test('Confirm all constructors were checked', () { var constructorCount = 0; for (final declaration in reflectClass(Event).declarations.keys) { @@ -667,7 +688,7 @@ void main() { // Change this integer below if your PR either adds or removes // an Event constructor - final eventsAccountedForInTests = 28; + final eventsAccountedForInTests = 29; expect(eventsAccountedForInTests, constructorCount, reason: 'If you added or removed an event constructor, ' 'ensure you have updated '