Skip to content

Store sessions per environment#6931

Draft
gonzaloriestra wants to merge 1 commit intomainfrom
store-sessions-per-env
Draft

Store sessions per environment#6931
gonzaloriestra wants to merge 1 commit intomainfrom
store-sessions-per-env

Conversation

@gonzaloriestra
Copy link
Contributor

@gonzaloriestra gonzaloriestra commented Mar 3, 2026

WHY are these changes introduced?

In #5914 we added support for multiple sessions, but if you switch between environments (production/development), the sessions get overwritten, so you have to log in again.

WHAT is this pull request doing?

Stores sessions grouped per environment, so they can be re-used when switching between them.

⚠️ All the current sessions will stop working, so new logins will be required once. We could also work on an automatic migration, but I think it's not worth it.

How to test your changes?

  • npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260303162727
  • shopify auth logout
  • shopify app versions list
  • SHOPIFY_SERVICE_ENV=local shopify app versions list
  • shopify app versions list
  • SHOPIFY_SERVICE_ENV=local shopify app versions list

It should only start the login flow once per environment.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.85% 14525/18420
🟡 Branches 73.17% 7223/9872
🟡 Functions 79.05% 3693/4672
🟡 Lines 79.19% 13724/17330

Test suite run success

3790 tests passing in 1448 suites.

Report generated by 🧪jest coverage report action from fc77660

@gonzaloriestra gonzaloriestra force-pushed the store-sessions-per-env branch from 3573760 to fc77660 Compare March 3, 2026 16:12
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 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/conf-store.d.ts
@@ -20,7 +20,7 @@ interface Cache {
 }
 export interface ConfSchema {
     sessionStore: string;
-    currentSessionId?: string;
+    currentSessionIds?: Record<string, string>;
     cache?: Cache;
 }
 /**
@@ -40,19 +40,21 @@ export declare function setSessions(session: string, config?: LocalStorage<ConfS
  */
 export declare function removeSessions(config?: LocalStorage<ConfSchema>): void;
 /**
- * Get current session ID.
+ * Get current session ID for a given identity FQDN.
  *
- * @returns Current session ID.
+ * @param fqdn - The identity FQDN to get the session ID for.
+ * @returns Current session ID for that environment.
  */
-export declare function getCurrentSessionId(config?: LocalStorage<ConfSchema>): string | undefined;
+export declare function getCurrentSessionId(fqdn: string, config?: LocalStorage<ConfSchema>): string | undefined;
 /**
- * Set current session ID.
+ * Set current session ID for a given identity FQDN.
  *
+ * @param fqdn - The identity FQDN to set the session ID for.
  * @param sessionId - Session ID.
  */
-export declare function setCurrentSessionId(sessionId: string, config?: LocalStorage<ConfSchema>): void;
+export declare function setCurrentSessionId(fqdn: string, sessionId: string, config?: LocalStorage<ConfSchema>): void;
 /**
- * Remove current session ID.
+ * Remove all current session IDs (across all environments).
  */
 export declare function removeCurrentSessionId(config?: LocalStorage<ConfSchema>): void;
 type CacheValueForKey<TKey extends keyof Cache> = NonNullable<Cache[TKey]>['value'];

@gonzaloriestra
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

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

Test the snapshot by installing your package globally:

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

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant