diff --git a/posthog.js b/posthog.js index f08ba7f7..6dcf9976 100644 --- a/posthog.js +++ b/posthog.js @@ -45,3 +45,32 @@ 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. + 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