Skip to content

Commit

Permalink
Added a couple parameters to Event.devtoolsEvent and `Event.excepti…
Browse files Browse the repository at this point in the history
…on` (#584)
  • Loading branch information
kenzieschmoll authored Sep 10, 2024
1 parent 55f6a0e commit 79e3b8e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
4 changes: 3 additions & 1 deletion pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 6.1.3-wip
## 6.1.3

- Require Dart 3.4.
- Added `isWasm` parameter to the `Event.devtoolsEvent` constructor.
- Added an optional parameter `data` to the `Event.exception` constructor.

## 6.1.2

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 @@ -87,7 +87,7 @@ const int kMaxLogFileSize = 25 * (1 << 20);
const String kLogFileName = 'dart-flutter-telemetry.log';

/// The current version of the package, should be in line with pubspec version.
const String kPackageVersion = '6.1.3-wip';
const String kPackageVersion = '6.1.3';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand Down
14 changes: 11 additions & 3 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ final class Event {
String? isExternalBuild,
String? isEmbedded,
String? ideLaunchedFeature,
String? isWasm,

// PerformanceScreenMetrics
int? uiDurationMicros,
Expand Down Expand Up @@ -419,6 +420,7 @@ final class Event {
if (isEmbedded != null) 'isEmbedded': isEmbedded,
if (ideLaunchedFeature != null)
'ideLaunchedFeature': ideLaunchedFeature,
if (isWasm != null) 'isWasm': isWasm,

// PerformanceScreenMetrics
if (uiDurationMicros != null) 'uiDurationMicros': uiDurationMicros,
Expand Down Expand Up @@ -480,9 +482,15 @@ final class Event {
/// 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};
/// [data] - optional structured data to include with the exception event.
Event.exception({
required String exception,
Map<String, Object?> data = const <String, Object?>{},
}) : eventName = DashEvent.exception,
eventData = {
'exception': exception,
...data,
};

/// 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: 6.1.3-wip
version: 6.1.3
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

environment:
Expand Down
14 changes: 11 additions & 3 deletions pkgs/unified_analytics/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,19 @@ void main() {
});

test('Event.exception constructed', () {
Event generateEvent() => Event.exception(exception: 'exception');
Event generateEvent() => Event.exception(
exception: 'exception',
data: {'foo': 'bar', 'baz': 1},
);

final constructedEvent = generateEvent();

expect(generateEvent, returnsNormally);
expect(constructedEvent.eventName, DashEvent.exception);
expect(constructedEvent.eventData['exception'], 'exception');
expect(constructedEvent.eventData.length, 1);
expect(constructedEvent.eventData['foo'], 'bar');
expect(constructedEvent.eventData['baz'], 1);
expect(constructedEvent.eventData.length, 3);
});

test('Event.timing constructed', () {
Expand Down Expand Up @@ -570,6 +575,7 @@ void main() {
isExternalBuild: 'isExternalBuild',
isEmbedded: 'isEmbedded',
ideLaunchedFeature: 'ideLaunchedFeature',
isWasm: 'true',
uiDurationMicros: 123,
rasterDurationMicros: 123,
shaderCompilationDurationMicros: 123,
Expand Down Expand Up @@ -603,6 +609,8 @@ void main() {
expect(constructedEvent.eventData['isEmbedded'], 'isEmbedded');
expect(
constructedEvent.eventData['ideLaunchedFeature'], 'ideLaunchedFeature');
expect(constructedEvent.eventData['isWasm'], 'true');

expect(constructedEvent.eventData['uiDurationMicros'], 123);
expect(constructedEvent.eventData['rasterDurationMicros'], 123);
expect(constructedEvent.eventData['shaderCompilationDurationMicros'], 123);
Expand All @@ -615,7 +623,7 @@ void main() {
expect(constructedEvent.eventData['rootSetCount'], 123);
expect(constructedEvent.eventData['rowCount'], 123);
expect(constructedEvent.eventData['inspectorTreeControllerId'], 123);
expect(constructedEvent.eventData.length, 27);
expect(constructedEvent.eventData.length, 28);
});

test('Confirm all constructors were checked', () {
Expand Down

0 comments on commit 79e3b8e

Please sign in to comment.