From 517914b2d8cc9e7581eee4419f44abddb12bce9c Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 22 Oct 2019 20:18:16 -0500 Subject: [PATCH] Move isSrcDir back to eventVersion --- packages/next/build/index.ts | 16 +++++++++++----- packages/next/export/index.ts | 2 +- packages/next/server/next-dev-server.ts | 12 +++++++----- packages/next/telemetry/anonymous-meta.ts | 8 +------- packages/next/telemetry/events/version.ts | 2 ++ packages/next/telemetry/storage.ts | 6 ++---- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 09bcdb6c99b59c..f2cebb192b1f12 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -85,23 +85,29 @@ export default async function build(dir: string, conf = null): Promise { ) } + const buildSpinner = createSpinner({ + prefixText: 'Creating an optimized production build', + }) + const config = loadConfig(PHASE_PRODUCTION_BUILD, dir, conf) const { target } = config const buildId = await generateBuildId(config.generateBuildId, nanoid) const distDir = path.join(dir, config.distDir) const publicDir = path.join(dir, 'public') const pagesDir = findPagesDir(dir) - const telemetry = new Telemetry({ - distDir, - isSrcDir: pagesDir.startsWith('src'), - }) + const telemetry = new Telemetry({ distDir }) let publicFiles: string[] = [] let hasPublicDir = false let backgroundWork: (Promise | undefined)[] = [] backgroundWork.push( - telemetry.record(eventVersion({ cliCommand: 'build' })), + telemetry.record( + eventVersion({ + cliCommand: 'build', + isSrcDir: pagesDir.startsWith('src'), + }) + ), eventNextPlugins(path.resolve(dir)).then(events => telemetry.record(events)) ) diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index 6205d11d071c23..dba1116a3f3d1c 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -95,7 +95,7 @@ export default async function( const distDir = join(dir, nextConfig.distDir) if (!options.buildExport) { const telemetry = new Telemetry({ distDir }) - telemetry.record(eventVersion({ cliCommand: 'export' })) + telemetry.record(eventVersion({ cliCommand: 'export', isSrcDir: null })) } const subFolders = nextConfig.exportTrailingSlash diff --git a/packages/next/server/next-dev-server.ts b/packages/next/server/next-dev-server.ts index 46a0863b5d74a2..0072b1b929eea0 100644 --- a/packages/next/server/next-dev-server.ts +++ b/packages/next/server/next-dev-server.ts @@ -206,11 +206,13 @@ export default class DevServer extends Server { await this.startWatcher() this.setDevReady!() - const telemetry = new Telemetry({ - distDir: this.distDir, - isSrcDir: this.pagesDir!.startsWith('src'), - }) - telemetry.record(eventVersion({ cliCommand: 'dev' })) + const telemetry = new Telemetry({ distDir: this.distDir }) + telemetry.record( + eventVersion({ + cliCommand: 'dev', + isSrcDir: this.pagesDir!.startsWith('src'), + }) + ) } protected async close() { diff --git a/packages/next/telemetry/anonymous-meta.ts b/packages/next/telemetry/anonymous-meta.ts index b7c28447f1e83c..db13bc6efed7d9 100644 --- a/packages/next/telemetry/anonymous-meta.ts +++ b/packages/next/telemetry/anonymous-meta.ts @@ -14,17 +14,12 @@ type AnonymousMeta = { isDocker: boolean isNowDev: boolean isCI: boolean - isSrcDir?: boolean ciName: string | null } let traits: AnonymousMeta | undefined -export function getAnonymousMeta({ - isSrcDir, -}: { - isSrcDir?: boolean -}): AnonymousMeta { +export function getAnonymousMeta(): AnonymousMeta { if (traits) { return traits } @@ -32,7 +27,6 @@ export function getAnonymousMeta({ const cpus = os.cpus() || [] const { NOW_REGION } = process.env traits = { - isSrcDir, // Software information systemPlatform: os.platform(), systemRelease: os.release(), diff --git a/packages/next/telemetry/events/version.ts b/packages/next/telemetry/events/version.ts index e8490af39180af..843de93c04e70f 100644 --- a/packages/next/telemetry/events/version.ts +++ b/packages/next/telemetry/events/version.ts @@ -4,6 +4,7 @@ type EventCliSessionStarted = { nextVersion: string nodeVersion: string cliCommand: string + isSrcDir: boolean | null } export function eventVersion( @@ -21,6 +22,7 @@ export function eventVersion( nextVersion: process.env.__NEXT_VERSION, nodeVersion: process.version, cliCommand: event.cliCommand, + isSrcDir: event.isSrcDir, } as EventCliSessionStarted, }, ] diff --git a/packages/next/telemetry/storage.ts b/packages/next/telemetry/storage.ts index 5a09a4227eaed8..39b9d5c6796860 100644 --- a/packages/next/telemetry/storage.ts +++ b/packages/next/telemetry/storage.ts @@ -44,15 +44,13 @@ export class Telemetry { private conf: Conf private sessionId: string private rawProjectId: string - private isSrcDir?: boolean - constructor({ distDir, isSrcDir }: { distDir: string; isSrcDir?: boolean }) { + constructor({ distDir }: { distDir: string }) { const storageDirectory = getStorageDirectory(distDir) this.conf = new Conf({ projectName: 'nextjs', cwd: storageDirectory }) this.sessionId = randomBytes(32).toString('hex') this.rawProjectId = getRawProjectId() - this.isSrcDir = isSrcDir this.notify() } @@ -204,7 +202,7 @@ export class Telemetry { projectId: this.projectId, sessionId: this.sessionId, } - const meta: EventMeta = getAnonymousMeta({ isSrcDir: this.isSrcDir }) + const meta: EventMeta = getAnonymousMeta() return _postPayload(`https://telemetry.nextjs.org/api/v1/record`, { context,