silverwolf-x/project / packages /next /src /telemetry /post-telemetry-payload.ts
silverwolf-x's picture
download
raw
1.09 kB
import retry from 'next/dist/compiled/async-retry'
interface Payload {
meta: { [key: string]: unknown }
context: {
anonymousId: string
projectId: string
sessionId: string
}
events: Array<{
eventName: string
fields: object
}>
}
export function postNextTelemetryPayload(payload: Payload, signal?: any) {
if (!signal && 'timeout' in AbortSignal) {
signal = AbortSignal.timeout(5000)
}
return (
retry(
() =>
fetch('https://telemetry.nextjs.org/api/v1/record', {
method: 'POST',
body: JSON.stringify(payload),
headers: { 'content-type': 'application/json' },
signal,
}).then((res) => {
if (!res.ok) {
const err = new Error(res.statusText)
;(err as any).response = res
throw err
}
}),
{ minTimeout: 500, retries: 1, factor: 1 }
)
.catch(() => {
// We swallow errors when telemetry cannot be sent
})
// Ensure promise is voided
.then(
() => {},
() => {}
)
)
}

Xet Storage Details

Size:
1.09 kB
·
Xet hash:
5c2811fc8caf405eb96e5bc183cc2ee3fa9fd7917687e58c02a781ab1dbe9c3c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.