fix(@angular/cli): record analytics for nested schematics

Prior to this commit, analytics were not recorded for nested schematics. This caused certain data to be incomplete. For example, when running `ng new` and selecting "yes" for SSR in the prompt, this choice was not recorded because the prompt exists within the `application` schematic.
This commit is contained in:
Alan Agius 2025-03-11 08:03:07 +00:00
parent e8958e363b
commit 2d03d8f113

View File

@ -143,27 +143,21 @@ export abstract class SchematicsCommandModule
workingDir === '' ? undefined : workingDir, workingDir === '' ? undefined : workingDir,
); );
let shouldReportAnalytics = true;
workflow.engineHost.registerOptionsTransform(async (schematic, options) => { workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
// Report analytics const {
if (shouldReportAnalytics) { collection: { name: collectionName },
shouldReportAnalytics = false; name: schematicName,
} = schematic;
const { const analytics = isPackageNameSafeForAnalytics(collectionName)
collection: { name: collectionName }, ? await this.getAnalytics()
name: schematicName, : undefined;
} = schematic;
const analytics = isPackageNameSafeForAnalytics(collectionName) analytics?.reportSchematicRunEvent({
? await this.getAnalytics() [EventCustomDimension.SchematicCollectionName]: collectionName,
: undefined; [EventCustomDimension.SchematicName]: schematicName,
...this.getAnalyticsParameters(options as unknown as {}),
analytics?.reportSchematicRunEvent({ });
[EventCustomDimension.SchematicCollectionName]: collectionName,
[EventCustomDimension.SchematicName]: schematicName,
...this.getAnalyticsParameters(options as unknown as {}),
});
}
return options; return options;
}); });