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

Remove vercel deprecated analytics option #9184

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
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
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
Loading