Skip to content

Commit 9963447

Browse files
biggs0125natebiggs
andauthored
Add wasm dry run event to unified analytics. (#2125)
Co-authored-by: Nate Biggs <[email protected]>
1 parent 6282b35 commit 9963447

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

pkgs/unified_analytics/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 8.0.4
2+
- Changed `Event.flutterWasmDryRun` to track dart2wasm dry run metrics from Flutter.
3+
14
## 8.0.3
25
- Changed `Event.contextStructure` to make optional data that's no longer being
36
collected and to add data about the size of library cycles.

pkgs/unified_analytics/lib/src/enums.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ enum DashEvent {
103103
description: 'Provides information about flutter commands that ran',
104104
toolOwner: DashTool.flutterTool,
105105
),
106+
flutterWasmDryRun(
107+
label: 'wasm_dry_run',
108+
description: 'Information for a dart2wasm dry run invoked from Flutter',
109+
toolOwner: DashTool.flutterTool,
110+
),
106111
flutterInjectDarwinPlugins(
107112
label: 'flutter_inject_darwin_plugins',
108113
description: 'Information on plugins injected into an iOS/macOS project',

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,19 @@ final class Event {
567567
},
568568
);
569569

570+
Event.flutterWasmDryRun({
571+
required String result,
572+
required int exitCode,
573+
String? findingsSummary,
574+
}) : this._(
575+
eventName: DashEvent.flutterWasmDryRun,
576+
eventData: {
577+
'result': result,
578+
'exitCode': result,
579+
if (findingsSummary != null) 'findings': findingsSummary,
580+
},
581+
);
582+
570583
/// Provides information about the plugins injected into an iOS or macOS
571584
/// project.
572585
///

pkgs/unified_analytics/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: >-
55
# LINT.IfChange
66
# When updating this, keep the version consistent with the changelog and the
77
# value in lib/src/constants.dart.
8-
version: 8.0.3
8+
version: 8.0.4
99
# LINT.ThenChange(lib/src/constants.dart)
1010
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics
1111
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics

pkgs/unified_analytics/test/event_test.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,50 @@ void main() {
400400
expect(constructedEvent.eventData.length, 4);
401401
});
402402

403+
test('Event.flutterWasmDryRun constructed', () {
404+
Event generateEventNoFindings() => Event.flutterWasmDryRun(
405+
result: 'success',
406+
exitCode: 123,
407+
);
408+
409+
final constructedEvent1 = generateEventNoFindings();
410+
411+
expect(generateEventNoFindings, returnsNormally);
412+
expect(constructedEvent1.eventName, DashEvent.flutterWasmDryRun);
413+
expect(constructedEvent1.eventData['result'], 'success');
414+
expect(constructedEvent1.eventData['exitCode'], 123);
415+
expect(constructedEvent1.eventData.length, 2);
416+
});
417+
test('Event.flutterWasmDryRun constructed', () {
418+
Event generateEventNoFindings() => Event.flutterWasmDryRun(
419+
result: 'success',
420+
exitCode: 123,
421+
);
422+
423+
final constructedEvent1 = generateEventNoFindings();
424+
425+
expect(generateEventNoFindings, returnsNormally);
426+
expect(constructedEvent1.eventName, DashEvent.flutterWasmDryRun);
427+
expect(constructedEvent1.eventData['result'], 'success');
428+
expect(constructedEvent1.eventData['exitCode'], 123);
429+
expect(constructedEvent1.eventData.length, 2);
430+
431+
Event generateEventFindings() => Event.flutterWasmDryRun(
432+
result: 'success',
433+
exitCode: 123,
434+
findingsSummary: '1,2,3'
435+
);
436+
437+
final constructedEvent2 = generateEventFindings();
438+
439+
expect(generateEventFindings, returnsNormally);
440+
expect(constructedEvent2.eventName, DashEvent.flutterWasmDryRun);
441+
expect(constructedEvent2.eventData['result'], 'success');
442+
expect(constructedEvent2.eventData['exitCode'], 123);
443+
expect(constructedEvent2.eventData['findingsSummary'], '1,2,3');
444+
expect(constructedEvent2.eventData.length, 3);
445+
});
446+
403447
test('Event.flutterInjectDarwinPlugins constructed', () {
404448
Event generateEvent() => Event.flutterInjectDarwinPlugins(
405449
platform: 'ios',

0 commit comments

Comments
 (0)