Skip to content

Commit

Permalink
Adding exception event + prep for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasyishak committed Nov 20, 2023
1 parent 7515ee5 commit a073844
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

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.5.0-wip';
const String kPackageVersion = '5.5.0';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand Down
4 changes: 4 additions & 0 deletions pkgs/unified_analytics/lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
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.5.0-wip
version: 5.5.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 @@ -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) {
Expand All @@ -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 '
Expand Down

0 comments on commit a073844

Please sign in to comment.