MCPcopy Create free account
hub / github.com/pollinations/pollinations / sendErrorEventToTinybird

Function sendErrorEventToTinybird

shared/events.ts:94–121  ·  view source on GitHub ↗
(
    event: TinybirdErrorEvent,
    tinybirdIngestUrl: string,
    tinybirdIngestToken: string,
    log: Logger,
)

Source from the content-addressed store, hash-verified

92}
93
94export async function sendErrorEventToTinybird(
95 event: TinybirdErrorEvent,
96 tinybirdIngestUrl: string,
97 tinybirdIngestToken: string,
98 log: Logger,
99): Promise<void> {
100 const body = JSON.stringify(removeUnset(event));
101
102 try {
103 const response = await fetch(tinybirdIngestUrl, {
104 method: "POST",
105 headers: {
106 Authorization: `Bearer ${tinybirdIngestToken}`,
107 "Content-Type": "application/x-ndjson",
108 },
109 body,
110 signal: AbortSignal.timeout(5000),
111 });
112
113 if (!response.ok) {
114 log.warn("Tinybird error event ingest failed: status={status}", {
115 status: response.status,
116 });
117 }
118 } catch (error) {
119 log.warn("Tinybird error event ingest failed: {error}", { error });
120 }
121}
122
123export function getTinybirdDatasourceIngestUrl(
124 referenceIngestUrl: string,

Callers 2

emitServerErrorFunction · 0.90
events.test.tsFile · 0.90

Calls 4

removeUnsetFunction · 0.90
stringifyMethod · 0.80
warnMethod · 0.80
fetchFunction · 0.50

Tested by

no test coverage detected