Skip to content

Commit

Permalink
Deprecate customerAccountUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
wizardlyhel committed Jan 24, 2025
1 parent e90bc58 commit 89de145
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 561 deletions.
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
49 changes: 0 additions & 49 deletions packages/hydrogen/src/customer/customer-account-helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe('return correct urls', () => {
describe('when shopId is provided', () => {
const getAccountUrl = createCustomerAccountHelper(
'2025-01',
customerAccountUrl,
shopId,
);

Expand Down Expand Up @@ -52,52 +51,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

0 comments on commit 89de145

Please sign in to comment.