Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions posthog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
});