Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for invalid pages #10403

Merged
merged 8 commits into from Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/next/build/index.ts
Expand Up @@ -770,9 +770,8 @@ export default async function build(dir: string, conf = null): Promise<void> {

const analysisEnd = process.hrtime(analysisBegin)
telemetry.record(
eventBuildOptimize({
eventBuildOptimize(pagePaths, {
durationInSeconds: analysisEnd[0],
totalPageCount: pagePaths.length,
staticPageCount: staticPages.size,
ssrPageCount: pagePaths.length - staticPages.size,
})
Expand Down
21 changes: 19 additions & 2 deletions packages/next/telemetry/events/build.ts
Expand Up @@ -19,13 +19,30 @@ type EventBuildOptimized = {
totalPageCount: number
staticPageCount: number
ssrPageCount: number
hasDunderPages: boolean
hasTestPages: boolean
}

const DUNDER_PAGES = /^[\\/]__generated__[\\/]/
Timer marked this conversation as resolved.
Show resolved Hide resolved
const TEST_PAGES = /^[\\/]__(tests|mocks)__[\\/]/
Timer marked this conversation as resolved.
Show resolved Hide resolved
const TEST_FILE = /\.(spec|test)\.[jt]sx?$/
Timer marked this conversation as resolved.
Show resolved Hide resolved

export function eventBuildOptimize(
event: EventBuildOptimized
pagePaths: string[],
event: Omit<
EventBuildOptimized,
'totalPageCount' | 'hasDunderPages' | 'hasTestPages'
>
): { eventName: string; payload: EventBuildOptimized } {
return {
eventName: EVENT_BUILD_OPTIMIZE,
payload: event,
payload: {
...event,
totalPageCount: pagePaths.length,
hasDunderPages: pagePaths.some(path => DUNDER_PAGES.test(path)),
hasTestPages: pagePaths.some(
path => TEST_PAGES.test(path) || TEST_FILE.test(path)
),
},
}
}