Skip to content

Commit 3a42c21

Browse files
committed
Add telemetry event
1 parent e05fe81 commit 3a42c21

File tree

6 files changed

+106
-4
lines changed

6 files changed

+106
-4
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+
## 7.0.3
2+
- Added `Event.flutterInjectDarwinPlugins` event for plugins injected into an iOS/macOS project.
3+
14
## 7.0.2
25
- Send `enabled_features` as an event parameter in all events rather than as a user property.
36

pkgs/unified_analytics/lib/src/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const int kMaxLogFileSize = 25 * (1 << 20);
8787
const String kLogFileName = 'dart-flutter-telemetry.log';
8888

8989
/// The current version of the package, should be in line with pubspec version.
90-
const String kPackageVersion = '7.0.2';
90+
const String kPackageVersion = '7.0.3';
9191

9292
/// The minimum length for a session.
9393
const int kSessionDurationMinutes = 30;

pkgs/unified_analytics/lib/src/enums.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ enum DashEvent {
7474
),
7575
codeSizeAnalysis(
7676
label: 'code_size_analysis',
77-
description: 'Indicates when the "--analyize-size" command is run',
77+
description: 'Indicates when the "--analyze-size" command is run',
7878
toolOwner: DashTool.flutterTool,
7979
),
8080
commandUsageValues(
@@ -98,6 +98,11 @@ enum DashEvent {
9898
description: 'Provides information about flutter commands that ran',
9999
toolOwner: DashTool.flutterTool,
100100
),
101+
flutterInjectDarwinPlugins(
102+
label: 'flutter_inject_darwin_plugins',
103+
description: 'Information on plugins injected into an iOS/macOS project',
104+
toolOwner: DashTool.flutterTool,
105+
),
101106
hotReloadTime(
102107
label: 'hot_reload_time',
103108
description: 'Hot reload duration',

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,71 @@ final class Event {
557557
},
558558
);
559559

560+
/// Provides information about the plugins injected into an iOS or macOS
561+
/// project.
562+
///
563+
/// This event is not sent if a project has no plugins.
564+
///
565+
/// [platform] - The project's platform. Either 'ios' or 'macos'.
566+
///
567+
/// [isModule] - whether the project is an add-to-app Flutter module.
568+
///
569+
/// [swiftPackageManagerUsed] - if Swift Package Manager can be used for the
570+
/// project's plugins.
571+
///
572+
/// [swiftPackageManagerFeatureEnabled] - if the Swift Package Manager feature
573+
/// flag is on. If false, Swift Package Manager is off for all projects on
574+
/// the development machine.
575+
///
576+
/// [projectDisabledSwiftPackageManager] - if the project's .pubspec has
577+
/// `disable-swift-package-manager: true`. This turns off Swift Package
578+
/// Manager for a single project.
579+
///
580+
/// [projectHasSwiftPackageManagerIntegration] - if the Xcode project has
581+
/// Swift Package Manager integration. If false, the project needs to be
582+
/// migrated.
583+
///
584+
/// [pluginCount] - the total number of plugins for this project. A plugin
585+
/// can be compatible with both Swift Package Manager and CocoaPods. Plugins
586+
/// compatible with both will be counted in both [swiftPackageCount] and
587+
/// [podCount]. Swift Package Manager was used to inject all plugins if
588+
/// [pluginCount] is equal to [swiftPackageCount].
589+
///
590+
/// [swiftPackageCount] - the number of plugins compatible with Swift Package
591+
/// Manager. This is less than or equal to [pluginCount]. If
592+
/// [swiftPackageCount] is less than [pluginCount], the project uses CocoaPods
593+
/// to inject plugins.
594+
///
595+
/// [podCount] - the number of plugins compatible with CocoaPods. This is less
596+
/// than or equal to [podCount].
597+
Event.flutterInjectDarwinPlugins({
598+
required String platform,
599+
required bool isModule,
600+
required bool swiftPackageManagerUsed,
601+
required bool swiftPackageManagerFeatureEnabled,
602+
required bool projectDisabledSwiftPackageManager,
603+
required bool projectHasSwiftPackageManagerIntegration,
604+
required int pluginCount,
605+
required int swiftPackageCount,
606+
required int podCount,
607+
}) : this._(
608+
eventName: DashEvent.flutterInjectDarwinPlugins,
609+
eventData: {
610+
'platform': platform,
611+
'isModule': isModule,
612+
'swiftPackageManagerUsed': swiftPackageManagerUsed,
613+
'swiftPackageManagerFeatureEnabled':
614+
swiftPackageManagerFeatureEnabled,
615+
'projectDisabledSwiftPackageManager':
616+
projectDisabledSwiftPackageManager,
617+
'projectHasSwiftPackageManagerIntegration':
618+
projectHasSwiftPackageManagerIntegration,
619+
'pluginCount': pluginCount,
620+
'swiftPackageCount': swiftPackageCount,
621+
'podCount': podCount,
622+
},
623+
);
624+
560625
// TODO: eliasyishak, remove this or replace once we have a generic
561626
// timing event that can be used by potentially more than one DashTool
562627
Event.hotReloadTime({required int timeMs})

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: 7.0.2
8+
version: 7.0.3
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: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,35 @@ void main() {
400400
expect(constructedEvent.eventData.length, 4);
401401
});
402402

403+
test('Event.flutterInjectDarwinPlugins constructed', () {
404+
Event generateEvent() => Event.flutterInjectDarwinPlugins(
405+
platform: 'ios',
406+
isModule: true,
407+
swiftPackageManagerUsed: true,
408+
swiftPackageManagerFeatureEnabled: true,
409+
projectDisabledSwiftPackageManager: false,
410+
projectHasSwiftPackageManagerIntegration: true,
411+
pluginCount: 123,
412+
swiftPackageCount: 456,
413+
podCount: 678,
414+
);
415+
416+
final constructedEvent = generateEvent();
417+
418+
expect(generateEvent, returnsNormally);
419+
expect(constructedEvent.eventName, DashEvent.flutterInjectDarwinPlugins);
420+
expect(constructedEvent.eventData['platform'], 'ios');
421+
expect(constructedEvent.eventData['isModule'], isTrue);
422+
expect(constructedEvent.eventData['swiftPackageManagerUsed'], isTrue);
423+
expect(constructedEvent.eventData['swiftPackageManagerFeatureEnabled'], isTrue);
424+
expect(constructedEvent.eventData['projectDisabledSwiftPackageManager'], isFalse);
425+
expect(constructedEvent.eventData['projectHasSwiftPackageManagerIntegration'], isTrue);
426+
expect(constructedEvent.eventData['pluginCount'], 123);
427+
expect(constructedEvent.eventData['swiftPackageCount'], 456);
428+
expect(constructedEvent.eventData['podCount'], 678);
429+
expect(constructedEvent.eventData.length, 9);
430+
});
431+
403432
test('Event.codeSizeAnalysis constructed', () {
404433
Event generateEvent() => Event.codeSizeAnalysis(platform: 'platform');
405434

@@ -634,7 +663,7 @@ void main() {
634663

635664
// Change this integer below if your PR either adds or removes
636665
// an Event constructor
637-
final eventsAccountedForInTests = 27;
666+
final eventsAccountedForInTests = 28;
638667
expect(eventsAccountedForInTests, constructorCount,
639668
reason: 'If you added or removed an event constructor, '
640669
'ensure you have updated '

0 commit comments

Comments
 (0)