Skip to content

restore theme dev analytics#7345

Draft
EvilGenius13 wants to merge 2 commits intomainfrom
jf-fix-theme-dev-analytics
Draft

restore theme dev analytics#7345
EvilGenius13 wants to merge 2 commits intomainfrom
jf-fix-theme-dev-analytics

Conversation

@EvilGenius13
Copy link
Copy Markdown
Contributor

@EvilGenius13 EvilGenius13 commented Apr 17, 2026

WHY are these changes introduced?

When users press Ctrl+C to exit shopify theme dev, the process immediately calls process.exit(), terminating before the oclif post-run hook can send analytics events. This means we lose telemetry data for theme dev sessions.

The backgroundJobPromise was originally typed as Promise<never> because it was only meant to reject on error (never resolve). This meant there was no mechanism to gracefully complete the promise chain on user-initiated exit.

WHAT is this pull request doing?

Fixes analytics not being sent when exiting theme dev via Ctrl+C by implementing graceful shutdown:

  1. Changes the Ctrl+C handler to resolve the background job promise instead of calling process.exit() directly
  2. After the main promise chain completes, polls postRunHookHasCompleted() with a 5-second timeout
  3. Calls process.exit(0) only after analytics have been sent (or timeout reached)

How to test your changes?

  1. Run shopify theme dev against a development store
  2. Press Ctrl+C to exit
  3. Verify analytics event is sent

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing, so I've added a changelog entry with pnpm changeset add

@EvilGenius13 EvilGenius13 changed the title fix(theme): restore theme dev analytics by resolving backgroundJobPromise on exit restore theme dev analytics Apr 17, 2026
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.

1 participant