export type ExperimentAudienceFilter = {type: 'EXPERIMENT' | 'GOAL' | 'PERSONALIZATION' | 'SEGMENT_CRITERIA' | 'SEGMENT' | 'FAVORITE', id: number, variationIds?: Array | undefined, include?: boolean | undefined}; export type FavoriteAudienceFilter = {type: 'EXPERIMENT' | 'GOAL' | 'PERSONALIZATION' | 'SEGMENT_CRITERIA' | 'SEGMENT' | 'FAVORITE', include?: boolean | undefined}; export type GoalAudienceFilter = {type: 'EXPERIMENT' | 'GOAL' | 'PERSONALIZATION' | 'SEGMENT_CRITERIA' | 'SEGMENT' | 'FAVORITE', ids?: Array | undefined, include?: boolean | undefined}; export type PersonalizationAudienceFilter = {type: 'EXPERIMENT' | 'GOAL' | 'PERSONALIZATION' | 'SEGMENT_CRITERIA' | 'SEGMENT' | 'FAVORITE', include?: boolean | undefined, id: number, exposition: 'ALL' | 'EXPOSED' | 'NOT_EXPOSED'}; export type SegmentAudienceFilter = {type: 'EXPERIMENT' | 'GOAL' | 'PERSONALIZATION' | 'SEGMENT_CRITERIA' | 'SEGMENT' | 'FAVORITE', ids: Array, include?: boolean | undefined}; export type Filter = {type: string}; export type SegmentCriteriaAudienceFilter = {type: 'EXPERIMENT' | 'GOAL' | 'PERSONALIZATION' | 'SEGMENT_CRITERIA' | 'SEGMENT' | 'FAVORITE', criterias: Array}; export type GetSegmentsGlobalStatsRequest = {siteId: number, startDate: string, endDate: string, analyticsLevel: 'VISIT' | 'VISITOR', filters?: (Array) | undefined}; export type GetApiAudiencesGlobalArgs = {request: GetSegmentsGlobalStatsRequest}; export type GetApiAudiencesGlobalOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get global audience * * GET /audiences/global */ export const getApiAudiencesGlobal = async (args: GetApiAudiencesGlobalArgs, options?: GetApiAudiencesGlobalOptions) => { const {baseUrl = "https://api.kameleoon.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.request != null) query.append("request", JSON.stringify(args.request)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/audiences/global${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };