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
6e77c071
Unverified
Commit
6e77c071
authored
Sep 05, 2019
by
Joe Haddad
Committed by
GitHub
Sep 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Next.js Telemetry Event Shapes (#8628)
* Update Next.js Telemetry Event Shapes * Force value as-is
parent
61b8b732
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
37 deletions
+54
-37
index.ts
packages/next/build/index.ts
+7
-3
next-dev-server.js
packages/next/server/next-dev-server.js
+1
-1
build.ts
packages/next/telemetry/events/build.ts
+11
-17
plugins.ts
packages/next/telemetry/events/plugins.ts
+7
-7
version.ts
packages/next/telemetry/events/version.ts
+13
-5
storage.ts
packages/next/telemetry/storage.ts
+15
-4
No files found.
packages/next/build/index.ts
View file @
6e77c071
...
@@ -64,7 +64,10 @@ export default async function build(dir: string, conf = null): Promise<void> {
...
@@ -64,7 +64,10 @@ export default async function build(dir: string, conf = null): Promise<void> {
await
verifyTypeScriptSetup
(
dir
)
await
verifyTypeScriptSetup
(
dir
)
let
backgroundWork
:
(
Promise
<
any
>
|
undefined
)[]
=
[]
let
backgroundWork
:
(
Promise
<
any
>
|
undefined
)[]
=
[]
backgroundWork
.
push
(
recordVersion
(),
recordNextPlugins
(
path
.
resolve
(
dir
)))
backgroundWork
.
push
(
recordVersion
({
cliCommand
:
'build'
}),
recordNextPlugins
(
path
.
resolve
(
dir
))
)
console
.
log
(
'Creating an optimized production build ...'
)
console
.
log
(
'Creating an optimized production build ...'
)
console
.
log
()
console
.
log
()
...
@@ -199,7 +202,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
...
@@ -199,7 +202,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
console
.
log
(
chalk
.
green
(
'Compiled successfully.
\
n'
))
console
.
log
(
chalk
.
green
(
'Compiled successfully.
\
n'
))
backgroundWork
.
push
(
backgroundWork
.
push
(
recordBuildDuration
({
recordBuildDuration
({
numberOfPages
:
allPagePaths
.
length
,
totalPageCount
:
allPagePaths
.
length
,
durationInSeconds
:
webpackBuildEnd
[
0
],
durationInSeconds
:
webpackBuildEnd
[
0
],
})
})
)
)
...
@@ -410,7 +413,8 @@ export default async function build(dir: string, conf = null): Promise<void> {
...
@@ -410,7 +413,8 @@ export default async function build(dir: string, conf = null): Promise<void> {
recordBuildOptimize
({
recordBuildOptimize
({
durationInSeconds
:
analysisEnd
[
0
],
durationInSeconds
:
analysisEnd
[
0
],
totalPageCount
:
allPagePaths
.
length
,
totalPageCount
:
allPagePaths
.
length
,
staticOptimizedPages
:
staticPages
.
size
,
staticPageCount
:
staticPages
.
size
,
ssrPageCount
:
allPagePaths
.
length
-
staticPages
.
size
,
})
})
)
)
...
...
packages/next/server/next-dev-server.js
View file @
6e77c071
...
@@ -179,7 +179,7 @@ export default class DevServer extends Server {
...
@@ -179,7 +179,7 @@ export default class DevServer extends Server {
await
this
.
startWatcher
()
await
this
.
startWatcher
()
this
.
setDevReady
()
this
.
setDevReady
()
recordVersion
({
isDev
:
true
})
recordVersion
({
cliCommand
:
'dev'
})
}
}
async
close
()
{
async
close
()
{
...
...
packages/next/telemetry/events/build.ts
View file @
6e77c071
import
{
record
}
from
'../storage'
import
{
record
}
from
'../storage'
const
EVENT_BUILD_DURATION
=
'NEXT_BUILD_
DURATION
'
const
EVENT_BUILD_DURATION
=
'NEXT_BUILD_
COMPLETED
'
type
BuildDurationEventShape
=
{
type
EventBuildCompleted
=
{
durationInSeconds
:
number
durationInSeconds
:
number
numberOfPages
:
number
totalPageCount
:
number
}
}
export
function
recordBuildDuration
(
event
:
BuildDurationEventShape
)
{
export
function
recordBuildDuration
(
event
:
EventBuildCompleted
)
{
return
record
({
return
record
({
eventName
:
EVENT_BUILD_DURATION
,
eventName
:
EVENT_BUILD_DURATION
,
payload
:
{
payload
:
event
,
seconds
:
event
.
durationInSeconds
,
pageCount
:
event
.
numberOfPages
,
},
})
})
}
}
const
EVENT_BUILD_OPTIMIZE
=
'NEXT_BUILD_OPTIMIZE'
const
EVENT_BUILD_OPTIMIZE
=
'NEXT_BUILD_OPTIMIZE
D
'
type
BuildAnalysisEventShape
=
{
type
EventBuildOptimized
=
{
durationInSeconds
:
number
durationInSeconds
:
number
totalPageCount
:
number
totalPageCount
:
number
staticOptimizedPages
:
number
staticPageCount
:
number
ssrPageCount
:
number
}
}
export
function
recordBuildOptimize
(
event
:
BuildAnalysisEventShape
)
{
export
function
recordBuildOptimize
(
event
:
EventBuildOptimized
)
{
return
record
({
return
record
({
eventName
:
EVENT_BUILD_OPTIMIZE
,
eventName
:
EVENT_BUILD_OPTIMIZE
,
payload
:
{
payload
:
event
,
seconds
:
event
.
durationInSeconds
,
pageCount
:
event
.
totalPageCount
,
pageAutomaticPrerenderedCount
:
event
.
staticOptimizedPages
,
},
})
})
}
}
packages/next/telemetry/events/plugins.ts
View file @
6e77c071
import
{
record
}
from
'../storage'
import
{
record
}
from
'../storage'
import
findUp
from
'find-up'
import
findUp
from
'find-up'
const
EVENT_PLUGIN_PRESENT
=
'NEXT_P
LUGIN_PRESENT
'
const
EVENT_PLUGIN_PRESENT
=
'NEXT_P
ACKAGE_DETECTED
'
type
PluginPresentEventShape
=
{
type
EventPackageDetected
=
{
p
lugin
Name
:
string
p
ackage
Name
:
string
p
lugin
Version
:
string
p
ackage
Version
:
string
}
}
const
plugins
=
[
const
plugins
=
[
...
@@ -177,9 +177,9 @@ export async function recordNextPlugins(dir: string) {
...
@@ -177,9 +177,9 @@ export async function recordNextPlugins(dir: string) {
}[]).
map
(({
pluginName
,
pluginVersion
})
=>
({
}[]).
map
(({
pluginName
,
pluginVersion
})
=>
({
eventName
:
EVENT_PLUGIN_PRESENT
,
eventName
:
EVENT_PLUGIN_PRESENT
,
payload
:
{
payload
:
{
pluginName
,
p
ackageName
:
p
luginName
,
pluginVersion
,
p
ackageVersion
:
p
luginVersion
,
}
as
PluginPresentEventShape
,
}
as
EventPackageDetected
,
}))
}))
)
)
}
catch
(
_
)
{}
}
catch
(
_
)
{}
...
...
packages/next/telemetry/events/version.ts
View file @
6e77c071
import
{
record
}
from
'../storage'
import
{
record
}
from
'../storage'
const
EVENT_VERSION
=
'NEXT_
VERSION
'
const
EVENT_VERSION
=
'NEXT_
CLI_SESSION_STARTED
'
export
function
recordVersion
({
isDev
=
false
}
=
{})
{
type
EventCliSessionStarted
=
{
nextVersion
:
string
nodeVersion
:
string
cliCommand
:
string
}
export
function
recordVersion
(
event
:
Omit
<
EventCliSessionStarted
,
'nextVersion'
|
'nodeVersion'
>
)
{
// This should be an invariant, if it fails our build tooling is broken.
// This should be an invariant, if it fails our build tooling is broken.
if
(
typeof
process
.
env
.
__NEXT_VERSION
!==
'string'
)
{
if
(
typeof
process
.
env
.
__NEXT_VERSION
!==
'string'
)
{
return
Promise
.
resolve
()
return
Promise
.
resolve
()
...
@@ -11,9 +19,9 @@ export function recordVersion({ isDev = false } = {}) {
...
@@ -11,9 +19,9 @@ export function recordVersion({ isDev = false } = {}) {
return
record
({
return
record
({
eventName
:
EVENT_VERSION
,
eventName
:
EVENT_VERSION
,
payload
:
{
payload
:
{
v
ersion
:
process
.
env
.
__NEXT_VERSION
,
nextV
ersion
:
process
.
env
.
__NEXT_VERSION
,
nodeVersion
:
process
.
version
,
nodeVersion
:
process
.
version
,
isDevelopment
:
isDev
,
cliCommand
:
event
.
cliCommand
,
},
}
as
EventCliSessionStarted
,
})
})
}
}
packages/next/telemetry/storage.ts
View file @
6e77c071
...
@@ -148,7 +148,15 @@ export function isTelemetryEnabled(): boolean {
...
@@ -148,7 +148,15 @@ export function isTelemetryEnabled(): boolean {
}
}
type
TelemetryEvent
=
{
eventName
:
string
;
payload
:
object
}
type
TelemetryEvent
=
{
eventName
:
string
;
payload
:
object
}
type
EventContext
=
{
anonymousId
:
string
projectId
:
string
sessionId
:
string
}
type
EventBatchShape
=
{
eventName
:
string
fields
:
object
}
function
_record
(
_events
:
TelemetryEvent
|
TelemetryEvent
[]):
Promise
<
any
>
{
function
_record
(
_events
:
TelemetryEvent
|
TelemetryEvent
[]):
Promise
<
any
>
{
let
events
:
TelemetryEvent
[]
let
events
:
TelemetryEvent
[]
if
(
Array
.
isArray
(
_events
))
{
if
(
Array
.
isArray
(
_events
))
{
...
@@ -185,14 +193,17 @@ function _record(_events: TelemetryEvent | TelemetryEvent[]): Promise<any> {
...
@@ -185,14 +193,17 @@ function _record(_events: TelemetryEvent | TelemetryEvent[]): Promise<any> {
return
Promise
.
resolve
()
return
Promise
.
resolve
()
}
}
const
context
=
{
anonymousProjectId
:
projectId
,
runId
:
randomRunId
}
const
context
:
EventContext
=
{
anonymousId
:
anonymousId
,
projectId
:
projectId
!
,
sessionId
:
randomRunId
!
,
}
return
_postPayload
(
`https://telemetry.nextjs.org/api/v1/record`
,
{
return
_postPayload
(
`https://telemetry.nextjs.org/api/v1/record`
,
{
anonymousId
,
context
,
context
,
events
:
events
.
map
(({
eventName
,
payload
})
=>
({
events
:
events
.
map
(({
eventName
,
payload
})
=>
({
eventName
,
eventName
,
fields
:
payload
,
fields
:
payload
,
})),
}))
as
Array
<
EventBatchShape
>
,
})
})
}
}
...
...
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