feat: add tag discovery analytics and reporting
This commit is contained in:
19
resources/js/lib/tagAnalytics.js
Normal file
19
resources/js/lib/tagAnalytics.js
Normal file
@@ -0,0 +1,19 @@
|
||||
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(() => {
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user