{"webLayers":[{"_id":"6939b797951bb0266c75d32d","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"url":"/shop/c/","type":"contains"},{"url":"/p/","type":"contains"}],"exclude_pages":null},"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":{"conditions":[{"attribute":{"id":"68023a615a9340075b9c45f7","type":"page_variable"},"constraint":{"operands":[{"type":"constant","value":"parts"}],"operator":"does not contain","type":"string"}},{"attribute":{"id":"68023a615a9340075b9c45f7","type":"page_variable"},"constraint":{"operands":[{"type":"constant","value":"bikes"}],"operator":"does not contain","type":"string"}}]},"page_vars":[]},{"_id":"69a984e32968473d323c9932","date_filter":{"enabled":false,"from_date":null,"to_date":null},"trigger":{"include_pages":[{"type":"any"}],"exclude_pages":null},"device_target":{"type":"any"},"frequency":"always","uses_personalization":true,"data":"","variables_target":null,"page_vars":[]}],"experiments":[],"constantManagedTags":[{"uses_overlay":false,"type":"js","parametrized_definition":"console.log('[Ref] Clarity - PDP Embedded Trigger Tag - QA (New Site)');\n /****************************************************************************************\n *                      \t\t EDIT THIS CODE\n ****************************************************************************************/\n\n/**\n * DISCLAIMER: MUST return a BOOLEAN\n *\n * Return TRUE if all triggering conditions are met\n * If TRUE Clarity will display\n * Don't show on parts\n */\nfunction additionalTriggeringConditions() {\n\t// const page = window.hd.dl.page || {};\n //   const categoryMap = page.name \u0026\u0026 page.name.split(\":\");\n //   const category_level_1 = categoryMap \u0026\u0026 categoryMap[0] ? categoryMap[0].trim().toLowerCase() : \"\";\n //   console.log('additionalTriggerConditions', category_level_1, !category_level_1.includes('parts'));\n //   console.log('additionalTriggerConditions', category_level_1, !category_level_1.includes('bikes'));\n\n //   if (!category_level_1.includes('parts') \u0026\u0026 !category_level_1.includes('bikes')) {\n //   \treturn true;\n //   }\n\t// return false;\n\ttrue;\n}\n\n/****************************************************************************************\n *                        DO NOT EDIT THIS CODE\n ****************************************************************************************/\n/** Tag parameters */\nconst clarityWeblayerId = \"687908d6a4d9224e3c531420\";\nconst displayWithNoProductID = \"true\";\n\n\nfunction getProductIds() {\n\treturn window.CLARITY_GLOBAL_CONFIG?.pageApi?.getProductIds();\n}\n\nfunction getPageType() {\n\treturn window.CLARITY_GLOBAL_CONFIG?.pageApi?.getPageType();\n}\n\nfunction pageApiExists() {\n\treturn window.CLARITY_GLOBAL_CONFIG?.pageApi?.isAvailable();\n}\n\n\nasync function pollWithTimeout(fn, predicate, name, interval = 10, timeout = 3000) {\n  const endTime = Date.now() + timeout;\n\n  while (Date.now() \u003c endTime) {\n    const result = await fn();\n    if (predicate(result)) {\n      return result;\n    }\n    await new Promise((resolve) =\u003e setTimeout(resolve, interval));\n  }\n\n  throw new Error(`Timeout: ${name} not found`);\n}\n\n/**\n * Simply returns the persisted clarityEnabled value.\n * (This value is assigned by the first code and stored in CLARITY_GLOBAL_CONFIG.enabled.)\n */\nfunction clarityEnabled() {\n    return window.CLARITY_GLOBAL_CONFIG \u0026\u0026 window.CLARITY_GLOBAL_CONFIG.enabled\n           ? window.CLARITY_GLOBAL_CONFIG.enabled\n           : null;\n}\n\n/**\n * Checks that Clarity is healthy and the global Clarity variant is assigned to the user\n */\nasync function clarityReadyCheck() {\n\tawait pollWithTimeout(\n\t\t() =\u003e { return window.CLARITY_GLOBAL_CONFIG \u0026\u0026 window.CLARITY_GLOBAL_CONFIG.health === 'ok' \u0026\u0026 window.CLARITY_GLOBAL_CONFIG.clarityWorkingHours === 'ok' \u0026\u0026 !!clarityEnabled() },\n\t\t(result) =\u003e result === true,\n\t\t'healthcheck'\n\t);\n}\n\nfunction checkProductIds(prodIds) {\n\treturn prodIds !== null \u0026\u0026 prodIds !== undefined;\n}\n\n// use force instead of displayWithNoProductID for cases like displayWithNoProductID is true and productIds is returning array value or empty string\nfunction launchClarity(force = false) {\n\t/** Retrieve product IDs and custom conditions */\n\tlet productIds = getProductIds();\n\tif (!force \u0026\u0026 (productIds === null || productIds === undefined)) {\n\t\treturn;\n\t}\n\tconst shouldTrigger = additionalTriggeringConditions();\n\n\t/** Decide whether to show Clarity */\n\tif (shouldTrigger) {\n\t\tif (typeof productIds !== 'string' \u0026\u0026 !force) {\n\t\t\twindow.exponea?.track('clarity', {\n\t\t\t\taction_type: 'clarity_error',\n\t\t\t\tlocation: 'FE:user_passive',\n\t\t\t\ttype: 'getProductIds_not_string',\n\t\t\t\tmessage: productIds,\n\t\t\t\tinteraction: false,\n\t\t\t\tpath: window.location.href,\n\t\t\t});\n\t\t} else if (typeof productIds === 'string' \u0026\u0026 ((productIds \u0026\u0026 productIds.length \u003e 0) || (displayWithNoProductID === 'true'))) {\n\t\t    window.exponea?.showWebLayer(clarityWeblayerId, { product_id: productIds || '', page_type: getPageType() });\n\t\t} else if (productIds?.length === 0 \u0026\u0026 !force) {\n\t\t\twindow.exponea?.track('clarity', {\n\t\t\t\taction_type: 'clarity_error',\n\t\t\t\tlocation: 'FE:user_passive',\n\t\t\t\ttype: 'getProductIds_empty',\n\t\t\t\tmessage: productIds,\n\t\t\t\tinteraction: false,\n\t\t\t\tpath: window.location.href,\n\t\t\t});\n\t\t}\n\t}\n}\n\n\nasync function main() {\n\ttry {\n\t\tawait pollWithTimeout(pageApiExists, value =\u003e value === true, 'pageAPIExists', 10, 5000);\n\t} catch {\n\t\twindow.exponea?.track('clarity', {\n\t\t\taction_type: 'load_failed',\n\t\t\ttype: 'page_api_not_available',\n\t\t\tmessage: 'page_api_not_available',\n\t\t\tinteraction: false,\n\t\t\tpath: window.location.href,\n\t\t});\n\t\treturn;\n\t}\n\n\tif(getPageType() !== 'pdp') {\n\t\twindow.exponea?.track('clarity', {\n\t\t\taction_type: 'load_failed',\n\t\t\ttype: 'not_pdp_page',\n\t\t\tmessage:getPageType(),\n\t\t\tinteraction: false,\n\t\t\tpath: window.location.href,\n\t\t});\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait clarityReadyCheck();\n\t} catch (e) {\n\t\tif (window.CLARITY_GLOBAL_CONFIG){\n\t\t\tif (window.CLARITY_GLOBAL_CONFIG.health !== 'ok') {\n\t\t\t\tconsole.warn('Clarity: Healthcheck failed', window.CLARITY_GLOBAL_CONFIG, e);\n\t\t\t\twindow.exponea?.track('clarity', {\n\t\t\t\t\taction_type: 'load_failed',\n\t\t\t\t\ttype: 'healthcheck_failed',\n\t\t\t\t\tmessage: window.CLARITY_GLOBAL_CONFIG,\n\t\t\t\t\tinteraction: false,\n\t\t\t\t\tpath: window.location.href,\n\t\t\t\t});\n\t\t\t} else if(window.CLARITY_GLOBAL_CONFIG.clarityWorkingHours !== 'ok') {\n\t\t\t\tconsole.warn('Clarity: Outside Working Hours', window.CLARITY_GLOBAL_CONFIG, e);\n\t\t\t\twindow.exponea?.track('clarity', {\n\t\t\t\t\taction_type: 'load_failed',\n\t\t\t\t\ttype: 'outside_working_hours',\n\t\t\t\t\tmessage: window.CLARITY_GLOBAL_CONFIG,\n\t\t\t\t\tinteraction: false,\n\t\t\t\t\tpath: window.location.href,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.warn('Clarity: Global Tag Failed', window.CLARITY_GLOBAL_CONFIG, e);\n\t\t\twindow.exponea?.track('clarity', {\n\t\t\t\taction_type: 'load_failed',\n\t\t\t\ttype: 'global_tag_failed',\n\t\t\t\tmessage: window.CLARITY_GLOBAL_CONFIG,\n\t\t\t\tinteraction: false,\n\t\t\t\tpath: window.location.href,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\tsetTimeout(async () =\u003e {\n\t\ttry {\n\t\t\tawait pollWithTimeout(getProductIds, checkProductIds, 'getProductId', 10, displayWithNoProductID === 'true' ? 300 : 2000);\n\t\t\tlaunchClarity();\n\t\t} catch(err) {\n\t\t\twindow.exponea?.track('clarity', {\n\t\t\t\taction_type: 'clarity_error',\n\t\t\t\tlocation: 'FE:user_passive',\n\t\t\t\ttype: 'getProductIds_fails',\n\t\t\t\tmessage: JSON.stringify(err),\n\t\t\t\tinteraction: false,\n\t\t\t\tpath: window.location.href,\n\t\t\t});\n\t\t\tconsole.warn('Clarity: Unable to fetch productIds', err);\n\t\t\tif (displayWithNoProductID === 'true') {\n\t\t\t\tlaunchClarity(true);\n\t\t\t}\n\t\t}\n\t}, 25);\n\n}\n\nmain();\n","trigger":{"include_pages":[{"url":"qa.harley-davidson.com","type":"contains"}],"exclude_pages":null},"_id":"68790881e20ba426352fb0d0"}],"vars":{"data":[{"id":"68023a615a9340075b9c45f7","name":"PDP Category Level 1","variable":{"type":"custom_function","custom_function":{"body":"function getPageCategory() {\n    const page = window.hd.dl.page || {};\n    const categoryMap = page.name \u0026\u0026 page.name.split(\":\");\n    const category_level_1 = categoryMap \u0026\u0026 categoryMap[0] ? categoryMap[0].trim().toLowerCase() : \"\";\n\n    return category_level_1;\n}\n\nconsole.log('getPageCategory', getPageCategory());\nreturn getPageCategory();"}}}]}}