Skip to content

Commit e847b49

Browse files
authored
Add telemetry for stable features (vercel#44201)
Follow up to vercel#44195 vercel#44194. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [x] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 966d2b1 commit e847b49

File tree

6 files changed

+90
-0
lines changed

6 files changed

+90
-0
lines changed

packages/next/build/webpack-config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,16 @@ export default async function getBaseWebpackConfig(
21472147
['swcImportSource', !!jsConfig?.compilerOptions?.jsxImportSource],
21482148
['swcEmotion', !!config.compiler?.emotion],
21492149
['turbotrace', !!config.experimental.turbotrace],
2150+
['transpilePackages', !!config.transpilePackages],
2151+
[
2152+
'allowMiddlewareResponseBody',
2153+
!!config.allowMiddlewareResponseBody,
2154+
],
2155+
[
2156+
'skipMiddlewareUrlNormalize',
2157+
!!config.skipMiddlewareUrlNormalize,
2158+
],
2159+
['skipTrailingSlashRedirect', !!config.skipTrailingSlashRedirect],
21502160
SWCBinaryTarget,
21512161
].filter<[Feature, boolean]>(Boolean as any)
21522162
)

packages/next/build/webpack/plugins/telemetry-plugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export type Feature =
3737
| 'swcEmotion'
3838
| `swc/target/${SWC_TARGET_TRIPLE}`
3939
| 'turbotrace'
40+
| 'transpilePackages'
41+
| 'allowMiddlewareResponseBody'
42+
| 'skipMiddlewareUrlNormalize'
43+
| 'skipTrailingSlashRedirect'
4044

4145
interface FeatureUsage {
4246
featureName: Feature
@@ -96,6 +100,10 @@ const BUILD_FEATURES: Array<Feature> = [
96100
'swc/target/aarch64-unknown-linux-musl',
97101
'swc/target/aarch64-pc-windows-msvc',
98102
'turbotrace',
103+
'transpilePackages',
104+
'allowMiddlewareResponseBody',
105+
'skipMiddlewareUrlNormalize',
106+
'skipTrailingSlashRedirect',
99107
]
100108

101109
const ELIMINATED_PACKAGES = new Set<string>()

packages/next/telemetry/events/build.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ export type EventBuildFeatureUsage = {
166166
| 'turbotrace'
167167
| 'build-lint'
168168
| 'vercelImageGeneration'
169+
| 'transpilePackages'
170+
| 'allowMiddlewareResponseBody'
171+
| 'skipMiddlewareUrlNormalize'
172+
| 'skipTrailingSlashRedirect'
169173
invocationCount: number
170174
}
171175
export function eventBuildFeatureUsage(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
allowMiddlewareResponseBody: true,
3+
skipMiddlewareUrlNormalize: true,
4+
skipTrailingSlashRedirect: true,
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
transpilePackages: ["foo"]
3+
}

test/integration/telemetry/test/index.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,4 +1090,64 @@ describe('Telemetry CLI', () => {
10901090
invocationCount: 1,
10911091
})
10921092
})
1093+
1094+
it('emits telemetry for transpilePackages', async () => {
1095+
await fs.rename(
1096+
path.join(appDir, 'next.config.transpile-packages'),
1097+
path.join(appDir, 'next.config.js')
1098+
)
1099+
1100+
const { stderr } = await nextBuild(appDir, [], {
1101+
stderr: true,
1102+
env: { NEXT_TELEMETRY_DEBUG: 1 },
1103+
})
1104+
1105+
await fs.rename(
1106+
path.join(appDir, 'next.config.js'),
1107+
path.join(appDir, 'next.config.transpile-packages')
1108+
)
1109+
1110+
const featureUsageEvents = findAllTelemetryEvents(
1111+
stderr,
1112+
'NEXT_BUILD_FEATURE_USAGE'
1113+
)
1114+
expect(featureUsageEvents).toContainEqual({
1115+
featureName: 'transpilePackages',
1116+
invocationCount: 1,
1117+
})
1118+
})
1119+
1120+
it('emits telemetry for middleware related options', async () => {
1121+
await fs.rename(
1122+
path.join(appDir, 'next.config.middleware-options'),
1123+
path.join(appDir, 'next.config.js')
1124+
)
1125+
1126+
const { stderr } = await nextBuild(appDir, [], {
1127+
stderr: true,
1128+
env: { NEXT_TELEMETRY_DEBUG: 1 },
1129+
})
1130+
1131+
await fs.rename(
1132+
path.join(appDir, 'next.config.js'),
1133+
path.join(appDir, 'next.config.middleware-options')
1134+
)
1135+
1136+
const featureUsageEvents = findAllTelemetryEvents(
1137+
stderr,
1138+
'NEXT_BUILD_FEATURE_USAGE'
1139+
)
1140+
expect(featureUsageEvents).toContainEqual({
1141+
featureName: 'allowMiddlewareResponseBody',
1142+
invocationCount: 1,
1143+
})
1144+
expect(featureUsageEvents).toContainEqual({
1145+
featureName: 'skipMiddlewareUrlNormalize',
1146+
invocationCount: 1,
1147+
})
1148+
expect(featureUsageEvents).toContainEqual({
1149+
featureName: 'skipTrailingSlashRedirect',
1150+
invocationCount: 1,
1151+
})
1152+
})
10931153
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy