Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enum + event constructor for code size analysis #200

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.4.0

- Added the `Event.codeSizeAnalysis` constructor

## 5.3.0

- User property "host_os_version" added to provide detail version information about the host
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const int kLogFileLength = 2500;
const String kLogFileName = 'dart-flutter-telemetry.log';

/// The current version of the package, should be in line with pubspec version.
const String kPackageVersion = '5.3.0';
const String kPackageVersion = '5.4.0';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand Down
5 changes: 5 additions & 0 deletions pkgs/unified_analytics/lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ enum DashEvent {

// Events for the Flutter CLI

codeSizeAnalysis(
label: 'code_size_analysis',
description: 'Indicates when the "--analyize-size" command is run',
toolOwner: DashTool.flutterTool,
),
doctorValidatorResult(
label: 'doctor_validator_result',
description: 'Results from a specific doctor validator',
Expand Down
9 changes: 9 additions & 0 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ final class Event {
if (removed != null) 'removed': removed,
};

/// An event that reports when the code size measurement is run
/// via `--analyze-size`.
///
/// [kind] - string identifier for which platform was run "ios", "apk",
eliasyishak marked this conversation as resolved.
Show resolved Hide resolved
/// "aab", etc.
Event.codeSizeAnalysis({required String kind})
: eventName = DashEvent.codeSizeAnalysis,
eventData = {'kind': kind};

/// Event that is emitted periodically to report the number of times a given
/// command has been executed.
///
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: >-
to Google Analytics.
# When updating this, keep the version consistent with the changelog and the
# value in lib/src/constants.dart.
version: 5.3.0
version: 5.4.0
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

environment:
Expand Down
13 changes: 12 additions & 1 deletion pkgs/unified_analytics/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,17 @@ void main() {
expect(constructedEvent.eventData.length, 3);
});

test('Event.codeSizeAnalysis constructed', () {
Event generateEvent() => Event.codeSizeAnalysis(kind: 'kind');

final constructedEvent = generateEvent();

expect(generateEvent, returnsNormally);
expect(constructedEvent.eventName, DashEvent.codeSizeAnalysis);
expect(constructedEvent.eventData['kind'], 'kind');
expect(constructedEvent.eventData.length, 1);
});

test('Confirm all constructors were checked', () {
var constructorCount = 0;
for (var declaration in reflectClass(Event).declarations.keys) {
Expand All @@ -406,7 +417,7 @@ void main() {

// Change this integer below if your PR either adds or removes
// an Event constructor
final eventsAccountedForInTests = 20;
final eventsAccountedForInTests = 21;
expect(eventsAccountedForInTests, constructorCount,
reason: 'If you added or removed an event constructor, '
'ensure you have updated '
Expand Down