Skip to content

Commit

Permalink
Initial commit with constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasyishak committed Oct 27, 2023
1 parent e828d45 commit a2cfdff
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
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 @@ -51,6 +51,11 @@ enum DashEvent {
description: 'Results from a specific doctor validator',
toolOwner: DashTool.flutterTool,
),
flutterBuildInfo(
label: 'flutter_build_info',
description: 'Information for a flutter build invocation',
toolOwner: DashTool.flutterTool,
),
hotReloadTime(
label: 'hot_reload_time',
description: 'Hot reload duration',
Expand Down
27 changes: 27 additions & 0 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,33 @@ final class Event {
if (statusInfo != null) 'statusInfo': statusInfo,
};

/// Event that is emitted from the flutter tool when a build invocation
/// has been run by the user
///
/// [label] -
///
/// [buildType] -
///
/// [command] -
///
/// [settings] -
///
/// [error] -
Event.flutterBuildInfo({
required String label,
required String buildType,
required String command,
required String settings,
required String error,
}) : eventName = DashEvent.flutterBuildInfo,
eventData = {
'label': label,
'buildType': buildType,
'command': command,
'settings': settings,
'error': error,
};

Event.hotReloadTime({required int timeMs})
: eventName = DashEvent.hotReloadTime,
eventData = {'timeMs': timeMs};
Expand Down
21 changes: 21 additions & 0 deletions pkgs/unified_analytics/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,27 @@ void main() {
expect(constructedEvent.eventData.length, 1);
});

test('Event.flutterBuildInfo constructed', () {
Event generateEvent() => Event.flutterBuildInfo(
label: 'label',
buildType: 'buildType',
command: 'command',
settings: 'settings',
error: 'error',
);

final constructedEvent = generateEvent();

expect(generateEvent, returnsNormally);
expect(constructedEvent.eventName, DashEvent.flutterBuildInfo);
expect(constructedEvent.eventData['label'], 'label');
expect(constructedEvent.eventData['buildType'], 'buildType');
expect(constructedEvent.eventData['command'], 'command');
expect(constructedEvent.eventData['settings'], 'settings');
expect(constructedEvent.eventData['error'], 'error');
expect(constructedEvent.eventData.length, 5);
});

test('Confirm all constructors were checked', () {
var constructorCount = 0;
for (var declaration in reflectClass(Event).declarations.keys) {
Expand Down

0 comments on commit a2cfdff

Please sign in to comment.