Skip to content

Commit

Permalink
feat(gatsby): distinguish total number of pages from number of writte…
Browse files Browse the repository at this point in the history
…n html files (#29149)
  • Loading branch information
pieh authored Jan 27, 2021
1 parent e771b2a commit e676944
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion packages/gatsby-telemetry/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ export class AnalyticsTracker {
this.metadataCache[event] = Object.assign(cached, obj)
}

addSiteMeasurement(event: string, obj): void {
addSiteMeasurement(
event: string,
obj: ITelemetryTagsPayload["siteMeasurements"]
): void {
const cachedEvent = this.metadataCache[event] || {}
const cachedMeasurements = cachedEvent.siteMeasurements || {}
this.metadataCache[event] = Object.assign(cachedEvent, {
Expand Down
5 changes: 0 additions & 5 deletions packages/gatsby/src/commands/build-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Bluebird from "bluebird"
import fs from "fs-extra"
import reporter from "gatsby-cli/lib/reporter"
import { createErrorFromString } from "gatsby-cli/lib/reporter/errors"
import telemetry from "gatsby-telemetry"
import { chunk } from "lodash"
import webpack from "webpack"

Expand Down Expand Up @@ -182,10 +181,6 @@ export const doBuildPages = async (
activity: IActivity,
workerPool: IWorkerPool
): Promise<void> => {
telemetry.addSiteMeasurement(`BUILD_END`, {
pagesCount: pagePaths.length,
})

try {
await renderHTMLQueue(workerPool, activity, rendererPath, pagePaths)
} catch (error) {
Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {
buildSSRBundleActivityProgress.end()
}

telemetry.addSiteMeasurement(`BUILD_END`, {
pagesCount: pagePaths.length, // number of html files that will be written
totalPagesCount: store.getState().pages.size, // total number of pages
})

const buildHTMLActivityProgress = report.createProgress(
`Building static HTML for pages`,
pagePaths.length,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/commands/develop-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (process.send) {
onExit(() => {
telemetry.trackCli(`DEVELOP_STOP`, {
siteMeasurements: {
pagesCount: store.getState().pages.size,
totalPagesCount: store.getState().pages.size,
},
})
})
Expand Down

0 comments on commit e676944

Please sign in to comment.