From 5ee1ef3b911bb076e4d2aeedb125c67f8cfe383a Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:21:44 -0500 Subject: [PATCH 1/4] Added event for general apple work flow events --- pkgs/unified_analytics/CHANGELOG.md | 1 + pkgs/unified_analytics/lib/src/enums.dart | 6 ++++++ pkgs/unified_analytics/lib/src/event.dart | 19 +++++++++++++++++++ pkgs/unified_analytics/test/event_test.dart | 19 ++++++++++++++++++- 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index 65b1c0f4f..dc94912a6 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -2,6 +2,7 @@ - Edit to the `Event.flutterCommandResult` constructor to add `commandHasTerminal` - Added timeout for `Analytics.setTelemetry` to prevent the clients from hanging +- Added the `Event.appleUsageEvent` constructor ## 5.4.0 diff --git a/pkgs/unified_analytics/lib/src/enums.dart b/pkgs/unified_analytics/lib/src/enums.dart index 18dc190cc..5f6183e91 100644 --- a/pkgs/unified_analytics/lib/src/enums.dart +++ b/pkgs/unified_analytics/lib/src/enums.dart @@ -46,6 +46,12 @@ enum DashEvent { // Events for the Flutter CLI + appleUsageEvent( + label: 'apple_usage_event', + description: + 'Events related to iOS/macOS workflows within the flutter tool', + toolOwner: DashTool.flutterTool, + ), codeSizeAnalysis( label: 'code_size_analysis', description: 'Indicates when the "--analyize-size" command is run', diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index f163653ba..190ce2f69 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart @@ -277,6 +277,25 @@ final class Event { if (error != null) 'error': error, }; + /// This is for various workflows within the flutter tool related + /// to iOS and macOS workflows. + /// + /// [workflow] - which workflow is running, such as "assemble". + /// + /// [parameter] - subcategory of the workflow, such as "ios-archive". + /// + /// [label] - usually to indicate success or failure of the workflow. + Event.appleUsageEvent({ + required String workflow, + required String parameter, + String? label, + }) : eventName = DashEvent.appleUsageEvent, + eventData = { + 'workflow': workflow, + 'parameter': parameter, + if (label != null) 'label': label, + }; + /// Provides information about which flutter command was run /// and whether it was successful. /// diff --git a/pkgs/unified_analytics/test/event_test.dart b/pkgs/unified_analytics/test/event_test.dart index 4d4c9148e..36f0c27e8 100644 --- a/pkgs/unified_analytics/test/event_test.dart +++ b/pkgs/unified_analytics/test/event_test.dart @@ -411,6 +411,23 @@ void main() { expect(constructedEvent.eventData.length, 1); }); + test('Event.appleUsageEvent constructed', () { + Event generateEvent() => Event.appleUsageEvent( + workflow: 'workflow', + parameter: 'parameter', + label: 'label', + ); + + final constructedEvent = generateEvent(); + + expect(generateEvent, returnsNormally); + expect(constructedEvent.eventName, DashEvent.appleUsageEvent); + expect(constructedEvent.eventData['workflow'], 'workflow'); + expect(constructedEvent.eventData['parameter'], 'parameter'); + expect(constructedEvent.eventData['label'], 'label'); + expect(constructedEvent.eventData.length, 3); + }); + test('Confirm all constructors were checked', () { var constructorCount = 0; for (var declaration in reflectClass(Event).declarations.keys) { @@ -419,7 +436,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 ' From 7515ee5b6dcfda3e523b15a2fa82b68f451399b2 Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:25:08 -0500 Subject: [PATCH 2/4] Organize members --- pkgs/unified_analytics/lib/src/event.dart | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index 190ce2f69..f85a85e71 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart @@ -19,6 +19,25 @@ final class Event { : eventName = DashEvent.analyticsCollectionEnabled, eventData = {'status': status}; + /// This is for various workflows within the flutter tool related + /// to iOS and macOS workflows. + /// + /// [workflow] - which workflow is running, such as "assemble". + /// + /// [parameter] - subcategory of the workflow, such as "ios-archive". + /// + /// [label] - usually to indicate success or failure of the workflow. + Event.appleUsageEvent({ + required String workflow, + required String parameter, + String? label, + }) : eventName = DashEvent.appleUsageEvent, + eventData = { + 'workflow': workflow, + 'parameter': parameter, + if (label != null) 'label': label, + }; + /// Event that is emitted periodically to report the performance of the /// analysis server's handling of a specific kind of notification from the /// client. @@ -277,25 +296,6 @@ final class Event { if (error != null) 'error': error, }; - /// This is for various workflows within the flutter tool related - /// to iOS and macOS workflows. - /// - /// [workflow] - which workflow is running, such as "assemble". - /// - /// [parameter] - subcategory of the workflow, such as "ios-archive". - /// - /// [label] - usually to indicate success or failure of the workflow. - Event.appleUsageEvent({ - required String workflow, - required String parameter, - String? label, - }) : eventName = DashEvent.appleUsageEvent, - eventData = { - 'workflow': workflow, - 'parameter': parameter, - if (label != null) 'label': label, - }; - /// Provides information about which flutter command was run /// and whether it was successful. /// From a0738446d5339bcfc69cd0980512b71bb1ca3f41 Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:36:59 -0500 Subject: [PATCH 3/4] Adding `exception` event + prep for publish --- pkgs/unified_analytics/CHANGELOG.md | 3 ++- pkgs/unified_analytics/lib/src/constants.dart | 2 +- pkgs/unified_analytics/lib/src/enums.dart | 4 ++++ pkgs/unified_analytics/lib/src/event.dart | 8 ++++++++ pkgs/unified_analytics/pubspec.yaml | 2 +- pkgs/unified_analytics/test/event_test.dart | 13 ++++++++++++- 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index dc94912a6..728d53e58 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -1,8 +1,9 @@ -## 5.5.0-wip +## 5.5.0 - Edit to the `Event.flutterCommandResult` constructor to add `commandHasTerminal` - Added timeout for `Analytics.setTelemetry` to prevent the clients from hanging - Added the `Event.appleUsageEvent` constructor +- Added the `Event.exception` constructor ## 5.4.0 diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index 8e2610dba..efd67f26f 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.5.0-wip'; +const String kPackageVersion = '5.5.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 5f6183e91..6f6e99aa4 100644 --- a/pkgs/unified_analytics/lib/src/enums.dart +++ b/pkgs/unified_analytics/lib/src/enums.dart @@ -22,6 +22,10 @@ enum DashEvent { label: 'analytics_collection_enabled', description: 'The opt-in status for analytics collection', ), + exception( + label: 'exception', + description: 'General errors to log', + ), surveyAction( label: 'survey_action', description: 'Actions taken by users when shown survey', diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index f85a85e71..4516c5922 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart @@ -266,6 +266,14 @@ final class Event { if (statusInfo != null) 'statusInfo': statusInfo, }; + /// Generic event for all dash tools to use when encountering an + /// exception that we want to log. + /// + /// [exception] - string representation of the exception that occured. + Event.exception({required String exception}) + : eventName = DashEvent.exception, + eventData = {'exception': exception}; + /// Event that is emitted from the flutter tool when a build invocation /// has been run by the user. /// diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index b733158ba..814884b0a 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.5.0-wip +version: 5.5.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 36f0c27e8..e1ba21667 100644 --- a/pkgs/unified_analytics/test/event_test.dart +++ b/pkgs/unified_analytics/test/event_test.dart @@ -428,6 +428,17 @@ void main() { expect(constructedEvent.eventData.length, 3); }); + test('Event.exception constructed', () { + Event generateEvent() => Event.exception(exception: 'exception'); + + final constructedEvent = generateEvent(); + + expect(generateEvent, returnsNormally); + expect(constructedEvent.eventName, DashEvent.exception); + expect(constructedEvent.eventData['exception'], 'exception'); + expect(constructedEvent.eventData.length, 1); + }); + test('Confirm all constructors were checked', () { var constructorCount = 0; for (var declaration in reflectClass(Event).declarations.keys) { @@ -436,7 +447,7 @@ void main() { // Change this integer below if your PR either adds or removes // an Event constructor - final eventsAccountedForInTests = 22; + final eventsAccountedForInTests = 23; expect(eventsAccountedForInTests, constructorCount, reason: 'If you added or removed an event constructor, ' 'ensure you have updated ' From cb253ac56dab86c95900b93857f68e85448a7050 Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:43:33 -0500 Subject: [PATCH 4/4] `label` --> `result` for `appleUsageEvent` --- pkgs/unified_analytics/lib/src/event.dart | 6 +++--- pkgs/unified_analytics/test/event_test.dart | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/unified_analytics/lib/src/event.dart b/pkgs/unified_analytics/lib/src/event.dart index 4516c5922..6058b68db 100644 --- a/pkgs/unified_analytics/lib/src/event.dart +++ b/pkgs/unified_analytics/lib/src/event.dart @@ -26,16 +26,16 @@ final class Event { /// /// [parameter] - subcategory of the workflow, such as "ios-archive". /// - /// [label] - usually to indicate success or failure of the workflow. + /// [result] - usually to indicate success or failure of the workflow. Event.appleUsageEvent({ required String workflow, required String parameter, - String? label, + String? result, }) : eventName = DashEvent.appleUsageEvent, eventData = { 'workflow': workflow, 'parameter': parameter, - if (label != null) 'label': label, + if (result != null) 'result': result, }; /// Event that is emitted periodically to report the performance of the diff --git a/pkgs/unified_analytics/test/event_test.dart b/pkgs/unified_analytics/test/event_test.dart index e1ba21667..013a442b2 100644 --- a/pkgs/unified_analytics/test/event_test.dart +++ b/pkgs/unified_analytics/test/event_test.dart @@ -415,7 +415,7 @@ void main() { Event generateEvent() => Event.appleUsageEvent( workflow: 'workflow', parameter: 'parameter', - label: 'label', + result: 'result', ); final constructedEvent = generateEvent(); @@ -424,7 +424,7 @@ void main() { expect(constructedEvent.eventName, DashEvent.appleUsageEvent); expect(constructedEvent.eventData['workflow'], 'workflow'); expect(constructedEvent.eventData['parameter'], 'parameter'); - expect(constructedEvent.eventData['label'], 'label'); + expect(constructedEvent.eventData['result'], 'result'); expect(constructedEvent.eventData.length, 3); });