Unverified Commit dfd18f97 authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Telemetry: include alternate bundler state in key events (#76886)

This includes `isRspack` in the following telemetry events, determining
it with the presence of `process.env.NEXT_RSPACK`:

- `NEXT_CLI_SESSION_STARTED`
- `NEXT_CLI_SESSION_STOPPED`
- `NEXT_BUILD_OPTIMIZED`

Test Plan: Verify these are included with `NEXT_TELEMETRY_DEBUG=1` for
both `next dev` and `next build`
parent 0ce9e53e
...@@ -103,6 +103,7 @@ type EventBuildOptimized = { ...@@ -103,6 +103,7 @@ type EventBuildOptimized = {
rewritesWithHasCount: number rewritesWithHasCount: number
redirectsWithHasCount: number redirectsWithHasCount: number
middlewareCount: number middlewareCount: number
isRspack: boolean
totalAppPagesCount?: number totalAppPagesCount?: number
staticAppPagesCount?: number staticAppPagesCount?: number
serverAppPagesCount?: number serverAppPagesCount?: number
...@@ -114,7 +115,7 @@ export function eventBuildOptimize( ...@@ -114,7 +115,7 @@ export function eventBuildOptimize(
pagePaths: string[], pagePaths: string[],
event: Omit< event: Omit<
EventBuildOptimized, EventBuildOptimized,
'totalPageCount' | 'hasDunderPages' | 'hasTestPages' 'totalPageCount' | 'hasDunderPages' | 'hasTestPages' | 'isRspack'
> >
): { eventName: string; payload: EventBuildOptimized } { ): { eventName: string; payload: EventBuildOptimized } {
return { return {
...@@ -134,6 +135,7 @@ export function eventBuildOptimize( ...@@ -134,6 +135,7 @@ export function eventBuildOptimize(
serverAppPagesCount: event.serverAppPagesCount, serverAppPagesCount: event.serverAppPagesCount,
edgeRuntimeAppCount: event.edgeRuntimeAppCount, edgeRuntimeAppCount: event.edgeRuntimeAppCount,
edgeRuntimePagesCount: event.edgeRuntimePagesCount, edgeRuntimePagesCount: event.edgeRuntimePagesCount,
isRspack: process.env.NEXT_RSPACK !== undefined,
}, },
} }
} }
......
...@@ -8,10 +8,14 @@ export type EventCliSessionStopped = { ...@@ -8,10 +8,14 @@ export type EventCliSessionStopped = {
durationMilliseconds?: number | null durationMilliseconds?: number | null
pagesDir?: boolean pagesDir?: boolean
appDir?: boolean appDir?: boolean
isRspack: boolean
} }
export function eventCliSessionStopped( export function eventCliSessionStopped(
event: Omit<EventCliSessionStopped, 'nextVersion' | 'nodeVersion'> event: Omit<
EventCliSessionStopped,
'nextVersion' | 'nodeVersion' | 'isRspack'
>
): { eventName: string; payload: EventCliSessionStopped }[] { ): { eventName: string; payload: EventCliSessionStopped }[] {
// 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.
if (typeof process.env.__NEXT_VERSION !== 'string') { if (typeof process.env.__NEXT_VERSION !== 'string') {
...@@ -30,6 +34,7 @@ export function eventCliSessionStopped( ...@@ -30,6 +34,7 @@ export function eventCliSessionStopped(
: {}), : {}),
pagesDir: event.pagesDir, pagesDir: event.pagesDir,
appDir: event.appDir, appDir: event.appDir,
isRspack: process.env.NEXT_RSPACK !== undefined,
} }
return [{ eventName: EVENT_VERSION, payload }] return [{ eventName: EVENT_VERSION, payload }]
} }
...@@ -33,6 +33,7 @@ type EventCliSessionStarted = { ...@@ -33,6 +33,7 @@ type EventCliSessionStarted = {
reactStrictMode: boolean reactStrictMode: boolean
webpackVersion: number | null webpackVersion: number | null
turboFlag: boolean turboFlag: boolean
isRspack: boolean
appDir: boolean | null appDir: boolean | null
pagesDir: boolean | null pagesDir: boolean | null
staticStaleTime: number | null staticStaleTime: number | null
...@@ -93,6 +94,7 @@ export function eventCliSession( ...@@ -93,6 +94,7 @@ export function eventCliSession(
| 'reactCompiler' | 'reactCompiler'
| 'reactCompilerCompilationMode' | 'reactCompilerCompilationMode'
| 'reactCompilerPanicThreshold' | 'reactCompilerPanicThreshold'
| 'isRspack'
> >
): { 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.
...@@ -136,6 +138,7 @@ export function eventCliSession( ...@@ -136,6 +138,7 @@ export function eventCliSession(
reactStrictMode: !!nextConfig?.reactStrictMode, reactStrictMode: !!nextConfig?.reactStrictMode,
webpackVersion: event.webpackVersion || null, webpackVersion: event.webpackVersion || null,
turboFlag: event.turboFlag || false, turboFlag: event.turboFlag || false,
isRspack: process.env.NEXT_RSPACK !== undefined,
appDir: event.appDir, appDir: event.appDir,
pagesDir: event.pagesDir, pagesDir: event.pagesDir,
staticStaleTime: nextConfig.experimental.staleTimes?.static ?? null, staticStaleTime: nextConfig.experimental.staleTimes?.static ?? null,
......
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