[unified_analytics]Add library cycle info to analysis server data (#2117)
diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index e5c26c9..bb1ba6a 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md
@@ -1,3 +1,7 @@ +## 8.0.3 +- Changed `Event.contextStructure` to make optional data that's no longer being + collected and to add data about the size of library cycles. + ## 8.0.2 - Added `Event.dartMCPEvent` for events from the `dart mcp-server` command.
diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index 3d472ea..449c591 100644 --- a/pkgs/unified_analytics/lib/src/constants.dart +++ b/pkgs/unified_analytics/lib/src/constants.dart
@@ -87,7 +87,7 @@ 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.2'; +const String kPackageVersion = '8.0.3'; /// The minimum length for a session. const int kSessionDurationMinutes = 30;
diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index 7fcaad6..45b0ac5 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart
@@ -309,18 +309,6 @@ /// Event that is emitted on shutdown to report the structure of the analysis /// contexts created immediately after startup. /// - /// [contextsFromBothFiles] - the number of contexts that were created because - /// of both a package config and an analysis options file. - /// - /// [contextsFromOptionsFiles] - the number of contexts that were created - /// because of an analysis options file. - /// - /// [contextsFromPackagesFiles] - the number of contexts that were created - /// because of a package config file. - /// - /// [contextsWithoutFiles] - the number of contexts that were created because - /// of the lack of either a package config or an analysis options file. - /// /// [immediateFileCount] - the number of files in one of the analysis /// contexts. /// @@ -341,11 +329,25 @@ /// /// [transitiveFileUniqueLineCount] - the number of lines in the unique /// transitive files. + /// + /// [libraryCycleLibraryCounts] - json encoded percentile values indicating + /// the number of libraries in a single library cycle. + /// + /// [libraryCycleLineCounts] - json encoded percentile values indicating the + /// number of lines of code in all of the files in a single library cycle. + /// + /// [contextsFromBothFiles] - the number of contexts that were created because + /// of both a package config and an analysis options file. + /// + /// [contextsFromOptionsFiles] - the number of contexts that were created + /// because of an analysis options file. + /// + /// [contextsFromPackagesFiles] - the number of contexts that were created + /// because of a package config file. + /// + /// [contextsWithoutFiles] - the number of contexts that were created because + /// of the lack of either a package config or an analysis options file. Event.contextStructure({ - required int contextsFromBothFiles, - required int contextsFromOptionsFiles, - required int contextsFromPackagesFiles, - required int contextsWithoutFiles, required int immediateFileCount, required int immediateFileLineCount, required int numberOfContexts, @@ -353,13 +355,15 @@ required int transitiveFileLineCount, required int transitiveFileUniqueCount, required int transitiveFileUniqueLineCount, + String libraryCycleLibraryCounts = '', + String libraryCycleLineCounts = '', + int contextsFromBothFiles = 0, + int contextsFromOptionsFiles = 0, + int contextsFromPackagesFiles = 0, + int contextsWithoutFiles = 0, }) : this._( eventName: DashEvent.contextStructure, eventData: { - 'contextsFromBothFiles': contextsFromBothFiles, - 'contextsFromOptionsFiles': contextsFromOptionsFiles, - 'contextsFromPackagesFiles': contextsFromPackagesFiles, - 'contextsWithoutFiles': contextsWithoutFiles, 'immediateFileCount': immediateFileCount, 'immediateFileLineCount': immediateFileLineCount, 'numberOfContexts': numberOfContexts, @@ -367,6 +371,12 @@ 'transitiveFileLineCount': transitiveFileLineCount, 'transitiveFileUniqueCount': transitiveFileUniqueCount, 'transitiveFileUniqueLineCount': transitiveFileUniqueLineCount, + 'libraryCycleLibraryCounts': libraryCycleLibraryCounts, + 'libraryCycleLineCounts': libraryCycleLineCounts, + 'contextsFromBothFiles': contextsFromBothFiles, + 'contextsFromOptionsFiles': contextsFromOptionsFiles, + 'contextsFromPackagesFiles': contextsFromPackagesFiles, + 'contextsWithoutFiles': contextsWithoutFiles, }, );
diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index 94b3fe9..b3517d6 100644 --- a/pkgs/unified_analytics/pubspec.yaml +++ b/pkgs/unified_analytics/pubspec.yaml
@@ -5,7 +5,7 @@ # LINT.IfChange # When updating this, keep the version consistent with the changelog and the # value in lib/src/constants.dart. -version: 8.0.2 +version: 8.0.3 # 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 9c4a99c..98924fb 100644 --- a/pkgs/unified_analytics/test/event_test.dart +++ b/pkgs/unified_analytics/test/event_test.dart
@@ -85,35 +85,35 @@ test('Event.contextStructure constructed', () { Event generateEvent() => Event.contextStructure( - contextsFromBothFiles: 1, - contextsFromOptionsFiles: 2, - contextsFromPackagesFiles: 3, - contextsWithoutFiles: 4, - immediateFileCount: 5, - immediateFileLineCount: 6, - numberOfContexts: 7, - transitiveFileCount: 8, - transitiveFileLineCount: 9, - transitiveFileUniqueCount: 10, - transitiveFileUniqueLineCount: 11, + immediateFileCount: 1, + immediateFileLineCount: 2, + numberOfContexts: 3, + transitiveFileCount: 4, + transitiveFileLineCount: 5, + transitiveFileUniqueCount: 6, + transitiveFileUniqueLineCount: 7, + libraryCycleLibraryCounts: 'a', + libraryCycleLineCounts: 'b', ); final constructedEvent = generateEvent(); expect(generateEvent, returnsNormally); expect(constructedEvent.eventName, DashEvent.contextStructure); - expect(constructedEvent.eventData['contextsFromBothFiles'], 1); - expect(constructedEvent.eventData['contextsFromOptionsFiles'], 2); - expect(constructedEvent.eventData['contextsFromPackagesFiles'], 3); - expect(constructedEvent.eventData['contextsWithoutFiles'], 4); - expect(constructedEvent.eventData['immediateFileCount'], 5); - expect(constructedEvent.eventData['immediateFileLineCount'], 6); - expect(constructedEvent.eventData['numberOfContexts'], 7); - expect(constructedEvent.eventData['transitiveFileCount'], 8); - expect(constructedEvent.eventData['transitiveFileLineCount'], 9); - expect(constructedEvent.eventData['transitiveFileUniqueCount'], 10); - expect(constructedEvent.eventData['transitiveFileUniqueLineCount'], 11); - expect(constructedEvent.eventData.length, 11); + expect(constructedEvent.eventData['immediateFileCount'], 1); + expect(constructedEvent.eventData['immediateFileLineCount'], 2); + expect(constructedEvent.eventData['numberOfContexts'], 3); + expect(constructedEvent.eventData['transitiveFileCount'], 4); + expect(constructedEvent.eventData['transitiveFileLineCount'], 5); + expect(constructedEvent.eventData['transitiveFileUniqueCount'], 6); + expect(constructedEvent.eventData['transitiveFileUniqueLineCount'], 7); + expect(constructedEvent.eventData['libraryCycleLibraryCounts'], 'a'); + expect(constructedEvent.eventData['libraryCycleLineCounts'], 'b'); + expect(constructedEvent.eventData['contextsFromBothFiles'], 0); + expect(constructedEvent.eventData['contextsFromOptionsFiles'], 0); + expect(constructedEvent.eventData['contextsFromPackagesFiles'], 0); + expect(constructedEvent.eventData['contextsWithoutFiles'], 0); + expect(constructedEvent.eventData.length, 13); }); test('Event.dartCliCommandExecuted constructed', () {