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
16 changes: 16 additions & 0 deletions src/js/ai-expert-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ document.addEventListener('DOMContentLoaded', function() {
}
modal.addEventListener('click', function(e) {
if (e.target === modal) closeModal();
// Track outbound link clicks within Expert modal
const link = e.target.closest('a[href]');
if (link && link.hostname !== location.hostname && typeof capture === 'function') {
capture('expert-app-link-clicked', { url: link.href, page: location.pathname });
}
});

// Handle prompt pill clicks
Expand Down Expand Up @@ -418,6 +423,8 @@ document.addEventListener('DOMContentLoaded', function() {
sessionId = crypto.randomUUID();
transferPayload = []

if (typeof capture === 'function') capture('expert-modal-opened', { has_prompt: !!userText, page: location.pathname });

// Reset auto-scroll to enabled when opening modal
autoScrollEnabled = true;

Expand Down Expand Up @@ -527,6 +534,9 @@ document.addEventListener('DOMContentLoaded', function() {
}

function closeModal() {
const userMsgCount = messages.filter(m => m.role === 'human').length;
if (typeof capture === 'function') capture('expert-modal-closed', { messages_sent: userMsgCount, page: location.pathname });

const homeTextarea = document.querySelector('textarea[aria-label="Describe your workflow"]');
const homeTextareaWrapper = homeTextarea ? homeTextarea.closest('.textarea-wrapper') : null;
const modalInputSection = modal.querySelector('.p-4.bg-white.rounded-b-none.md\\:rounded-b-lg');
Expand Down Expand Up @@ -1267,6 +1277,9 @@ document.addEventListener('DOMContentLoaded', function() {
const message = modalInput.value.trim();
if (!message) return; // Don't send empty messages

const msgIndex = messages.filter(m => m.role === 'human').length + 1;
if (typeof capture === 'function') capture('expert-message-sent', { message_index: msgIndex, page: location.pathname });

// Clear the input
modalInput.value = '';

Expand Down Expand Up @@ -1365,6 +1378,9 @@ document.addEventListener('DOMContentLoaded', function() {
e.preventDefault();
const message = modalInput.value.trim();
if (message) {
const msgIndex = messages.filter(m => m.role === 'human').length + 1;
if (typeof capture === 'function') capture('expert-message-sent', { message_index: msgIndex, page: location.pathname });

modalInput.value = '';


Expand Down
Loading