mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[cli] Ignore VERCEL_ANALYTICS_ID if @vercel/speed-insights is present on the project (#11305)
In the past, we used the `VERCEL_ANALYTICS_ID` environment variable with the previous Speed Insights feature on Vercel to activate specific logic in Next.js, Nuxt and Gatsby for collecting and sending web vitals data. With the new Speed Insights, that's not required anymore. We no longer want to set the environment variable when detecting the new `@vercel/speed-insights` package. This PR confirms that the variable is not set if the new package is detected.
This commit is contained in:
54
packages/static-build/test/builds.test.js
vendored
54
packages/static-build/test/builds.test.js
vendored
@@ -328,6 +328,60 @@ export default vercelConfig;
|
||||
FOUR_MINUTES
|
||||
);
|
||||
|
||||
describe('when @vercel/speed-insights is present', () => {
|
||||
it(
|
||||
'Should build Gatsby without the "@vercel/gatsby-plugin-vercel-analytics" plugin',
|
||||
async () => {
|
||||
const { workPath } = await runBuildLambda(
|
||||
path.join(
|
||||
__dirname,
|
||||
'build-fixtures/15-gatsby-default-with-speed-insights-package'
|
||||
)
|
||||
);
|
||||
|
||||
const contents = await fs.readdir(workPath);
|
||||
|
||||
expect(contents.some(name => name === 'gatsby-config.js')).toBeTruthy();
|
||||
|
||||
expect(require(path.join(workPath, 'gatsby-config.js')))
|
||||
.toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"plugins": Array [],
|
||||
}
|
||||
`);
|
||||
|
||||
expect(warnSpy).not.toHaveBeenCalledWith(
|
||||
'Vercel Speed Insights auto-injection is deprecated in favor of @vercel/speed-insights package. Learn more: https://vercel.link/upgrate-to-speed-insights-package'
|
||||
);
|
||||
},
|
||||
FOUR_MINUTES
|
||||
);
|
||||
|
||||
it(
|
||||
'Should build Nuxt.js without the "@nuxtjs/web-vitals" plugin',
|
||||
async () => {
|
||||
const fixture = path.join(
|
||||
__dirname,
|
||||
'build-fixtures/16-nuxtjs-default-with-speed-insights-package'
|
||||
);
|
||||
const { workPath } = await runBuildLambda(fixture);
|
||||
|
||||
// The `.nuxtrc` file should not contain the plugin in `modules[]`
|
||||
const rc = await fs.readFile(path.join(workPath, '.nuxtrc'), 'utf8');
|
||||
expect(rc.includes('modules[]=@nuxtjs/web-vitals')).toBeFalsy();
|
||||
|
||||
// The `package.json` file should not have the plugin listed as a dependency
|
||||
const pkg = require(path.join(workPath, 'package.json'));
|
||||
expect(pkg.dependencies['@nuxtjs/web-vitals']).toBe(undefined);
|
||||
|
||||
expect(warnSpy).not.toHaveBeenCalledWith(
|
||||
'Vercel Speed Insights auto-injection is deprecated in favor of @vercel/speed-insights package. Learn more: https://vercel.link/upgrate-to-speed-insights-package'
|
||||
);
|
||||
},
|
||||
FOUR_MINUTES
|
||||
);
|
||||
});
|
||||
|
||||
it(
|
||||
'Should build Nuxt.js with "@nuxtjs/web-vitals" plugin',
|
||||
async () => {
|
||||
|
||||
Reference in New Issue
Block a user