2019-08-29 18:43:06 +02:00
|
|
|
import { record } from '../storage'
|
|
|
|
|
2019-09-05 02:31:35 +02:00
|
|
|
const EVENT_VERSION = 'NEXT_CLI_SESSION_STARTED'
|
2019-08-29 18:43:06 +02:00
|
|
|
|
2019-09-05 02:31:35 +02:00
|
|
|
type EventCliSessionStarted = {
|
|
|
|
nextVersion: string
|
|
|
|
nodeVersion: string
|
|
|
|
cliCommand: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export function recordVersion(
|
|
|
|
event: Omit<EventCliSessionStarted, 'nextVersion' | 'nodeVersion'>
|
|
|
|
) {
|
2019-08-29 18:43:06 +02:00
|
|
|
// This should be an invariant, if it fails our build tooling is broken.
|
|
|
|
if (typeof process.env.__NEXT_VERSION !== 'string') {
|
|
|
|
return Promise.resolve()
|
|
|
|
}
|
|
|
|
|
|
|
|
return record({
|
|
|
|
eventName: EVENT_VERSION,
|
|
|
|
payload: {
|
2019-09-05 02:31:35 +02:00
|
|
|
nextVersion: process.env.__NEXT_VERSION,
|
2019-08-29 18:43:06 +02:00
|
|
|
nodeVersion: process.version,
|
2019-09-05 02:31:35 +02:00
|
|
|
cliCommand: event.cliCommand,
|
|
|
|
} as EventCliSessionStarted,
|
2019-08-29 18:43:06 +02:00
|
|
|
})
|
|
|
|
}
|