import { Analytics } from '../../../core/analytics' interface IDemandbaseData { Segments: { IsCompany: boolean CompanyProfile?: { annual_sales: string company_name: string country_name: string demandbase_sid: string employee_count: string industry: string isp: boolean web_site: string } } } declare global { interface Window { Demandbase?: IDemandbaseData } } export async function loadDemandbase(analytics: Analytics): Promise { const Demandbase = window.Demandbase if (!Demandbase) { return } if ( !Demandbase || !Demandbase.Segments || !Demandbase.Segments.IsCompany || !Demandbase.Segments.CompanyProfile || analytics.group().traits()?.website ) { return } const company = Demandbase.Segments.CompanyProfile if (!company.isp && !company.web_site) { return } await analytics.group(company.demandbase_sid, { website: company.web_site, intentSource: 'demandbase', name: company.company_name || undefined, country: company.country_name || undefined, industry: company.industry || undefined, number_of_employees: company.employee_count || undefined, annual_revenue: company.annual_sales || undefined, }) }