export type CreateApiApiCdpProfilesPublicV1AppAppIdUpdateProfileArgs = {app_id: string, body: {identifiers: {user_id: string} | {cookie_id: unknown}, attributes: {[key: string]: string | number | boolean | string}}}; export type CreateApiApiCdpProfilesPublicV1AppAppIdUpdateProfileOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create or update profile attributes * * POST /api/cdp/profiles/public/v1/app/{app_id}/update-profile */ export const createApiApiCdpProfilesPublicV1AppAppIdUpdateProfile = async (args: CreateApiApiCdpProfilesPublicV1AppAppIdUpdateProfileArgs, options?: CreateApiApiCdpProfilesPublicV1AppAppIdUpdateProfileOptions) => { const {baseUrl = "https://example.piwik.pro", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/cdp/profiles/public/v1/app/${encodeURIComponent(String(args.app_id))}/update-profile${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 };