export type CreateApiEngageProfileListAppendArgs = {ip?: number | undefined, strict?: number | undefined, verbose?: number | undefined, callback?: string | undefined, body: Array<{$token: string, $distinct_id: string, $append: Record}>}; export type CreateApiEngageProfileListAppendOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Append to List Property * * POST /engage#profile-list-append */ export const createApiEngageProfileListAppend = async (args: CreateApiEngageProfileListAppendArgs, options?: CreateApiEngageProfileListAppendOptions) => { const {baseUrl = "https://mixpanel.com/api/query", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/plain") if (args.ip != null) query.append("ip", String(args.ip)) if (args.strict != null) query.append("strict", String(args.strict)) if (args.verbose != null) query.append("verbose", String(args.verbose)) if (args.callback != null) query.append("callback", String(args.callback)) const url = `${baseUrl.replace(/\/+$/, '')}/engage#profile-list-append${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 res.text() };