Closed feugy closed 9 months ago
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
speed-insights-nextjs | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Dec 13, 2023 1:11pm |
speed-insights-nuxt | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Dec 13, 2023 1:11pm |
speed-insights-remix | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Dec 13, 2023 1:11pm |
speed-insights-sveltekit | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Dec 13, 2023 1:11pm |
speed-insights-vue | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Dec 13, 2023 1:11pm |
Agreed that using a component is better DX!
I'm exploring an alternative approach to address the beforeSend
as props limitation that might be more suitable than excluding that future (in my opinion), although not ideal.
Here's how it would work and how it would be documented:
Note: Because of some limitations (blah blah), if you want to use the
beforeSend
feature, you can define aspeedInsightsBeforeSend
function in an inline script in your Astro page or layout:<script is:inline> function speedInsightsBeforeSend(data){ console.log("Capured event!") return data; } </script>
Here's how the function will be used internally:
// ...
const beforeSend = window.speedInsightsBeforeSend;
injectSpeedInsights({ route, ...props, framework: 'astro', beforeSend });
// ...
Let me know what you think ๐
@MoustaphaDev thanks for the review!
Thats a great idea. I just updated the code to look for window.speedInsightsBeforeSend
to support that!
Updated to latest versions :) Thanks all
๐ What's in there?
This is an initial draft for Astro first-class support.
beforeSend
is supported by usingspeedInsightsBeforeSend
as global window functionTODO list:
๐งช How to test?
There's a new example app, based on the Astro official blog template
pnpm i
apps/astro/src/components/BaseHead.astro
to setscriptSrc="https://va.vercel-scripts.com/v1/speed-insights/script.js"
on the speed insights component. This will attempt to report metrics so we can see the reported payloads.cd apps/astro && pnpm dev
to start the appโ Notes to reviewers