Skip to content

feat(core): append channel to kv key to make it channel aware#1075

Merged
jorgemoya merged 3 commits intomainfrom
kv-channel
Jul 9, 2024
Merged

feat(core): append channel to kv key to make it channel aware#1075
jorgemoya merged 3 commits intomainfrom
kv-channel

Conversation

@jorgemoya
Copy link
Copy Markdown
Contributor

What/Why?

We need for kv keys to be channel aware when using multiple locales.

Testing

Locally each locale/channel has its own kv pairs.

@jorgemoya jorgemoya requested a review from a team July 8, 2024 21:20
@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
catalyst-latest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 9, 2024 4:15pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
catalyst-1millionproducts-store ⬜️ Ignored (Inspect) Visit Preview Jul 9, 2024 4:15pm
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Jul 9, 2024 4:15pm
catalyst-test-store ⬜️ Ignored (Inspect) Visit Preview Jul 9, 2024 4:15pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Jul 9, 2024 4:15pm
catalyst-unstable ⬜️ Ignored (Inspect) Visit Preview Jul 9, 2024 4:15pm

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 8, 2024

🦋 Changeset detected

Latest commit: f4914a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread core/lib/kv/keys.ts Outdated
Comment on lines +2 to +3
export const kvKey = (key: string, channelId?: string) =>
`${channelId ?? process.env.BIGCOMMERCE_CHANNEL_ID ?? '1'}_${key}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thoughts on moving the KV namespace logic to this fn? .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do

Comment thread core/middlewares/with-routes.ts Outdated
};

event.waitUntil(kv.set(routeCacheKvKey(pathname), routeCache));
event.waitUntil(kv.set(kvKey(`v3_${pathname}`, channelId), routeCache));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thoughts on moving the key version v3 to kvKey()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we need v3? 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's an easy way for us to change all keys if needed. I think we should keep it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 9, 2024

⚡️🏠 Lighthouse report

Lighthouse ran against https://catalyst-latest-ny1bwvr61-bigcommerce-platform.vercel.app

🖥️ Desktop

We ran Lighthouse against the changes on a desktop and produced this report. Here's the summary:

Category Score
🟢 Performance 93
🟢 Accessibility 100
🟢 Best practices 100
🟠 SEO 82

📱 Mobile

We ran Lighthouse against the changes on a mobile and produced this report. Here's the summary:

Category Score
🟢 Performance 91
🟢 Accessibility 100
🟢 Best practices 100
🟠 SEO 85

@jorgemoya jorgemoya added this pull request to the merge queue Jul 9, 2024
Merged via the queue into main with commit 4bf7d16 Jul 9, 2024
@jorgemoya jorgemoya deleted the kv-channel branch July 9, 2024 16:29
@github-actions github-actions Bot mentioned this pull request Jul 9, 2024
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.

2 participants