Skip to content

Commit

Permalink
Remove vercel deprecated analytics option (#9184)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Nov 24, 2023
1 parent bd0c2e9 commit a145ac0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-snails-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': major
---

Removes deprecated `analytics` option. Use the `webAnalytics` option instead.
18 changes: 3 additions & 15 deletions packages/integrations/vercel/src/serverless/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ function getAdapter({
}

export interface VercelServerlessConfig {
/**
* @deprecated
*/
analytics?: boolean;

/** Configuration for [Vercel Web Analytics](https://vercel.com/docs/concepts/analytics). */
webAnalytics?: VercelWebAnalyticsConfig;

Expand Down Expand Up @@ -108,7 +103,6 @@ export interface VercelServerlessConfig {
}

export default function vercelServerless({
analytics,
webAnalytics,
speedInsights,
includeFiles,
Expand Down Expand Up @@ -151,21 +145,15 @@ export default function vercelServerless({
);
}

if (webAnalytics?.enabled || analytics) {
if (analytics) {
logger.warn(
`The \`analytics\` property is deprecated. Please use the new \`webAnalytics\` and \`speedInsights\` properties instead.`
);
}

if (webAnalytics?.enabled) {
injectScript(
'head-inline',
await getInjectableWebAnalyticsContent({
mode: command === 'dev' ? 'development' : 'production',
})
);
}
if (command === 'build' && (speedInsights?.enabled || analytics)) {
if (command === 'build' && speedInsights?.enabled) {
injectScript('page', 'import "@astrojs/vercel/speed-insights"');
}
const outDir = getVercelOutput(config.root);
Expand All @@ -178,7 +166,7 @@ export default function vercelServerless({
redirects: false,
},
vite: {
...getSpeedInsightsViteConfig(speedInsights?.enabled || analytics),
...getSpeedInsightsViteConfig(speedInsights?.enabled),
ssr: {
external: ['@vercel/nft'],
},
Expand Down
19 changes: 4 additions & 15 deletions packages/integrations/vercel/src/static/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ function getAdapter(): AstroAdapter {
}

export interface VercelStaticConfig {
/**
* @deprecated
*/
analytics?: boolean;
webAnalytics?: VercelWebAnalyticsConfig;
speedInsights?: VercelSpeedInsightsConfig;
imageService?: boolean;
Expand All @@ -53,7 +49,6 @@ export interface VercelStaticConfig {
}

export default function vercelStatic({
analytics,
webAnalytics,
speedInsights,
imageService,
Expand All @@ -65,22 +60,16 @@ export default function vercelStatic({
return {
name: '@astrojs/vercel',
hooks: {
'astro:config:setup': async ({ command, config, injectScript, updateConfig, logger }) => {
if (webAnalytics?.enabled || analytics) {
if (analytics) {
logger.warn(
`The \`analytics\` property is deprecated. Please use the new \`webAnalytics\` and \`speedInsights\` properties instead.`
);
}

'astro:config:setup': async ({ command, config, injectScript, updateConfig }) => {
if (webAnalytics?.enabled) {
injectScript(
'head-inline',
await getInjectableWebAnalyticsContent({
mode: command === 'dev' ? 'development' : 'production',
})
);
}
if (command === 'build' && (speedInsights?.enabled || analytics)) {
if (command === 'build' && speedInsights?.enabled) {
injectScript('page', 'import "@astrojs/vercel/speed-insights"');
}
const outDir = new URL('./static/', getVercelOutput(config.root));
Expand All @@ -91,7 +80,7 @@ export default function vercelStatic({
redirects: false,
},
vite: {
...getSpeedInsightsViteConfig(speedInsights?.enabled || analytics),
...getSpeedInsightsViteConfig(speedInsights?.enabled),
},
...getAstroImageConfig(
imageService,
Expand Down

0 comments on commit a145ac0

Please sign in to comment.