Skip to content

Commit 6f4de57

Browse files
authored
[UA] Introduce flutterTrackAndroidDependencies (#2312)
Towards [181559](flutter/flutter#181559) <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Most changes should add an entry to the changelog and may need to [rev the pubspec package version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change). - Changes to packages require [corresponding tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing). Many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback. **Note**: The Dart team is trialing Gemini Code Assist. Don't take its comments as final Dart team feedback. Use the suggestions if they're helpful; otherwise, wait for a human reviewer. </details>
1 parent e501121 commit 6f4de57

File tree

6 files changed

+107
-3
lines changed

6 files changed

+107
-3
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.14
2+
- Added `Event.flutterTrackAndroidDependencies` to track android dependencies.
3+
14
## 8.0.13
25
- Deprecated `Event.flutterWasmDryRun` in favor of `Event.flutterWasmDryRunPackage`.
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 = '8.0.13';
90+
const String kPackageVersion = '8.0.14';
9191

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

pkgs/unified_analytics/lib/src/enums.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ enum DashEvent {
122122
description: 'Information on plugins injected into an iOS/macOS project',
123123
toolOwner: DashTool.flutterTool,
124124
),
125+
flutterTrackAndroidDependencies(
126+
label: 'flutter_android_dependencies',
127+
description:
128+
'Information related to min/target/compile SDK, JDK, NDK, Gradle version',
129+
toolOwner: DashTool.flutterTool,
130+
),
125131
hotReloadTime(
126132
label: 'hot_reload_time',
127133
description: 'Hot reload duration',

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,47 @@ final class Event {
764764
},
765765
);
766766

767+
/// Provides information about the android dependencies of a project.
768+
///
769+
/// * [isModule] - whether the project is an add-to-app Flutter module.
770+
///
771+
/// * [agpVersion] - the Android Gradle plugin of the build target.
772+
///
773+
/// * [minSDK] - the minimum SDK version supported by the build target.
774+
///
775+
/// * [targetSDK] - the target SDK version the build target is built against.
776+
///
777+
/// * [compileSDK] - the compile SDK version the build target is built
778+
/// against.
779+
///
780+
/// * [jdkVersion] - the JDK version used by the build target.
781+
///
782+
/// * [ndkVersion] - the NDK version used by the build target.
783+
///
784+
/// * [gradleVersion] - the Gradle version used by the build target.
785+
Event.flutterTrackAndroidDependencies({
786+
bool? isModule,
787+
String? agpVersion,
788+
int? minSDK,
789+
int? targetSDK,
790+
int? compileSDK,
791+
int? jdkVersion,
792+
String? ndkVersion,
793+
String? gradleVersion,
794+
}) : this._(
795+
eventName: DashEvent.flutterTrackAndroidDependencies,
796+
eventData: {
797+
if (isModule != null) 'isModule': isModule,
798+
if (agpVersion != null) 'agpVersion': agpVersion,
799+
if (minSDK != null) 'minSDK': minSDK,
800+
if (targetSDK != null) 'targetSDK': targetSDK,
801+
if (compileSDK != null) 'compileSDK': compileSDK,
802+
if (jdkVersion != null) 'jdkVersion': jdkVersion,
803+
if (ndkVersion != null) 'ndkVersion': ndkVersion,
804+
if (gradleVersion != null) 'gradleVersion': gradleVersion,
805+
},
806+
);
807+
767808
// TODO: eliasyishak, remove this or replace once we have a generic
768809
// timing event that can be used by potentially more than one DashTool.
769810
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: 8.0.13
8+
version: 8.0.14
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: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,60 @@ void main() {
530530
expect(constructedEvent.eventData.length, 9);
531531
});
532532

533+
group('Event.flutterTrackAndroidDependencies', () {
534+
test('constructed', () {
535+
Event generateEvent() => Event.flutterTrackAndroidDependencies(
536+
isModule: true,
537+
agpVersion: '8.2.2',
538+
minSDK: 24,
539+
targetSDK: 36,
540+
compileSDK: 36,
541+
jdkVersion: 24,
542+
ndkVersion: '28.0.13004108',
543+
gradleVersion: '8.10.2',
544+
);
545+
546+
final constructedEvent = generateEvent();
547+
548+
expect(generateEvent, returnsNormally);
549+
expect(constructedEvent.eventName,
550+
DashEvent.flutterTrackAndroidDependencies);
551+
expect(constructedEvent.eventData['isModule'], isTrue);
552+
expect(constructedEvent.eventData['agpVersion'], '8.2.2');
553+
expect(constructedEvent.eventData['minSDK'], 24);
554+
expect(constructedEvent.eventData['targetSDK'], 36);
555+
expect(constructedEvent.eventData['compileSDK'], 36);
556+
expect(constructedEvent.eventData['jdkVersion'], 24);
557+
expect(constructedEvent.eventData['ndkVersion'], '28.0.13004108');
558+
expect(constructedEvent.eventData['gradleVersion'], '8.10.2');
559+
expect(constructedEvent.eventData.length, 8);
560+
});
561+
562+
test('constructor arguments default to null if not specified', () {
563+
Event generateEvent() => Event.flutterTrackAndroidDependencies(
564+
isModule: true,
565+
agpVersion: '8.2.2',
566+
targetSDK: 36,
567+
jdkVersion: 24,
568+
gradleVersion: '8.10.2',
569+
);
570+
571+
final constructedEvent = generateEvent();
572+
573+
expect(generateEvent, returnsNormally);
574+
expect(constructedEvent.eventName,
575+
DashEvent.flutterTrackAndroidDependencies);
576+
expect(constructedEvent.eventData['isModule'], isTrue);
577+
expect(constructedEvent.eventData['agpVersion'], '8.2.2');
578+
expect(constructedEvent.eventData['minSDK'], null);
579+
expect(constructedEvent.eventData['targetSDK'], 36);
580+
expect(constructedEvent.eventData['compileSDK'], null);
581+
expect(constructedEvent.eventData['jdkVersion'], 24);
582+
expect(constructedEvent.eventData['ndkVersion'], null);
583+
expect(constructedEvent.eventData['gradleVersion'], '8.10.2');
584+
expect(constructedEvent.eventData.length, 5);
585+
});
586+
});
533587
test('Event.codeSizeAnalysis constructed', () {
534588
Event generateEvent() => Event.codeSizeAnalysis(platform: 'platform');
535589

@@ -785,7 +839,7 @@ void main() {
785839

786840
// Change this integer below if your PR either adds or removes
787841
// an Event constructor
788-
final eventsAccountedForInTests = 33;
842+
final eventsAccountedForInTests = 34;
789843
expect(eventsAccountedForInTests, constructorCount,
790844
reason: 'If you added or removed an event constructor, '
791845
'ensure you have updated '

0 commit comments

Comments
 (0)