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

Remove deprecated prop customerAccountUrl from createCustomerAccountClient #2730

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-baboons-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/hydrogen': patch
---

Remove deprecated `customerAccountUrl`
3 changes: 0 additions & 3 deletions packages/hydrogen/src/createHydrogenContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ export function createHydrogenContext<
// defaults
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID,
shopId: env.SHOP_ID,

// deprecated - keep until next major release
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_API_URL,
});

/*
Expand Down
54 changes: 1 addition & 53 deletions packages/hydrogen/src/customer/customer-account-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ const customerAccountUrl = `https://shopify.com/${shopId}`;

describe('return correct urls', () => {
describe('when shopId is provided', () => {
const getAccountUrl = createCustomerAccountHelper(
'2025-01',
customerAccountUrl,
shopId,
);
const getAccountUrl = createCustomerAccountHelper('2025-01', shopId);

it('returns customer account base url', () => {
expect(getAccountUrl(URL_TYPE.CA_BASE_URL)).toBe(customerAccountUrl);
Expand Down Expand Up @@ -52,52 +48,4 @@ describe('return correct urls', () => {
);
});
});

describe('when shopId is not provided', () => {
const getAccountUrl = createCustomerAccountHelper(
'2025-01',
customerAccountUrl,
undefined,
);

it('returns customer account base url', () => {
expect(getAccountUrl(URL_TYPE.CA_BASE_URL)).toBe(customerAccountUrl);
});

it('returns customer account auth url', () => {
expect(getAccountUrl(URL_TYPE.CA_BASE_AUTH_URL)).toBe(
`${customerAccountUrl}/auth`,
);
});

it('returns customer account graphql url', () => {
expect(getAccountUrl(URL_TYPE.GRAPHQL)).toBe(
`https://shopify.com/${shopId}/account/customer/api/2025-01/graphql`,
);
});

it('returns customer account authorize url', () => {
expect(getAccountUrl(URL_TYPE.AUTH)).toBe(
`${customerAccountUrl}/auth/oauth/authorize`,
);
});

it('returns customer account login scope', () => {
expect(getAccountUrl(URL_TYPE.LOGIN_SCOPE)).toBe(
'openid email https://api.customers.com/auth/customer.graphql',
);
});

it('returns customer account token exchange url', () => {
expect(getAccountUrl(URL_TYPE.TOKEN_EXCHANGE)).toBe(
`${customerAccountUrl}/auth/oauth/token`,
);
});

it('returns customer account logout url', () => {
expect(getAccountUrl(URL_TYPE.LOGOUT)).toBe(
`${customerAccountUrl}/auth/logout`,
);
});
});
});
13 changes: 3 additions & 10 deletions packages/hydrogen/src/customer/customer-account-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@ export enum URL_TYPE {

export function createCustomerAccountHelper(
customerApiVersion: string,
deprecatedCustomerAccountUrl?: string,
shopId?: string,
shopId: string,
) {
const customerAccountUrl = shopId
? `https://shopify.com/${shopId}`
: deprecatedCustomerAccountUrl;

const customerAccountAuthUrl = shopId
? `https://shopify.com/authentication/${shopId}`
: `${deprecatedCustomerAccountUrl}/auth`;
const customerAccountUrl = `https://shopify.com/${shopId}`;
const customerAccountAuthUrl = `https://shopify.com/authentication/${shopId}`;

return function getCustomerAccountUrl(urlType: URL_TYPE): string {
switch (urlType) {
case URL_TYPE.CA_BASE_URL:
// @ts-expect-error
return customerAccountUrl;
case URL_TYPE.CA_BASE_AUTH_URL:
return customerAccountAuthUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default {
waitUntil: (p) => executionContext.waitUntil(p),
/* Public Customer Account API client ID for your store */
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_ID,
/* Public account URL for your store */
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_URL,
/* Shop Id */
shopId: env.SHOP_ID,
request,
session,
customAuthStatusHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default {
waitUntil: (p) => executionContext.waitUntil(p),
/* Public Customer Account API client ID for your store */
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_ID,
/* Public account URL for your store */
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_URL,
/* Shop Id */
shopId: env.SHOP_ID,
request,
session,
customAuthStatusHandler,
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrogen/src/customer/customer.example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default {
waitUntil: (p) => executionContext.waitUntil(p),
/* Public Customer Account API token for your store */
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_ID,
/* Public account URL for your store */
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_URL,
/* Shop Id */
shopId: env.SHOP_ID,
request,
session,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrogen/src/customer/customer.example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default {
waitUntil: (p) => executionContext.waitUntil(p),
/* Public Customer Account API client ID for your store */
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_ID,
/* Public account URL for your store */
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_URL,
/* Shop Id */
shopId: env.SHOP_ID,
request,
session,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default {
waitUntil: (p) => executionContext.waitUntil(p),
/* Public Customer Account API client ID for your store */
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_ID,
/* Public account URL for your store */
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_URL,
/* Shop Id */
shopId: env.SHOP_ID,
request,
session,
customAuthStatusHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default {
waitUntil: (p) => executionContext.waitUntil(p),
/* Public Customer Account API client ID for your store */
customerAccountId: env.PUBLIC_CUSTOMER_ACCOUNT_ID,
/* Public account URL for your store */
customerAccountUrl: env.PUBLIC_CUSTOMER_ACCOUNT_URL,
/* Shop Id */
shopId: env.SHOP_ID,
request,
session,
customAuthStatusHandler,
Expand Down
Loading
Loading