mirror of
https://github.com/bartvdbraak/hellob.art.git
synced 2025-05-01 19:41:22 +00:00
fix: rectify typescript rules
This commit is contained in:
parent
8c5bbe2e77
commit
04e711d232
1 changed files with 2 additions and 6 deletions
|
@ -3,15 +3,13 @@ import { onCLS, onFCP, onFID, onLCP, onTTFB } from 'web-vitals';
|
||||||
|
|
||||||
const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals';
|
const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals';
|
||||||
|
|
||||||
// Improve type safety by defining the navigator.connection type
|
|
||||||
interface NavigatorWithConnection extends Navigator {
|
interface NavigatorWithConnection extends Navigator {
|
||||||
connection: {
|
connection: {
|
||||||
effectiveType: string;
|
effectiveType: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
type Params = Record<string, string>;
|
||||||
type Params = Record<string, any>; // Define a type for 'params'
|
|
||||||
|
|
||||||
function getConnectionSpeed() {
|
function getConnectionSpeed() {
|
||||||
return 'connection' in navigator &&
|
return 'connection' in navigator &&
|
||||||
|
@ -49,10 +47,8 @@ function sendToAnalytics(
|
||||||
console.log('[Web Vitals]', metric.name, JSON.stringify(body, null, 2));
|
console.log('[Web Vitals]', metric.name, JSON.stringify(body, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize body to a URLSearchParams object
|
|
||||||
const searchParams = new URLSearchParams(body);
|
const searchParams = new URLSearchParams(body);
|
||||||
|
|
||||||
// The type 'Record<string, string>' is compatible with 'URLSearchParams'
|
|
||||||
const blob = new Blob([searchParams.toString()], {
|
const blob = new Blob([searchParams.toString()], {
|
||||||
type: 'application/x-www-form-urlencoded'
|
type: 'application/x-www-form-urlencoded'
|
||||||
});
|
});
|
||||||
|
@ -69,7 +65,7 @@ function sendToAnalytics(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function webVitals(options: {
|
export function webVitals(options: {
|
||||||
params: Params; // Use the defined 'Params' type here
|
params: Params;
|
||||||
path: string;
|
path: string;
|
||||||
analyticsId: string;
|
analyticsId: string;
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
|
|
Loading…
Reference in a new issue