mirror of
https://github.com/bartvdbraak/hellob.art.git
synced 2025-04-26 09:01:21 +00:00
refactor: prettier format fixes
This commit is contained in:
parent
95d99e0970
commit
5b6289b665
3 changed files with 79 additions and 73 deletions
|
@ -58,6 +58,7 @@ I'm open to contributions! If you find any bugs, have suggestions, or want to ad
|
|||
This project is licensed under the GPLv3 License. Feel free to explore, learn, and have fun!
|
||||
|
||||
Some dependencies may hold different licenses but are in compliance with GPLv3:
|
||||
|
||||
- `MIT`: Compatible with GPLv3.
|
||||
- `Apache 2.0`: Compatible with GPLv3.
|
||||
- `BSD-3-Clause`: Compatible with GPLv3.
|
||||
|
|
|
@ -14,17 +14,22 @@ interface NavigatorWithConnection extends Navigator {
|
|||
type Params = Record<string, any>; // Define a type for 'params'
|
||||
|
||||
function getConnectionSpeed() {
|
||||
return 'connection' in navigator && 'connection' && 'effectiveType' in (navigator as NavigatorWithConnection).connection
|
||||
return 'connection' in navigator &&
|
||||
'connection' &&
|
||||
'effectiveType' in (navigator as NavigatorWithConnection).connection
|
||||
? (navigator as NavigatorWithConnection).connection.effectiveType
|
||||
: '';
|
||||
}
|
||||
|
||||
function sendToAnalytics(metric: Metric, options: {
|
||||
function sendToAnalytics(
|
||||
metric: Metric,
|
||||
options: {
|
||||
params: Params;
|
||||
path: string;
|
||||
analyticsId: string;
|
||||
debug: boolean;
|
||||
}) {
|
||||
}
|
||||
) {
|
||||
const page = Object.entries(options.params).reduce(
|
||||
(acc, [key, value]) => acc.replace(value, `[${key}]`),
|
||||
options.path
|
||||
|
@ -37,7 +42,7 @@ function sendToAnalytics(metric: Metric, options: {
|
|||
href: location.href,
|
||||
event_name: metric.name,
|
||||
value: metric.value.toString(),
|
||||
speed: getConnectionSpeed(),
|
||||
speed: getConnectionSpeed()
|
||||
};
|
||||
|
||||
if (options.debug) {
|
||||
|
@ -49,7 +54,7 @@ function sendToAnalytics(metric: Metric, options: {
|
|||
|
||||
// The type 'Record<string, string>' is compatible with 'URLSearchParams'
|
||||
const blob = new Blob([searchParams.toString()], {
|
||||
type: 'application/x-www-form-urlencoded',
|
||||
type: 'application/x-www-form-urlencoded'
|
||||
});
|
||||
if (navigator.sendBeacon) {
|
||||
navigator.sendBeacon(vitalsUrl, blob);
|
||||
|
@ -58,7 +63,7 @@ function sendToAnalytics(metric: Metric, options: {
|
|||
body: blob,
|
||||
method: 'POST',
|
||||
credentials: 'omit',
|
||||
keepalive: true,
|
||||
keepalive: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue