mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
chore: added correct referrer policy
This commit is contained in:
1 parent
d6b7b6ff91
commit
3c3a16a64a
2 files changed
+44
-14
No files matched your search
@@ -1,18 +1,48 @@
|
||||
function telemetry() {
|
||||
return fetch('https://app.supabase.io/api/telemetry/page', {
|
||||
mode: 'cors', // 'cors' by default,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
referrer: document.referrer,
|
||||
title: document.title,
|
||||
}),
|
||||
}).catch((error) => {
|
||||
console.error('Error at telemetry - post:', error)
|
||||
setTimeout(function () {
|
||||
return fetch('https://app.supabase.io/api/telemetry/page', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
referrerPolicy: 'no-referrer-when-downgrade',
|
||||
body: JSON.stringify({
|
||||
referrer: document.referrer,
|
||||
title: document.title,
|
||||
}),
|
||||
}).catch((error) => {
|
||||
console.error('Error at telemetry - post:', error)
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function pageState() {
|
||||
;(function () {
|
||||
var pushState = history.pushState
|
||||
var replaceState = history.replaceState
|
||||
|
||||
history.pushState = function () {
|
||||
pushState.apply(history, arguments)
|
||||
window.dispatchEvent(new Event('pushstate'))
|
||||
window.dispatchEvent(new Event('locationchange'))
|
||||
}
|
||||
|
||||
history.replaceState = function () {
|
||||
replaceState.apply(history, arguments)
|
||||
window.dispatchEvent(new Event('replacestate'))
|
||||
window.dispatchEvent(new Event('locationchange'))
|
||||
}
|
||||
|
||||
window.addEventListener('popstate', function () {
|
||||
window.dispatchEvent(new Event('locationchange'))
|
||||
})
|
||||
})()
|
||||
|
||||
window.addEventListener('locationchange', function () {
|
||||
telemetry()
|
||||
})
|
||||
}
|
||||
|
||||
pageState()
|
||||
telemetry()
|
||||
@@ -5,12 +5,12 @@ interface DataProps {
|
||||
|
||||
export const post = (url: string, data: DataProps, options = {}) => {
|
||||
return fetch(url, {
|
||||
mode: 'cors', // 'cors' by default,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
referrerPolicy: 'no-referrer-when-downgrade',
|
||||
body: JSON.stringify(data),
|
||||
...options,
|
||||
}).catch((error) => {
|
||||
|
||||
Reference in new issue
Block a user