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' ...@@ -2,22 +2,42 @@ import ciEnvironment from 'ci-info'
import isDockerFunction from 'is-docker' import isDockerFunction from 'is-docker'
import os from 'os' import os from 'os'
export function getAnonymousTraits() { type AnonymousMeta = {
const cpus = os.cpus() || [] 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 // Software information
platform: os.platform(), systemPlatform: os.platform(),
release: os.release(), systemRelease: os.release(),
arch: os.arch(), systemArchitecture: os.arch(),
// Machine information // Machine information
cpuCount: cpus.length, cpuCount: cpus.length,
cpuModel: cpus.length ? cpus[0].model : null, cpuModel: cpus.length ? cpus[0].model : null,
cpuSpeed: cpus.length ? cpus[0].speed : 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 // Environment information
isDocker: isDockerFunction(), isDocker: isDockerFunction(),
isCI: ciEnvironment.isCI, isCI: ciEnvironment.isCI,
ciName: (ciEnvironment.isCI && ciEnvironment.name) || null, ciName: (ciEnvironment.isCI && ciEnvironment.name) || null,
} }
return traits
} }
...@@ -5,8 +5,9 @@ import { BinaryLike, createHash, randomBytes } from 'crypto' ...@@ -5,8 +5,9 @@ import { BinaryLike, createHash, randomBytes } from 'crypto'
import findUp from 'find-up' import findUp from 'find-up'
import isDockerFunction from 'is-docker' import isDockerFunction from 'is-docker'
import path from 'path' import path from 'path'
import { getAnonymousMeta } from './anonymous-meta'
import { _postPayload } from './post-payload' import { _postPayload } from './post-payload'
import { getAnonymousTraits } from './anonymous-traits'
import { getProjectId } from './project-id' import { getProjectId } from './project-id'
let config: Conf<any> | undefined let config: Conf<any> | undefined
...@@ -65,14 +66,6 @@ function notify() { ...@@ -65,14 +66,6 @@ function notify() {
console.log() console.log()
} }
function register(anonymousId: string) {
const traits = getAnonymousTraits()
_postPayload(`https://telemetry.nextjs.org/api/v1/register`, {
anonymousId: anonymousId,
fields: traits,
})
}
function setup() { function setup() {
if (config) { if (config) {
return return
...@@ -107,10 +100,6 @@ function setup() { ...@@ -107,10 +100,6 @@ function setup() {
} }
notify() notify()
if (!isDisabled) {
register(anonymousId)
}
} }
export function computeHash(payload: BinaryLike): string | null { export function computeHash(payload: BinaryLike): string | null {
...@@ -153,6 +142,7 @@ type EventContext = { ...@@ -153,6 +142,7 @@ type EventContext = {
projectId: string projectId: string
sessionId: string sessionId: string
} }
type EventMeta = { [key: string]: unknown }
type EventBatchShape = { type EventBatchShape = {
eventName: string eventName: string
fields: object fields: object
...@@ -198,8 +188,10 @@ function _record(_events: TelemetryEvent | TelemetryEvent[]): Promise<any> { ...@@ -198,8 +188,10 @@ function _record(_events: TelemetryEvent | TelemetryEvent[]): Promise<any> {
projectId: projectId!, projectId: projectId!,
sessionId: randomRunId!, sessionId: randomRunId!,
} }
const meta: EventMeta = getAnonymousMeta()
return _postPayload(`https://telemetry.nextjs.org/api/v1/record`, { return _postPayload(`https://telemetry.nextjs.org/api/v1/record`, {
context, context,
meta,
events: events.map(({ eventName, payload }) => ({ events: events.map(({ eventName, payload }) => ({
eventName, eventName,
fields: payload, 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