|
| 1 | +(function () { |
| 2 | + var PRODUCTION_HOST = 'docs.openhands.dev'; |
| 3 | + var SETUP_PATH = '/openhands/usage/agent-canvas/setup'; |
| 4 | + var LINKEDIN_PARTNER_ID = '10045108'; |
| 5 | + var LINKEDIN_CONVERSION_ID = 29318740; |
| 6 | + var initialized = false; |
| 7 | + |
| 8 | + function isSetupPage() { |
| 9 | + return ( |
| 10 | + window.location.hostname === PRODUCTION_HOST && |
| 11 | + window.location.pathname.replace(/\/+$/, '') === SETUP_PATH |
| 12 | + ); |
| 13 | + } |
| 14 | + |
| 15 | + function initializeLinkedIn() { |
| 16 | + if (initialized) return; |
| 17 | + initialized = true; |
| 18 | + |
| 19 | + window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; |
| 20 | + if (window._linkedin_data_partner_ids.indexOf(LINKEDIN_PARTNER_ID) === -1) { |
| 21 | + window._linkedin_data_partner_ids.push(LINKEDIN_PARTNER_ID); |
| 22 | + } |
| 23 | + |
| 24 | + if (!window.lintrk) { |
| 25 | + window.lintrk = function (action, payload) { |
| 26 | + window.lintrk.q.push([action, payload]); |
| 27 | + }; |
| 28 | + window.lintrk.q = []; |
| 29 | + } |
| 30 | + |
| 31 | + if (!document.querySelector('script[src="https://snap.licdn.com/li.lms-analytics/insight.min.js"]')) { |
| 32 | + var script = document.createElement('script'); |
| 33 | + script.async = true; |
| 34 | + script.src = 'https://snap.licdn.com/li.lms-analytics/insight.min.js'; |
| 35 | + document.head.appendChild(script); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + document.addEventListener('click', function (event) { |
| 40 | + if (!isSetupPage() || !(event.target instanceof Element)) return; |
| 41 | + |
| 42 | + var copyButton = event.target.closest( |
| 43 | + 'button[data-testid="copy-code-button"], button[aria-label^="Copy"]', |
| 44 | + ); |
| 45 | + if (!copyButton) return; |
| 46 | + |
| 47 | + initializeLinkedIn(); |
| 48 | + window.lintrk('track', { conversion_id: LINKEDIN_CONVERSION_ID }); |
| 49 | + }); |
| 50 | + |
| 51 | + if (isSetupPage()) initializeLinkedIn(); |
| 52 | +})(); |
0 commit comments