pages/ValuePartnership/GlobePage/pointTracking.jsjavascript
// content headlines carry inline markup (<sup>, <sub>, &nbsp;) - tracking wants plain text
const plainText = (html) =>
  html
    ? html
        .replace(/<[^>]*>/g, "")
        .replace(/&nbsp;/g, " ")
        .replace(/\s+/g, " ")
        .trim() || null
    : null;

/**
 * Tracking payload of a globe point, shared by every globe_* event: the id
 * plus the names an evaluation needs without looking the id up - the case
 * title (the details headline, else the preview teaser's; impact points
 * usually have neither, so null), customer and country.
 *
 * @param {object} point a content.valuePartnership.points entry
 * @returns {{pointId: string, type: string, caseTitle: ?string, customer: ?string, country: ?string}}
 */
export const pointTrackingInfo = (point) => ({
  pointId: point.id,
  type: point.type,
  caseTitle: plainText(point.headline || point.figure?.headline),
  customer: point.customer || null,
  country: point.country || null,
});