import type { WidgetData } from "../../domain"; import { getUserId } from "../UserIdentificationService"; /** * Build a unique storage ID from instanceKey, journey, and userId. * Uses the format: instanceKey:journey:userId (filters out falsy values) * * @param instanceKey - The widget instance key * @param data - The widget data containing journey/form_id and user identification * @returns A colon-separated storage ID string */ export function buildStorageId(instanceKey: string, data: WidgetData): string { const userId = getUserId(data); return [instanceKey, data?.journey, userId].filter(Boolean).join(':'); }