Unverified Commit 9ab17091 authored by Keen Yee Liau's avatar Keen Yee Liau Committed by GitHub

telemetry: track usage of 'optimizeFonts' (#31522)

`optimizeFonts` is enabled by default, but the Aurora team would like
to find out how many users explicitly turn it off.
parent b80c3789
...@@ -1350,14 +1350,24 @@ export default async function build( ...@@ -1350,14 +1350,24 @@ export default async function build(
) )
} }
const optimizeCss: EventBuildFeatureUsage = { const features: EventBuildFeatureUsage[] = [
{
featureName: 'experimental/optimizeCss', featureName: 'experimental/optimizeCss',
invocationCount: config.experimental.optimizeCss ? 1 : 0, invocationCount: config.experimental.optimizeCss ? 1 : 0,
} },
telemetry.record({ {
featureName: 'optimizeFonts',
invocationCount: config.optimizeFonts ? 1 : 0,
},
]
telemetry.record(
features.map((feature) => {
return {
eventName: EVENT_BUILD_FEATURE_USAGE, eventName: EVENT_BUILD_FEATURE_USAGE,
payload: optimizeCss, payload: feature,
}
}) })
)
await promises.writeFile( await promises.writeFile(
path.join(distDir, SERVER_FILES_MANIFEST), path.join(distDir, SERVER_FILES_MANIFEST),
......
...@@ -131,6 +131,7 @@ export type EventBuildFeatureUsage = { ...@@ -131,6 +131,7 @@ export type EventBuildFeatureUsage = {
| 'next/script' | 'next/script'
| 'next/dynamic' | 'next/dynamic'
| 'experimental/optimizeCss' | 'experimental/optimizeCss'
| 'optimizeFonts'
| 'swcLoader' | 'swcLoader'
| 'swcMinify' | 'swcMinify'
invocationCount: number invocationCount: number
......
...@@ -575,6 +575,9 @@ describe('Telemetry CLI', () => { ...@@ -575,6 +575,9 @@ describe('Telemetry CLI', () => {
}) })
const regex = /NEXT_BUILD_FEATURE_USAGE[\s\S]+?{([\s\S]+?)}/g const regex = /NEXT_BUILD_FEATURE_USAGE[\s\S]+?{([\s\S]+?)}/g
regex.exec(stderr).pop() // optimizeCss regex.exec(stderr).pop() // optimizeCss
const optimizeFonts = regex.exec(stderr).pop()
expect(optimizeFonts).toContain(`"featureName": "optimizeFonts"`)
expect(optimizeFonts).toContain(`"invocationCount": 1`)
const swcLoader = regex.exec(stderr).pop() const swcLoader = regex.exec(stderr).pop()
expect(swcLoader).toContain(`"featureName": "swcLoader"`) expect(swcLoader).toContain(`"featureName": "swcLoader"`)
expect(swcLoader).toContain(`"invocationCount": 1`) expect(swcLoader).toContain(`"invocationCount": 1`)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment