rsnext/packages/next/telemetry/events/version.ts
Joe Haddad de670b3834
Do Not Rely on Module State (#8968)
* Do Not Rely on Module State

* Update storage.ts
2019-10-10 13:18:07 -04:00

27 lines
700 B
TypeScript

const EVENT_VERSION = 'NEXT_CLI_SESSION_STARTED'
type EventCliSessionStarted = {
nextVersion: string
nodeVersion: string
cliCommand: string
}
export function eventVersion(
event: Omit<EventCliSessionStarted, 'nextVersion' | 'nodeVersion'>
): { eventName: string; payload: EventCliSessionStarted }[] {
// This should be an invariant, if it fails our build tooling is broken.
if (typeof process.env.__NEXT_VERSION !== 'string') {
return []
}
return [
{
eventName: EVENT_VERSION,
payload: {
nextVersion: process.env.__NEXT_VERSION,
nodeVersion: process.version,
cliCommand: event.cliCommand,
} as EventCliSessionStarted,
},
]
}