From 3b4ec19d6ff0acacce0c01c9ba3b3041f88b693f Mon Sep 17 00:00:00 2001 From: Mo King Date: Mon, 13 Oct 2025 12:42:01 -0400 Subject: [PATCH 1/4] attempt to set up posthog feedback listener events --- feedback-analytics.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 feedback-analytics.js diff --git a/feedback-analytics.js b/feedback-analytics.js new file mode 100644 index 00000000..926324bb --- /dev/null +++ b/feedback-analytics.js @@ -0,0 +1,28 @@ + +document.addEventListener('DOMContentLoaded', (event) => { + // Function to handle feedback clicks + const handleFeedback = (isHelpful) => { + const pagePath = window.location.pathname; + posthog.capture('Feedback Submitted', { + page: pagePath, + helpful: isHelpful + }); + }; + + // Find the feedback buttons. + // Note: This is a best-effort attempt to find the buttons. + // If this doesn't work, you may need to provide more specific CSS selectors. + const feedbackContainer = document.querySelector('.feedback-toolbar'); + if (feedbackContainer) { + const yesButton = Array.from(feedbackContainer.querySelectorAll('button')).find(button => button.textContent.trim() === 'Yes'); + const noButton = Array.from(feedbackContainer.querySelectorAll('button')).find(button => button.textContent.trim() === 'No'); + + if (yesButton) { + yesButton.addEventListener('click', () => handleFeedback(true)); + } + + if (noButton) { + noButton.addEventListener('click', () => handleFeedback(false)); + } + } +}); From 3c0d9c380e005606d487ecdd7d2909d8ad559f22 Mon Sep 17 00:00:00 2001 From: Mo King Date: Mon, 13 Oct 2025 12:44:49 -0400 Subject: [PATCH 2/4] Add console.log --- feedback-analytics.js | 1 + 1 file changed, 1 insertion(+) diff --git a/feedback-analytics.js b/feedback-analytics.js index 926324bb..4fab0e02 100644 --- a/feedback-analytics.js +++ b/feedback-analytics.js @@ -2,6 +2,7 @@ document.addEventListener('DOMContentLoaded', (event) => { // Function to handle feedback clicks const handleFeedback = (isHelpful) => { + console.log('Feedback button clicked!', { page: window.location.pathname, helpful: isHelpful }); const pagePath = window.location.pathname; posthog.capture('Feedback Submitted', { page: pagePath, From bcf221026ff2e7319a77cd78d0a693e5eb598bf6 Mon Sep 17 00:00:00 2001 From: Mo King Date: Mon, 13 Oct 2025 12:58:41 -0400 Subject: [PATCH 3/4] Merge posthog files --- feedback-analytics.js | 29 ----------------------------- posthog.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 29 deletions(-) delete mode 100644 feedback-analytics.js diff --git a/feedback-analytics.js b/feedback-analytics.js deleted file mode 100644 index 4fab0e02..00000000 --- a/feedback-analytics.js +++ /dev/null @@ -1,29 +0,0 @@ - -document.addEventListener('DOMContentLoaded', (event) => { - // Function to handle feedback clicks - const handleFeedback = (isHelpful) => { - console.log('Feedback button clicked!', { page: window.location.pathname, helpful: isHelpful }); - const pagePath = window.location.pathname; - posthog.capture('Feedback Submitted', { - page: pagePath, - helpful: isHelpful - }); - }; - - // Find the feedback buttons. - // Note: This is a best-effort attempt to find the buttons. - // If this doesn't work, you may need to provide more specific CSS selectors. - const feedbackContainer = document.querySelector('.feedback-toolbar'); - if (feedbackContainer) { - const yesButton = Array.from(feedbackContainer.querySelectorAll('button')).find(button => button.textContent.trim() === 'Yes'); - const noButton = Array.from(feedbackContainer.querySelectorAll('button')).find(button => button.textContent.trim() === 'No'); - - if (yesButton) { - yesButton.addEventListener('click', () => handleFeedback(true)); - } - - if (noButton) { - noButton.addEventListener('click', () => handleFeedback(false)); - } - } -}); diff --git a/posthog.js b/posthog.js index f08ba7f7..71e5a2b4 100644 --- a/posthog.js +++ b/posthog.js @@ -45,3 +45,34 @@ defaults: "2025-05-24", person_profiles: "identified_only", // or 'always' to create profiles for anonymous users as well }); + +document.addEventListener('DOMContentLoaded', (event) => { + // Function to handle feedback clicks + const handleFeedback = (isHelpful) => { + console.log('Feedback button clicked!', { page: window.location.pathname, helpful: isHelpful }); + const pagePath = window.location.pathname; + if (window.posthog) { + posthog.capture('Feedback Submitted', { + page: pagePath, + helpful: isHelpful + }); + } + }; + + // Find the feedback buttons. + // Note: This is a best-effort attempt to find the buttons. + // If this doesn't work, you may need to provide more specific CSS selectors. + const feedbackContainer = document.querySelector('.feedback-toolbar'); + if (feedbackContainer) { + const yesButton = Array.from(feedbackContainer.querySelectorAll('button')).find(button => button.textContent.trim() === 'Yes'); + const noButton = Array.from(feedbackContainer.querySelectorAll('button')).find(button => button.textContent.trim() === 'No'); + + if (yesButton) { + yesButton.addEventListener('click', () => handleFeedback(true)); + } + + if (noButton) { + noButton.addEventListener('click', () => handleFeedback(false)); + } + } +}); \ No newline at end of file From aeac83166338a6350bf99893b97dc78a89cb98dd Mon Sep 17 00:00:00 2001 From: Mo King Date: Mon, 13 Oct 2025 13:13:13 -0400 Subject: [PATCH 4/4] Update --- posthog.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/posthog.js b/posthog.js index 71e5a2b4..6dcf9976 100644 --- a/posthog.js +++ b/posthog.js @@ -60,8 +60,6 @@ document.addEventListener('DOMContentLoaded', (event) => { }; // Find the feedback buttons. - // Note: This is a best-effort attempt to find the buttons. - // If this doesn't work, you may need to provide more specific CSS selectors. const feedbackContainer = document.querySelector('.feedback-toolbar'); if (feedbackContainer) { const yesButton = Array.from(feedbackContainer.querySelectorAll('button')).find(button => button.textContent.trim() === 'Yes');