Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
3052a8ff
Unverified
Commit
3052a8ff
authored
Sep 07, 2019
by
Joe Haddad
Committed by
GitHub
Sep 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Telemetry Registration (#8664)
parent
3000d719
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
13 deletions
+48
-13
anonymous-meta.ts
packages/next/telemetry/anonymous-meta.ts
+43
-0
storage.ts
packages/next/telemetry/storage.ts
+5
-13
No files found.
packages/next/telemetry/anonymous-
traits
.ts
→
packages/next/telemetry/anonymous-
meta
.ts
View file @
3052a8ff
...
@@ -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
p
latform
:
os
.
platform
(),
systemP
latform
:
os
.
platform
(),
r
elease
:
os
.
release
(),
systemR
elease
:
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
}
}
packages/next/telemetry/storage.ts
View file @
3052a8ff
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment