Skip to content

[Phase 1] Track auto-upgrade metrics in Monorail#7001

Open
alfonso-noriega wants to merge 3 commits intomainfrom
03-12-observe-auto-upgrade-metrics
Open

[Phase 1] Track auto-upgrade metrics in Monorail#7001
alfonso-noriega wants to merge 3 commits intomainfrom
03-12-observe-auto-upgrade-metrics

Conversation

@alfonso-noriega
Copy link
Copy Markdown
Contributor

@alfonso-noriega alfonso-noriega commented Mar 13, 2026

Summary

Tracked metrics

Field Type When emitted
env_auto_upgrade_enabled boolean Every command (sent via analytics layer)
env_auto_upgrade_accepted boolean When user is prompted to enable auto-upgrade (to be wired)
env_auto_upgrade_skipped_reason string When upgrade is skipped (major_version)
env_auto_upgrade_success boolean After upgrade attempt — whether it succeeded or failed

Changes

  • packages/cli-kit/src/public/node/monorail.ts: Schema fields aligned with Monorail v1.21
  • packages/cli-kit/src/public/node/hooks/postrun.ts: Emits env_auto_upgrade_skipped_reason and env_auto_upgrade_success at decision points
  • packages/cli-kit/src/public/node/hooks/postrun.test.ts: Tests cover skipped_reason, success, and failure scenarios

Schema alignment

Fields match Shopify/monorail#23360 (app_cli3_command v1.21).

Removed fields not in the schema:

  • env_auto_upgrade_triggered — upgrade attempts are inferred from the presence of env_auto_upgrade_skipped_reason or env_auto_upgrade_success
  • env_auto_upgrade_package_manager — already tracked via env_package_manager in the analytics layer

Test plan

  • pnpm vitest run src/public/node/hooks/postrun.test.ts — all 7 tests pass
  • Verify Monorail schema PR is merged before shipping

@alfonso-noriega alfonso-noriega changed the base branch from 03-12-port_auto_upgrade_poc_to_main to graphite-base/7001 April 9, 2026 12:15
@alfonso-noriega alfonso-noriega force-pushed the 03-12-observe-auto-upgrade-metrics branch from 2869478 to e33833f Compare April 9, 2026 12:15
@alfonso-noriega alfonso-noriega changed the base branch from graphite-base/7001 to main April 9, 2026 12:15
Copy link
Copy Markdown
Contributor Author

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

@alfonso-noriega alfonso-noriega force-pushed the 03-12-observe-auto-upgrade-metrics branch from 00ff291 to 5bff8e0 Compare April 9, 2026 16:38
- Adds Monorail tracking for auto-upgrade events
- Tracked metrics: triggered, package_manager, skipped_reason, success
- Updated postrun hook to record metrics at each decision point
- Added tests for all metric recording scenarios

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alfonso-noriega alfonso-noriega force-pushed the 03-12-observe-auto-upgrade-metrics branch from 5bff8e0 to bf2d5b2 Compare April 10, 2026 16:41
alfonso-noriega and others added 2 commits April 13, 2026 10:31
Aligns CLI metrics with the Monorail schema defined in Shopify/monorail#23360.

- Remove env_auto_upgrade_triggered (not in schema)
- Keep env_auto_upgrade_package_manager, env_auto_upgrade_skipped_reason,
  env_auto_upgrade_success (match schema fields)
- env_auto_upgrade_enabled already sent via analytics layer
- env_auto_upgrade_accepted to be wired when prompt flow lands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Package manager is already tracked via env_package_manager in the
analytics layer. No need to duplicate it in auto-upgrade metrics.
@github-actions
Copy link
Copy Markdown
Contributor

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/analytics.d.ts
@@ -23,6 +23,7 @@ interface EnvironmentData {
     env_auth_method: string;
     env_is_wsl: boolean;
     env_build_repository: string;
+    env_auto_upgrade_enabled: boolean | null;
 }
 export declare function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData>;
 export declare function getSensitiveEnvironmentData(config: Interfaces.Config): Promise<{
packages/cli-kit/dist/public/node/metadata.d.ts
@@ -34,7 +34,7 @@ export type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic
  * @returns A container for the metadata.
  */
 export declare function createRuntimeMetadataContainer<TPublic extends AnyJson, TSensitive extends AnyJson = Record<string, never>>(defaultPublicMetadata?: Partial<TPublic>): RuntimeMetadataManager<TPublic, TSensitive>;
-type CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> & PickByPrefix<MonorailEventPublic, 'cmd_app_'> & PickByPrefix<MonorailEventPublic, 'cmd_create_app_'> & PickByPrefix<MonorailEventPublic, 'cmd_theme_'> & PickByPrefix<MonorailEventPublic, 'store_'>;
+type CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> & PickByPrefix<MonorailEventPublic, 'cmd_app_'> & PickByPrefix<MonorailEventPublic, 'cmd_create_app_'> & PickByPrefix<MonorailEventPublic, 'cmd_theme_'> & PickByPrefix<MonorailEventPublic, 'store_'> & PickByPrefix<MonorailEventPublic, 'env_auto_upgrade_'>;
 declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
     commandStartOptions: {
         startTime: number;
packages/cli-kit/dist/public/node/monorail.d.ts
@@ -46,6 +46,10 @@ export interface Schemas {
             cmd_all_timing_network_ms?: Optional<number>;
             cmd_all_timing_prompts_ms?: Optional<number>;
             cmd_all_timing_active_ms?: Optional<number>;
+            env_auto_upgrade_enabled?: Optional<boolean>;
+            env_auto_upgrade_accepted?: Optional<boolean>;
+            env_auto_upgrade_skipped_reason?: Optional<string>;
+            env_auto_upgrade_success?: Optional<boolean>;
             cmd_extensions_binary_from_source?: Optional<boolean>;
             cmd_scaffold_required_auth?: Optional<boolean>;
             cmd_scaffold_template_custom?: Optional<boolean>;
packages/cli-kit/dist/public/node/upgrade.d.ts
@@ -2,7 +2,7 @@
  * Utility function for generating an install command for the user to run
  * to install an updated version of Shopify CLI.
  *
- * @returns A string with the command to run.
+ * @returns A string with the command to run, or undefined if the package manager cannot be determined.
  */
 export declare function cliInstallCommand(): string | undefined;
 /**

@alfonso-noriega alfonso-noriega marked this pull request as ready for review April 13, 2026 09:15
@alfonso-noriega alfonso-noriega requested review from a team as code owners April 13, 2026 09:15
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not relevant for the users 🔥

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover? 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants