Skip to content

Commit 958c660

Browse files
committed
feat(metrics): Set up Glean frontend metrics for Churn intervention
1 parent 67ee6f2 commit 958c660

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1396
-20
lines changed

.circleci/config.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,34 @@ commands:
299299
name: Wait for Customs
300300
command: yarn workspace fxa-customs-server start
301301

302+
ensure-glean-venv:
303+
steps:
304+
- run:
305+
name: Ensure Python venv has pip and glean_parser
306+
command: |
307+
set -euxo pipefail
308+
309+
unset PYTHONDONTWRITEBYTECODE
310+
export PIP_NO_COMPILE=1
311+
312+
python3 --version
313+
rm -rf .venv
314+
python3 -m venv .venv --without-pip
315+
. .venv/bin/activate
316+
317+
curl -sSL https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py
318+
python /tmp/get-pip.py --no-compile
319+
320+
python -m pip install --no-compile --upgrade 'glean_parser~=14.5'
321+
python -m pip --version
322+
302323
lint:
303324
parameters:
304325
nx_run:
305326
type: string
306327
default: run-many
307328
steps:
329+
- ensure-glean-venv
308330
- run:
309331
name: Linting
310332
command: npx nx << parameters.nx_run >> --parallel=1 -t lint
@@ -315,6 +337,7 @@ commands:
315337
type: string
316338
default: run-many
317339
steps:
340+
- ensure-glean-venv
318341
- run:
319342
name: Pre building shared libraries
320343
command: NODE_OPTIONS="--max-old-space-size=7168" npx nx run-many -t build --projects=tag:scope:shared:lib --parallel=2 --verbose
@@ -428,6 +451,7 @@ commands:
428451
type: string
429452
default: run-many
430453
steps:
454+
- ensure-glean-venv
431455
- run:
432456
name: Build
433457
command: NODE_OPTIONS="--max-old-space-size=7168" npx nx << parameters.nx_run >> -t build --parallel=2 --all --verbose
@@ -712,6 +736,7 @@ jobs:
712736
- git-checkout
713737
- restore-workspace
714738
- gcp-cli/setup
739+
- ensure-glean-venv
715740
- run:
716741
name: Build shared libs
717742
command: NODE_OPTIONS="--max-old-space-size=7168" npx nx run-many -t build --projects=tag:scope:shared:lib --parallel=2

_dev/docker/ci/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# workspace will be restored into the project folder.
77
FROM cimg/node:22.15.1 AS test-runner
88
RUN sudo apt-get update && sudo apt-get install -y \
9-
python3-venv
9+
python3-venv \
10+
python3-pip
1011
WORKDIR /home/circleci
1112
COPY --chown=circleci:circleci project project
1213
WORKDIR /home/circleci/project
@@ -39,7 +40,8 @@ RUN npx playwright install --with-deps firefox chromium webkit;
3940
# workspace will be restored into the project folder.
4041
FROM cimg/node:22.15.1-browsers AS functional-test-runner
4142
RUN sudo apt-get update && sudo apt-get install -y \
42-
python3-venv
43+
python3-venv \
44+
python3-pip
4345
WORKDIR /home/circleci
4446
COPY --chown=circleci:circleci --from=playwright-install /home/circleci/.cache/ms-playwright .cache/ms-playwright/
4547
COPY --chown=circleci:circleci project project

apps/payments/api/.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ GLEAN_CONFIG__APPLICATION_ID=
5757
GLEAN_CONFIG__VERSION=0.0.0
5858
GLEAN_CONFIG__CHANNEL='development'
5959
GLEAN_CONFIG__LOGGER_APP_NAME='fxa-payments-next'
60+
61+
# Glean Client Config
62+
GLEAN_CLIENT_CONFIG__ENABLED=true
63+
GLEAN_CLIENT_CONFIG__APPLICATION_ID=
64+
GLEAN_CLIENT_CONFIG__VERSION=0.0.0
65+
GLEAN_CLIENT_CONFIG__CHANNEL='development'

apps/payments/next/.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ GLEAN_CONFIG__APPLICATION_ID=
110110
GLEAN_CONFIG__CHANNEL='development'
111111
GLEAN_CONFIG__LOGGER_APP_NAME='fxa-payments-next'
112112

113+
# Glean Client Config
114+
GLEAN_CLIENT_CONFIG__ENABLED=true
115+
GLEAN_CLIENT_CONFIG__APPLICATION_ID=
116+
# GLEAN_CLIENT_CONFIG__VERSION= # Set in next.config.js
117+
GLEAN_CLIENT_CONFIG__CHANNEL='development'
118+
113119
# CSP Config
114120
CSP__ACCOUNTS_STATIC_CDN=https://cdn.accounts.firefox.com
115121
CSP__PAYPAL_API='https://www.sandbox.paypal.com'

apps/payments/next/app/[locale]/layout.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ export default async function RootProviderLayout({
2626
config={{
2727
stripePublicApiKey: config.stripePublicApiKey,
2828
paypalClientId: config.paypal.clientId,
29+
glean:
30+
config.gleanClientConfig?.enabled !== undefined &&
31+
config.gleanClientConfig?.applicationId &&
32+
config.gleanClientConfig?.version &&
33+
config.gleanClientConfig?.channel
34+
? {
35+
enabled: config.gleanClientConfig.enabled,
36+
applicationId: config.gleanClientConfig.applicationId,
37+
version: config.gleanClientConfig.version,
38+
channel: config.gleanClientConfig.channel,
39+
}
40+
: undefined,
2941
sentry: {
3042
...config.sentry, //spread to make sure its a POJO
3143
},

apps/payments/next/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ export const config = validate(
159159
{
160160
...process.env,
161161
GLEAN_CONFIG__VERSION: process.env['GLEAN_CONFIG__VERSION'],
162+
GLEAN_CLIENT_CONFIG__VERSION:
163+
process.env['GLEAN_CLIENT_CONFIG__VERSION'],
162164
},
163165
PaymentsNextConfig
164166
);

apps/payments/next/next.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const nextConfig = {
2121
env: {
2222
version,
2323
GLEAN_CONFIG__VERSION: version,
24+
GLEAN_CLIENT_CONFIG__VERSION: version,
2425
},
2526
distDir: 'build',
2627
experimental: {
@@ -96,11 +97,11 @@ const nextConfig = {
9697
headers: [
9798
{
9899
key: 'Strict-Transport-Security',
99-
value: 'max-age=63072000; includeSubDomains; preload'
100-
}
100+
value: 'max-age=63072000; includeSubDomains; preload',
101+
},
101102
],
102103
},
103-
]
104+
];
104105
},
105106
};
106107

apps/payments/next/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"projectType": "application",
66
"targets": {
77
"build": {
8-
"dependsOn": ["l10n-bundle", "glean-generate"]
8+
"dependsOn": ["l10n-bundle", "glean-generate", "payments-metrics:glean-generate-frontend"]
99
},
1010
"dev": {
1111
"options": {
@@ -39,7 +39,7 @@
3939
},
4040
"start": {
4141
"command": "pm2 start apps/payments/next/pm2.config.js && yarn check:url localhost:3035/__heartbeat__",
42-
"dependsOn": ["l10n-bundle", "glean-generate"]
42+
"dependsOn": ["l10n-bundle", "glean-generate", "payments-metrics:glean-generate-frontend"]
4343
},
4444
"stop": {
4545
"command": "pm2 stop apps/payments/next/pm2.config.js"

libs/payments/cart/src/lib/cart.service.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ import {
131131
CommonMetricsFactory,
132132
MockPaymentsGleanConfigProvider,
133133
MockPaymentsGleanFactory,
134+
MockPaymentsGleanClientFactory,
134135
PaymentsGleanManager,
135136
PaymentsGleanService,
136137
} from '@fxa/payments/metrics';
@@ -216,6 +217,7 @@ describe('CartService', () => {
216217
MockLocationConfigProvider,
217218
MockNotifierSnsConfigProvider,
218219
MockPaymentsGleanFactory,
220+
MockPaymentsGleanClientFactory,
219221
MockPaymentsGleanConfigProvider,
220222
MockPaypalClientConfigProvider,
221223
MockProfileClientConfigProvider,

libs/payments/cart/src/lib/checkout.service.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ import {
126126
CommonMetricsFactory,
127127
MockPaymentsGleanConfigProvider,
128128
MockPaymentsGleanFactory,
129+
MockPaymentsGleanClientFactory,
129130
PaymentsGleanManager,
130131
PaymentsGleanService,
131132
} from '@fxa/payments/metrics';
@@ -196,6 +197,7 @@ describe('CheckoutService', () => {
196197
MockCurrencyConfigProvider,
197198
MockFirestoreProvider,
198199
MockPaymentsGleanFactory,
200+
MockPaymentsGleanClientFactory,
199201
MockLocationConfigProvider,
200202
MockNimbusManagerConfigProvider,
201203
MockNimbusClientConfigProvider,

0 commit comments

Comments
 (0)