diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index 4e40e8cf2..63ff3de92 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.2.0 + +- Added the `Event.hotRunnerInfo` constructor + ## 5.1.0 - Added the `Event.flutterBuildInfo` constructor diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index 2c2686488..43c7c5843 100644 --- a/pkgs/unified_analytics/lib/src/constants.dart +++ b/pkgs/unified_analytics/lib/src/constants.dart @@ -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.1.0'; +const String kPackageVersion = '5.2.0'; /// The minimum length for a session. const int kSessionDurationMinutes = 30; diff --git a/pkgs/unified_analytics/lib/src/enums.dart b/pkgs/unified_analytics/lib/src/enums.dart index 806f3ab64..db9e89e06 100644 --- a/pkgs/unified_analytics/lib/src/enums.dart +++ b/pkgs/unified_analytics/lib/src/enums.dart @@ -61,6 +61,11 @@ enum DashEvent { description: 'Hot reload duration', toolOwner: DashTool.flutterTool, ), + hotRunnerInfo( + label: 'hot_runner_info', + description: 'Information related to the Flutter hot runner', + toolOwner: DashTool.flutterTool, + ), // Events for language_server below diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index 4dbb0643f..3681b59fd 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart @@ -266,10 +266,64 @@ final class Event { if (error != null) 'error': error, }; + // TODO: eliasyishak, remove this or replace once we have a generic + // timing event that can be used by potentially more than one DashTool Event.hotReloadTime({required int timeMs}) : eventName = DashEvent.hotReloadTime, eventData = {'timeMs': timeMs}; + // TODO: eliasyishak, add better dartdocs to explain each param + /// Events to be sent for the Flutter Hot Runner. + Event.hotRunnerInfo({ + required String label, + required String targetPlatform, + required String sdkName, + required bool emulator, + required bool fullRestart, + String? reason, + int? finalLibraryCount, + int? syncedLibraryCount, + int? syncedClassesCount, + int? syncedProceduresCount, + int? syncedBytes, + int? invalidatedSourcesCount, + int? transferTimeInMs, + int? overallTimeInMs, + int? compileTimeInMs, + int? findInvalidatedTimeInMs, + int? scannedSourcesCount, + int? reassembleTimeInMs, + int? reloadVMTimeInMs, + }) : eventName = DashEvent.hotRunnerInfo, + eventData = { + 'label': label, + 'targetPlatform': targetPlatform, + 'sdkName': sdkName, + 'emulator': emulator, + 'fullRestart': fullRestart, + if (reason != null) 'reason': reason, + if (finalLibraryCount != null) 'finalLibraryCount': finalLibraryCount, + if (syncedLibraryCount != null) + 'syncedLibraryCount': syncedLibraryCount, + if (syncedClassesCount != null) + 'syncedClassesCount': syncedClassesCount, + if (syncedProceduresCount != null) + 'syncedProceduresCount': syncedProceduresCount, + if (syncedBytes != null) 'syncedBytes': syncedBytes, + if (invalidatedSourcesCount != null) + 'invalidatedSourcesCount': invalidatedSourcesCount, + if (transferTimeInMs != null) 'transferTimeInMs': transferTimeInMs, + if (overallTimeInMs != null) 'overallTimeInMs': overallTimeInMs, + if (compileTimeInMs != null) 'compileTimeInMs': compileTimeInMs, + if (findInvalidatedTimeInMs != null) + 'findInvalidatedTimeInMs': findInvalidatedTimeInMs, + if (scannedSourcesCount != null) + 'scannedSourcesCount': scannedSourcesCount, + if (reassembleTimeInMs != null) + 'reassembleTimeInMs': reassembleTimeInMs, + if (reloadVMTimeInMs != null) 'reloadVMTimeInMs': reloadVMTimeInMs, + }; + /// Event that is emitted periodically to report the number of times each lint /// has been enabled. /// diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index f23adbb04..a65eafc37 100644 --- a/pkgs/unified_analytics/pubspec.yaml +++ b/pkgs/unified_analytics/pubspec.yaml @@ -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.1.0 +version: 5.2.0 repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics environment: diff --git a/pkgs/unified_analytics/test/event_test.dart b/pkgs/unified_analytics/test/event_test.dart index 0dd1f57ec..1d65106fd 100644 --- a/pkgs/unified_analytics/test/event_test.dart +++ b/pkgs/unified_analytics/test/event_test.dart @@ -332,6 +332,55 @@ void main() { expect(constructedEvent.eventData.length, 5); }); + test('Event.hotRunnerInfo constructed', () { + Event generateEvent() => Event.hotRunnerInfo( + label: 'label', + targetPlatform: 'targetPlatform', + sdkName: 'sdkName', + emulator: false, + fullRestart: true, + reason: 'reason', + finalLibraryCount: 5, + syncedLibraryCount: 6, + syncedClassesCount: 7, + syncedProceduresCount: 8, + syncedBytes: 9, + invalidatedSourcesCount: 10, + transferTimeInMs: 11, + overallTimeInMs: 12, + compileTimeInMs: 13, + findInvalidatedTimeInMs: 14, + scannedSourcesCount: 15, + reassembleTimeInMs: 16, + reloadVMTimeInMs: 17, + ); + + final constructedEvent = generateEvent(); + + expect(generateEvent, returnsNormally); + expect(constructedEvent.eventName, DashEvent.hotRunnerInfo); + expect(constructedEvent.eventData['label'], 'label'); + expect(constructedEvent.eventData['targetPlatform'], 'targetPlatform'); + expect(constructedEvent.eventData['sdkName'], 'sdkName'); + expect(constructedEvent.eventData['emulator'], false); + expect(constructedEvent.eventData['fullRestart'], true); + expect(constructedEvent.eventData['reason'], 'reason'); + expect(constructedEvent.eventData['finalLibraryCount'], 5); + expect(constructedEvent.eventData['syncedLibraryCount'], 6); + expect(constructedEvent.eventData['syncedClassesCount'], 7); + expect(constructedEvent.eventData['syncedProceduresCount'], 8); + expect(constructedEvent.eventData['syncedBytes'], 9); + expect(constructedEvent.eventData['invalidatedSourcesCount'], 10); + expect(constructedEvent.eventData['transferTimeInMs'], 11); + expect(constructedEvent.eventData['overallTimeInMs'], 12); + expect(constructedEvent.eventData['compileTimeInMs'], 13); + expect(constructedEvent.eventData['findInvalidatedTimeInMs'], 14); + expect(constructedEvent.eventData['scannedSourcesCount'], 15); + expect(constructedEvent.eventData['reassembleTimeInMs'], 16); + expect(constructedEvent.eventData['reloadVMTimeInMs'], 17); + expect(constructedEvent.eventData.length, 19); + }); + test('Confirm all constructors were checked', () { var constructorCount = 0; for (var declaration in reflectClass(Event).declarations.keys) { @@ -340,7 +389,7 @@ void main() { // Change this integer below if your PR either adds or removes // an Event constructor - final eventsAccountedForInTests = 18; + final eventsAccountedForInTests = 19; expect(eventsAccountedForInTests, constructorCount, reason: 'If you added or removed an event constructor, ' 'ensure you have updated '