@siftd/connect-agent 0.2.24 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/heartbeat.js +18 -1
- package/package.json +1 -1
package/dist/heartbeat.js
CHANGED
|
@@ -8,9 +8,26 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { hostname } from 'os';
|
|
10
10
|
import { createHash } from 'crypto';
|
|
11
|
+
import { readFileSync } from 'fs';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import { dirname, join } from 'path';
|
|
11
14
|
import { getServerUrl, getAgentToken, getUserId, isCloudMode } from './config.js';
|
|
12
15
|
const HEARTBEAT_INTERVAL = 10000; // 10 seconds
|
|
13
|
-
|
|
16
|
+
// Read version from package.json dynamically
|
|
17
|
+
function getVersion() {
|
|
18
|
+
try {
|
|
19
|
+
// Try to find package.json relative to this file
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = dirname(__filename);
|
|
22
|
+
const pkgPath = join(__dirname, '..', 'package.json');
|
|
23
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
24
|
+
return pkg.version || '0.0.0';
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return '0.0.0';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const VERSION = getVersion();
|
|
14
31
|
const state = {
|
|
15
32
|
intervalId: null,
|
|
16
33
|
runnerId: null,
|