mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
Support deprecating Web Vitals table (#11096)
This commit is contained in:
parent
8e465d621e
commit
0dbd8eeb77
4 changed files with 57 additions and 1 deletions
5
.changeset/good-turtles-guess.md
Normal file
5
.changeset/good-turtles-guess.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/web-vitals": patch
|
||||
---
|
||||
|
||||
Adds support for deprecating the web vitals DB table, so the integration can be removed if desired
|
|
@ -27,6 +27,55 @@ This **[Astro integration][astro-integration]** enables tracking real-world webs
|
|||
|
||||
Learn more about [Astro DB](https://docs.astro.build/en/guides/astro-db/) and [deploying with Astro Studio](https://docs.astro.build/en/guides/astro-db/#astro-studio) in the Astro docs.
|
||||
|
||||
## Uninstalling
|
||||
|
||||
To remove the Web Vitals integration, follow the Astro DB deprecation process:
|
||||
|
||||
1. Mark the integration as deprecated in `astro.config.mjs`, by setting the `deprecated` option to `true`:
|
||||
|
||||
```js
|
||||
import db from '@astrojs/db';
|
||||
import webVitals from '@astrojs/web-vitals';
|
||||
import { defineConfig } from 'astro/config';
|
||||
|
||||
export default defineConfig({
|
||||
integrations: [
|
||||
db(),
|
||||
// Mark the web vitals integration as deprecated:
|
||||
webVitals({ deprecated: true }),
|
||||
],
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
2. Push the deprecation to Astro Studio:
|
||||
|
||||
```sh
|
||||
npx astro db push
|
||||
```
|
||||
|
||||
3. Remove the web vitals integration in `astro.config.mjs`:
|
||||
|
||||
```diff
|
||||
import db from '@astrojs/db';
|
||||
- import webVitals from '@astrojs/web-vitals';
|
||||
import { defineConfig } from 'astro/config';
|
||||
|
||||
export default defineConfig({
|
||||
integrations: [
|
||||
db(),
|
||||
- webVitals({ deprecated: true }),
|
||||
],
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
4. Push the table deletion to Astro Studio:
|
||||
|
||||
```sh
|
||||
npx astro db push
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
- Get help in the [Astro Discord][discord]. Post questions in our `#support` forum, or visit our dedicated `#dev` channel to discuss current development and more!
|
||||
|
|
|
@ -11,6 +11,7 @@ const Metric = defineTable({
|
|||
rating: column.text(),
|
||||
timestamp: column.date(),
|
||||
},
|
||||
deprecated: Boolean(process.env.DEPRECATE_WEB_VITALS) ?? false,
|
||||
});
|
||||
|
||||
// export const AstrojsWebVitals_Metric = asDrizzleTable('AstrojsWebVitals_Metric', Metric);
|
||||
|
|
|
@ -2,7 +2,8 @@ import { defineDbIntegration } from '@astrojs/db/utils';
|
|||
import { AstroError } from 'astro/errors';
|
||||
import { WEB_VITALS_ENDPOINT_PATH } from './constants.js';
|
||||
|
||||
export default function webVitals() {
|
||||
export default function webVitals({ deprecated }: { deprecated?: boolean } = {}) {
|
||||
process.env.DEPRECATE_WEB_VITALS = deprecated ? 'true' : undefined;
|
||||
return defineDbIntegration({
|
||||
name: '@astrojs/web-vitals',
|
||||
hooks: {
|
||||
|
|
Loading…
Add table
Reference in a new issue