Detect code review category based on GitHub url

This commit is contained in:
Rohid
2024-08-20 11:58:56 +06:00
parent 6ea75f1f75
commit fa5537a972
2 changed files with 19 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ import config from '../config/config';
import { SendHeartbeat } from '../types/heartbeats';
import { GrandTotal, SummariesPayload } from '../types/summaries';
import { ApiKeyPayload, AxiosUserResponse, User } from '../types/user';
import { IS_EDGE, IS_FIREFOX, generateProjectFromDevSites } from '../utils';
import { IS_EDGE, IS_FIREFOX, generateProjectFromDevSites, isCodeReviewing } from '../utils';
import { getApiKey } from '../utils/apiKey';
import changeExtensionState from '../utils/changeExtensionState';
import contains from '../utils/contains';
@@ -112,7 +112,7 @@ class WakaTimeCore {
* Depending on various factors detects the current active tab URL or domain,
* and sends it to WakaTime for logging.
*/
async recordHeartbeat(payload = {}): Promise<void> {
async recordHeartbeat(payload: Record<string, unknown> = {}): Promise<void> {
const apiKey = await getApiKey();
if (!apiKey) {
return changeExtensionState('notLogging');
@@ -166,6 +166,12 @@ class WakaTimeCore {
// Checks dev websites
const project = generateProjectFromDevSites(url);
// Check if code reviewing
const codeReviewing = isCodeReviewing(url);
if (codeReviewing) {
payload.category = 'code reviewing';
}
if (items.loggingStyle == 'blacklist') {
if (!contains(url, items.blacklist as string)) {
await this.sendHeartbeat(