213 lines
7.9 KiB
HTML
213 lines
7.9 KiB
HTML
|
|
<!DOCTYPE html>
|
|||
|
|
<html lang="ru">
|
|||
|
|
<head>
|
|||
|
|
<meta charset="UTF-8">
|
|||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|||
|
|
<title>Отладка AI Drawer</title>
|
|||
|
|
<style>
|
|||
|
|
body {
|
|||
|
|
font-family: Arial, sans-serif;
|
|||
|
|
padding: 20px;
|
|||
|
|
background-color: #f5f5f5;
|
|||
|
|
}
|
|||
|
|
.debug-panel {
|
|||
|
|
background: white;
|
|||
|
|
padding: 20px;
|
|||
|
|
border-radius: 10px;
|
|||
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|||
|
|
margin-bottom: 20px;
|
|||
|
|
}
|
|||
|
|
.test-button {
|
|||
|
|
background: #2196f3;
|
|||
|
|
color: white;
|
|||
|
|
border: none;
|
|||
|
|
padding: 10px 20px;
|
|||
|
|
border-radius: 5px;
|
|||
|
|
cursor: pointer;
|
|||
|
|
margin: 5px;
|
|||
|
|
}
|
|||
|
|
.test-button:hover {
|
|||
|
|
background: #1976d2;
|
|||
|
|
}
|
|||
|
|
.log {
|
|||
|
|
background: #f8f9fa;
|
|||
|
|
padding: 10px;
|
|||
|
|
border-radius: 5px;
|
|||
|
|
margin: 10px 0;
|
|||
|
|
font-family: monospace;
|
|||
|
|
font-size: 12px;
|
|||
|
|
white-space: pre-wrap;
|
|||
|
|
max-height: 300px;
|
|||
|
|
overflow-y: auto;
|
|||
|
|
}
|
|||
|
|
.error {
|
|||
|
|
background: #ffebee;
|
|||
|
|
color: #c62828;
|
|||
|
|
}
|
|||
|
|
.success {
|
|||
|
|
background: #e8f5e8;
|
|||
|
|
color: #2e7d32;
|
|||
|
|
}
|
|||
|
|
</style>
|
|||
|
|
</head>
|
|||
|
|
<body>
|
|||
|
|
<div class="debug-panel">
|
|||
|
|
<h2>🔍 Отладка AI Drawer</h2>
|
|||
|
|
<p>Эта страница поможет диагностировать проблемы с AI Drawer в CRM.</p>
|
|||
|
|
|
|||
|
|
<button class="test-button" onclick="testAIDrawer()">Тестировать AI Drawer</button>
|
|||
|
|
<button class="test-button" onclick="testProxy()">Тестировать прокси</button>
|
|||
|
|
<button class="test-button" onclick="testTypebot()">Тестировать Typebot</button>
|
|||
|
|
<button class="test-button" onclick="clearLog()">Очистить лог</button>
|
|||
|
|
|
|||
|
|
<div id="log" class="log"></div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<script>
|
|||
|
|
function log(message, type = 'info') {
|
|||
|
|
const logDiv = document.getElementById('log');
|
|||
|
|
const timestamp = new Date().toLocaleTimeString();
|
|||
|
|
const logEntry = `[${timestamp}] ${message}\n`;
|
|||
|
|
logDiv.textContent += logEntry;
|
|||
|
|
logDiv.scrollTop = logDiv.scrollHeight;
|
|||
|
|
|
|||
|
|
if (type === 'error') {
|
|||
|
|
logDiv.className = 'log error';
|
|||
|
|
} else if (type === 'success') {
|
|||
|
|
logDiv.className = 'log success';
|
|||
|
|
} else {
|
|||
|
|
logDiv.className = 'log';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
console.log(`[AI Drawer Debug] ${message}`);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function clearLog() {
|
|||
|
|
document.getElementById('log').textContent = '';
|
|||
|
|
document.getElementById('log').className = 'log';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
async function testAIDrawer() {
|
|||
|
|
log('🧪 Тестирование AI Drawer...');
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
// Проверяем, есть ли AI Drawer на странице
|
|||
|
|
const drawer = document.querySelector('.ai-drawer');
|
|||
|
|
const toggle = document.querySelector('.ai-drawer-toggle');
|
|||
|
|
|
|||
|
|
if (drawer) {
|
|||
|
|
log('✅ AI Drawer найден на странице', 'success');
|
|||
|
|
} else {
|
|||
|
|
log('❌ AI Drawer НЕ найден на странице', 'error');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (toggle) {
|
|||
|
|
log('✅ Кнопка AI Drawer найдена', 'success');
|
|||
|
|
} else {
|
|||
|
|
log('❌ Кнопка AI Drawer НЕ найдена', 'error');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Проверяем JavaScript функции
|
|||
|
|
if (typeof sendToAI === 'function') {
|
|||
|
|
log('✅ Функция sendToAI доступна', 'success');
|
|||
|
|
} else {
|
|||
|
|
log('❌ Функция sendToAI НЕ доступна', 'error');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (typeof sendToTypebot === 'function') {
|
|||
|
|
log('✅ Функция sendToTypebot доступна', 'success');
|
|||
|
|
} else {
|
|||
|
|
log('❌ Функция sendToTypebot НЕ доступна', 'error');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Проверяем конфигурацию
|
|||
|
|
if (typeof AI_CONFIG !== 'undefined') {
|
|||
|
|
log('✅ AI_CONFIG доступна: ' + JSON.stringify(AI_CONFIG), 'success');
|
|||
|
|
} else {
|
|||
|
|
log('❌ AI_CONFIG НЕ доступна', 'error');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} catch (error) {
|
|||
|
|
log('❌ Ошибка при тестировании AI Drawer: ' + error.message, 'error');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
async function testProxy() {
|
|||
|
|
log('🧪 Тестирование прокси...');
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
const response = await fetch('/aiassist/typebot_proxy.php', {
|
|||
|
|
method: 'POST',
|
|||
|
|
headers: {
|
|||
|
|
'Content-Type': 'application/json',
|
|||
|
|
},
|
|||
|
|
body: JSON.stringify({
|
|||
|
|
action: 'startChat',
|
|||
|
|
message: 'Тест прокси',
|
|||
|
|
context: {
|
|||
|
|
projectId: 'test',
|
|||
|
|
module: 'Test',
|
|||
|
|
view: 'Test',
|
|||
|
|
userId: 'test'
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
const result = await response.json();
|
|||
|
|
|
|||
|
|
if (result.success) {
|
|||
|
|
log('✅ Прокси работает: ' + JSON.stringify(result.data), 'success');
|
|||
|
|
} else {
|
|||
|
|
log('❌ Прокси ошибка: ' + result.error, 'error');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} catch (error) {
|
|||
|
|
log('❌ Ошибка прокси: ' + error.message, 'error');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
async function testTypebot() {
|
|||
|
|
log('🧪 Тестирование Typebot...');
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
// Проверяем доступность Typebot
|
|||
|
|
const response = await fetch('https://bot.klientprav.tech/api/v1/typebots/my-typebot-lezm06l');
|
|||
|
|
|
|||
|
|
if (response.ok) {
|
|||
|
|
log('✅ Typebot доступен', 'success');
|
|||
|
|
} else {
|
|||
|
|
log('❌ Typebot недоступен: HTTP ' + response.status, 'error');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} catch (error) {
|
|||
|
|
log('❌ Ошибка Typebot: ' + error.message, 'error');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Автоматический тест при загрузке
|
|||
|
|
window.onload = function() {
|
|||
|
|
log('🚀 Отладка AI Drawer запущена');
|
|||
|
|
log('📍 URL: ' + window.location.href);
|
|||
|
|
log('📍 User Agent: ' + navigator.userAgent);
|
|||
|
|
|
|||
|
|
// Проверяем, находимся ли мы в CRM
|
|||
|
|
if (window.location.hostname.includes('crm.clientright.ru')) {
|
|||
|
|
log('✅ Мы находимся в CRM', 'success');
|
|||
|
|
} else {
|
|||
|
|
log('⚠️ Мы НЕ в CRM', 'error');
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Перехватываем ошибки JavaScript
|
|||
|
|
window.addEventListener('error', function(e) {
|
|||
|
|
log('❌ JavaScript ошибка: ' + e.message + ' в ' + e.filename + ':' + e.lineno, 'error');
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// Перехватываем необработанные промисы
|
|||
|
|
window.addEventListener('unhandledrejection', function(e) {
|
|||
|
|
log('❌ Необработанная ошибка промиса: ' + e.reason, 'error');
|
|||
|
|
});
|
|||
|
|
</script>
|
|||
|
|
</body>
|
|||
|
|
</html>
|