I asked chatgpt and they said to use cookies. I tested it and it works. Here’s the code
const webhookUrl = "airtable-webhook-url-here";
// Check if the code has already been executed today
const lastExecutionTimestamp = localStorage.getItem('lastExecutionTimestamp');
const today = new Date().toISOString().split('T')[0]; // Get the current date in YYYY-MM-DD format
if (window.logged_in_user && lastExecutionTimestamp !== today) {
async function postLastSeenTime(url, data) {
const response = await fetch(url, {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json'
},
redirect: 'follow',
referrerPolicy: 'no-referrer',
body: JSON.stringify(data)
});
return response;
}
postLastSeenTime(webhookUrl, {
recordId: window.logged_in_user['airtable_record_id'],
date: Date.now()
}).then((data) => {
console.log(data);
// Store the current timestamp to indicate the code has been executed today
localStorage.setItem('lastExecutionTimestamp', today);
});
}