MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / sendEvent

Function sendEvent

scripts/seed-events.mjs:438–458  ·  view source on GitHub ↗
(payload, ua, ip)

Source from the content-addressed store, hash-verified

436// ---------------------------------------------------------------------------
437
438async function sendEvent(payload, ua, ip) {
439 const headers = {
440 'Content-Type': 'application/json',
441 'user-agent': ua,
442 'openpanel-client-id': CLIENT_ID,
443 'x-forwarded-for': ip,
444 origin: ORIGIN,
445 };
446
447 const res = await fetch(TRACK_URL, {
448 method: 'POST',
449 headers,
450 body: JSON.stringify(payload),
451 });
452
453 if (!res.ok) {
454 const text = await res.text().catch(() => '');
455 console.warn(` [WARN] ${res.status} ${payload.type}/${payload.payload?.name ?? ''}: ${text.slice(0, 120)}`);
456 }
457 return res;
458}
459
460// ---------------------------------------------------------------------------
461// Build session event list

Callers 1

mainFunction · 0.85

Calls 4

fetchFunction · 0.50
stringifyMethod · 0.45
catchMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected