npm package diff

Package: @forge/cli

Versions: 12.3.0-next.0-experimental-8a53773 - 12.3.0-next.2

File: package/out/command-line/command.js

Index: package/out/command-line/command.js
===================================================================
--- package/out/command-line/command.js
+++ package/out/command-line/command.js
@@ -6,8 +6,9 @@
 const semver_1 = tslib_1.__importDefault(require("semver"));
 const cli_shared_1 = require("@forge/cli-shared");
 const environment_1 = require("./environment");
 const version_info_1 = require("./version-info");
+const anon_user_id_1 = require("./anon-user-id");
 const errors_1 = require("./errors");
 const command_suggestion_service_1 = tslib_1.__importDefault(require("../service/command-suggestion-service"));
 const sentry_1 = require("./sentry");
 class WrapperError extends commander_1.CommanderError {
@@ -206,8 +207,9 @@
     }
     actionProcessor = async (cb, ...args) => {
         const cmdName = this.cmd.name();
         const analyticsName = this.analyticsName ?? cmdName;
+        let cred = (0, anon_user_id_1.getAnonId)(true);
         let attributes = {};
         try {
             if (this.cliDetails) {
                 attributes = {
@@ -219,9 +221,9 @@
             }
             if (cmdName === 'tunnel') {
                 attributes['isCloudflareTunnel'] = true;
             }
-            await this.analyticsClient.reportCommandInvoke(analyticsName, attributes);
+            this.analyticsClient.reportCommandInvoke(analyticsName, cred, attributes);
             const options = last(args);
             await (0, sentry_1.setSentryCmdOptFlags)(analyticsName, options);
             const nonInteractive = options.nonInteractive ?? false;
             const json = options.json ?? false;
@@ -249,9 +251,12 @@
                 if (value) {
                     attributes[analyticsAttribute ?? preconditionAttribute] = value;
                 }
             }
-            await this.checkAuthentication();
+            const actualCred = await this.checkAuthentication();
+            if (actualCred) {
+                cred = actualCred;
+            }
             let accountId;
             try {
                 accountId = (await this.credentialStore.getCredentials()).accountId;
             }
@@ -261,22 +266,23 @@
             await (0, sentry_1.setSentryEnvFlags)(accountId, attributes['appId']);
             const result = await cb(...args);
             if (result) {
                 attributes = { ...attributes, ...result.analytics };
+                if (result.creds) {
+                    cred = result.creds;
+                }
             }
-            await this.analyticsClient.reportSuccess(analyticsName, attributes);
+            this.analyticsClient.reportSuccess(analyticsName, cred, attributes);
         }
         catch (e) {
             attributes = { ...(0, cli_shared_1.getErrorAttributes)(e), ...attributes };
-            await this.analyticsClient.reportInvokeFailure(analyticsName, attributes, e);
+            this.analyticsClient.reportInvokeFailure(analyticsName, cred, attributes, e);
             if (e instanceof errors_1.DeferredErrors) {
-                for (const err of e.getErrors()) {
-                    await this.analyticsClient.reportFailure(analyticsName, attributes, err);
-                }
+                e.getErrors().forEach((error) => this.analyticsClient.reportFailure(analyticsName, cred, attributes, error));
                 process.exit(1);
             }
             else {
-                await this.analyticsClient.reportFailure(analyticsName, attributes, e);
+                this.analyticsClient.reportFailure(analyticsName, cred, attributes, e);
                 await (0, cli_shared_1.exitOnError)(this.ui, e);
             }
         }
     };
@@ -337,9 +343,15 @@
         this.findLastValidCommand(argv).command.outputHelp();
     }
     async reportHelp(cmdError) {
         try {
-            await this.analyticsClient.reportSuccess('help', { command: cmdError.getCommandName() });
+            let cred = (0, anon_user_id_1.getAnonId)(true);
+            try {
+                cred = await this.credentialStore.getCredentials();
+            }
+            catch (noTokenError) {
+            }
+            this.analyticsClient.reportSuccess('help', cred, { command: cmdError.getCommandName() });
         }
         catch (err) {
         }
     }