Skip to content

Commit 823b89c

Browse files
Merge branch 'main' into 642-cache-for-newsletter-subscriptions-data
2 parents 1ea583d + 0f64327 commit 823b89c

File tree

13 files changed

+559
-309
lines changed

13 files changed

+559
-309
lines changed

ab-testing/cdk/lib/__snapshots__/abTestingConfig.test.ts.snap

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ exports[`The ID5 Baton Lambda stack > matches the CODE snapshot 1`] = `
44
"gu:cdk:constructs": [],
55
"gu:cdk:version": "62.0.1"
66
},
7+
"Parameters": {
8+
"BuildId": {
9+
"Type": "String",
10+
"Description": "The riff-raff build id, automatically generated and provided by riff-raff"
11+
}
12+
},
713
"Resources": {
814
"InvokeDictionaryDeployLambda": {
915
"Type": "Custom::FastlyEdgeDictionaryDeploy",
@@ -24,7 +30,10 @@ exports[`The ID5 Baton Lambda stack > matches the CODE snapshot 1`] = `
2430
]
2531
]
2632
},
27-
"ServiceTimeout": "300"
33+
"ServiceTimeout": "300",
34+
"BuildId": {
35+
"Ref": "BuildId"
36+
}
2837
},
2938
"UpdateReplacePolicy": "Delete",
3039
"DeletionPolicy": "Delete"
@@ -39,6 +48,12 @@ exports[`The ID5 Baton Lambda stack > matches the PROD snapshot 1`] = `
3948
"gu:cdk:constructs": [],
4049
"gu:cdk:version": "62.0.1"
4150
},
51+
"Parameters": {
52+
"BuildId": {
53+
"Type": "String",
54+
"Description": "The riff-raff build id, automatically generated and provided by riff-raff"
55+
}
56+
},
4257
"Resources": {
4358
"InvokeDictionaryDeployLambda": {
4459
"Type": "Custom::FastlyEdgeDictionaryDeploy",
@@ -59,7 +74,10 @@ exports[`The ID5 Baton Lambda stack > matches the PROD snapshot 1`] = `
5974
]
6075
]
6176
},
62-
"ServiceTimeout": "300"
77+
"ServiceTimeout": "300",
78+
"BuildId": {
79+
"Ref": "BuildId"
80+
}
6381
},
6482
"UpdateReplacePolicy": "Delete",
6583
"DeletionPolicy": "Delete"

ab-testing/cdk/lib/abTestingConfig.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { GuStackProps } from "@guardian/cdk/lib/constructs/core/stack.js";
22
import { GuStack } from "@guardian/cdk/lib/constructs/core/stack.js";
33
import type { App } from "aws-cdk-lib";
4-
import { CustomResource, Duration } from "aws-cdk-lib";
4+
import { CfnParameter, CustomResource, Duration } from "aws-cdk-lib";
55
import { Function } from "aws-cdk-lib/aws-lambda";
66
import { lambdaFunctionName } from "./deploymentLambda.ts";
77

@@ -15,11 +15,21 @@ export class AbTestingConfig extends GuStack {
1515
`${lambdaFunctionName}-${this.stage}`,
1616
);
1717

18+
const buildId = new CfnParameter(this, "BuildId", {
19+
type: "String",
20+
description:
21+
"The riff-raff build id, automatically generated and provided by riff-raff",
22+
});
23+
1824
// Trigger the Lambda to run upon deployment
1925
new CustomResource(this, "InvokeDictionaryDeployLambda", {
2026
serviceToken: lambda.functionArn,
2127
serviceTimeout: Duration.minutes(5),
2228
resourceType: "Custom::FastlyEdgeDictionaryDeploy",
29+
properties: {
30+
/** Ensures the custom resource is invoked on every deploy */
31+
BuildId: buildId.valueAsString,
32+
},
2333
});
2434
}
2535
}

