Upload beautify

This commit is contained in:
2026-02-14 15:14:12 +01:00
parent e129618910
commit 79192345e3
249 changed files with 24436 additions and 1021 deletions

View File

@@ -0,0 +1,18 @@
export function sendFeedAnalyticsEvent(payload) {
const endpoint = '/api/analytics/feed'
const body = JSON.stringify(payload)
if (typeof navigator !== 'undefined' && typeof navigator.sendBeacon === 'function') {
const blob = new Blob([body], { type: 'application/json' })
navigator.sendBeacon(endpoint, blob)
return
}
fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
keepalive: true,
}).catch(() => {
})
}

View File

@@ -0,0 +1,24 @@
export function emitUploadEvent(eventName, payload = {}) {
try {
if (typeof window !== 'undefined') {
window.dispatchEvent(
new CustomEvent('skinbase:upload-analytics', {
detail: {
event: eventName,
payload,
timestamp: Date.now(),
},
})
)
}
const endpoint = typeof window !== 'undefined' ? window?.SKINBASE_UPLOAD_ANALYTICS_URL : null
if (endpoint && typeof navigator !== 'undefined' && typeof navigator.sendBeacon === 'function') {
const body = JSON.stringify({ event: eventName, payload, ts: Date.now() })
const blob = new Blob([body], { type: 'application/json' })
navigator.sendBeacon(endpoint, blob)
}
} catch {
// analytics must remain non-blocking
}
}

View File

@@ -0,0 +1,23 @@
export function init() {
return '/api/uploads/init'
}
export function chunk() {
return '/api/uploads/chunk'
}
export function finish() {
return '/api/uploads/finish'
}
export function status(id) {
return `/api/uploads/status/${id}`
}
export function cancel() {
return '/api/uploads/cancel'
}
export function publish(id) {
return `/api/uploads/${id}/publish`
}