Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from gatsbyjs:master #884

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 31 additions & 34 deletions packages/gatsby/src/bootstrap/load-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,43 @@ export async function loadConfig({
})
}

if (config && processFlags) {
if (processFlags) {
// Setup flags
if (config) {
// Get flags
const {
enabledConfigFlags,
unknownFlagMessage,
unfitFlagMessage,
message,
} = handleFlags(availableFlags, config.flags)
const {
enabledConfigFlags,
unknownFlagMessage,
unfitFlagMessage,
message,
} = handleFlags(availableFlags, config?.flags ?? {})

if (unknownFlagMessage !== ``) {
reporter.warn(unknownFlagMessage)
}
if (unfitFlagMessage !== ``) {
reporter.warn(unfitFlagMessage)
}
// set process.env for each flag
enabledConfigFlags.forEach(flag => {
process.env[flag.env] = `true`
})

// Print out message.
if (message !== ``) {
reporter.info(message)
}
if (unknownFlagMessage !== ``) {
reporter.warn(unknownFlagMessage)
}
if (unfitFlagMessage !== ``) {
reporter.warn(unfitFlagMessage)
}
// set process.env for each flag
enabledConfigFlags.forEach(flag => {
process.env[flag.env] = `true`
})

process.env.GATSBY_SLICES = `true`
// Print out message.
if (message !== ``) {
reporter.info(message)
}

// track usage of feature
enabledConfigFlags.forEach(flag => {
if (flag.telemetryId) {
telemetry.trackFeatureIsUsed(flag.telemetryId)
}
})
process.env.GATSBY_SLICES = `true`

// Track the usage of config.flags
if (config.flags) {
telemetry.trackFeatureIsUsed(`ConfigFlags`)
// track usage of feature
enabledConfigFlags.forEach(flag => {
if (flag.telemetryId) {
telemetry.trackFeatureIsUsed(flag.telemetryId)
}
})

// Track the usage of config.flags
if (config?.flags) {
telemetry.trackFeatureIsUsed(`ConfigFlags`)
}
}

Expand Down