Skip to content

Commit

Permalink
Only record metrics if user confirms ext:install (#6047)
Browse files Browse the repository at this point in the history
* Only record metrics if user confirms ext:install

* format
  • Loading branch information
joehan authored Jun 28, 2023
1 parent 4db12d2 commit 893971f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/commands/ext-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,12 @@ export const command = new Command("ext:install [extensionRef]")
// Should parse spec locally so we don't need project ID.
source = await createSourceFromLocation(needProjectId({ projectId }), extensionRef);
await displayExtensionVersionInfo({ spec: source.spec });
void trackGA4("extension_added_to_manifest", {
published: "local",
interactive: options.nonInteractive ? "false" : "true",
});
} else {
const extension = await extensionsApi.getExtension(extensionRef);
const ref = refs.parse(extensionRef);
ref.version = await resolveVersion(ref, extension);
const extensionVersionRef = refs.toExtensionVersionRef(ref);
extensionVersion = await extensionsApi.getExtensionVersion(extensionVersionRef);
void trackGA4("extension_added_to_manifest", {
published: extensionVersion.listing?.state === "APPROVED" ? "published" : "uploaded",
interactive: options.nonInteractive ? "false" : "true",
});
await displayExtensionVersionInfo({
spec: extensionVersion.spec,
extensionVersion,
Expand Down Expand Up @@ -143,6 +135,19 @@ export const command = new Command("ext:install [extensionRef]")
)}'. Please make sure this is a valid extension and try again.`
);
}

if (source) {
void trackGA4("extension_added_to_manifest", {
published: "local",
interactive: options.nonInteractive ? "false" : "true",
});
} else if (extensionVersion) {
void trackGA4("extension_added_to_manifest", {
published: extensionVersion.listing?.state === "APPROVED" ? "published" : "uploaded",
interactive: options.nonInteractive ? "false" : "true",
});
}

try {
return installToManifest({
projectId,
Expand Down

0 comments on commit 893971f

Please sign in to comment.