start refactor

This commit is contained in:
Alan Hamlett
2024-08-27 13:45:10 +02:00
parent 6d77323cb8
commit d5e94de63c
15 changed files with 498 additions and 443 deletions

View File

@@ -1,3 +1,5 @@
import { getHeartbeatFromPage } from './utils/heartbeat';
const oneMinute = 60000;
const fiveMinutes = 300000;
@@ -89,12 +91,8 @@ function debounce(func: () => void, timeout = oneMinute, maxWaitTime = fiveMinut
}
const sendHeartbeat = debounce(async () => {
const { hostname } = document.location;
const projectDetails = getParser[hostname]?.();
if (projectDetails) {
chrome.runtime.sendMessage({ projectDetails, recordHeartbeat: true });
}
const heartbeat = getHeartbeatFromPage();
chrome.runtime.sendMessage({ heartbeat: heartbeat, task: 'sendHeartbeat' });
});
chrome.runtime.onMessage.addListener((request: { message: string }, sender, sendResponse) => {