Unverified Commit 3052a8ff authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Remove Telemetry Registration (#8664)

parent 3000d719
......@@ -2,22 +2,42 @@ import ciEnvironment from 'ci-info'
import isDockerFunction from 'is-docker'
import os from 'os'
export function getAnonymousTraits() {
const cpus = os.cpus() || []
type AnonymousMeta = {
systemPlatform: NodeJS.Platform
systemRelease: string
systemArchitecture: string
cpuCount: number
cpuModel: string | null
cpuSpeed: number | null
memoryInMb: number
isDocker: boolean
isCI: boolean
ciName: string | null
}
return {
let traits: AnonymousMeta | undefined
export function getAnonymousMeta(): AnonymousMeta {
if (traits) {
return traits
}
const cpus = os.cpus() || []
traits = {
// Software information
platform: os.platform(),
release: os.release(),
arch: os.arch(),
systemPlatform: os.platform(),
systemRelease: os.release(),
systemArchitecture: os.arch(),
// Machine information
cpuCount: cpus.length,
cpuModel: cpus.length ? cpus[0].model : null,
cpuSpeed: cpus.length ? cpus[0].speed : null,
totalMemory: Number((os.totalmem() / Math.pow(1024, 3) || 0).toFixed(2)),
memoryInMb: Math.trunc(os.totalmem() / Math.pow(1024, 2)),
// Environment information
isDocker: isDockerFunction(),
isCI: ciEnvironment.isCI,
ciName: (ciEnvironment.isCI && ciEnvironment.name) || null,
}
return traits
}
......@@ -5,8 +5,9 @@ import { BinaryLike, createHash, randomBytes } from 'crypto'
import findUp from 'find-up'
import isDockerFunction from 'is-docker'
import path from 'path'
import { getAnonymousMeta } from './anonymous-meta'
import { _postPayload } from './post-payload'
import { getAnonymousTraits } from './anonymous-traits'
import { getProjectId } from './project-id'
let config: Conf<any> | undefined
......@@ -65,14 +66,6 @@ function notify() {
console.log()
}
function register(anonymousId: string) {
const traits = getAnonymousTraits()
_postPayload(`https://telemetry.nextjs.org/api/v1/register`, {
anonymousId: anonymousId,
fields: traits,
})
}
function setup() {
if (config) {
return
......@@ -107,10 +100,6 @@ function setup() {
}
notify()
if (!isDisabled) {
register(anonymousId)
}
}
export function computeHash(payload: BinaryLike): string | null {
......@@ -153,6 +142,7 @@ type EventContext = {
projectId: string
sessionId: string
}
type EventMeta = { [key: string]: unknown }
type EventBatchShape = {
eventName: string
fields: object
......@@ -198,8 +188,10 @@ function _record(_events: TelemetryEvent | TelemetryEvent[]): Promise<any> {
projectId: projectId!,
sessionId: randomRunId!,
}
const meta: EventMeta = getAnonymousMeta()
return _postPayload(`https://telemetry.nextjs.org/api/v1/record`, {
context,
meta,
events: events.map(({ eventName, payload }) => ({
eventName,
fields: payload,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment