Skip to content

Commit 893971f

Browse files
authored
Only record metrics if user confirms ext:install (#6047)
* Only record metrics if user confirms ext:install * format
1 parent 4db12d2 commit 893971f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/commands/ext-install.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,12 @@ export const command = new Command("ext:install [extensionRef]")
7373
// Should parse spec locally so we don't need project ID.
7474
source = await createSourceFromLocation(needProjectId({ projectId }), extensionRef);
7575
await displayExtensionVersionInfo({ spec: source.spec });
76-
void trackGA4("extension_added_to_manifest", {
77-
published: "local",
78-
interactive: options.nonInteractive ? "false" : "true",
79-
});
8076
} else {
8177
const extension = await extensionsApi.getExtension(extensionRef);
8278
const ref = refs.parse(extensionRef);
8379
ref.version = await resolveVersion(ref, extension);
8480
const extensionVersionRef = refs.toExtensionVersionRef(ref);
8581
extensionVersion = await extensionsApi.getExtensionVersion(extensionVersionRef);
86-
void trackGA4("extension_added_to_manifest", {
87-
published: extensionVersion.listing?.state === "APPROVED" ? "published" : "uploaded",
88-
interactive: options.nonInteractive ? "false" : "true",
89-
});
9082
await displayExtensionVersionInfo({
9183
spec: extensionVersion.spec,
9284
extensionVersion,
@@ -143,6 +135,19 @@ export const command = new Command("ext:install [extensionRef]")
143135
)}'. Please make sure this is a valid extension and try again.`
144136
);
145137
}
138+
139+
if (source) {
140+
void trackGA4("extension_added_to_manifest", {
141+
published: "local",
142+
interactive: options.nonInteractive ? "false" : "true",
143+
});
144+
} else if (extensionVersion) {
145+
void trackGA4("extension_added_to_manifest", {
146+
published: extensionVersion.listing?.state === "APPROVED" ? "published" : "uploaded",
147+
interactive: options.nonInteractive ? "false" : "true",
148+
});
149+
}
150+
146151
try {
147152
return installToManifest({
148153
projectId,

0 commit comments

Comments
 (0)