Skip to content

Commit

Permalink
New enum + constructor added for nullSafetyAnalysisResult
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasyishak committed Nov 13, 2023
1 parent 68b4e6b commit 924058a
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
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.5.0

- Added the `Event.nullSafetyAnalysisResult` constructor

## 5.4.0

- Added the `Event.codeSizeAnalysis` constructor
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.4.0';
const String kPackageVersion = '5.5.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 @@ -76,6 +76,11 @@ enum DashEvent {
description: 'Information related to the Flutter hot runner',
toolOwner: DashTool.flutterTool,
),
nullSafetyAnalysisResult(
label: 'null_safety_analysis_results',
description: 'Information related to null safety analysis within flutter',
toolOwner: DashTool.flutterTool,
),

// Events for language_server below

Expand Down
24 changes: 24 additions & 0 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ final class Event {
'method': method,
};

/// Contains information about null safety migration within a flutter project.
///
/// [runtimeMode] - The null safety runtime mode the app should be built in.
///
/// [nullSafeMigratedLibraries] - count of libraries with language versions
/// that are greater than 2.12 to indicate migration to null safety.
///
/// [nullSafeTotalLibraries] - the total number of packages in the package
/// config.
///
/// [languageVersion] - the dart language version for the package.
Event.nullSafetyAnalysisResult({
required String runtimeMode,
required int nullSafeMigratedLibraries,
required int nullSafeTotalLibraries,
String? languageVersion,
}) : eventName = DashEvent.nullSafetyAnalysisResult,
eventData = {
'runtimeMode': runtimeMode,
'nullSafeMigratedLibraries': nullSafeMigratedLibraries,
'nullSafeTotalLibraries': nullSafeTotalLibraries,
if (languageVersion != null) 'languageVersion': languageVersion,
};

/// Event that is emitted periodically to report the performance of the
/// analysis server's handling of a specific kind of request from the client.
///
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.4.0
version: 5.5.0
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

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

test('Event.nullSafetyAnalysisResult constructed', () {
Event generateEvent() => Event.nullSafetyAnalysisResult(
runtimeMode: 'runtimeMode',
nullSafeMigratedLibraries: 4,
nullSafeTotalLibraries: 5,
languageVersion: 'languageVersion');

final constructedEvent = generateEvent();

expect(generateEvent, returnsNormally);
expect(constructedEvent.eventName, DashEvent.nullSafetyAnalysisResult);
expect(constructedEvent.eventData['runtimeMode'], 'runtimeMode');
expect(constructedEvent.eventData['nullSafeMigratedLibraries'], 4);
expect(constructedEvent.eventData['nullSafeTotalLibraries'], 5);
expect(constructedEvent.eventData['languageVersion'], 'languageVersion');
expect(constructedEvent.eventData.length, 4);
});

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

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

0 comments on commit 924058a

Please sign in to comment.