Skip to content

Commit 125b9a9

Browse files
authored
Add a new Event for analytics for new analyzer plugins (#2286)
1 parent 9f6c3c9 commit 125b9a9

File tree

6 files changed

+73
-13
lines changed

6 files changed

+73
-13
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.12
2+
- Added `Event.plugins` to track new analyzer plugins
3+
14
## 8.0.11
25
- Added `DashEvent.ideEvent` to track IDE reported events.
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.11';
90+
const String kPackageVersion = '8.0.12';
9191

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

pkgs/unified_analytics/lib/src/enums.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,17 @@ enum DashEvent {
170170
),
171171
pluginRequest(
172172
label: 'plugin_request',
173-
description: 'Request responses from plugins',
173+
description:
174+
'Analyzer plugin performance information regarding server requests',
175+
),
176+
plugins(
177+
label: 'plugins',
178+
description: 'Information about how often _new_ analyzer plugins were used',
174179
),
175180
pluginUse(
176181
label: 'plugin_use',
177-
description: 'Information about how often a plugin was used',
182+
description:
183+
'Information about how often a _legacy_ analyzer plugin was used',
178184
),
179185
serverSession(
180186
label: 'server_session',

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -866,16 +866,16 @@ final class Event {
866866
},
867867
);
868868

869-
/// Event that is emitted periodically to report the performance of plugins
870-
/// when handling requests.
869+
/// Event that is emitted periodically to report the performance of analyzer
870+
/// plugins when handling requests.
871871
///
872-
/// [duration] - json encoded percentile values indicating how long it took
872+
/// [duration] - JSON-encoded percentile values indicating how long it took
873873
/// from the time the request was sent to the plugin until the response
874874
/// was processed by the server.
875875
///
876876
/// [method] - the name of the request sent to the plugin.
877877
///
878-
/// [pluginId] - the id of the plugin whose performance is being reported.
878+
/// [pluginId] - the ID of the plugin whose performance is being reported.
879879
Event.pluginRequest({
880880
required String duration,
881881
required String method,
@@ -889,16 +889,45 @@ final class Event {
889889
},
890890
);
891891

892+
/// Event that is emitted periodically to report information about how _new_
893+
/// analyzer plugins are used.
894+
///
895+
/// - [count] - the number of new plugins that were configured.
896+
/// - [lintRuleCounts] - JSON-encoded percentile values indicating the number
897+
/// of enabled lint rules for each plugin.
898+
/// - [warningRuleCounts] - JSON-encoded percentile values indicating the
899+
/// number of enabled warning rules for each plugin.
900+
/// - [fixCounts] - JSON-encoded percentile values indicating the number of
901+
/// fixes provided by each plugin.
902+
/// - [assistCounts] - JSON-encoded percentile values indicating the number of
903+
/// assists provided by each plugin.
904+
Event.plugins({
905+
required int count,
906+
required String lintRuleCounts,
907+
required String warningRuleCounts,
908+
required String fixCounts,
909+
required String assistCounts,
910+
}) : this._(
911+
eventName: DashEvent.plugins,
912+
eventData: {
913+
'count': count,
914+
'lintRuleCounts': lintRuleCounts,
915+
'warningRuleCounts': warningRuleCounts,
916+
'fixCounts': fixCounts,
917+
'assistCounts': assistCounts,
918+
},
919+
);
920+
892921
/// Event that is emitted periodically to report the frequency with which a
893-
/// given plugin has been used.
922+
/// given _legacy_ analyzer plugin has been used.
894923
///
895924
/// [count] - the number of times plugins usage was changed, which will always
896925
/// be at least one.
897926
///
898-
/// [enabled] - json encoded percentile values indicating the number of
899-
/// contexts for which the plugin was enabled.
927+
/// [enabled] - JSON-encoded percentile values indicating the number of
928+
/// analysis contexts for which the plugin was enabled.
900929
///
901-
/// [pluginId] - the id of the plugin associated with the data.
930+
/// [pluginId] - the ID of the plugin associated with the data.
902931
Event.pluginUse({
903932
required int count,
904933
required String enabled,

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.11
8+
version: 8.0.12
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,28 @@ void main() {
270270
expect(constructedEvent.eventData.length, 3);
271271
});
272272

273+
test('Event.plugins constructed', () {
274+
Event generateEvent() => Event.plugins(
275+
count: 5,
276+
lintRuleCounts: 'lintRuleCounts',
277+
warningRuleCounts: 'warningRuleCounts',
278+
fixCounts: 'fixCounts',
279+
assistCounts: 'assistCounts',
280+
);
281+
282+
final constructedEvent = generateEvent();
283+
284+
expect(generateEvent, returnsNormally);
285+
expect(constructedEvent.eventName, DashEvent.plugins);
286+
expect(constructedEvent.eventData['count'], 5);
287+
expect(constructedEvent.eventData['lintRuleCounts'], 'lintRuleCounts');
288+
expect(
289+
constructedEvent.eventData['warningRuleCounts'], 'warningRuleCounts');
290+
expect(constructedEvent.eventData['fixCounts'], 'fixCounts');
291+
expect(constructedEvent.eventData['assistCounts'], 'assistCounts');
292+
expect(constructedEvent.eventData, hasLength(5));
293+
});
294+
273295
test('Event.pluginUse constructed', () {
274296
Event generateEvent() => Event.pluginUse(
275297
count: 5,
@@ -804,7 +826,7 @@ void main() {
804826

805827
// Change this integer below if your PR either adds or removes
806828
// an Event constructor
807-
final eventsAccountedForInTests = 32;
829+
final eventsAccountedForInTests = 33;
808830
expect(eventsAccountedForInTests, constructorCount,
809831
reason: 'If you added or removed an event constructor, '
810832
'ensure you have updated '

0 commit comments

Comments
 (0)