Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store hidden config per client ID #5399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

isaacroldan
Copy link
Contributor

@isaacroldan isaacroldan commented Feb 17, 2025

WHY are these changes introduced?

The current implementation stores dev store URLs in a flat structure, which can lead to conflicts when developers work with multiple organizations. This change introduces app-specific storage of dev store URLs.

WHAT is this pull request doing?

Updates the hidden configuration structure to store dev store URLs under app-specific keys, preventing conflicts when connecting to different organizations. The change includes:

  • Modifying the AppHiddenConfig interface to use app names as keys
  • Using deep merge for config updates
  • Updating store context handling to reference app-specific store URLs

Example:

{
  "testa8e113c942b95b54c1d0ffbc2": {
    "dev_store_url": "test-store-3.myshopify.com"
  },
  "test6f7048e1a203d6ae64c601f1": {
    "dev_store_url": "test-store-2.myshopify.com"
  }
}

How to test your changes?

  1. Create multiple app configurations in your app
  2. Run dev commands for different apps
  3. Verify that each app maintains its own dev store URL
  4. Confirm that switching between apps preserves their respective store configurations

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

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

Copy link
Contributor Author

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

@isaacroldan isaacroldan changed the title Update tests Store dev store URL per app configuration name Feb 17, 2025
@isaacroldan isaacroldan marked this pull request as ready for review February 17, 2025 10:03
@isaacroldan isaacroldan requested a review from a team as a code owner February 17, 2025 10:03
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

Copy link
Contributor

github-actions bot commented Feb 17, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
75.77% (+0.04% 🔼)
9135/12057
🟡 Branches
70.96% (+0.04% 🔼)
4466/6294
🟡 Functions
75.44% (+0.02% 🔼)
2377/3151
🟡 Lines
76.31% (+0.05% 🔼)
8625/11302
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app.ts
88.57% (-0.32% 🔻)
69.89% (-0.44% 🔻)
93.1% (+0.12% 🔼)
90.6% (+0.19% 🔼)
🟢
... / app-event-watcher.ts
95.18% (-1.2% 🔻)
86.49% (-2.7% 🔻)
95.45% 100%

Test suite run success

2075 tests passing in 924 suites.

Report generated by 🧪jest coverage report action from f80eebf

@isaacroldan isaacroldan force-pushed the 02-17-save_dev_stores_per_app branch 5 times, most recently from bb0435a to 53c2446 Compare February 17, 2025 14:50
@isaacroldan isaacroldan changed the title Store dev store URL per app configuration name Store dev store URL per app client-id Feb 17, 2025
@isaacroldan isaacroldan changed the title Store dev store URL per app client-id Store hidden config per client ID Feb 20, 2025
@isaacroldan isaacroldan force-pushed the 02-17-save_dev_stores_per_app branch from 53c2446 to 3c10440 Compare February 20, 2025 11:31
Copy link
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

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

The purpose and the code LGTM, but what happens with the users that already had a saved store without client ID? Will they lose it? I couldn't test it yet

Copy link
Contributor Author

isaacroldan commented Feb 20, 2025

Yes, they'll be forced to reselect the store.
It will only happen for users that created an app with the last release.

I think that's preferable over having to support some "migration" code forever.

@amcaplan
Copy link
Contributor

I'm OK with that limited-blast-radius impact, but I think our code should include a test that ensures we can handle the old format without exploding. Otherwise we might accidentally make a future change that breaks things and users won't easily be able to fix it.

Copy link
Contributor

I agree it's preferable. But I think it's something we should at least discuss, maybe gather some numbers, decide if we want to inform the user somehow... Another option could be to support the migration only for a few versions, as it doesn't look too complicate.

@isaacroldan isaacroldan force-pushed the 02-17-save_dev_stores_per_app branch 2 times, most recently from 080b1ea to 883ce69 Compare February 21, 2025 10:02
Copy link
Contributor Author

Ok, added a simple migration in the loadHiddenConfig function, we can remove that (2 lines) in 1-2 versions.

Copy link
Contributor Author

Also added a bunch of tests to cover all possible cases

@isaacroldan isaacroldan force-pushed the 02-17-save_dev_stores_per_app branch from 883ce69 to f80eebf Compare February 21, 2025 10:04
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.

3 participants