diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..39bbd26 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,4 @@ +{ + "image": "mcr.microsoft.com/devcontainers/universal:2", + "features": {} +} diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..435338d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms +T2M +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..f014b36 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package ta2ma vers.1 + +on: + push: + branches: [ "principale" ] + pull_request: + branches: [ "principale" ] + +jobs:workflow process services of mailing + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/docs/speed-insights-getting-started.md b/docs/speed-insights-getting-started.md new file mode 100644 index 0000000..bbd2f4a --- /dev/null +++ b/docs/speed-insights-getting-started.md @@ -0,0 +1,541 @@ +# Getting started with Speed Insights + +This guide will help you get started with using Vercel Speed Insights on your project, showing you how to enable it, add the package to your project, deploy your app to Vercel, and view your data in the dashboard. + +To view instructions on using the Vercel Speed Insights in your project for your framework, use the **Choose a framework** dropdown on the right (at the bottom in mobile view). + +## Prerequisites + +- A Vercel account. If you don't have one, you can [sign up for free](https://vercel.com/signup). +- A Vercel project. If you don't have one, you can [create a new project](https://vercel.com/new). +- The Vercel CLI installed. If you don't have it, you can install it using the following command: + +```bash +# Install with pnpm +pnpm i vercel +``` + +```bash +# Install with yarn +yarn i vercel +``` + +```bash +# Install with npm +npm i vercel +``` + +```bash +# Install with bun +bun i vercel +``` + +## Enable Speed Insights in Vercel + +On the [Vercel dashboard](/dashboard), select your Project followed by the **Speed Insights** tab. You can also select the button below to be taken there. Then, select **Enable** from the dialog. + +> **💡 Note:** Enabling Speed Insights will add new routes (scoped at`/_vercel/speed-insights/*`) after your next deployment. + +## Add `@vercel/speed-insights` to your project + +### For Next.js, SvelteKit, Remix, Create React App, Nuxt, Vue, Other, and Astro + +Using the package manager of your choice, add the `@vercel/speed-insights` package to your project: + +```bash +# Install with pnpm +pnpm i @vercel/speed-insights +``` + +```bash +# Install with yarn +yarn i @vercel/speed-insights +``` + +```bash +# Install with npm +npm i @vercel/speed-insights +``` + +```bash +# Install with bun +bun i @vercel/speed-insights +``` + +### For HTML + +**💡 Note:** When using the HTML implementation, there is no need to install the `@vercel/speed-insights` package. + +## Add the `SpeedInsights` component to your app + +### For Next.js (Pages Router) + +The `SpeedInsights` component is a wrapper around the tracking script, offering more seamless integration with Next.js. + +Add the following component to your main app file: + +```typescript +// pages/_app.tsx +import type { AppProps } from 'next/app'; +import { SpeedInsights } from '@vercel/speed-insights/next'; + +function MyApp({ Component, pageProps }: AppProps) { + return ( + <> + + + + ); +} + +export default MyApp; +``` + +```javascript +// pages/_app.jsx +import { SpeedInsights } from "@vercel/speed-insights/next"; + +function MyApp({ Component, pageProps }) { + return ( + <> + + + + ); +} + +export default MyApp; +``` + +For versions of Next.js older than 13.5, import the `` component from `@vercel/speed-insights/react`. Then pass it the pathname of the route, as shown below: + +```typescript +// pages/example-component.tsx +import { SpeedInsights } from "@vercel/speed-insights/react"; +import { useRouter } from "next/router"; + +export default function Layout() { + const router = useRouter(); + + return ; +} +``` + +```javascript +// pages/example-component.jsx +import { SpeedInsights } from "@vercel/speed-insights/react"; +import { useRouter } from "next/router"; + +export default function Layout() { + const router = useRouter(); + + return ; +} +``` + +### For Next.js (App Router) + +The `SpeedInsights` component is a wrapper around the tracking script, offering more seamless integration with Next.js. + +Add the following component to the root layout: + +```typescript +// app/layout.tsx +import { SpeedInsights } from "@vercel/speed-insights/next"; + +export default function RootLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + Next.js + + + {children} + + + + ); +} +``` + +```javascript +// app/layout.jsx +import { SpeedInsights } from "@vercel/speed-insights/next"; + +export default function RootLayout({ children }) { + return ( + + + Next.js + + + {children} + + + + ); +} +``` + +For versions of Next.js older than 13.5, import the `` component from `@vercel/speed-insights/react`. + +Create a dedicated component to avoid opting out from SSR on the layout and pass the pathname of the route to the `SpeedInsights` component: + +```typescript +// app/insights.tsx +"use client"; + +import { SpeedInsights } from "@vercel/speed-insights/react"; +import { usePathname } from "next/navigation"; + +export function Insights() { + const pathname = usePathname(); + + return ; +} +``` + +```javascript +// app/insights.jsx +"use client"; + +import { SpeedInsights } from "@vercel/speed-insights/react"; +import { usePathname } from "next/navigation"; + +export function Insights() { + const pathname = usePathname(); + + return ; +} +``` + +Then, import the `Insights` component in your layout: + +```typescript +// app/layout.tsx +import type { ReactNode } from "react"; +import { Insights } from "./insights"; + +export default function RootLayout({ children }: { children: ReactNode }) { + return ( + + + Next.js + + + {children} + + + + ); +} +``` + +```javascript +// app/layout.jsx +import { Insights } from "./insights"; + +export default function RootLayout({ children }) { + return ( + + + Next.js + + + {children} + + + + ); +} +``` + +### For Create React App + +The `SpeedInsights` component is a wrapper around the tracking script, offering more seamless integration with React. + +Add the following component to the main app file. + +```typescript +// App.tsx +import { SpeedInsights } from '@vercel/speed-insights/react'; + +export default function App() { + return ( +
+ {/* ... */} + +
+ ); +} +``` + +```javascript +// App.jsx +import { SpeedInsights } from "@vercel/speed-insights/react"; + +export default function App() { + return ( +
+ {/* ... */} + +
+ ); +} +``` + +### For Remix + +The `SpeedInsights` component is a wrapper around the tracking script, offering a seamless integration with Remix. + +Add the following component to your root file: + +```typescript +// app/root.tsx +import { SpeedInsights } from '@vercel/speed-insights/remix'; + +export default function App() { + return ( + + + {/* ... */} + + + + ); +} +``` + +```javascript +// app/root.jsx +import { SpeedInsights } from "@vercel/speed-insights/remix"; + +export default function App() { + return ( + + + {/* ... */} + + + + ); +} +``` + +### For SvelteKit + +Add the following component to your root file: + +```typescript +// src/routes/+layout.ts +import { injectSpeedInsights } from "@vercel/speed-insights/sveltekit"; + +injectSpeedInsights(); +``` + +```javascript +// src/routes/+layout.js +import { injectSpeedInsights } from "@vercel/speed-insights/sveltekit"; + +injectSpeedInsights(); +``` + +### For HTML + +Add the following scripts before the closing tag of the ``: + +```html + + + +``` + +### For Vue + +The `SpeedInsights` component is a wrapper around the tracking script, offering more seamless integration with Vue. + +Add the following component to the main app template. + +```typescript + + + + +``` + +```vue + + + + +``` + +### For Nuxt + +The `SpeedInsights` component is a wrapper around the tracking script, offering more seamless integration with Nuxt. + +Add the following component to the default layout. + +```typescript + + + + +``` + +```vue + + + + +``` + +### For Other Frameworks + +Import the `injectSpeedInsights` function from the package, which will add the tracking script to your app. **This should only be called once in your app, and must run in the client**. + +Add the following code to your main app file: + +```typescript +// main.ts +import { injectSpeedInsights } from "@vercel/speed-insights"; + +injectSpeedInsights(); +``` + +```javascript +// main.js +import { injectSpeedInsights } from "@vercel/speed-insights"; + +injectSpeedInsights(); +``` + +### For Astro + +Speed Insights is available for both [static](/docs/frameworks/astro#static-rendering) and [SSR](/docs/frameworks/astro#server-side-rendering) Astro apps. + +To enable this feature, declare the `` component from `@vercel/speed-insights/astro` near the bottom of one of your layout components, such as `BaseHead.astro`: + +```typescript +--- +// BaseHead.astro +import SpeedInsights from '@vercel/speed-insights/astro'; +const { title, description } = Astro.props; +--- +{title} + + + + +``` + +```astro +--- +// BaseHead.astro +import SpeedInsights from '@vercel/speed-insights/astro'; +const { title, description } = Astro.props; +--- +{title} + + + + +``` + +Optionally, you can remove sensitive information from the URL by adding a `speedInsightsBeforeSend` function to the global `window` object. The `` component will call this method before sending any data to Vercel: + +```typescript +--- +// BaseHead.astro +import SpeedInsights from '@vercel/speed-insights/astro'; +const { title, description } = Astro.props; +--- +{title} + + + + + +``` + +```astro +--- +// BaseHead.astro +import SpeedInsights from '@vercel/speed-insights/astro'; +const { title, description } = Astro.props; +--- +{title} + + + + + +``` + +[Learn more about `beforeSend`](/docs/speed-insights/package#beforesend). + +## Deploy your app to Vercel + +You can deploy your app to Vercel's global [CDN](/docs/cdn) by running the following command from your terminal: + +```bash +vercel deploy +``` + +Alternatively, you can [connect your project's git repository](/docs/git#deploying-a-git-repository), which will enable Vercel to deploy your latest pushes and merges to main. + +Once your app is deployed, it's ready to begin tracking performance metrics. + +> **💡 Note:** If everything is set up correctly, you should be able to find the `/_vercel/speed-insights/script.js` script inside the body tag of your page. + +## View your data in the dashboard + +Once your app is deployed, and users have visited your site, you can view the data in the dashboard. + +To do so, go to your [dashboard](/dashboard), select your project, and click the **Speed Insights** tab. + +After a few days of visitors, you'll be able to start exploring your metrics. For more information on how to use Speed Insights, see [Using Speed Insights](/docs/speed-insights/using-speed-insights). + +Learn more about how Vercel supports [privacy and data compliance standards](/docs/speed-insights/privacy-policy) with Vercel Speed Insights. + +## Next steps + +Now that you have Vercel Speed Insights set up, you can explore the following topics to learn more: + +- [Learn how to use the `@vercel/speed-insights` package](/docs/speed-insights/package) +- [Learn about metrics](/docs/speed-insights/metrics) +- [Read about privacy and compliance](/docs/speed-insights/privacy-policy) +- [Explore pricing](/docs/speed-insights/limits-and-pricing) +- [Troubleshooting](/docs/speed-insights/troubleshooting)