Skip to content

Commit

Permalink
more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll committed Nov 8, 2024
1 parent d0aeb95 commit 927241c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 3 additions & 5 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ final class Event {
if (ideLaunchedFeature != null)
'ideLaunchedFeature': ideLaunchedFeature,
if (isWasm != null) 'isWasm': isWasm,
if (additionalMetrics != null)
...additionalMetrics.toMap()
..removeWhere((key, value) => value == null),
if (additionalMetrics != null) ...additionalMetrics.toMap(),
};

/// Event that contains the results for a specific doctor validator.
Expand Down Expand Up @@ -856,7 +854,7 @@ final class Event {
/// allows custom metrics to be added by a unified_analytics client.
abstract base class CustomMetrics {
/// Converts the custom metrics data to a [Map] object.
///
///
/// This must be a JSON encodable [Map].
Map<String, Object?> toMap();
Map<String, Object> toMap();
}
8 changes: 1 addition & 7 deletions pkgs/unified_analytics/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,6 @@ void main() {
isWasm: 'true',
additionalMetrics: _TestMetrics(
stringField: 'test',
// Since this value is null, it should not be included in the event
// JSON below.
nullableField: null,
intField: 100,
boolField: false,
),
Expand Down Expand Up @@ -692,20 +689,17 @@ void main() {
final class _TestMetrics extends CustomMetrics {
_TestMetrics({
required this.stringField,
required this.nullableField,
required this.intField,
required this.boolField,
});

final String stringField;
final String? nullableField;
final int intField;
final bool boolField;

@override
Map<String, Object?> toMap() => {
Map<String, Object> toMap() => {
'stringField': stringField,
'nullableField': nullableField,
'intField': intField,
'boolField': boolField,
};
Expand Down

0 comments on commit 927241c

Please sign in to comment.