Report usage of deferred-components
to analytics. (#159307)
Towards https://github.com/flutter/flutter/issues/159212. /cc @jtmcdole --------- Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
This commit is contained in:
parent
fae695ed61
commit
4ff6698838
@ -310,6 +310,14 @@ class AssembleCommand extends FlutterCommand {
|
||||
"Try re-running 'flutter build ios' or the appropriate build command."
|
||||
);
|
||||
}
|
||||
if (deferredTargets.isNotEmpty) {
|
||||
// Record to analytics that DeferredComponents is being used.
|
||||
globals.analytics.send(Event.flutterBuildInfo(
|
||||
label: 'assemble-deferred-components',
|
||||
buildType: 'android',
|
||||
settings: deferredTargets.map((Target t) => t.name).join(','),
|
||||
));
|
||||
}
|
||||
if (_flutterProject.manifest.deferredComponents != null
|
||||
&& decodedDefines.contains('validate-deferred-components=true')
|
||||
&& deferredTargets.isNotEmpty
|
||||
|
@ -143,6 +143,13 @@ class BuildAppBundleCommand extends BuildSubCommand {
|
||||
// Do all setup verification that doesn't involve loading units. Checks that
|
||||
// require generated loading units are done after gen_snapshot in assemble.
|
||||
final List<DeferredComponent>? deferredComponents = FlutterProject.current().manifest.deferredComponents;
|
||||
if (deferredComponents != null && boolArg('deferred-components')) {
|
||||
// Record to analytics that DeferredComponents is being used.
|
||||
globals.analytics.send(Event.flutterBuildInfo(
|
||||
label: 'build-appbundle-deferred-components',
|
||||
buildType: 'android',
|
||||
));
|
||||
}
|
||||
if (deferredComponents != null && boolArg('deferred-components') && boolArg('validate-deferred-components') && !boolArg('debug')) {
|
||||
final DeferredComponentsPrebuildValidator validator = DeferredComponentsPrebuildValidator(
|
||||
project.directory,
|
||||
|
@ -94,6 +94,35 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('flutter assemble sends assemble-deferred-components', () async {
|
||||
final AssembleCommand command = AssembleCommand(
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
);
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||
await commandRunner.run(<String>[
|
||||
'assemble',
|
||||
'-o Output',
|
||||
'-dTargetPlatform=android',
|
||||
'-dBuildMode=release',
|
||||
'android_aot_deferred_components_bundle_release_android-arm64',
|
||||
]);
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'assemble-deferred-components',
|
||||
buildType: 'android',
|
||||
settings: 'android_aot_deferred_components_bundle_release_android-arm64',
|
||||
),
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
Analytics: () => fakeAnalytics,
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('flutter assemble sends usage values correctly with platform', () async {
|
||||
final AssembleCommand command = AssembleCommand(
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)));
|
||||
|
@ -148,6 +148,49 @@ void main() {
|
||||
Analytics: () => fakeAnalytics,
|
||||
ProcessInfo: () => processInfo,
|
||||
});
|
||||
|
||||
testUsingContext('use of the deferred components feature sends a build info event indicating so', () async {
|
||||
final String projectPath = await createProject(
|
||||
tempDir,
|
||||
arguments: <String>[
|
||||
'--empty',
|
||||
'--no-pub',
|
||||
'--template=app',
|
||||
],
|
||||
);
|
||||
|
||||
// Add deferred manifest.
|
||||
final File pubspec = globals.localFileSystem
|
||||
.directory(projectPath)
|
||||
.childFile('pubspec.yaml');
|
||||
final String modifiedContents = pubspec
|
||||
.readAsStringSync()
|
||||
.replaceAll('flutter:', 'flutter:\n deferred-components:');
|
||||
pubspec.writeAsStringSync(modifiedContents);
|
||||
printOnFailure(pubspec.readAsStringSync());
|
||||
|
||||
final Directory oldCwd = globals.localFileSystem.currentDirectory;
|
||||
try {
|
||||
globals.localFileSystem.currentDirectory = globals.localFileSystem.directory(projectPath);
|
||||
await runBuildAppBundleCommand(projectPath);
|
||||
} finally {
|
||||
globals.localFileSystem.currentDirectory = oldCwd;
|
||||
}
|
||||
|
||||
expect(
|
||||
fakeAnalytics.sentEvents,
|
||||
contains(
|
||||
Event.flutterBuildInfo(
|
||||
label: 'build-appbundle-deferred-components',
|
||||
buildType: 'android',
|
||||
),
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => FakeAndroidBuilder(),
|
||||
Analytics: () => fakeAnalytics,
|
||||
ProcessInfo: () => processInfo,
|
||||
});
|
||||
});
|
||||
|
||||
group('Gradle', () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user