export type StorefrontTiktokConversionUserData = {email?: (string | null) | undefined, phone?: (string | null) | undefined, external_id?: (string | null) | undefined, ttclid?: (string | null) | undefined, ttp?: (string | null) | undefined, user_agent?: (string | null) | undefined, ip?: (string | null) | undefined} | {[key: string]: unknown}; export type StorefrontTiktokConversionEvent = {event_id: string, event: string, parameters?: {[key: string]: unknown} | undefined}; export type StorefrontAnalyticsVariantItem = {variant_unique_id: string, quantity: number}; export type StorefrontAnalyticsBundlePriceOptionItem = {bundle_price_option_unique_id: string, quantity: number}; export type StorefrontTiktokConversionEventRequest = {tracking_context?: string | undefined, tracking_trigger?: string | undefined, tracking_asset_id?: number | undefined, tracking_token?: string | undefined, tracking_renderer?: ('vue' | 'html') | undefined, event_source_url: string, referrer_url?: (string | null) | undefined, user: StorefrontTiktokConversionUserData, events: Array, variants?: Array | undefined, bundle_price_options?: Array | undefined} | {[key: string]: unknown}; export type CreateApiV3PagesPageUniqueIdAnalyticsTiktokEventsArgs = {body: StorefrontTiktokConversionEventRequest}; export type CreateApiV3PagesPageUniqueIdAnalyticsTiktokEventsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send a landing page TikTok Events API event * * POST /v3/pages/{page_unique_id}/analytics/tiktok/events */ export const createApiV3PagesPageUniqueIdAnalyticsTiktokEvents = async (args: CreateApiV3PagesPageUniqueIdAnalyticsTiktokEventsArgs, options?: CreateApiV3PagesPageUniqueIdAnalyticsTiktokEventsOptions) => { const {baseUrl = "https://api.scalev.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v3/pages/${encodeURIComponent(String(args.page_unique_id))}/analytics/tiktok/events${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 };