Skip to content

Commit

Permalink
Update optimize event with static 404 status (#10420)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Haddad <timer150@gmail.com>
  • Loading branch information
ijjk and Timer committed Feb 4, 2020
1 parent ecd628b commit ec39aa4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/next/build/index.ts
Expand Up @@ -773,6 +773,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
durationInSeconds: analysisEnd[0],
staticPageCount: staticPages.size,
ssrPageCount: pagePaths.length - staticPages.size,
hasStatic404: useStatic404,
})
)

Expand Down
1 change: 1 addition & 0 deletions packages/next/telemetry/events/build.ts
Expand Up @@ -40,6 +40,7 @@ type EventBuildOptimized = {
ssrPageCount: number
hasDunderPages: boolean
hasTestPages: boolean
hasStatic404: boolean
}

export function eventBuildOptimize(
Expand Down
11 changes: 11 additions & 0 deletions test/integration/telemetry/test/index.test.js
Expand Up @@ -8,6 +8,7 @@ import {
findPort,
killApp,
waitFor,
nextBuild,
} from 'next-test-utils'

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
Expand Down Expand Up @@ -117,6 +118,16 @@ describe('Telemetry CLI', () => {
expect(event2).toMatch(/hasTestPages.*?true/)
})

it('detect static 404 correctly for `next build`', async () => {
const { stderr } = await nextBuild(appDir, [], {
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})

const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/.exec(stderr).pop()
expect(event1).toMatch(/hasStatic404.*?true/)
})

it('detects isSrcDir dir correctly for `next dev`', async () => {
let port = await findPort()
let stderr = ''
Expand Down

0 comments on commit ec39aa4

Please sign in to comment.