-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event for dev process stop (#42255)
x-ref: [slack thread](https://vercel.slack.com/archives/C02HEJASXGD/p1667173179573409?thread_ts=1667165920.338789&channel=C02HEJASXGD&message_ts=1667173179.573409) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information
Showing
4 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const EVENT_VERSION = 'NEXT_CLI_SESSION_STOPPED' | ||
|
||
export type EventCliSessionStopped = { | ||
cliCommand: string | ||
nextVersion: string | ||
nodeVersion: string | ||
turboFlag?: boolean | null | ||
durationMilliseconds?: number | null | ||
} | ||
|
||
export function eventCliSession( | ||
event: Omit<EventCliSessionStopped, 'nextVersion' | 'nodeVersion'> | ||
): { eventName: string; payload: EventCliSessionStopped }[] { | ||
// This should be an invariant, if it fails our build tooling is broken. | ||
if (typeof process.env.__NEXT_VERSION !== 'string') { | ||
return [] | ||
} | ||
|
||
const payload: EventCliSessionStopped = { | ||
nextVersion: process.env.__NEXT_VERSION, | ||
nodeVersion: process.version, | ||
cliCommand: event.cliCommand, | ||
durationMilliseconds: event.durationMilliseconds, | ||
...(typeof event.turboFlag !== 'undefined' | ||
? { | ||
turboFlag: !!event.turboFlag, | ||
} | ||
: {}), | ||
} | ||
return [{ eventName: EVENT_VERSION, payload }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters