Skip to content

Commit 0ee24e2

Browse files
committed
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. (cherry picked from commit 2d03d8f)
1 parent 83fcffb commit 0ee24e2

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

packages/angular/cli/src/command-builder/schematics-command-module.ts

+14-20
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,21 @@ export abstract class SchematicsCommandModule
143143
workingDir === '' ? undefined : workingDir,
144144
);
145145

146-
let shouldReportAnalytics = true;
147146
workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
148-
// Report analytics
149-
if (shouldReportAnalytics) {
150-
shouldReportAnalytics = false;
151-
152-
const {
153-
collection: { name: collectionName },
154-
name: schematicName,
155-
} = schematic;
156-
157-
const analytics = isPackageNameSafeForAnalytics(collectionName)
158-
? await this.getAnalytics()
159-
: undefined;
160-
161-
analytics?.reportSchematicRunEvent({
162-
[EventCustomDimension.SchematicCollectionName]: collectionName,
163-
[EventCustomDimension.SchematicName]: schematicName,
164-
...this.getAnalyticsParameters(options as unknown as {}),
165-
});
166-
}
147+
const {
148+
collection: { name: collectionName },
149+
name: schematicName,
150+
} = schematic;
151+
152+
const analytics = isPackageNameSafeForAnalytics(collectionName)
153+
? await this.getAnalytics()
154+
: undefined;
155+
156+
analytics?.reportSchematicRunEvent({
157+
[EventCustomDimension.SchematicCollectionName]: collectionName,
158+
[EventCustomDimension.SchematicName]: schematicName,
159+
...this.getAnalyticsParameters(options as unknown as {}),
160+
});
167161

168162
return options;
169163
});

0 commit comments

Comments
 (0)