Skip to content

Commit 7bf22c9

Browse files
authored
[unified_analytics]Add library cycle info to analysis server data (#2117)
1 parent 1e110fc commit 7bf22c9

File tree

5 files changed

+59
-45
lines changed

5 files changed

+59
-45
lines changed

pkgs/unified_analytics/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 8.0.3
2+
- Changed `Event.contextStructure` to make optional data that's no longer being
3+
collected and to add data about the size of library cycles.
4+
15
## 8.0.2
26
- Added `Event.dartMCPEvent` for events from the `dart mcp-server` command.
37

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.2';
90+
const String kPackageVersion = '8.0.3';
9191

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

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,6 @@ final class Event {
309309
/// Event that is emitted on shutdown to report the structure of the analysis
310310
/// contexts created immediately after startup.
311311
///
312-
/// [contextsFromBothFiles] - the number of contexts that were created because
313-
/// of both a package config and an analysis options file.
314-
///
315-
/// [contextsFromOptionsFiles] - the number of contexts that were created
316-
/// because of an analysis options file.
317-
///
318-
/// [contextsFromPackagesFiles] - the number of contexts that were created
319-
/// because of a package config file.
320-
///
321-
/// [contextsWithoutFiles] - the number of contexts that were created because
322-
/// of the lack of either a package config or an analysis options file.
323-
///
324312
/// [immediateFileCount] - the number of files in one of the analysis
325313
/// contexts.
326314
///
@@ -341,32 +329,54 @@ final class Event {
341329
///
342330
/// [transitiveFileUniqueLineCount] - the number of lines in the unique
343331
/// transitive files.
332+
///
333+
/// [libraryCycleLibraryCounts] - json encoded percentile values indicating
334+
/// the number of libraries in a single library cycle.
335+
///
336+
/// [libraryCycleLineCounts] - json encoded percentile values indicating the
337+
/// number of lines of code in all of the files in a single library cycle.
338+
///
339+
/// [contextsFromBothFiles] - the number of contexts that were created because
340+
/// of both a package config and an analysis options file.
341+
///
342+
/// [contextsFromOptionsFiles] - the number of contexts that were created
343+
/// because of an analysis options file.
344+
///
345+
/// [contextsFromPackagesFiles] - the number of contexts that were created
346+
/// because of a package config file.
347+
///
348+
/// [contextsWithoutFiles] - the number of contexts that were created because
349+
/// of the lack of either a package config or an analysis options file.
344350
Event.contextStructure({
345-
required int contextsFromBothFiles,
346-
required int contextsFromOptionsFiles,
347-
required int contextsFromPackagesFiles,
348-
required int contextsWithoutFiles,
349351
required int immediateFileCount,
350352
required int immediateFileLineCount,
351353
required int numberOfContexts,
352354
required int transitiveFileCount,
353355
required int transitiveFileLineCount,
354356
required int transitiveFileUniqueCount,
355357
required int transitiveFileUniqueLineCount,
358+
String libraryCycleLibraryCounts = '',
359+
String libraryCycleLineCounts = '',
360+
int contextsFromBothFiles = 0,
361+
int contextsFromOptionsFiles = 0,
362+
int contextsFromPackagesFiles = 0,
363+
int contextsWithoutFiles = 0,
356364
}) : this._(
357365
eventName: DashEvent.contextStructure,
358366
eventData: {
359-
'contextsFromBothFiles': contextsFromBothFiles,
360-
'contextsFromOptionsFiles': contextsFromOptionsFiles,
361-
'contextsFromPackagesFiles': contextsFromPackagesFiles,
362-
'contextsWithoutFiles': contextsWithoutFiles,
363367
'immediateFileCount': immediateFileCount,
364368
'immediateFileLineCount': immediateFileLineCount,
365369
'numberOfContexts': numberOfContexts,
366370
'transitiveFileCount': transitiveFileCount,
367371
'transitiveFileLineCount': transitiveFileLineCount,
368372
'transitiveFileUniqueCount': transitiveFileUniqueCount,
369373
'transitiveFileUniqueLineCount': transitiveFileUniqueLineCount,
374+
'libraryCycleLibraryCounts': libraryCycleLibraryCounts,
375+
'libraryCycleLineCounts': libraryCycleLineCounts,
376+
'contextsFromBothFiles': contextsFromBothFiles,
377+
'contextsFromOptionsFiles': contextsFromOptionsFiles,
378+
'contextsFromPackagesFiles': contextsFromPackagesFiles,
379+
'contextsWithoutFiles': contextsWithoutFiles,
370380
},
371381
);
372382

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.2
8+
version: 8.0.3
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: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,35 +85,35 @@ void main() {
8585

8686
test('Event.contextStructure constructed', () {
8787
Event generateEvent() => Event.contextStructure(
88-
contextsFromBothFiles: 1,
89-
contextsFromOptionsFiles: 2,
90-
contextsFromPackagesFiles: 3,
91-
contextsWithoutFiles: 4,
92-
immediateFileCount: 5,
93-
immediateFileLineCount: 6,
94-
numberOfContexts: 7,
95-
transitiveFileCount: 8,
96-
transitiveFileLineCount: 9,
97-
transitiveFileUniqueCount: 10,
98-
transitiveFileUniqueLineCount: 11,
88+
immediateFileCount: 1,
89+
immediateFileLineCount: 2,
90+
numberOfContexts: 3,
91+
transitiveFileCount: 4,
92+
transitiveFileLineCount: 5,
93+
transitiveFileUniqueCount: 6,
94+
transitiveFileUniqueLineCount: 7,
95+
libraryCycleLibraryCounts: 'a',
96+
libraryCycleLineCounts: 'b',
9997
);
10098

10199
final constructedEvent = generateEvent();
102100

103101
expect(generateEvent, returnsNormally);
104102
expect(constructedEvent.eventName, DashEvent.contextStructure);
105-
expect(constructedEvent.eventData['contextsFromBothFiles'], 1);
106-
expect(constructedEvent.eventData['contextsFromOptionsFiles'], 2);
107-
expect(constructedEvent.eventData['contextsFromPackagesFiles'], 3);
108-
expect(constructedEvent.eventData['contextsWithoutFiles'], 4);
109-
expect(constructedEvent.eventData['immediateFileCount'], 5);
110-
expect(constructedEvent.eventData['immediateFileLineCount'], 6);
111-
expect(constructedEvent.eventData['numberOfContexts'], 7);
112-
expect(constructedEvent.eventData['transitiveFileCount'], 8);
113-
expect(constructedEvent.eventData['transitiveFileLineCount'], 9);
114-
expect(constructedEvent.eventData['transitiveFileUniqueCount'], 10);
115-
expect(constructedEvent.eventData['transitiveFileUniqueLineCount'], 11);
116-
expect(constructedEvent.eventData.length, 11);
103+
expect(constructedEvent.eventData['immediateFileCount'], 1);
104+
expect(constructedEvent.eventData['immediateFileLineCount'], 2);
105+
expect(constructedEvent.eventData['numberOfContexts'], 3);
106+
expect(constructedEvent.eventData['transitiveFileCount'], 4);
107+
expect(constructedEvent.eventData['transitiveFileLineCount'], 5);
108+
expect(constructedEvent.eventData['transitiveFileUniqueCount'], 6);
109+
expect(constructedEvent.eventData['transitiveFileUniqueLineCount'], 7);
110+
expect(constructedEvent.eventData['libraryCycleLibraryCounts'], 'a');
111+
expect(constructedEvent.eventData['libraryCycleLineCounts'], 'b');
112+
expect(constructedEvent.eventData['contextsFromBothFiles'], 0);
113+
expect(constructedEvent.eventData['contextsFromOptionsFiles'], 0);
114+
expect(constructedEvent.eventData['contextsFromPackagesFiles'], 0);
115+
expect(constructedEvent.eventData['contextsWithoutFiles'], 0);
116+
expect(constructedEvent.eventData.length, 13);
117117
});
118118

119119
test('Event.dartCliCommandExecuted constructed', () {

0 commit comments

Comments
 (0)