Skip to content

Commit

Permalink
Add telemetry for image config formats (avif/webp) (#36289)
Browse files Browse the repository at this point in the history
This PR adds telemetry for image config formats since AVIF is opt-in (#30180).

See docs https://nextjs.org/docs/api-reference/next/image#acceptable-formats
  • Loading branch information
styfle authored Apr 19, 2022
1 parent 91fd597 commit 835aeae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/next/telemetry/events/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type EventCliSessionStarted = {
imageDomainsCount: number | null
imageSizes: string | null
imageLoader: string | null
imageFormats: string | null
trailingSlashEnabled: boolean
reactStrictMode: boolean
webpackVersion: number | null
Expand Down Expand Up @@ -66,6 +67,7 @@ export function eventCliSession(
| 'imageDomainsCount'
| 'imageSizes'
| 'imageLoader'
| 'imageFormats'
| 'trailingSlashEnabled'
| 'reactStrictMode'
>
Expand Down Expand Up @@ -97,6 +99,7 @@ export function eventCliSession(
imageDomainsCount: images?.domains ? images.domains.length : null,
imageSizes: images?.imageSizes ? images.imageSizes.join(',') : null,
imageLoader: images?.loader,
imageFormats: images?.formats ? images.formats.join(',') : null,
trailingSlashEnabled: !!nextConfig?.trailingSlash,
reactStrictMode: !!nextConfig?.reactStrictMode,
webpackVersion: event.webpackVersion || null,
Expand Down
1 change: 1 addition & 0 deletions test/integration/telemetry/next.config.i18n-images
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = phase => {
return {
images: {
formats: ['image/avif', 'image/webp'],
imageSizes: [64, 128, 256, 512, 1024],
domains: ['example.com'],
},
Expand Down
1 change: 1 addition & 0 deletions test/integration/telemetry/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ describe('Telemetry CLI', () => {
expect(event1).toMatch(/"localeDetectionEnabled": true/)
expect(event1).toMatch(/"imageDomainsCount": 1/)
expect(event1).toMatch(/"imageSizes": "64,128,256,512,1024"/)
expect(event1).toMatch(/"imageFormats": "image\/avif,image\/webp"/)
expect(event1).toMatch(/"trailingSlashEnabled": false/)
expect(event1).toMatch(/"reactStrictMode": false/)

Expand Down

0 comments on commit 835aeae

Please sign in to comment.