mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add metrics for android gradle plugin version (#168181)
Add android gradle plugin version to any events logging gradle builds. Fixes: #164148 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing.
This commit is contained in:
parent
0c6b9bca07
commit
fe1952ad78
@ -33,6 +33,7 @@ import 'android_builder.dart';
|
||||
import 'android_studio.dart';
|
||||
import 'gradle_errors.dart';
|
||||
import 'gradle_utils.dart';
|
||||
import 'gradle_utils.dart' as gradle;
|
||||
import 'java.dart';
|
||||
import 'migrations/android_studio_java_gradle_conflict_migration.dart';
|
||||
import 'migrations/cmake_android_16k_pages_migration.dart';
|
||||
@ -286,11 +287,25 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
||||
_OutputParser? outputParser,
|
||||
}) async {
|
||||
final bool usesAndroidX = isAppUsingAndroidX(project.android.hostAppGradleRoot);
|
||||
final String? agpVersion = gradle.getAgpVersion(
|
||||
project.android.hostAppGradleRoot,
|
||||
globals.logger,
|
||||
);
|
||||
if (usesAndroidX) {
|
||||
_analytics.send(Event.flutterBuildInfo(label: 'app-using-android-x', buildType: 'gradle'));
|
||||
_analytics.send(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'app-using-android-x',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $agpVersion',
|
||||
),
|
||||
);
|
||||
} else if (!usesAndroidX) {
|
||||
_analytics.send(
|
||||
Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(
|
||||
label: 'app-not-using-android-x',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $agpVersion',
|
||||
),
|
||||
);
|
||||
|
||||
_logger.printStatus(
|
||||
@ -394,7 +409,11 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
||||
if (exitCode == 0) {
|
||||
final String successEventLabel = 'gradle-${detectedGradleError!.eventLabel}-success';
|
||||
_analytics.send(
|
||||
Event.flutterBuildInfo(label: successEventLabel, buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(
|
||||
label: successEventLabel,
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $agpVersion',
|
||||
),
|
||||
);
|
||||
return exitCode;
|
||||
}
|
||||
@ -403,7 +422,13 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
||||
}
|
||||
}
|
||||
final String usageLabel = 'gradle-${detectedGradleError!.eventLabel}-failure';
|
||||
_analytics.send(Event.flutterBuildInfo(label: usageLabel, buildType: 'gradle'));
|
||||
_analytics.send(
|
||||
Event.flutterBuildInfo(
|
||||
label: usageLabel,
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $agpVersion',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
|
@ -7,6 +7,8 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/android/android_studio.dart';
|
||||
import 'package:flutter_tools/src/android/gradle_utils.dart'
|
||||
show templateAndroidGradlePluginVersion;
|
||||
import 'package:flutter_tools/src/android/java.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
@ -707,7 +709,13 @@ void main() {
|
||||
|
||||
expect(
|
||||
analytics.sentEvents,
|
||||
contains(Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle')),
|
||||
contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'app-not-using-android-x',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $templateAndroidGradlePluginVersion',
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
},
|
||||
@ -763,7 +771,13 @@ void main() {
|
||||
|
||||
expect(
|
||||
analytics.sentEvents,
|
||||
contains(Event.flutterBuildInfo(label: 'app-using-android-x', buildType: 'gradle')),
|
||||
contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'app-using-android-x',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $templateAndroidGradlePluginVersion',
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
},
|
||||
|
@ -6,6 +6,8 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/android/gradle_utils.dart'
|
||||
show templateAndroidGradlePluginVersion;
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
@ -296,7 +298,13 @@ void main() {
|
||||
|
||||
expect(
|
||||
analytics.sentEvents,
|
||||
contains(Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle')),
|
||||
contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'app-not-using-android-x',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $templateAndroidGradlePluginVersion',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
@ -336,7 +344,13 @@ void main() {
|
||||
|
||||
expect(
|
||||
analytics.sentEvents,
|
||||
contains(Event.flutterBuildInfo(label: 'app-using-android-x', buildType: 'gradle')),
|
||||
contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'app-using-android-x',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: $templateAndroidGradlePluginVersion',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
|
@ -147,8 +147,16 @@ void main() {
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
containsAll(<Event>[
|
||||
Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(label: 'gradle-random-event-label-failure', buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(
|
||||
label: 'app-not-using-android-x',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: null',
|
||||
),
|
||||
Event.flutterBuildInfo(
|
||||
label: 'gradle-random-event-label-failure',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: null',
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
@ -334,7 +342,11 @@ void main() {
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.flutterBuildInfo(label: 'gradle-random-event-label-failure', buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(
|
||||
label: 'gradle-random-event-label-failure',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: null',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -424,7 +436,11 @@ void main() {
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.flutterBuildInfo(label: 'gradle-random-event-label-failure', buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(
|
||||
label: 'gradle-random-event-label-failure',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: null',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -601,7 +617,11 @@ void main() {
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.flutterBuildInfo(label: 'gradle-random-event-label-success', buildType: 'gradle'),
|
||||
Event.flutterBuildInfo(
|
||||
label: 'gradle-random-event-label-success',
|
||||
buildType: 'gradle',
|
||||
settings: 'androidGradlePluginVersion: null',
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
|
Loading…
Reference in New Issue
Block a user