export type CreateApiVisitForgetArgs = {'user-agent': string, siteCode: string, body: BodyInit}; export type CreateApiVisitForgetOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Remove data for several visitors * * POST /visit/forget */ export const createApiVisitForget = async (args: CreateApiVisitForgetArgs, options?: CreateApiVisitForgetOptions) => { const {baseUrl = "https://api.kameleoon.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "text/plain") if (args['user-agent'] != null) headers.set("user-agent", String(args['user-agent'])) if (args.siteCode != null) query.append("siteCode", String(args.siteCode)) const url = `${baseUrl.replace(/\/+$/, '')}/visit/forget${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };