Skip to content

Send analytics in background#7615

Draft
gonzaloriestra wants to merge 1 commit into
mainfrom
background-analytics
Draft

Send analytics in background#7615
gonzaloriestra wants to merge 1 commit into
mainfrom
background-analytics

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes #0000

WHAT is this pull request doing?

How to test your changes?

Post-release steps

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 — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

@gonzaloriestra
Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label May 22, 2026
@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/public/node/analytics.d.ts
 import { RuntimeData } from '../../private/node/analytics/storage.js';
 import { Interfaces } from '@oclif/core';
 export type CommandExitMode = 'ok' | 'unexpected_error' | 'expected_error';
 interface ReportAnalyticsEventOptions {
     config: Interfaces.Config;
     errorMessage?: string;
     exitMode: CommandExitMode;
 }
+export declare function sendAnalyticsEventFromFile(payloadFile: string): Promise<void>;
 /**
  * Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.
  *
  * The payload for an event includes both generic data, and data gathered from installed plug-ins.
  *
  */
 export declare function reportAnalyticsEvent(options: ReportAnalyticsEventOptions): Promise<void>;
 /**
  * Records timing data for performance monitoring. Call twice with the same
  * event name to start and stop timing. First call starts the timer, second
  * call stops it and records the duration.
  *
  * @example
  * ```ts
  *   recordTiming('theme-upload') // Start timing
  *   // ... do work ...
  *   recordTiming('theme-upload') // Stop timing and record duration
  * ```
  *
  * @param eventName - Unique identifier for the timing event
  */
 export declare function recordTiming(eventName: string): void;
 /**
  * Records error information for debugging and monitoring. Use this to track
  * any exceptions or error conditions that occur during theme operations.
  * Errors are automatically categorized for easier analysis.
  *
  * @example
  * ```ts
  *   try {
  *     // ... risky operation ...
  *   } catch (error) {
  *     recordError(error)
  *   }
  * ```
  *
  * @param error - Error object or message to record
  */
 export declare function recordError<T>(error: T): T;
 /**
  * Records retry attempts for network operations. Use this to track when
  * operations are retried due to transient failures. Helps identify
  * problematic endpoints or operations that frequently fail.
  *
  * @example
  * ```ts
  *   recordRetry('https://api.shopify.com/themes', 'upload')
  * ```
  *
  * @param url - The URL or endpoint being retried
  * @param operation - Description of the operation being retried
  */
 export declare function recordRetry(url: string, operation: string): void;
 /**
  * Records custom events for tracking specific user actions or system events.
  * Use this for important milestones, user interactions, or significant
  * state changes in the application.
  *
  * @example
  * ```ts
  *   recordEvent('theme-dev-started')
  *   recordEvent('file-watcher-connected')
  * ```
  *
  * @param eventName - Descriptive name for the event
  */
 export declare function recordEvent(eventName: string): void;
 /**
  * Compiles and returns all runtime analytics data collected during the session.
  * This includes timing measurements, error records, retry attempts, and custom
  * events. Use this to retrieve a complete snapshot of analytics data for
  * reporting or debugging purposes.
  *
  * @example
  * ```ts
  *   const analyticsData = compileData()
  *   console.log(`Recorded ${analyticsData.timings.length} timing events`)
  *   console.log(`Recorded ${analyticsData.errors.length} errors`)
  * ```
  *
  * @returns Object containing all collected analytics data including timings, errors, retries, and events
  */
 export declare function compileData(): RuntimeData;
 export {};

@github-actions
Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260522143741

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

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

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant