UNPKG

@nuxtjs/web-vitals

Version:
19 lines (18 loc) 492 B
import { webVitals } from "./web-vitals.mjs"; import { sendToAnalytics } from "~web-vitals-provider"; import webVitalsOptions from "#build/web-vitals-config.mjs"; const sendVitals = (to) => webVitals({ options: webVitalsOptions, sendToAnalytics, route: to }); export default function(ctx) { const router = ctx.app && ctx.app.router || ctx.$router; if (!router) { return; } router.onReady((to) => { sendVitals(to); router.afterEach((to2) => sendVitals(to2)); }); }