-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby): release plugin option validation (#27437)
* chore(gatsby): add @gatsbyVersion pragma to pluginOptionsSchema Node API This will make Gatsby prompt users on old versions of gatsby that don't support the API to upgrade to the new version. * 2.25.0! * Remove GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION feature flag * Fix incorrect option in gatsby-admin; * Fix tests * Remove obsolete snapshots * Trigger Build * Remove flag from remark-autolink-headers * Fix gatsby-plugin-mdx default
- Loading branch information
Showing
24 changed files
with
505 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
process.env.GATSBY_RECIPES_NO_COLOR = "true" | ||
process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION = "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 36 additions & 46 deletions
82
packages/gatsby-plugin-google-analytics/src/gatsby-node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,38 @@ | ||
if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) { | ||
exports.pluginOptionsSchema = ({ Joi }) => | ||
// TODO: make sure that trackingId gets required() when releasing a major version | ||
Joi.object({ | ||
trackingId: Joi.string().description( | ||
`The property ID; the tracking code won't be generated without it` | ||
exports.pluginOptionsSchema = ({ Joi }) => | ||
// TODO: make sure that trackingId gets required() when releasing a major version | ||
Joi.object({ | ||
trackingId: Joi.string().description( | ||
`The property ID; the tracking code won't be generated without it` | ||
), | ||
head: Joi.boolean() | ||
.default(false) | ||
.description( | ||
`Defines where to place the tracking script - \`true\` in the head and \`false\` in the body` | ||
), | ||
head: Joi.boolean() | ||
.default(false) | ||
.description( | ||
`Defines where to place the tracking script - \`true\` in the head and \`false\` in the body` | ||
), | ||
anonymize: Joi.boolean().default(false), | ||
respectDNT: Joi.boolean().default(false), | ||
exclude: Joi.array() | ||
.items(Joi.string()) | ||
.default([]) | ||
.description(`Avoids sending pageview hits from custom paths`), | ||
pageTransitionDelay: Joi.number() | ||
.default(0) | ||
.description( | ||
`Delays sending pageview hits on route update (in milliseconds)` | ||
), | ||
optimizeId: Joi.string().description( | ||
`Enables Google Optimize using your container Id` | ||
anonymize: Joi.boolean().default(false), | ||
respectDNT: Joi.boolean().default(false), | ||
exclude: Joi.array() | ||
.items(Joi.string()) | ||
.default([]) | ||
.description(`Avoids sending pageview hits from custom paths`), | ||
pageTransitionDelay: Joi.number() | ||
.default(0) | ||
.description( | ||
`Delays sending pageview hits on route update (in milliseconds)` | ||
), | ||
experimentId: Joi.string().description( | ||
`Enables Google Optimize Experiment ID` | ||
), | ||
variationId: Joi.string().description( | ||
`Set Variation ID. 0 for original 1,2,3....` | ||
), | ||
defer: Joi.boolean().description( | ||
`Defers execution of google analytics script after page load` | ||
), | ||
sampleRate: Joi.number(), | ||
siteSpeedSampleRate: Joi.number(), | ||
cookieDomain: Joi.string(), | ||
}) | ||
} else { | ||
exports.onPreInit = ({ reporter }, { trackingId } = {}) => { | ||
if (!trackingId) { | ||
reporter.warn( | ||
`The Google Analytics plugin requires a tracking ID. Did you mean to add it?` | ||
) | ||
} | ||
} | ||
} | ||
optimizeId: Joi.string().description( | ||
`Enables Google Optimize using your container Id` | ||
), | ||
experimentId: Joi.string().description( | ||
`Enables Google Optimize Experiment ID` | ||
), | ||
variationId: Joi.string().description( | ||
`Set Variation ID. 0 for original 1,2,3....` | ||
), | ||
defer: Joi.boolean().description( | ||
`Defers execution of google analytics script after page load` | ||
), | ||
sampleRate: Joi.number(), | ||
siteSpeedSampleRate: Joi.number(), | ||
cookieDomain: Joi.string(), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.