dotcom-rendering/cdk/bin/cdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ new RenderingCDKStack(cdkApp, 'FaciaRendering-PROD', {
6868
stage: 'PROD',
6969
domainName: 'facia-rendering.guardianapis.com',
7070
scaling: {
71-
minimumInstances: 48,
72-
maximumInstances: 240,
71+
minimumInstances: 21,
72+
maximumInstances: 210,
7373
policies: {
7474
step: {
7575
cpu: cpuScalingSteps,
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
import type { ProductBlockElement } from '../../src/types/content';
2+
import { productImage } from './productImage';
3+
4+
export const exampleProduct: ProductBlockElement = {
5+
_type: 'model.dotcomrendering.pageElements.ProductBlockElement',
6+
elementId: 'b1f6e8e2-3f3a-4f0c-8d1e-5f3e3e3e3e3e',
7+
primaryHeadingHtml: 'Best overall',
8+
secondaryHeadingHtml: 'Bosch Sky Kettle',
9+
brandName: 'Bosch',
10+
productName: 'Sky Kettle',
11+
image: productImage,
12+
displayType: 'InlineWithProductCard',
13+
lowestPrice: '£39.99',
14+
customAttributes: [
15+
{ name: 'What we love', value: 'It pours well and looks great' },
16+
{
17+
name: "What we don't love",
18+
value: 'The handle feels a bit cheap compared to the rest of it',
19+
},
20+
],
21+
productCtas: [
22+
{
23+
url: 'https://www.johnlewis.com/bosch-twk7203gb-sky-variable-temperature-kettle-1-7l-black/p3228625',
24+
text: '',
25+
retailer: 'John Lewis',
26+
price: '£45.99',
27+
},
28+
{
29+
url: 'https://www.amazon.co.uk/Bosch-TWK7203GB-Sky-Variable-Temperature/dp/B07Z8VQ2V6',
30+
text: '',
31+
retailer: 'Amazon',
32+
price: '£39.99',
33+
},
34+
],
35+
starRating: 'none-selected',
36+
content: [
37+
{
38+
displayCredit: true,
39+
_type: 'model.dotcomrendering.pageElements.ImageBlockElement',
40+
role: 'inline',
41+
media: {
42+
allImages: [
43+
{
44+
index: 0,
45+
fields: {
46+
height: '3213',
47+
width: '3213',
48+
},
49+
mediaType: 'Image',
50+
mimeType: 'image/jpeg',
51+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/3213.jpg',
52+
},
53+
{
54+
index: 1,
55+
fields: {
56+
isMaster: 'true',
57+
height: '3213',
58+
width: '3213',
59+
},
60+
mediaType: 'Image',
61+
mimeType: 'image/jpeg',
62+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
63+
},
64+
{
65+
index: 2,
66+
fields: {
67+
height: '2000',
68+
width: '2000',
69+
},
70+
mediaType: 'Image',
71+
mimeType: 'image/jpeg',
72+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/2000.jpg',
73+
},
74+
{
75+
index: 3,
76+
fields: {
77+
height: '1000',
78+
width: '1000',
79+
},
80+
mediaType: 'Image',
81+
mimeType: 'image/jpeg',
82+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/1000.jpg',
83+
},
84+
{
85+
index: 4,
86+
fields: {
87+
height: '500',
88+
width: '500',
89+
},
90+
mediaType: 'Image',
91+
mimeType: 'image/jpeg',
92+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/500.jpg',
93+
},
94+
{
95+
index: 5,
96+
fields: {
97+
height: '140',
98+
width: '140',
99+
},
100+
mediaType: 'Image',
101+
mimeType: 'image/jpeg',
102+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/140.jpg',
103+
},
104+
],
105+
},
106+
elementId: '76686aa1-2e47-4616-b4ed-a88d0afe07ed',
107+
imageSources: [
108+
{
109+
weighting: 'inline',
110+
srcSet: [
111+
{
112+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
113+
width: 620,
114+
},
115+
{
116+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
117+
width: 1240,
118+
},
119+
{
120+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
121+
width: 605,
122+
},
123+
{
124+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
125+
width: 1210,
126+
},
127+
{
128+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
129+
width: 445,
130+
},
131+
{
132+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
133+
width: 890,
134+
},
135+
],
136+
},
137+
{
138+
weighting: 'thumbnail',
139+
srcSet: [
140+
{
141+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
142+
width: 140,
143+
},
144+
{
145+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
146+
width: 280,
147+
},
148+
{
149+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
150+
width: 120,
151+
},
152+
{
153+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
154+
width: 240,
155+
},
156+
],
157+
},
158+
{
159+
weighting: 'supporting',
160+
srcSet: [
161+
{
162+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
163+
width: 380,
164+
},
165+
{
166+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
167+
width: 760,
168+
},
169+
{
170+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
171+
width: 300,
172+
},
173+
{
174+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
175+
width: 600,
176+
},
177+
{
178+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
179+
width: 620,
180+
},
181+
{
182+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
183+
width: 1240,
184+
},
185+
{
186+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
187+
width: 605,
188+
},
189+
{
190+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
191+
width: 1210,
192+
},
193+
{
194+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
195+
width: 445,
196+
},
197+
{
198+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
199+
width: 890,
200+
},
201+
],
202+
},
203+
],
204+
data: {
205+
alt: 'Testing Bosch Sky Kettle',
206+
credit: 'Photograph: Rachel Ogden/The Guardian',
207+
},
208+
},
209+
{
210+
_type: 'model.dotcomrendering.pageElements.LinkBlockElement',
211+
url: 'https://www.johnlewis.com/bosch-twk7203gb-sky-variable-temperature-kettle-1-7l-black/p3228625',
212+
label: '£79.99 at John Lewis',
213+
linkType: 'ProductButton',
214+
},
215+
{
216+
_type: 'model.dotcomrendering.pageElements.LinkBlockElement',
217+
url: 'https://www.amazon.co.uk/Bosch-TWK7203GB-Sky-Variable-Temperature/dp/B07Z8VQ2V6',
218+
label: '£79.99 at Amazon',
219+
linkType: 'ProductButton',
220+
},
221+
{
222+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
223+
html: '<p>Offering variable temperatures and a double-walled stainless-steel housing, the 3kW Sky is a brilliant blend of robust form and function. It boasts a low minimum boil (300ml), a keep-warm setting and touch controls.</p>',
224+
elementId: '4a27eb68-6a03-4e82-a7d0-e4f1ef3ccb6f',
225+
},
226+
{
227+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
228+
html: '<p><strong>Why we love it<br></strong>I found it difficult to select a best kettle from so many that performed well, but the Bosch Sky clinched it because it’s such a good all-rounder that will suit most people. It pours well, has a button that’s within easy reach of the handle so it’s simple to open the lid without touching it, and it’s insulated so the exterior doesn’t become too hot to touch. From a design perspective, it has a more industrial feel than many others – no frippery here – but not too modern that it wouldn’t fit into most kitchens. Its display is thoughtfully designed, easy to keep clean and lights up as it heats.</p>',
229+
elementId: 'f48f03d4-bece-4763-874b-4027a311643e',
230+
},
231+
{
232+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
233+
html: '<p>The exterior doesn’t get too hot (up to 40C), and while it wasn’t the fastest to boil in testing, it was only seconds behind the Dualit below. It clicked off at boiling point, and the water was still a toasty 78C 30 minutes later. At the hour point, it was 66C, and two hours 52C, meaning you’ll spend less time and energy reboiling.</p>',
234+
elementId: 'df571922-33b1-416a-8b3d-ee756b638cc1',
235+
},
236+
{
237+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
238+
html: '<p><strong>It’s a shame that … </strong> its premium look ends at the handle, which seems cheap and plasticky next to the sleek aesthetic of the rest of it.</p>',
239+
elementId: 'd98fc724-8908-46e2-acc6-4739ad4d5719',
240+
},
241+
],
242+
};

dotcom-rendering/src/client/sentryLoader/sentryLoader.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Enable Sentry when it passes loading conditions', () => {
3434
}),
3535
).toEqual(true);
3636
});
37-
it('does enable Sentry for 0.1% of users', () => {
37+
it('does enable Sentry for 1% of users', () => {
3838
expect(
3939
isSentryEnabled({
4040
isDev: false,
@@ -56,7 +56,7 @@ describe('Enable Sentry when it passes loading conditions', () => {
5656
isDev: false,
5757
enableSentryReporting: true,
5858
isInBrowserVariantTest: false,
59-
random: 99.9001 / 100,
59+
random: 99.0001 / 100,
6060
}),
6161
).toEqual(true);
6262
expect(

dotcom-rendering/src/client/sentryLoader/sentryLoader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ const isSentryEnabled = ({
2424
if (isInBrowserVariantTest) return true;
2525
// Sentry lets you configure sampleRate to reduce the volume of events sent
2626
// but this filter only happens _after_ the library is loaded. The Guardian
27-
// measures page views in the billions so we only want to log 0.1% of errors that
27+
// measures page views in the billions so we only want to log 1% of errors that
2828
// happen but if we used sampleRate to do this we'd be needlessly downloading
29-
// Sentry 99.9% of the time. So instead we just do some math here and use that
29+
// Sentry 99% of the time. So instead we just do some math here and use that
3030
// to prevent the Sentry script from ever loading.
31-
if (random <= 999 / 1000) return false;
31+
if (random <= 99 / 100) return false;
3232
return true;
3333
};
3434

0 commit comments

Comments
 (0)