Skip to content

Commit ce9d2ad

Browse files
authored
Add Event.analysisStatistics() constructor. (#2191)
1 parent 19f91a0 commit ce9d2ad

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-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.6
2+
- Added `Event.analysisStatistics` for events from Dart Analysis Server, about analysis.
3+
14
## 8.0.5
25
- Fix `Event.flutterWasmDryRun` fields.
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.5';
90+
const String kPackageVersion = '8.0.6';
9191

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

pkgs/unified_analytics/lib/src/enums.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ enum DashEvent {
126126

127127
// Events for language_server below
128128

129+
analysisStatistics(
130+
label: 'analysis_statistics',
131+
description: 'Dart analyzer statistics',
132+
),
129133
clientNotification(
130134
label: 'client_notification',
131135
description: 'Notifications sent from the client',

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ final class Event {
103103
},
104104
);
105105

106+
/// Event that is emitted periodically to report the performance of the
107+
/// analyzer.
108+
///
109+
/// [workingDuration] - json encoded percentile values indicating how long
110+
/// the analysis status was "working".
111+
Event.analysisStatistics({
112+
required String workingDuration,
113+
}) : this._(
114+
eventName: DashEvent.analysisStatistics,
115+
eventData: {
116+
'workingDuration': workingDuration,
117+
},
118+
);
119+
106120
/// Event that is emitted periodically to report the performance of the
107121
/// analysis server's handling of a specific kind of request from the client.
108122
///

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.5
8+
version: 8.0.6
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: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ import 'package:unified_analytics/src/event.dart';
1010
import 'package:unified_analytics/unified_analytics.dart';
1111

1212
void main() {
13+
test('Event.analysisStatistics constructed', () {
14+
Event generateEvent() =>
15+
Event.analysisStatistics(workingDuration: 'workingDuration');
16+
17+
final constructedEvent = generateEvent();
18+
19+
expect(generateEvent, returnsNormally);
20+
expect(constructedEvent.eventName, DashEvent.analysisStatistics);
21+
expect(constructedEvent.eventData['workingDuration'], 'workingDuration');
22+
expect(constructedEvent.eventData.length, 1);
23+
});
24+
1325
test('Event.analyticsCollectionEnabled constructed', () {
1426
Event generateEvent() => Event.analyticsCollectionEnabled(status: false);
1527

@@ -729,7 +741,7 @@ void main() {
729741

730742
// Change this integer below if your PR either adds or removes
731743
// an Event constructor
732-
final eventsAccountedForInTests = 30;
744+
final eventsAccountedForInTests = 31;
733745
expect(eventsAccountedForInTests, constructorCount,
734746
reason: 'If you added or removed an event constructor, '
735747
'ensure you have updated '

0 commit comments

Comments
 (0)