Skip to content

Commit 8aea17f

Browse files
authored
Merge pull request #20405 from mozilla/FXA-13476.v2
feat(strapi): Add mobile promo w/new 'default' content type, add SetPassword RP customizations
2 parents fecc92e + fd251fe commit 8aea17f

28 files changed

Lines changed: 766 additions & 95 deletions

File tree

libs/shared/cms/src/__generated__/gql.ts

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/shared/cms/src/__generated__/graphql.ts

Lines changed: 57 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/shared/cms/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './lib/constants';
88
export * from './lib/legal-terms-configuration.manager';
99
export * from './lib/product-configuration.manager';
1010
export * from './lib/relying-party-configuration.manager';
11+
export * from './lib/default-configuration.manager';
1112
export * from './lib/queries/cancel-interstitial-offer';
1213
export * from './lib/queries/capability-service-by-plan-ids';
1314
export * from './lib/queries/churn-intervention-by-product-id';
@@ -22,6 +23,7 @@ export * from './lib/queries/page-content-by-price-ids';
2223
export * from './lib/queries/purchase-with-details-offering-content';
2324
export * from './lib/queries/services-with-capabilities';
2425
export * from './lib/queries/relying-party';
26+
export * from './lib/queries/default';
2527
export * from './lib/queries/validation';
2628
export * from './lib/strapi.client';
2729
export * from './lib/strapi.client.config';
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import { getOperationName } from '@apollo/client/utilities';
6+
import { Inject, Injectable } from '@nestjs/common';
7+
import { StatsD } from 'hot-shots';
8+
9+
import { StatsDService } from '@fxa/shared/metrics/statsd';
10+
import { defaultCmsQuery } from '@fxa/shared/cms';
11+
import { StrapiClient, StrapiClientEventResponse } from './strapi.client';
12+
import { LOGGER_PROVIDER } from '@fxa/shared/log';
13+
import type { Logger } from '@fxa/shared/log';
14+
15+
@Injectable()
16+
export class DefaultCmsConfigurationManager {
17+
constructor(
18+
private strapiClient: StrapiClient,
19+
@Inject(StatsDService)
20+
private statsd: StatsD,
21+
@Inject(LOGGER_PROVIDER) private readonly log: Logger
22+
) {
23+
if (this.strapiClient.on) {
24+
this.strapiClient.on('response', this.onStrapiClientResponse.bind(this));
25+
}
26+
}
27+
28+
onStrapiClientResponse(response: StrapiClientEventResponse) {
29+
const defaultTags = {
30+
method: response.method,
31+
error: response.error ? 'true' : 'false',
32+
cache: `${response.cache}`,
33+
cacheType: `${response.cacheType}`,
34+
};
35+
const operationName = response.query && getOperationName(response.query);
36+
const tags = operationName
37+
? { ...defaultTags, operationName }
38+
: defaultTags;
39+
if (response.error) {
40+
this.log.error('cms.default.requestFailed', {
41+
operationName,
42+
error: response.error,
43+
});
44+
}
45+
this.statsd.timing(
46+
'cms_default_request',
47+
response.elapsed,
48+
undefined,
49+
tags
50+
);
51+
}
52+
53+
async fetchDefault() {
54+
return await this.strapiClient.query(defaultCmsQuery, {});
55+
}
56+
57+
async invalidateCache() {
58+
return await this.strapiClient.invalidateQueryCache(defaultCmsQuery, {});
59+
}
60+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
export * from './query';
6+
export * from './types';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import { graphql } from '../../../__generated__/gql';
6+
7+
export const defaultCmsQuery = graphql(`
8+
query Default {
9+
default {
10+
promoQrImageUrl
11+
}
12+
}
13+
`);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
export interface DefaultCmsResult {
6+
promoQrImageUrl: string | null;
7+
}

libs/shared/cms/src/lib/queries/relying-party/factories.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,11 @@ export const RelyingPartyResultFactory = (
242242
},
243243
splitLayout: faker.datatype.boolean(),
244244
},
245+
PostVerifySetPasswordPage: {
246+
headline: faker.string.sample(),
247+
description: faker.string.sample(),
248+
primaryButtonText: faker.string.sample(),
249+
pageTitle: faker.string.sample(),
250+
},
245251
...override,
246252
});

libs/shared/cms/src/lib/queries/relying-party/query.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ export const relyingPartyQuery = graphql(`
173173
}
174174
splitLayout
175175
}
176+
PostVerifySetPasswordPage {
177+
headline
178+
description
179+
primaryButtonText
180+
pageTitle
181+
}
176182
NewDeviceLoginEmail {
177183
subject
178184
headline

libs/shared/cms/src/lib/queries/relying-party/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export interface RelyingPartyResult {
7979
SigninRecoveryChoicePage?: Page;
8080
SigninRecoveryCodePage?: Page;
8181
SigninRecoveryPhonePage?: Page;
82+
PostVerifySetPasswordPage?: Page;
8283
shared: Shared;
8384
NewDeviceLoginEmail?: Email;
8485
VerifyLoginCodeEmail?: Email;

0 commit comments

Comments
 (0)