Skip to content

Commit ef88d4e

Browse files
feat: track Agent Canvas copy conversions (#901)
Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 605ea3e commit ef88d4e

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

‎docs.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,13 @@
721721
"src": "/openhands/canvas-handoff.js",
722722
"defer": "true"
723723
}
724+
},
725+
{
726+
"tag": "script",
727+
"attributes": {
728+
"src": "/openhands/linkedin-copy-tracking.js",
729+
"defer": "true"
730+
}
724731
}
725732
],
726733
"contextual": {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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

Comments
 (0)