Skip to content

Commit

Permalink
Add userBenefitsApiUrl to schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertbates committed Jan 15, 2025
1 parent 0099434 commit 36dece9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
8 changes: 3 additions & 5 deletions dotcom-rendering/playwright/tests/user.features.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test.describe('User cookies tests', () => {
const userAttributesApiUrl =
'https://members-data-api.theguardian.com/user-attributes';
const userBenefitsApiUrl =
'https://user-benefits.code.dev-guardianapis.com';
'https://user-benefits.code.dev-guardianapis.com/me';
test(`Request to user features API is sent when no user features expiry cookie`, async ({
context,
page,
Expand All @@ -22,7 +22,7 @@ test.describe('User cookies tests', () => {
await disableCMP(context);

const userBenefitsApiPromise = page.waitForRequest(
`${userBenefitsApiUrl}/me`,
`${userBenefitsApiUrl}`,
);

await loadPageNoOkta(page, standardArticle, {
Expand Down Expand Up @@ -68,9 +68,7 @@ test.describe('User cookies tests', () => {

await disableCMP(context);

const userBenefitsApiPromise = page.waitForRequest(
`${userBenefitsApiUrl}/me`,
);
const userBenefitsApiPromise = page.waitForRequest(userBenefitsApiUrl);

await loadPageNoOkta(page, standardArticle, {
// user-features expects this config to be present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,7 @@
"isPhotoEssay": false,
"ampIframeUrl": "https://assets.guim.co.uk/data/vendor/2533d5cb94302889e6a8f1b24b5329e7/amp-iframe.html",
"userAttributesApiUrl": "https://members-data-api.theguardian.com/user-attributes",
"userBenefitsApiUrl": "https://user-benefits.guardianapis.com/benefits/me",
"isLive": false,
"publication": "theguardian.com",
"brazeApiKey": "7f28c639-8bda-48ff-a3f6-24345abfc07c",
Expand Down
6 changes: 2 additions & 4 deletions dotcom-rendering/src/client/userFeatures/userBenefitsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ export const syncDataFromUserBenefitsApi = async (
signedInAuthStatus: SignedInWithOkta | SignedInWithCookies,
): Promise<UserBenefits> => {
const response = await fetchJson(
`${
window.guardian.config.page.userBenefitsApiUrl ??
'https://user-benefits.code.dev-guardianapis.com/benefits/me'
}/me`,
window.guardian.config.page.userBenefitsApiUrl ??
'https://user-benefits.code.dev-guardianapis.com/benefits/me',
{
mode: 'cors',
...getOptionsHeadersWithOkta(signedInAuthStatus),
Expand Down
6 changes: 5 additions & 1 deletion dotcom-rendering/src/model/front-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"userAttributesApiUrl": {
"type": "string"
},
"userBenefitsApiUrl": {
"type": "string"
},
"host": {
"type": "string"
},
Expand Down Expand Up @@ -343,6 +346,7 @@
"supportUrl",
"switches",
"userAttributesApiUrl",
"userBenefitsApiUrl",
"webTitle"
]
},
Expand Down Expand Up @@ -3873,4 +3877,4 @@
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
6 changes: 5 additions & 1 deletion dotcom-rendering/src/model/tag-page-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@
"userAttributesApiUrl": {
"type": "string"
},
"userBenefitsApiUrl": {
"type": "string"
},
"host": {
"type": "string"
},
Expand Down Expand Up @@ -1236,6 +1239,7 @@
"supportUrl",
"switches",
"userAttributesApiUrl",
"userBenefitsApiUrl",
"webTitle"
]
},
Expand Down Expand Up @@ -1937,4 +1941,4 @@
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
1 change: 1 addition & 0 deletions dotcom-rendering/src/types/front.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export type FEFrontConfigType = {
ampIframeUrl: string;
beaconUrl: string;
userAttributesApiUrl: string;
userBenefitsApiUrl: string;
host: string;
brazeApiKey?: string;
calloutsUrl: string;
Expand Down

0 comments on commit 36dece9

Please sign in to comment.