<?php
require_once __DIR__.'/../includes/functions.php';
header('Content-Type: application/json');
$raw = file_get_contents('php://input');
$data = json_decode($raw, true) ?: [];
mj_log_error_event([
  'error_type'=>'javascript_error',
  'error_message'=>$data['message'] ?? 'JavaScript error',
  'error_file'=>$data['source'] ?? '',
  'error_line'=>(int)($data['line'] ?? 0),
  'stack_trace'=>$data['stack'] ?? '',
  'priority'=>'normal'
]);
echo json_encode(['ok'=>true]);
