export function sendTagInteractionEvent(payload) {
  const endpoint = '/api/analytics/tags'
  const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || ''
  const body = JSON.stringify(payload)

  fetch(endpoint, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
      'X-Requested-With': 'XMLHttpRequest',
      ...(csrfToken ? { 'X-CSRF-TOKEN': csrfToken } : {}),
    },
    body,
    keepalive: true,
    credentials: 'same-origin',
  }).catch(() => {
  })
}
