export type CreateApiV1LogsArgs = {Authorization: string, body: {[key: string]: unknown}}; export type CreateApiV1LogsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * OTLP logs ingest * * POST /v1/logs */ export const createApiV1Logs = async (args: CreateApiV1LogsArgs, options?: CreateApiV1LogsOptions) => { const {baseUrl = "https://agent.getaxonflow.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/logs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };