Compare commits
5 Commits
45a3040614
...
e7696925e7
| Author | SHA1 | Date |
|---|---|---|
|
|
e7696925e7 | |
|
|
558ea81fc2 | |
|
|
4ab4164f65 | |
|
|
deb66976e9 | |
|
|
1d71f8f369 |
|
|
@ -15,6 +15,7 @@
|
||||||
"chalk": "^5.6.2",
|
"chalk": "^5.6.2",
|
||||||
"electron-store": "^11.0.2",
|
"electron-store": "^11.0.2",
|
||||||
"get-windows": "^9.2.3",
|
"get-windows": "^9.2.3",
|
||||||
|
"https": "^1.0.0",
|
||||||
"lucide-react": "^0.552.0",
|
"lucide-react": "^0.552.0",
|
||||||
"luxon": "^3.7.2",
|
"luxon": "^3.7.2",
|
||||||
"os-utils": "^0.0.14",
|
"os-utils": "^0.0.14",
|
||||||
|
|
@ -7021,6 +7022,12 @@
|
||||||
"node": ">=10.19.0"
|
"node": ">=10.19.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/https": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-4EC57ddXrkaF0x83Oj8sM6SLQHAWXw90Skqu2M4AEWENZ3F02dFJE/GARA8igO79tcgYqGrD7ae4f5L3um2lgg==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
"node_modules/https-proxy-agent": {
|
"node_modules/https-proxy-agent": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm-run-all --parallel dev:react dev:electron",
|
"dev": "npm-run-all --parallel dev:react dev:electron",
|
||||||
"dev:react": "vite",
|
"dev:react": "vite",
|
||||||
"dev:electron": "npm run build && cross-env NODE_ENV=development electron .",
|
"dev:electron": "npm run build && cross-env NODE_ENV=development electron --inspect=5858 .",
|
||||||
"prod:electron": "npm run build && cross-env NODE_ENV=production electron .",
|
"prod:electron": "npm run build && cross-env NODE_ENV=production electron .",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
"chalk": "^5.6.2",
|
"chalk": "^5.6.2",
|
||||||
"electron-store": "^11.0.2",
|
"electron-store": "^11.0.2",
|
||||||
"get-windows": "^9.2.3",
|
"get-windows": "^9.2.3",
|
||||||
|
"https": "^1.0.0",
|
||||||
"lucide-react": "^0.552.0",
|
"lucide-react": "^0.552.0",
|
||||||
"luxon": "^3.7.2",
|
"luxon": "^3.7.2",
|
||||||
"os-utils": "^0.0.14",
|
"os-utils": "^0.0.14",
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,17 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||||
import { getToken } from '../utils/tokenHelper.js';
|
import { getToken } from '../utils/tokenHelper.js';
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { sendTokenExpired } from '../ipc/ipcHandler.js';
|
import { sendTokenExpired } from '../ipc/ipcHandler.js';
|
||||||
|
import https from 'https';
|
||||||
|
|
||||||
const TOKEN_KEY = 'ACCESS_TOKEN';
|
const TOKEN_KEY = 'ACCESS_TOKEN';
|
||||||
|
|
||||||
|
const httpsAgent = new https.Agent({
|
||||||
|
rejectUnauthorized: false
|
||||||
|
});
|
||||||
|
|
||||||
const api: AxiosInstance = axios.create({
|
const api: AxiosInstance = axios.create({
|
||||||
baseURL: 'https://dreadingly-unfighting-pandora.ngrok-free.dev/api/v1/va', // 🔁 your backend
|
baseURL: 'https://quality-friendly-goldfish.ngrok-free.app/api/v1/va', // 🔁 your backend
|
||||||
|
httpsAgent
|
||||||
// timeout: 10000,
|
// timeout: 10000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,9 +160,9 @@ app.on("ready", async () => {
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
|
|
||||||
app.on('browser-window-blur', () => {
|
// app.on('browser-window-blur', () => {
|
||||||
globalShortcut.unregisterAll();
|
// globalShortcut.unregisterAll();
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,18 @@ import { app, BrowserWindow, desktopCapturer } from "electron";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import https from 'https';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import { saveToken } from "./tokenHelper.js";
|
import { saveToken } from "./tokenHelper.js";
|
||||||
import { activeWindow } from "get-windows";
|
import { activeWindow } from "get-windows";
|
||||||
import { exec } from "child_process";
|
import { exec } from "child_process";
|
||||||
import { getUIPath } from "../pathResolver.js";
|
import { getUIPath } from "../pathResolver.js";
|
||||||
|
|
||||||
|
const httpsAgent = new https.Agent({
|
||||||
|
rejectUnauthorized: false
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Blur using an offscreen canvas
|
// Blur using an offscreen canvas
|
||||||
async function blurAndCompressBase64Image(base64: string): Promise<Buffer> {
|
async function blurAndCompressBase64Image(base64: string): Promise<Buffer> {
|
||||||
const buffer = Buffer.from(base64.replace(/^data:image\/\w+;base64,/, ''), 'base64');
|
const buffer = Buffer.from(base64.replace(/^data:image\/\w+;base64,/, ''), 'base64');
|
||||||
|
|
@ -55,7 +61,6 @@ export const handleLogin = async (credentials: { email: string, password: string
|
||||||
// Call your login API
|
// Call your login API
|
||||||
console.log("🟡 login Request received", credentials);
|
console.log("🟡 login Request received", credentials);
|
||||||
|
|
||||||
console.log("Doom");
|
|
||||||
console.log("app.getAppPath()", app.getAppPath());
|
console.log("app.getAppPath()", app.getAppPath());
|
||||||
console.log("UIPATH", getUIPath());
|
console.log("UIPATH", getUIPath());
|
||||||
console.log("Doom 1");
|
console.log("Doom 1");
|
||||||
|
|
@ -64,9 +69,9 @@ export const handleLogin = async (credentials: { email: string, password: string
|
||||||
try {
|
try {
|
||||||
console.log("➡️ Calling API...");
|
console.log("➡️ Calling API...");
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
'https://dreadingly-unfighting-pandora.ngrok-free.dev/api/v1/va/login',
|
'https://quality-friendly-goldfish.ngrok-free.app/api/v1/va/login',
|
||||||
{ userDetails: { ...credentials } },
|
{ userDetails: { ...credentials } },
|
||||||
{ headers: { "ngrok-skip-browser-warning": 69420 } }
|
{ headers: { "ngrok-skip-browser-warning": 69420 }, httpsAgent }
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("API CAlled", response)
|
console.log("API CAlled", response)
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ const DashboardLayout = () => {
|
||||||
console.log(" Current elapsed time:", elapsedTime);
|
console.log(" Current elapsed time:", elapsedTime);
|
||||||
|
|
||||||
setLoadingStop(true);
|
setLoadingStop(true);
|
||||||
|
handleSocketDisconnect();
|
||||||
|
|
||||||
// STEP 1: Send final PATCH with last active window data
|
// STEP 1: Send final PATCH with last active window data
|
||||||
// This ensures the last window activity is recorded before logout
|
// This ensures the last window activity is recorded before logout
|
||||||
|
|
@ -345,6 +346,8 @@ const DashboardLayout = () => {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
handleSocketConnect()
|
||||||
|
|
||||||
setActiveProjectLogId(res?.data?.logId);
|
setActiveProjectLogId(res?.data?.logId);
|
||||||
console.log(" Tracking started. Log ID:", res?.data?.logId);
|
console.log(" Tracking started. Log ID:", res?.data?.logId);
|
||||||
|
|
||||||
|
|
@ -396,6 +399,7 @@ const DashboardLayout = () => {
|
||||||
|
|
||||||
// Trigger auto-stop
|
// Trigger auto-stop
|
||||||
handleLimitExceeded();
|
handleLimitExceeded();
|
||||||
|
handleSocketDisconnect();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|
@ -438,6 +442,84 @@ const DashboardLayout = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSocketConnect = async () => {
|
||||||
|
|
||||||
|
const token = await window.electron.getToken("ACCESS_TOKEN");
|
||||||
|
|
||||||
|
if (socketRef.current) {
|
||||||
|
console.warn("Already connected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!selectedProject?.projectId) return
|
||||||
|
|
||||||
|
console.log(selectedProject?.projectId, "SelectedProject ID")
|
||||||
|
socketRef.current = io("https://quality-friendly-goldfish.ngrok-free.app", {
|
||||||
|
transports: ["websocket"],
|
||||||
|
secure: true,
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
reconnection: true,
|
||||||
|
withCredentials: true,
|
||||||
|
forceNew: true,
|
||||||
|
extraHeaders: {
|
||||||
|
"Access-Control-Allow-Origin": "*"
|
||||||
|
},
|
||||||
|
auth: {
|
||||||
|
token: token,
|
||||||
|
projectId: selectedProject?.projectId,
|
||||||
|
userType: "va"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
socketRef.current.on("connect", () => {
|
||||||
|
console.log("🟢 Connected:", socketRef.current?.id);
|
||||||
|
setIsConnected(true);
|
||||||
|
|
||||||
|
// Start sending every 5 seconds
|
||||||
|
intervalRef.current = setInterval(async () => {
|
||||||
|
const apps = await window.electron.getRunningApps()
|
||||||
|
socketRef.current?.emit("getVisibleApps", { token: await token, apps });
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
|
||||||
|
socketRef.current.on("appToCapture", async ({ appTitle }) => {
|
||||||
|
console.log("📸 Capture requested for:", appTitle);
|
||||||
|
|
||||||
|
const base64String = await window.electron.captureAppScreenShot(appTitle);
|
||||||
|
if (base64String && socketRef.current) {
|
||||||
|
socketRef.current.emit("sendImage", {
|
||||||
|
token: token,
|
||||||
|
image: base64String,
|
||||||
|
title: appTitle,
|
||||||
|
projectId: selectedProject?.projectId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
socketRef.current.on("disconnect", () => {
|
||||||
|
console.log("🔴 Disconnected");
|
||||||
|
setIsConnected(false);
|
||||||
|
if (intervalRef.current) {
|
||||||
|
clearInterval(intervalRef.current);
|
||||||
|
intervalRef.current = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSocketDisconnect = () => {
|
||||||
|
if (intervalRef.current) {
|
||||||
|
clearInterval(intervalRef.current);
|
||||||
|
intervalRef.current = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (socketRef.current) {
|
||||||
|
socketRef.current.disconnect();
|
||||||
|
socketRef.current = null;
|
||||||
|
setIsConnected(false);
|
||||||
|
console.log("🔌 Disconnected manually");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const trackingState: TrackingState = {
|
const trackingState: TrackingState = {
|
||||||
selectedProject,
|
selectedProject,
|
||||||
isTracking,
|
isTracking,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue