Skip to content

Commit a6e7e59

Browse files
authored
feat: add framework, build system, and package manager to telemetry for every command (#5752)
* feat: add framework data to telemetry for every command * feat: add build system and package manager * chore: rearrange * chore: format * chore: remove export * chore: refactor * chore: format
1 parent 8a5d588 commit a6e7e59

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/commands/base-command.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import process from 'process'
33
import { format } from 'util'
44

5+
import { Project } from '@netlify/build-info'
6+
// eslint-disable-next-line import/extensions, n/no-missing-import
7+
import { NodeFS } from '@netlify/build-info/node'
58
import { resolveConfig } from '@netlify/config'
69
import { Command, Option } from 'commander'
710
import debug from 'debug'
@@ -456,6 +459,22 @@ export default class BaseCommand extends Command {
456459

457460
const globalConfig = await getGlobalConfig()
458461

462+
// Get framework, add to analytics payload for every command, if a framework is set
463+
const fs = new NodeFS()
464+
const project = new Project(fs, buildDir)
465+
const frameworks = await project.detectFrameworks()
466+
467+
const frameworkIDs = frameworks?.map((framework) => framework.id)
468+
469+
if (frameworkIDs?.length !== 0) {
470+
this.setAnalyticsPayload({ frameworks: frameworkIDs })
471+
}
472+
473+
this.setAnalyticsPayload({
474+
packageManager: project.packageManager?.name,
475+
buildSystem: project.buildSystems.map(({ id }) => id),
476+
})
477+
459478
actionCommand.netlify = {
460479
// api methods
461480
api,

src/commands/dev/dev.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const dev = async (options, command) => {
123123
exit(1)
124124
}
125125

126-
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live })
126+
command.setAnalyticsPayload({ live: options.live })
127127

128128
const liveTunnelUrl = await handleLiveTunnel({ options, site, api, settings })
129129
const url = liveTunnelUrl || getProxyUrl(settings)

src/commands/serve/serve.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const serve = async (options, command) => {
8080
exit(1)
8181
}
8282

83-
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live })
83+
command.setAnalyticsPayload({ live: options.live })
8484

8585
log(`${NETLIFYDEVLOG} Building site for production`)
8686
log(

0 commit comments

Comments
 (0)