Skip to content

[UA] Add a Flutter event for plugins injected into an iOS/macOS project. #2062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 8.0.1
- Added `Event.flutterInjectDarwinPlugins` event for plugins injected into an iOS/macOS project.

## 8.0.0
- Send `enabled_features` as an event parameter in all events rather than as a user property.

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 = '8.0.0';
const String kPackageVersion = '8.0.1';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand Down
7 changes: 6 additions & 1 deletion pkgs/unified_analytics/lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum DashEvent {
),
codeSizeAnalysis(
label: 'code_size_analysis',
description: 'Indicates when the "--analyize-size" command is run',
description: 'Indicates when the "--analyze-size" command is run',
toolOwner: DashTool.flutterTool,
),
commandUsageValues(
Expand All @@ -98,6 +98,11 @@ enum DashEvent {
description: 'Provides information about flutter commands that ran',
toolOwner: DashTool.flutterTool,
),
flutterInjectDarwinPlugins(
label: 'flutter_inject_darwin_plugins',
description: 'Information on plugins injected into an iOS/macOS project',
toolOwner: DashTool.flutterTool,
),
hotReloadTime(
label: 'hot_reload_time',
description: 'Hot reload duration',
Expand Down
65 changes: 65 additions & 0 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,71 @@ final class Event {
},
);

/// Provides information about the plugins injected into an iOS or macOS
/// project.
///
/// This event is not sent if a project has no plugins.
///
/// [platform] - The project's platform. Either 'ios' or 'macos'.
///
/// [isModule] - whether the project is an add-to-app Flutter module.
///
/// [swiftPackageManagerUsable] - if `true`, Swift Package Manager can be used
/// for the project's plugins if any are Swift Package Manager compatible.
///
/// [swiftPackageManagerFeatureEnabled] - if the Swift Package Manager feature
/// flag is on. If false, Swift Package Manager is off for all projects on
/// the development machine.
///
/// [projectDisabledSwiftPackageManager] - if the project's .pubspec has
/// `disable-swift-package-manager: true`. This turns off Swift Package
/// Manager for a single project.
///
/// [projectHasSwiftPackageManagerIntegration] - if the Xcode project has
/// Swift Package Manager integration. If `false`, the project needs to be
/// migrated.
///
/// [pluginCount] - the total number of plugins for this project. A plugin
/// can be compatible with both Swift Package Manager and CocoaPods. Plugins
/// compatible with both will be counted in both [swiftPackageCount] and
/// [podCount]. Swift Package Manager was used to inject all plugins if
/// [pluginCount] is equal to [swiftPackageCount].
///
/// [swiftPackageCount] - the number of plugins compatible with Swift Package
/// Manager. This is less than or equal to [pluginCount]. If
/// [swiftPackageCount] is less than [pluginCount], the project uses CocoaPods
/// to inject plugins.
///
/// [podCount] - the number of plugins compatible with CocoaPods. This is less
/// than or equal to [podCount].
Event.flutterInjectDarwinPlugins({
required String platform,
required bool isModule,
required bool swiftPackageManagerUsable,
required bool swiftPackageManagerFeatureEnabled,
required bool projectDisabledSwiftPackageManager,
required bool projectHasSwiftPackageManagerIntegration,
required int pluginCount,
required int swiftPackageCount,
required int podCount,
}) : this._(
eventName: DashEvent.flutterInjectDarwinPlugins,
eventData: {
'platform': platform,
'isModule': isModule,
'swiftPackageManagerUsable': swiftPackageManagerUsable,
'swiftPackageManagerFeatureEnabled':
swiftPackageManagerFeatureEnabled,
'projectDisabledSwiftPackageManager':
projectDisabledSwiftPackageManager,
'projectHasSwiftPackageManagerIntegration':
projectHasSwiftPackageManagerIntegration,
'pluginCount': pluginCount,
'swiftPackageCount': swiftPackageCount,
'podCount': podCount,
},
);

// TODO: eliasyishak, remove this or replace once we have a generic
// timing event that can be used by potentially more than one DashTool
Event.hotReloadTime({required int timeMs})
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 @@ -5,7 +5,7 @@ description: >-
# LINT.IfChange
# When updating this, keep the version consistent with the changelog and the
# value in lib/src/constants.dart.
version: 8.0.0
version: 8.0.1
# LINT.ThenChange(lib/src/constants.dart)
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics
Expand Down
35 changes: 34 additions & 1 deletion pkgs/unified_analytics/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,39 @@ void main() {
expect(constructedEvent.eventData.length, 4);
});

test('Event.flutterInjectDarwinPlugins constructed', () {
Event generateEvent() => Event.flutterInjectDarwinPlugins(
platform: 'ios',
isModule: true,
swiftPackageManagerUsable: true,
swiftPackageManagerFeatureEnabled: true,
projectDisabledSwiftPackageManager: false,
projectHasSwiftPackageManagerIntegration: true,
pluginCount: 123,
swiftPackageCount: 456,
podCount: 678,
);

final constructedEvent = generateEvent();

expect(generateEvent, returnsNormally);
expect(constructedEvent.eventName, DashEvent.flutterInjectDarwinPlugins);
expect(constructedEvent.eventData['platform'], 'ios');
expect(constructedEvent.eventData['isModule'], isTrue);
expect(constructedEvent.eventData['swiftPackageManagerUsable'], isTrue);
expect(constructedEvent.eventData['swiftPackageManagerFeatureEnabled'],
isTrue);
expect(constructedEvent.eventData['projectDisabledSwiftPackageManager'],
isFalse);
expect(
constructedEvent.eventData['projectHasSwiftPackageManagerIntegration'],
isTrue);
expect(constructedEvent.eventData['pluginCount'], 123);
expect(constructedEvent.eventData['swiftPackageCount'], 456);
expect(constructedEvent.eventData['podCount'], 678);
expect(constructedEvent.eventData.length, 9);
});

test('Event.codeSizeAnalysis constructed', () {
Event generateEvent() => Event.codeSizeAnalysis(platform: 'platform');

Expand Down Expand Up @@ -634,7 +667,7 @@ void main() {

// Change this integer below if your PR either adds or removes
// an Event constructor
final eventsAccountedForInTests = 27;
final eventsAccountedForInTests = 28;
expect(eventsAccountedForInTests, constructorCount,
reason: 'If you added or removed an event constructor, '
'ensure you have updated '
Expand Down