Don't send a heartbeat on sites like 'chrome://newtab/' or 'about:newtab'

This commit is contained in:
Sebastian Velez
2023-04-28 13:37:38 -05:00
parent b2d1fdc9c6
commit 673fd0d63f
3 changed files with 14 additions and 0 deletions

View File

@@ -53,6 +53,10 @@ describe('wakatime config', () => {
"loggingType": "domain",
"logoutUserUrl": "https://wakatime.com/logout",
"name": "WakaTime",
"nonTrackableSites": [
"chrome://",
"about:",
],
"socialMediaSites": [
"facebook.com",
"instagram.com",

View File

@@ -87,6 +87,7 @@ export interface Config {
* Extension name
*/
name: string;
nonTrackableSites: string[];
socialMediaSites: string[];
states: ApiStates[];
/**
@@ -159,6 +160,8 @@ const config: Config = {
name: 'WakaTime',
nonTrackableSites: ['chrome://', 'about:'],
socialMediaSites: [
'facebook.com',
'instagram.com',

View File

@@ -149,6 +149,13 @@ class WakaTimeCore {
url = document.URL;
}
for (const site of config.nonTrackableSites) {
if (url.startsWith(site)) {
// Don't send a heartbeat on sites like 'chrome://newtab/' or 'about:newtab'
return;
}
}
const hostname = getDomainFromUrlWithoutProtocol(url).replace('www.', '');
if (!items.trackSocialMedia) {
if ((items.socialMediaSites as string[]).includes(hostname)) {