From 09f5d8aed4da93b403304e35e3a2003d162ce7ce Mon Sep 17 00:00:00 2001 From: Sagarika Dasgupta Date: Tue, 14 Oct 2025 13:12:26 -0500 Subject: [PATCH 1/7] telemetry for function-testing-helpers usage tracking --- packages/app/src/cli/commands/app/function/run.ts | 14 ++++++++++++++ packages/cli-kit/src/public/node/monorail.ts | 3 +++ packages/cli/oclif.manifest.json | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/packages/app/src/cli/commands/app/function/run.ts b/packages/app/src/cli/commands/app/function/run.ts index 2e5ea046c2a..62ae0dd3a7c 100644 --- a/packages/app/src/cli/commands/app/function/run.ts +++ b/packages/app/src/cli/commands/app/function/run.ts @@ -7,6 +7,7 @@ import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli' import {Flags} from '@oclif/core' import {renderAutocompletePrompt, isTTY} from '@shopify/cli-kit/node/ui' import {outputDebug} from '@shopify/cli-kit/node/output' +import {addPublicMetadata} from '@shopify/cli-kit/node/metadata' const DEFAULT_FUNCTION_EXPORT = '_start' @@ -33,11 +34,24 @@ export default class FunctionRun extends AppUnlinkedCommand { description: 'Name of the WebAssembly export to invoke.', env: 'SHOPIFY_FLAG_EXPORT', }), + 'invoked-by': Flags.string({ + hidden: true, + description: 'Internal flag to track which client invoked this command.', + env: 'SHOPIFY_FLAG_INVOKED_BY', + }), } public async run(): Promise { const {flags} = await this.parse(FunctionRun) + // Track which client invoked this command + const invokedBy = flags['invoked-by'] + if (invokedBy) { + await addPublicMetadata(() => ({ + cmd_app_function_run_invoked_by: invokedBy, + })) + } + let functionExport = DEFAULT_FUNCTION_EXPORT const app = await localAppContext({ diff --git a/packages/cli-kit/src/public/node/monorail.ts b/packages/cli-kit/src/public/node/monorail.ts index 10ff35ab7c1..47d867d2206 100644 --- a/packages/cli-kit/src/public/node/monorail.ts +++ b/packages/cli-kit/src/public/node/monorail.ts @@ -88,6 +88,9 @@ export interface Schemas { cmd_app_warning_api_key_deprecation_displayed?: Optional cmd_app_deployment_mode?: Optional + // Function related commands + cmd_app_function_run_invoked_by?: Optional + // Dev related commands cmd_dev_tunnel_type?: Optional cmd_dev_tunnel_custom_hash?: Optional diff --git a/packages/cli/oclif.manifest.json b/packages/cli/oclif.manifest.json index daef3718dc4..341227b9521 100644 --- a/packages/cli/oclif.manifest.json +++ b/packages/cli/oclif.manifest.json @@ -1131,6 +1131,15 @@ "name": "input", "type": "option" }, + "invoked-by": { + "description": "Internal flag to track which client invoked this command.", + "env": "SHOPIFY_FLAG_INVOKED_BY", + "hasDynamicHelp": false, + "hidden": true, + "multiple": false, + "name": "invoked-by", + "type": "option" + }, "json": { "allowNo": false, "char": "j", From 2b9ee4ffa9d90cb31f0c8c04541fb8f88abc4a50 Mon Sep 17 00:00:00 2001 From: Sagarika Dasgupta Date: Wed, 15 Oct 2025 09:02:26 -0500 Subject: [PATCH 2/7] making invoked-by only readable by setting an env variable --- packages/app/src/cli/commands/app/function/run.ts | 7 +------ packages/cli/oclif.manifest.json | 9 --------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/app/src/cli/commands/app/function/run.ts b/packages/app/src/cli/commands/app/function/run.ts index 62ae0dd3a7c..9cb59a9157f 100644 --- a/packages/app/src/cli/commands/app/function/run.ts +++ b/packages/app/src/cli/commands/app/function/run.ts @@ -34,18 +34,13 @@ export default class FunctionRun extends AppUnlinkedCommand { description: 'Name of the WebAssembly export to invoke.', env: 'SHOPIFY_FLAG_EXPORT', }), - 'invoked-by': Flags.string({ - hidden: true, - description: 'Internal flag to track which client invoked this command.', - env: 'SHOPIFY_FLAG_INVOKED_BY', - }), } public async run(): Promise { const {flags} = await this.parse(FunctionRun) // Track which client invoked this command - const invokedBy = flags['invoked-by'] + const invokedBy = process.env.SHOPIFY_FLAG_INVOKED_BY if (invokedBy) { await addPublicMetadata(() => ({ cmd_app_function_run_invoked_by: invokedBy, diff --git a/packages/cli/oclif.manifest.json b/packages/cli/oclif.manifest.json index 341227b9521..daef3718dc4 100644 --- a/packages/cli/oclif.manifest.json +++ b/packages/cli/oclif.manifest.json @@ -1131,15 +1131,6 @@ "name": "input", "type": "option" }, - "invoked-by": { - "description": "Internal flag to track which client invoked this command.", - "env": "SHOPIFY_FLAG_INVOKED_BY", - "hasDynamicHelp": false, - "hidden": true, - "multiple": false, - "name": "invoked-by", - "type": "option" - }, "json": { "allowNo": false, "char": "j", From fe35d017d9ff6965fa0d39b83ad19017aabfb22c Mon Sep 17 00:00:00 2001 From: Sagarika Dasgupta Date: Wed, 15 Oct 2025 13:02:51 -0500 Subject: [PATCH 3/7] making the field more generic --- packages/app/src/cli/commands/app/function/run.ts | 4 ++-- packages/cli-kit/src/public/node/monorail.ts | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/app/src/cli/commands/app/function/run.ts b/packages/app/src/cli/commands/app/function/run.ts index 9cb59a9157f..3cc2c21182f 100644 --- a/packages/app/src/cli/commands/app/function/run.ts +++ b/packages/app/src/cli/commands/app/function/run.ts @@ -40,10 +40,10 @@ export default class FunctionRun extends AppUnlinkedCommand { const {flags} = await this.parse(FunctionRun) // Track which client invoked this command - const invokedBy = process.env.SHOPIFY_FLAG_INVOKED_BY + const invokedBy = process.env.INVOKED_BY if (invokedBy) { await addPublicMetadata(() => ({ - cmd_app_function_run_invoked_by: invokedBy, + cmd_all_invoked_by: invokedBy, })) } diff --git a/packages/cli-kit/src/public/node/monorail.ts b/packages/cli-kit/src/public/node/monorail.ts index 47d867d2206..c92820c58ea 100644 --- a/packages/cli-kit/src/public/node/monorail.ts +++ b/packages/cli-kit/src/public/node/monorail.ts @@ -57,6 +57,7 @@ export interface Schemas { cmd_all_exit?: Optional cmd_all_force?: Optional cmd_all_last_graphql_request_id?: Optional + cmd_all_invoked_by?: Optional cmd_all_timing_network_ms?: Optional cmd_all_timing_prompts_ms?: Optional @@ -88,9 +89,6 @@ export interface Schemas { cmd_app_warning_api_key_deprecation_displayed?: Optional cmd_app_deployment_mode?: Optional - // Function related commands - cmd_app_function_run_invoked_by?: Optional - // Dev related commands cmd_dev_tunnel_type?: Optional cmd_dev_tunnel_custom_hash?: Optional From 58585e0ec2e2c679f7c743cec33670daf850c619 Mon Sep 17 00:00:00 2001 From: Sagarika Dasgupta Date: Thu, 16 Oct 2025 08:47:18 -0500 Subject: [PATCH 4/7] reverting to using a full flag so it gets automatically included in monorail payload args field --- .../interfaces/app-function-run.interface.ts | 6 +++++ .../generated/generated_docs_data.json | 11 +++++++- .../app/src/cli/commands/app/function/run.ts | 14 ++++------ packages/cli-kit/src/public/node/monorail.ts | 1 - packages/cli/README.md | 27 ++++++++++--------- packages/cli/oclif.manifest.json | 9 +++++++ 6 files changed, 44 insertions(+), 24 deletions(-) diff --git a/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts b/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts index 3e13075ee10..e2786df1657 100644 --- a/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts +++ b/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts @@ -24,6 +24,12 @@ export interface appfunctionrun { */ '-i, --input '?: string + /** + * The client that invoked this command. + * @environment SHOPIFY_FLAG_INVOKED_BY + */ + '-b, --invoked-by '?: string + /** * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON diff --git a/docs-shopify.dev/generated/generated_docs_data.json b/docs-shopify.dev/generated/generated_docs_data.json index 971f2310826..cbfc2960540 100644 --- a/docs-shopify.dev/generated/generated_docs_data.json +++ b/docs-shopify.dev/generated/generated_docs_data.json @@ -1292,6 +1292,15 @@ "isOptional": true, "environmentValue": "SHOPIFY_FLAG_VERBOSE" }, + { + "filePath": "docs-shopify.dev/commands/interfaces/app-function-run.interface.ts", + "syntaxKind": "PropertySignature", + "name": "-b, --invoked-by ", + "value": "string", + "description": "The client that invoked this command.", + "isOptional": true, + "environmentValue": "SHOPIFY_FLAG_INVOKED_BY" + }, { "filePath": "docs-shopify.dev/commands/interfaces/app-function-run.interface.ts", "syntaxKind": "PropertySignature", @@ -1329,7 +1338,7 @@ "environmentValue": "SHOPIFY_FLAG_JSON" } ], - "value": "export interface appfunctionrun {\n /**\n * The Client ID of your app.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Name of the WebAssembly export to invoke.\n * @environment SHOPIFY_FLAG_EXPORT\n */\n '-e, --export '?: string\n\n /**\n * The input JSON to pass to the function. If omitted, standard input is used.\n * @environment SHOPIFY_FLAG_INPUT\n */\n '-i, --input '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Reset all your settings.\n * @environment SHOPIFY_FLAG_RESET\n */\n '--reset'?: ''\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface appfunctionrun {\n /**\n * The Client ID of your app.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Name of the WebAssembly export to invoke.\n * @environment SHOPIFY_FLAG_EXPORT\n */\n '-e, --export '?: string\n\n /**\n * The input JSON to pass to the function. If omitted, standard input is used.\n * @environment SHOPIFY_FLAG_INPUT\n */\n '-i, --input '?: string\n\n /**\n * The client that invoked this command.\n * @environment SHOPIFY_FLAG_INVOKED_BY\n */\n '-b, --invoked-by '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Reset all your settings.\n * @environment SHOPIFY_FLAG_RESET\n */\n '--reset'?: ''\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } diff --git a/packages/app/src/cli/commands/app/function/run.ts b/packages/app/src/cli/commands/app/function/run.ts index 3cc2c21182f..f47e5e5d011 100644 --- a/packages/app/src/cli/commands/app/function/run.ts +++ b/packages/app/src/cli/commands/app/function/run.ts @@ -7,7 +7,6 @@ import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli' import {Flags} from '@oclif/core' import {renderAutocompletePrompt, isTTY} from '@shopify/cli-kit/node/ui' import {outputDebug} from '@shopify/cli-kit/node/output' -import {addPublicMetadata} from '@shopify/cli-kit/node/metadata' const DEFAULT_FUNCTION_EXPORT = '_start' @@ -34,19 +33,16 @@ export default class FunctionRun extends AppUnlinkedCommand { description: 'Name of the WebAssembly export to invoke.', env: 'SHOPIFY_FLAG_EXPORT', }), + 'invoked-by': Flags.string({ + char: 'b', + description: 'The client that invoked this command.', + env: 'SHOPIFY_FLAG_INVOKED_BY', + }), } public async run(): Promise { const {flags} = await this.parse(FunctionRun) - // Track which client invoked this command - const invokedBy = process.env.INVOKED_BY - if (invokedBy) { - await addPublicMetadata(() => ({ - cmd_all_invoked_by: invokedBy, - })) - } - let functionExport = DEFAULT_FUNCTION_EXPORT const app = await localAppContext({ diff --git a/packages/cli-kit/src/public/node/monorail.ts b/packages/cli-kit/src/public/node/monorail.ts index c92820c58ea..10ff35ab7c1 100644 --- a/packages/cli-kit/src/public/node/monorail.ts +++ b/packages/cli-kit/src/public/node/monorail.ts @@ -57,7 +57,6 @@ export interface Schemas { cmd_all_exit?: Optional cmd_all_force?: Optional cmd_all_last_graphql_request_id?: Optional - cmd_all_invoked_by?: Optional cmd_all_timing_network_ms?: Optional cmd_all_timing_prompts_ms?: Optional diff --git a/packages/cli/README.md b/packages/cli/README.md index 41a104121be..55bf090a925 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -414,19 +414,20 @@ Run a function locally for testing. ``` USAGE - $ shopify app function run [--client-id | -c ] [-e ] [-i ] [-j] [--no-color] [--path - ] [--reset | ] [--verbose] - -FLAGS - -c, --config= The name of the app configuration. - -e, --export= Name of the WebAssembly export to invoke. - -i, --input= The input JSON to pass to the function. If omitted, standard input is used. - -j, --json Output the result as JSON. - --client-id= The Client ID of your app. - --no-color Disable color output. - --path= The path to your function directory. - --reset Reset all your settings. - --verbose Increase the verbosity of the output. + $ shopify app function run [--client-id | -c ] [-e ] [-i ] [-b ] [-j] + [--no-color] [--path ] [--reset | ] [--verbose] + +FLAGS + -b, --invoked-by= The client that invoked this command. + -c, --config= The name of the app configuration. + -e, --export= Name of the WebAssembly export to invoke. + -i, --input= The input JSON to pass to the function. If omitted, standard input is used. + -j, --json Output the result as JSON. + --client-id= The Client ID of your app. + --no-color Disable color output. + --path= The path to your function directory. + --reset Reset all your settings. + --verbose Increase the verbosity of the output. DESCRIPTION Run a function locally for testing. diff --git a/packages/cli/oclif.manifest.json b/packages/cli/oclif.manifest.json index daef3718dc4..5c9bf9a86e2 100644 --- a/packages/cli/oclif.manifest.json +++ b/packages/cli/oclif.manifest.json @@ -1131,6 +1131,15 @@ "name": "input", "type": "option" }, + "invoked-by": { + "char": "b", + "description": "The client that invoked this command.", + "env": "SHOPIFY_FLAG_INVOKED_BY", + "hasDynamicHelp": false, + "multiple": false, + "name": "invoked-by", + "type": "option" + }, "json": { "allowNo": false, "char": "j", From 799b462a3a73a135e55ac13c68fa21371aec8eea Mon Sep 17 00:00:00 2001 From: Sagarika Dasgupta Date: Fri, 17 Oct 2025 08:20:37 -0500 Subject: [PATCH 5/7] hiding flag because it is internal --- .../interfaces/app-function-run.interface.ts | 6 ----- .../generated/generated_docs_data.json | 11 +------- .../app/src/cli/commands/app/function/run.ts | 1 + packages/cli/README.md | 27 +++++++++---------- packages/cli/oclif.manifest.json | 1 + 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts b/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts index e2786df1657..3e13075ee10 100644 --- a/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts +++ b/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts @@ -24,12 +24,6 @@ export interface appfunctionrun { */ '-i, --input '?: string - /** - * The client that invoked this command. - * @environment SHOPIFY_FLAG_INVOKED_BY - */ - '-b, --invoked-by '?: string - /** * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON diff --git a/docs-shopify.dev/generated/generated_docs_data.json b/docs-shopify.dev/generated/generated_docs_data.json index cbfc2960540..971f2310826 100644 --- a/docs-shopify.dev/generated/generated_docs_data.json +++ b/docs-shopify.dev/generated/generated_docs_data.json @@ -1292,15 +1292,6 @@ "isOptional": true, "environmentValue": "SHOPIFY_FLAG_VERBOSE" }, - { - "filePath": "docs-shopify.dev/commands/interfaces/app-function-run.interface.ts", - "syntaxKind": "PropertySignature", - "name": "-b, --invoked-by ", - "value": "string", - "description": "The client that invoked this command.", - "isOptional": true, - "environmentValue": "SHOPIFY_FLAG_INVOKED_BY" - }, { "filePath": "docs-shopify.dev/commands/interfaces/app-function-run.interface.ts", "syntaxKind": "PropertySignature", @@ -1338,7 +1329,7 @@ "environmentValue": "SHOPIFY_FLAG_JSON" } ], - "value": "export interface appfunctionrun {\n /**\n * The Client ID of your app.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Name of the WebAssembly export to invoke.\n * @environment SHOPIFY_FLAG_EXPORT\n */\n '-e, --export '?: string\n\n /**\n * The input JSON to pass to the function. If omitted, standard input is used.\n * @environment SHOPIFY_FLAG_INPUT\n */\n '-i, --input '?: string\n\n /**\n * The client that invoked this command.\n * @environment SHOPIFY_FLAG_INVOKED_BY\n */\n '-b, --invoked-by '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Reset all your settings.\n * @environment SHOPIFY_FLAG_RESET\n */\n '--reset'?: ''\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface appfunctionrun {\n /**\n * The Client ID of your app.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Name of the WebAssembly export to invoke.\n * @environment SHOPIFY_FLAG_EXPORT\n */\n '-e, --export '?: string\n\n /**\n * The input JSON to pass to the function. If omitted, standard input is used.\n * @environment SHOPIFY_FLAG_INPUT\n */\n '-i, --input '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Reset all your settings.\n * @environment SHOPIFY_FLAG_RESET\n */\n '--reset'?: ''\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } diff --git a/packages/app/src/cli/commands/app/function/run.ts b/packages/app/src/cli/commands/app/function/run.ts index f47e5e5d011..3a8c08ef35d 100644 --- a/packages/app/src/cli/commands/app/function/run.ts +++ b/packages/app/src/cli/commands/app/function/run.ts @@ -35,6 +35,7 @@ export default class FunctionRun extends AppUnlinkedCommand { }), 'invoked-by': Flags.string({ char: 'b', + hidden: true, description: 'The client that invoked this command.', env: 'SHOPIFY_FLAG_INVOKED_BY', }), diff --git a/packages/cli/README.md b/packages/cli/README.md index 55bf090a925..41a104121be 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -414,20 +414,19 @@ Run a function locally for testing. ``` USAGE - $ shopify app function run [--client-id | -c ] [-e ] [-i ] [-b ] [-j] - [--no-color] [--path ] [--reset | ] [--verbose] - -FLAGS - -b, --invoked-by= The client that invoked this command. - -c, --config= The name of the app configuration. - -e, --export= Name of the WebAssembly export to invoke. - -i, --input= The input JSON to pass to the function. If omitted, standard input is used. - -j, --json Output the result as JSON. - --client-id= The Client ID of your app. - --no-color Disable color output. - --path= The path to your function directory. - --reset Reset all your settings. - --verbose Increase the verbosity of the output. + $ shopify app function run [--client-id | -c ] [-e ] [-i ] [-j] [--no-color] [--path + ] [--reset | ] [--verbose] + +FLAGS + -c, --config= The name of the app configuration. + -e, --export= Name of the WebAssembly export to invoke. + -i, --input= The input JSON to pass to the function. If omitted, standard input is used. + -j, --json Output the result as JSON. + --client-id= The Client ID of your app. + --no-color Disable color output. + --path= The path to your function directory. + --reset Reset all your settings. + --verbose Increase the verbosity of the output. DESCRIPTION Run a function locally for testing. diff --git a/packages/cli/oclif.manifest.json b/packages/cli/oclif.manifest.json index 5c9bf9a86e2..ff50d7bd2eb 100644 --- a/packages/cli/oclif.manifest.json +++ b/packages/cli/oclif.manifest.json @@ -1136,6 +1136,7 @@ "description": "The client that invoked this command.", "env": "SHOPIFY_FLAG_INVOKED_BY", "hasDynamicHelp": false, + "hidden": true, "multiple": false, "name": "invoked-by", "type": "option" From 95fca9678a915eeee3fd9106087acf471a068e92 Mon Sep 17 00:00:00 2001 From: Sagarika Dasgupta Date: Fri, 17 Oct 2025 11:00:07 -0500 Subject: [PATCH 6/7] adding all SHOPIFY_ prefixed environment variables to monorail --- .../app/src/cli/commands/app/function/run.ts | 6 ---- .../cli-kit/src/private/node/analytics.ts | 5 ++++ .../cli-kit/src/public/node/analytics.test.ts | 30 +++++++++++++++++++ packages/cli-kit/src/public/node/monorail.ts | 1 + packages/cli/oclif.manifest.json | 10 ------- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/packages/app/src/cli/commands/app/function/run.ts b/packages/app/src/cli/commands/app/function/run.ts index 3a8c08ef35d..2e5ea046c2a 100644 --- a/packages/app/src/cli/commands/app/function/run.ts +++ b/packages/app/src/cli/commands/app/function/run.ts @@ -33,12 +33,6 @@ export default class FunctionRun extends AppUnlinkedCommand { description: 'Name of the WebAssembly export to invoke.', env: 'SHOPIFY_FLAG_EXPORT', }), - 'invoked-by': Flags.string({ - char: 'b', - hidden: true, - description: 'The client that invoked this command.', - env: 'SHOPIFY_FLAG_INVOKED_BY', - }), } public async run(): Promise { diff --git a/packages/cli-kit/src/private/node/analytics.ts b/packages/cli-kit/src/private/node/analytics.ts index 0a46ad9528b..67a869ee8d8 100644 --- a/packages/cli-kit/src/private/node/analytics.ts +++ b/packages/cli-kit/src/private/node/analytics.ts @@ -97,9 +97,14 @@ export async function getEnvironmentData(config: Interfaces.Config): Promise key.startsWith('SHOPIFY_'))) +} + function getPluginNames(config: Interfaces.Config) { const pluginNames = [...config.plugins.keys()] return pluginNames.sort().filter((plugin) => !plugin.startsWith('@oclif/')) diff --git a/packages/cli-kit/src/public/node/analytics.test.ts b/packages/cli-kit/src/public/node/analytics.test.ts index 544d1e4ed37..437ee1bb93e 100644 --- a/packages/cli-kit/src/public/node/analytics.test.ts +++ b/packages/cli-kit/src/public/node/analytics.test.ts @@ -185,6 +185,36 @@ describe('event tracking', () => { }) }) + test('sends SHOPIFY_ environment variables in sensitive payload', async () => { + const originalEnv = {...process.env} + process.env.SHOPIFY_TEST_VAR = 'test_value' + process.env.SHOPIFY_ANOTHER_VAR = 'another_value' + process.env.NOT_SHOPIFY_VAR = 'should_not_appear' + + await inProjectWithFile('package.json', async (args) => { + const commandContent = {command: 'dev', topic: 'app'} + await startAnalytics({commandContent, args, currentTime: currentDate.getTime() - 100}) + + // When + const config = { + runHook: vi.fn().mockResolvedValue({successes: [], failures: []}), + plugins: [], + } as any + await reportAnalyticsEvent({config, exitMode: 'ok'}) + + // Then + const sensitivePayload = publishEventMock.mock.calls[0]![2] + expect(publishEventMock).toHaveBeenCalledOnce() + expect(sensitivePayload).toHaveProperty('env_shopify_variables') + expect(sensitivePayload.env_shopify_variables).toBeDefined() + + const shopifyVars = JSON.parse(sensitivePayload.env_shopify_variables as string) + expect(shopifyVars).toHaveProperty('SHOPIFY_TEST_VAR', 'test_value') + expect(shopifyVars).toHaveProperty('SHOPIFY_ANOTHER_VAR', 'another_value') + expect(shopifyVars).not.toHaveProperty('NOT_SHOPIFY_VAR') + }) + }) + test('does nothing when analytics are disabled', async () => { await inProjectWithFile('package.json', async (args) => { // Given diff --git a/packages/cli-kit/src/public/node/monorail.ts b/packages/cli-kit/src/public/node/monorail.ts index 10ff35ab7c1..d84be2b05a6 100644 --- a/packages/cli-kit/src/public/node/monorail.ts +++ b/packages/cli-kit/src/public/node/monorail.ts @@ -27,6 +27,7 @@ export interface Schemas { // Environment env_plugin_installed_all?: Optional + env_shopify_variables?: Optional } public: { business_platform_id?: Optional diff --git a/packages/cli/oclif.manifest.json b/packages/cli/oclif.manifest.json index ff50d7bd2eb..daef3718dc4 100644 --- a/packages/cli/oclif.manifest.json +++ b/packages/cli/oclif.manifest.json @@ -1131,16 +1131,6 @@ "name": "input", "type": "option" }, - "invoked-by": { - "char": "b", - "description": "The client that invoked this command.", - "env": "SHOPIFY_FLAG_INVOKED_BY", - "hasDynamicHelp": false, - "hidden": true, - "multiple": false, - "name": "invoked-by", - "type": "option" - }, "json": { "allowNo": false, "char": "j", From 8f7a7798057801bf65fefd917f6ddd8caadefcd8 Mon Sep 17 00:00:00 2001 From: Sagarika Dasgupta Date: Tue, 21 Oct 2025 08:55:46 -0500 Subject: [PATCH 7/7] updating monorail topic version --- packages/cli-kit/src/public/node/monorail.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli-kit/src/public/node/monorail.ts b/packages/cli-kit/src/public/node/monorail.ts index d84be2b05a6..10f1ecf1b8c 100644 --- a/packages/cli-kit/src/public/node/monorail.ts +++ b/packages/cli-kit/src/public/node/monorail.ts @@ -10,7 +10,7 @@ const url = 'https://monorail-edge.shopifysvc.com/v1/produce' type Optional = T | null // This is the topic name of the main event we log to Monorail, the command tracker -export const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.19' +export const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.20' export interface Schemas { [MONORAIL_COMMAND_TOPIC]: {