UNPKG

@ezbot-ai/javascript-sdk

Version:

The easiest way to interact with ezbot via JS (node and browser)

40 lines (39 loc) 1.53 kB
/// <reference types="node" /> import { Agent as HttpsAgent } from 'https'; import { Prediction, PredictionsResponse } from './types'; export type { Prediction, PredictionsResponse }; export type PredictionsParams = { projectId: number | string; sessionId?: string; userId?: string; pageUrlPath?: string; userAgent?: string; referrer?: string; utmSource?: string; utmMedium?: string; utmCampaign?: string; utmContent?: string; utmTerm?: string; domainSessionIdx?: number; tz?: string; }; export type RequestMeta = { userAgent?: string; referrer?: string; origin?: string; headers?: Record<string, string>; }; export type EzbotServerClientOptions = { baseUrl?: string; timeoutMs?: number; agentOptions?: ConstructorParameters<typeof HttpsAgent>[0]; }; export type EzbotServerClient = { getPredictions: (params: Readonly<PredictionsParams>, meta?: Readonly<RequestMeta>) => Promise<Array<Prediction>>; dispose: () => unknown; }; export declare function extractUtmFromSearchParams(obj: Record<string, string | string[] | undefined>): Pick<PredictionsParams, 'utmSource' | 'utmMedium' | 'utmCampaign' | 'utmContent' | 'utmTerm'>; export declare function buildQueryParams(params: Readonly<PredictionsParams>): string; export declare const DEFAULT_API_BASE_URL = "https://api.ezbot.ai"; export declare function createEzbotClient(options: Readonly<EzbotServerClientOptions>): EzbotServerClient; export declare function generateSessionId(): string;