Unverified Commit 0aec1df2 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add telemetry for adapterPath config usage (#92228)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## What?

Adds telemetry tracking for when the `adapterPath` config option is used
in Next.js.

## Why?

As mentioned in the Slack discussion, telemetry for adapter usage was
missing. This helps track adoption of the adapter feature.

## How?

- Added `adapterPath` field to the `EventCliSessionStarted` type in
`telemetry/events/version.ts`
- The field is automatically populated from `nextConfig.adapterPath`
when CLI sessions start
- This covers both `next dev` and `next build` commands

The telemetry emits a CLI session event with `"adapterPath": true` when
the config option is set, and `"adapterPath": false` when it's not.

## Testing

Updated the test in `test/integration/telemetry/test/config.test.ts` to:
1. Create a config with `adapterPath` set
2. Run a build with telemetry debug enabled
3. Verify the CLI session telemetry includes `"adapterPath": true`

The test passes locally.
parent e9597e6c
...@@ -40,6 +40,7 @@ type EventCliSessionStarted = { ...@@ -40,6 +40,7 @@ type EventCliSessionStarted = {
reactCompiler: boolean reactCompiler: boolean
reactCompilerCompilationMode: string | null reactCompilerCompilationMode: string | null
reactCompilerPanicThreshold: string | null reactCompilerPanicThreshold: string | null
adapterPath: boolean
} }
export function eventCliSession( export function eventCliSession(
...@@ -75,6 +76,7 @@ export function eventCliSession( ...@@ -75,6 +76,7 @@ export function eventCliSession(
| 'reactCompilerCompilationMode' | 'reactCompilerCompilationMode'
| 'reactCompilerPanicThreshold' | 'reactCompilerPanicThreshold'
| 'isRspack' | 'isRspack'
| 'adapterPath'
> >
): { eventName: string; payload: EventCliSessionStarted }[] { ): { eventName: string; payload: EventCliSessionStarted }[] {
// This should be an invariant, if it fails our build tooling is broken. // This should be an invariant, if it fails our build tooling is broken.
...@@ -132,6 +134,7 @@ export function eventCliSession( ...@@ -132,6 +134,7 @@ export function eventCliSession(
typeof nextConfig.reactCompiler !== 'boolean' typeof nextConfig.reactCompiler !== 'boolean'
? (nextConfig.reactCompiler?.panicThreshold ?? null) ? (nextConfig.reactCompiler?.panicThreshold ?? null)
: null, : null,
adapterPath: !!nextConfig?.adapterPath,
} }
return [{ eventName: EVENT_VERSION, payload }] return [{ eventName: EVENT_VERSION, payload }]
} }
module.exports = {
name: 'test-adapter',
}
const path = require('path')
module.exports = {
adapterPath: path.join(__dirname, 'adapter.js'),
}
...@@ -342,6 +342,34 @@ describe('config telemetry', () => { ...@@ -342,6 +342,34 @@ describe('config telemetry', () => {
}) })
}) })
it('emits telemetry for usage of `adapterPath`', async () => {
await fs.rename(
path.join(appDir, 'next.config.adapter-path'),
path.join(appDir, 'next.config.js')
)
const { stderr } = await nextBuild(appDir, [], {
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: '1' },
})
await fs.rename(
path.join(appDir, 'next.config.js'),
path.join(appDir, 'next.config.adapter-path')
)
try {
const event1 = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/
.exec(stderr)
.pop()
expect(event1).toMatch(/"adapterPath": true/)
} catch (err) {
require('console').error('failing stderr', stderr, err)
throw err
}
})
it('emits telemetry for usage of middleware', async () => { it('emits telemetry for usage of middleware', async () => {
await fs.writeFile( await fs.writeFile(
path.join(appDir, 'middleware.js'), path.join(appDir, 'middleware.js'),
......
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