Skip to content

Add analytics opt-out that matches ai-toolkit#7503

Open
dmerand wants to merge 1 commit intomainfrom
dlm-opt-out-ai-toolkit-env-match
Open

Add analytics opt-out that matches ai-toolkit#7503
dmerand wants to merge 1 commit intomainfrom
dlm-opt-out-ai-toolkit-env-match

Conversation

@dmerand
Copy link
Copy Markdown
Contributor

@dmerand dmerand commented May 8, 2026

What

Make the CLI treat OPT_OUT_INSTRUMENTATION=true as an analytics opt-out, alongside the existing SHOPIFY_CLI_NO_ANALYTICS=1 env var.

This also updates the usage-reporting docs to mention both opt-out paths.

Why

ai-toolkit and related Shopify agent surfaces already use OPT_OUT_INSTRUMENTATION as the common telemetry opt-out.

When those tools invoke Shopify CLI, the mismatch is awkward: the surrounding tooling can be opted out with one env var, but the CLI still requires a different one. This makes the CLI accept the same opt-out signal as an alias without changing the existing SHOPIFY_CLI_NO_ANALYTICS behavior.

How

  • add OPT_OUT_INSTRUMENTATION to the shared environment-variable constants in cli-kit
  • update analyticsDisabled() to return true when either opt-out env var is truthy
  • update the usage-reporting docs to mention both env vars

Copy link
Copy Markdown
Contributor Author

dmerand commented May 8, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label May 8, 2026
@dmerand dmerand marked this pull request as ready for review May 8, 2026 20:53
@dmerand dmerand requested review from a team as code owners May 8, 2026 20:53
Copilot AI review requested due to automatic review settings May 8, 2026 20:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/constants.d.ts
@@ -8,6 +8,7 @@ export declare const environmentVariables: {
     env: string;
     firstPartyDev: string;
     noAnalytics: string;
+    optOutInstrumentation: string;
     appAutomationToken: string;
     partnersToken: string;
     runAsUser: string;
packages/cli-kit/dist/public/node/context/local.d.ts
@@ -53,7 +53,7 @@ export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
  * Returns true if reporting analytics is enabled.
  *
  * @param env - The environment variables from the environment of the current process.
- * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
+ * @returns True unless SHOPIFY_CLI_NO_ANALYTICS or OPT_OUT_INSTRUMENTATION is truthy, or debug mode is enabled.
  */
 export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
 /**

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns Shopify CLI’s analytics opt-out behavior with other Shopify tooling by accepting OPT_OUT_INSTRUMENTATION=true as an alias for the existing SHOPIFY_CLI_NO_ANALYTICS=1 opt-out, and updates documentation accordingly.

Changes:

  • Add OPT_OUT_INSTRUMENTATION to cli-kit’s shared environment-variable constants.
  • Update analyticsDisabled() to disable analytics when either opt-out env var is truthy (or when in development).
  • Update usage-reporting docs (source + generated output) to mention both opt-out options.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/cli-kit/src/public/node/context/local.ts Extends analytics opt-out detection to include OPT_OUT_INSTRUMENTATION.
packages/cli-kit/src/public/node/context/local.test.ts Adds unit tests covering the new opt-out env var behavior.
packages/cli-kit/src/private/node/constants.ts Adds a shared constant key for OPT_OUT_INSTRUMENTATION.
docs-shopify.dev/static/cli.doc.ts Updates usage-reporting docs to mention both opt-out env vars.
docs-shopify.dev/generated/generated_static_pages.json Updates generated docs content to match the static docs change.
.changeset/quiet-otters-wave.md Adds a patch changeset documenting the new opt-out alias.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 94 to 99
/**
* Returns true if reporting analytics is enabled.
*
* @param env - The environment variables from the environment of the current process.
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS or OPT_OUT_INSTRUMENTATION is truthy, or debug mode is enabled.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants