chore: edit heartbeat payload to not send is_debugging

This commit is contained in:
Sebastian Velez
2023-01-19 10:04:33 -05:00
parent 5b6f6e92b0
commit 75e6372f2b
3 changed files with 8 additions and 21 deletions

View File

@@ -70,17 +70,6 @@ class WakaTimeCore {
if (tabs.length == 0) return; if (tabs.length == 0) return;
const currentActiveTab = tabs[0]; const currentActiveTab = tabs[0];
let debug = false;
// If the current active tab has devtools open
if (
inArray(
currentActiveTab.id,
this.tabsWithDevtoolsOpen.map((tab) => tab.id),
)
) {
debug = true;
}
if (items.loggingStyle == 'blacklist') { if (items.loggingStyle == 'blacklist') {
if (!contains(currentActiveTab.url as string, items.blacklist as string)) { if (!contains(currentActiveTab.url as string, items.blacklist as string)) {
@@ -89,7 +78,6 @@ class WakaTimeCore {
project: null, project: null,
url: currentActiveTab.url as string, url: currentActiveTab.url as string,
}, },
debug,
apiKey, apiKey,
); );
} else { } else {
@@ -104,7 +92,7 @@ class WakaTimeCore {
items.whitelist as string, items.whitelist as string,
); );
if (heartbeat.url) { if (heartbeat.url) {
await this.sendHeartbeat(heartbeat, debug, apiKey); await this.sendHeartbeat(heartbeat, apiKey);
} else { } else {
await changeExtensionState('whitelisted'); await changeExtensionState('whitelisted');
console.log(`${currentActiveTab.url} is not on a whitelist.`); console.log(`${currentActiveTab.url} is not on a whitelist.`);
@@ -183,7 +171,7 @@ class WakaTimeCore {
* @param heartbeat * @param heartbeat
* @param debug * @param debug
*/ */
async sendHeartbeat(heartbeat: SendHeartbeat, debug: boolean, apiKey: string): Promise<void> { async sendHeartbeat(heartbeat: SendHeartbeat, apiKey: string): Promise<void> {
let payload; let payload;
const loggingType = await this.getLoggingType(); const loggingType = await this.getLoggingType();
@@ -191,12 +179,12 @@ class WakaTimeCore {
// And send that in heartbeat // And send that in heartbeat
if (loggingType == 'domain') { if (loggingType == 'domain') {
heartbeat.url = getDomainFromUrl(heartbeat.url); heartbeat.url = getDomainFromUrl(heartbeat.url);
payload = this.preparePayload(heartbeat, 'domain', debug); payload = this.preparePayload(heartbeat, 'domain');
await this.sendPostRequestToApi(payload, apiKey); await this.sendPostRequestToApi(payload, apiKey);
} }
// Send entity in heartbeat // Send entity in heartbeat
else if (loggingType == 'url') { else if (loggingType == 'url') {
payload = this.preparePayload(heartbeat, 'url', debug); payload = this.preparePayload(heartbeat, 'url');
await this.sendPostRequestToApi(payload, apiKey); await this.sendPostRequestToApi(payload, apiKey);
} }
} }
@@ -224,10 +212,9 @@ class WakaTimeCore {
* @returns {*} * @returns {*}
* @private * @private
*/ */
preparePayload(heartbeat: SendHeartbeat, type: string, debug = false): Record<string, unknown> { preparePayload(heartbeat: SendHeartbeat, type: string): Record<string, unknown> {
return { return {
entity: heartbeat.url, entity: heartbeat.url,
is_debugging: debug,
plugin: 'browser-wakatime/' + config.version, plugin: 'browser-wakatime/' + config.version,
project: heartbeat.project ?? '<<LAST_PROJECT>>', project: heartbeat.project ?? '<<LAST_PROJECT>>',
time: moment().format('X'), time: moment().format('X'),

View File

@@ -10,7 +10,7 @@ export default async function changeExtensionIcon(color?: ColorIconTypes): Promi
if (color) { if (color) {
const path = `./graphics/wakatime-logo-38-${color}.png`; const path = `./graphics/wakatime-logo-38-${color}.png`;
await browser.browserAction.setIcon({ await browser.action.setIcon({
path: path, path: path,
}); });
} else { } else {
@@ -21,7 +21,7 @@ export default async function changeExtensionIcon(color?: ColorIconTypes): Promi
theme === config.theme theme === config.theme
? './graphics/wakatime-logo-38.png' ? './graphics/wakatime-logo-38.png'
: './graphics/wakatime-logo-38-white.png'; : './graphics/wakatime-logo-38-white.png';
await browser.browserAction.setIcon({ await browser.action.setIcon({
path: path, path: path,
}); });
} }

View File

@@ -12,5 +12,5 @@ export default async function changeExtensionTooltip(text: string): Promise<void
text = `${config.name} - ${text}`; text = `${config.name} - ${text}`;
} }
await browser.browserAction.setTitle({ title: text }); await browser.action.setTitle({ title: text });
} }