parent
49990f558d
commit
4ba2b78729
1 changed files with 8 additions and 4 deletions
|
@ -26,8 +26,6 @@ const TELEMETRY_KEY_ID = `telemetry.anonymousId`
|
|||
// See the `oneWayHash` function.
|
||||
const TELEMETRY_KEY_SALT = `telemetry.salt`
|
||||
|
||||
const { NEXT_TELEMETRY_DISABLED, NEXT_TELEMETRY_DEBUG } = process.env
|
||||
|
||||
type TelemetryEvent = { eventName: string; payload: object }
|
||||
type EventContext = {
|
||||
anonymousId: string
|
||||
|
@ -51,10 +49,16 @@ export class Telemetry {
|
|||
private conf: Conf<any> | null
|
||||
private sessionId: string
|
||||
private rawProjectId: string
|
||||
private NEXT_TELEMETRY_DISABLED: any
|
||||
private NEXT_TELEMETRY_DEBUG: any
|
||||
|
||||
private queue: Set<Promise<RecordObject>>
|
||||
|
||||
constructor({ distDir }: { distDir: string }) {
|
||||
// Read in the constructor so that .env can be loaded before reading
|
||||
const { NEXT_TELEMETRY_DISABLED, NEXT_TELEMETRY_DEBUG } = process.env
|
||||
this.NEXT_TELEMETRY_DISABLED = NEXT_TELEMETRY_DISABLED
|
||||
this.NEXT_TELEMETRY_DEBUG = NEXT_TELEMETRY_DEBUG
|
||||
const storageDirectory = getStorageDirectory(distDir)
|
||||
|
||||
try {
|
||||
|
@ -125,7 +129,7 @@ export class Telemetry {
|
|||
}
|
||||
|
||||
private get isDisabled(): boolean {
|
||||
if (!!NEXT_TELEMETRY_DISABLED || !this.conf) {
|
||||
if (!!this.NEXT_TELEMETRY_DISABLED || !this.conf) {
|
||||
return true
|
||||
}
|
||||
return this.conf.get(TELEMETRY_KEY_ENABLED, true) === false
|
||||
|
@ -206,7 +210,7 @@ export class Telemetry {
|
|||
return Promise.resolve()
|
||||
}
|
||||
|
||||
if (NEXT_TELEMETRY_DEBUG) {
|
||||
if (this.NEXT_TELEMETRY_DEBUG) {
|
||||
// Print to standard error to simplify selecting the output
|
||||
events.forEach(({ eventName, payload }) =>
|
||||
console.error(
|
||||
|
|
Loading…
Reference in a new issue