From c492519c16e308be859d0680a7ffd044e2ceed11 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Tue, 26 Jul 2022 14:23:34 -0700 Subject: [PATCH] Collect telemetry for next/future/image Track adoption of next/future/image and add relevant test. --- .../next/build/webpack/plugins/telemetry-plugin.ts | 2 ++ packages/next/telemetry/events/build.ts | 1 + test/integration/telemetry/pages/about.js | 5 +++++ test/integration/telemetry/test/index.test.js | 12 ++++++++++++ 4 files changed, 20 insertions(+) diff --git a/packages/next/build/webpack/plugins/telemetry-plugin.ts b/packages/next/build/webpack/plugins/telemetry-plugin.ts index 8bc73c20240e..16526b6f7419 100644 --- a/packages/next/build/webpack/plugins/telemetry-plugin.ts +++ b/packages/next/build/webpack/plugins/telemetry-plugin.ts @@ -23,6 +23,7 @@ export type SWC_TARGET_TRIPLE = export type Feature = | 'next/image' + | 'next/future/image' | 'next/script' | 'next/dynamic' | 'swcLoader' @@ -59,6 +60,7 @@ interface Connection { // Map of a feature module to the file it belongs in the next package. const FEATURE_MODULE_MAP: ReadonlyMap = new Map([ ['next/image', '/next/image.js'], + ['next/future/image', '/next/future/image.js'], ['next/script', '/next/script.js'], ['next/dynamic', '/next/dynamic.js'], ]) diff --git a/packages/next/telemetry/events/build.ts b/packages/next/telemetry/events/build.ts index e37bea378c70..0d4ea009dee5 100644 --- a/packages/next/telemetry/events/build.ts +++ b/packages/next/telemetry/events/build.ts @@ -132,6 +132,7 @@ export type EventBuildFeatureUsage = { // *before* you make changes here. featureName: | 'next/image' + | 'next/future/image' | 'next/script' | 'next/dynamic' | 'experimental/optimizeCss' diff --git a/test/integration/telemetry/pages/about.js b/test/integration/telemetry/pages/about.js index 95d1f9ba9b6e..f35888107b95 100644 --- a/test/integration/telemetry/pages/about.js +++ b/test/integration/telemetry/pages/about.js @@ -1,4 +1,5 @@ import Image from 'next/image' +import { Image as FutureImage } from 'next/future/image' import profilePic from '../public/small.jpg' function About() { @@ -12,3 +13,7 @@ function About() { } export default About + +export function AboutFutureImage() { + return +} diff --git a/test/integration/telemetry/test/index.test.js b/test/integration/telemetry/test/index.test.js index 90a886577c57..1750ad835551 100644 --- a/test/integration/telemetry/test/index.test.js +++ b/test/integration/telemetry/test/index.test.js @@ -837,6 +837,18 @@ describe('Telemetry CLI', () => { }, ]) }) + + it('emits telemetry for usage of next/future/image', async () => { + const { stderr } = await nextBuild(appDir, [], { + stderr: true, + env: { NEXT_TELEMETRY_DEBUG: 1 }, + }) + const featureUsageEvents = findAllEvents(stderr, 'NEXT_BUILD_FEATURE_USAGE') + expect(featureUsageEvents).toContainEqual({ + featureName: 'next/future/image', + invocationCount: 1, + }) + }) }) /**