Skip to content

Use preview identity for store open analytics#8005

Open
alfonso-noriega wants to merge 1 commit into
mainfrom
store-open-preview-identity
Open

Use preview identity for store open analytics#8005
alfonso-noriega wants to merge 1 commit into
mainfrom
store-open-preview-identity

Conversation

@alfonso-noriega

@alfonso-noriega alfonso-noriega commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Preview-store commands should attribute command analytics to the store-auth identity selected by --store when the command reads that preview store from the local store-auth cache.

shopify store open --store <preview-store> goes through getStoreInfo, which already records preview store metadata (store_id, domain/hash) from the cached preview-store session. However, it did not set the analytics user_id from that same cached session, so the Monorail event could fall back to the current CLI user/session instead.

WHAT is this pull request doing?

When getStoreInfo detects a locally stored preview-store session, it now also calls:

setLastSeenUserId(storedSession.userId)

This aligns preview-store store open with store info: both commands share the same getStoreInfo path and now emit analytics using:

  • store_id from storedSession.preview.shopId
  • user_id from storedSession.userId

This only applies to the preview-store cache path. Business Platform-backed store info/open flows continue to use the normal CLI authentication identity.

How to test your changes?

pnpm test packages/store/src/cli/services/store/info/index.test.ts

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
  • No changeset: this changes internal analytics attribution only and has no user-visible CLI behavior change.

@alfonso-noriega alfonso-noriega requested a review from a team as a code owner July 6, 2026 09:22

alfonso-noriega commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

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

@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 Jul 6, 2026
@alfonso-noriega alfonso-noriega force-pushed the store-open-preview-identity branch from 6243ecd to d36622e Compare July 6, 2026 10:11
@github-actions

github-actions Bot commented Jul 6, 2026

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/metadata.d.ts
@@ -45,6 +45,7 @@ declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
     };
 } & {
     environmentFlags: string;
+    commandUserId?: string;
 } & PickByPrefix<{
     args: string;
     error_message?: string | null;
@@ -66,6 +67,7 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
     };
 } & {
     environmentFlags: string;
+    commandUserId?: string;
 } & PickByPrefix<{
     args: string;
     error_message?: string | null;
@@ -86,6 +88,7 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
     };
 } & {
     environmentFlags: string;
+    commandUserId?: string;
 } & PickByPrefix<{
     args: string;
     error_message?: string | null;
@@ -97,6 +100,7 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
     env_plugin_installed_all?: string | null;
     env_shopify_variables?: string | null;
 }, "store_", never>>, onError?: MetadataErrorHandling) => Promise<void>, runWithTimer: (field: NumericKeyOf<CmdFieldsFromMonorail>) => <T>(fn: () => Promise<T>) => Promise<T>;
+export declare function addCommandUserIdMetadata(userId: string): Promise<void>;
 export type Public = PublicSchema<typeof coreData>;
 export type Sensitive = SensitiveSchema<typeof coreData>;
 export {};
\ No newline at end of file

Assisted-By: devx/655cd991-b9e0-480d-ba60-50e176a7ce76
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.

2 participants