export type AdHawkDatasetType = 'ImpressionTotals' | 'GenderTotals' | 'DailyImpressions' | 'DwellRange' | 'AgeRange' | 'DayOfWeekByHourHeatmap' | 'ImpressionsByGenderByDay' | 'ImpressionsByAgeGroupByDay' | 'GenderAgeHeatmap' | 'DailyAverageDwell' | 'ImpressionsByDeviceAndPingType' | 'ImpressionsByMedia' | 'EventsTotals' | 'DailyEvents' | 'EventsByEventName' | 'EventsByDeviceName' | 'EventsByDeviceCountry' | 'AverageDwellByEventName' | 'EventsBySession' | 'AverageDwellBySession' | 'AverageEventsByNameAndSession' | 'NetworkPingTotals' | 'NetworkAlertTotals' | 'NetworkAlertsByLocation'; export type AdHawkIntervalType = 'Minute' | 'Hour' | 'Day' | 'Week' | 'Month'; export type AdHawkDatasetPostBody = {dataset_type: AdHawkDatasetType, interval_type?: AdHawkIntervalType | undefined, device_id?: (Array | null) | undefined, start_date?: (string | null) | undefined, end_date?: (string | null) | undefined, compare_start_time?: (string | null) | undefined, compare_end_time?: (string | null) | undefined}; export type CreateApiAdhawkDatasetArgs = {body: AdHawkDatasetPostBody}; export type CreateApiAdhawkDatasetOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns AdHawk dataset based on the provided post parameters. * This is a legacy endpoint that returns raw dataset results. * Consider using the newer typed endpoints for better structure. * * POST /adhawk/dataset * * Also accepts auth: ApiKeyInHeader, ApiKeyInQuery */ export const createApiAdhawkDataset = async (args: CreateApiAdhawkDatasetArgs, options?: CreateApiAdhawkDatasetOptions) => { const {baseUrl = "https://api.reveldigital.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/adhawk/dataset${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 };