import { track } from "./track.js";
function setWindowProperties(data) {
// These properties are used by some of our marketing automation tools
if (data?.company?.domain) {
window.sixDomain = data.company.domain; // chili piper
}
if (data?.company?.industry) {
window.sixIndustry = data.company.industry; // VWO for testing personalizations
}
if (data?.segments?.names) {
window.sixSegments = data.segments.names; // ??
}
if (data?.company?.name) {
window.sixName = data.company.name; // ??
}
}
/**
* Add 6sense information as window properties, then send them to our analytics destinations
*
* This function can be used wherever a {@link SixSenseCompanyApiCallback} is required
*
* @example
* window.lr_analytics.init({
* sixSense: {
* enabled: true,
* apiKey: 'xyz',
* companyDetails: {
* enabled: true,
* apiKey: 'xyz',
* callback: window.lr_analytics.sixSenseCallbacks.sendSegmentEvents
* }
* }
* });
*
* @example
* window.lr_analytics.init({
* sixSense: {
* enabled: true,
* apiKey: 'xyz',
* companyDetails: {
* enabled: true,
* apiKey: 'xyz',
* callback: (response) => {
* window.lr_analytics.sixSenseCallbacks.sendSegmentEvents(response);
* // do something else with the response
* }
* }
* }
* });
*
* @param {string} sixSenseResponse - The 6sense company API response
*/
export function sendSegmentEvents(sixSenseResponse) {
const data = JSON.parse(sixSenseResponse);
setWindowProperties(data);
if (data?.company?.domain) {
track("6sense domain", {
domain: data.company.domain,
employees: data.company.employee_count,
hq: data.company.country,
industry: data.company.industry,
});
}
if (data?.segments?.names) {
track("6sense segments", {
segments: data.segments.names.join(","),
});
}
}