@todesktop/runtime
Advanced tools
Comparing version
@@ -22,2 +22,15 @@ "use strict"; | ||
} | ||
function onWebContentsEvent(event, callback) { | ||
electron_1.webContents.getAllWebContents().forEach((webContents) => { | ||
if (webContents.isLoading()) { | ||
webContents.on(event, callback); | ||
} | ||
else { | ||
callback(); | ||
} | ||
}); | ||
electron_1.app.on("web-contents-created", (_, webContents) => { | ||
webContents.on(event, callback); | ||
}); | ||
} | ||
function sendHttpRequest(url, body) { | ||
@@ -73,2 +86,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const config = Object.assign({ apiUrl: process.env.TODESKTOP_SMOKE_TEST_API_URL || "", autoRestart: true, enabled: Boolean(process.env.TODESKTOP_SMOKE_TEST), feedUrl: process.env.TODESKTOP_SMOKE_TEST_FEED_URL || "", initOptions: {}, secret: process.env.TODESKTOP_SMOKE_TEST_SECRET || "", startedAtMs: Date.now() }, configFromEnv); | ||
let appReadyTimeMs; | ||
function callApi(event, data = {}) { | ||
@@ -79,2 +93,9 @@ sendHttpRequest(config.apiUrl, Object.assign({ event }, data)).catch((e) => { | ||
} | ||
let combinedPerformanceData = {}; | ||
function sendPerformanceCall(additionalFields = {}) { | ||
combinedPerformanceData = Object.assign(Object.assign(Object.assign({}, combinedPerformanceData), additionalFields), { appReadyAtMs: appReadyTimeMs, appStartedAtMs: process.getCreationTime(), cpuUsage: process.cpuUsage(), memoryUsage: process.memoryUsage(), metrics: electron_1.app.getAppMetrics(), processMemoryInfo: appReadyTimeMs | ||
? process.getProcessMemoryInfo() | ||
: undefined, smokeTestRuntimeStartedAtMs: config.startedAtMs }); | ||
callApi("performance", combinedPerformanceData); | ||
} | ||
if (!config.enabled || | ||
@@ -117,2 +138,11 @@ !config.apiUrl || | ||
}); | ||
electron_1.app.on("ready", () => { | ||
appReadyTimeMs = Date.now(); | ||
onWebContentsEvent("dom-ready", () => { | ||
sendPerformanceCall({ webContentsDomReadyAtMs: Date.now() }); | ||
}); | ||
onWebContentsEvent("did-finish-load", () => { | ||
sendPerformanceCall({ webContentsFinishLoadAtMs: Date.now() }); | ||
}); | ||
}); | ||
const originalProcessExit = process.exit; | ||
@@ -140,4 +170,5 @@ process.exit = function patchedProcessExit(code = 0) { | ||
callApi("timer", { fromStartMs: Date.now() - config.startedAtMs }); | ||
sendPerformanceCall(); | ||
}, 1000); | ||
} | ||
exports.default = initSmokeTest; |
@@ -1,1 +0,1 @@ | ||
export declare const CLIENT_VERSION = "1.6.2"; | ||
export declare const CLIENT_VERSION = "1.6.3-0"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CLIENT_VERSION = void 0; | ||
exports.CLIENT_VERSION = "1.6.2"; | ||
exports.CLIENT_VERSION = "1.6.3-0"; |
@@ -7,3 +7,3 @@ { | ||
"name": "@todesktop/runtime", | ||
"version": "1.6.2", | ||
"version": "1.6.3-0", | ||
"license": "MIT", | ||
@@ -10,0 +10,0 @@ "author": "ToDesktop <hi@todesktop.com> (https://www.todesktop.com/)", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
92548
1.58%1511
2.16%1
Infinity%