adding fredy version

This commit is contained in:
weakmap@gmail.com
2024-12-17 13:07:25 +01:00
parent 214e714c03
commit 3b8279c714
3 changed files with 75 additions and 47 deletions

View File

@@ -3,10 +3,12 @@ import { getJobs } from '../storage/jobStorage.js';
import {getUniqueId} from './uniqueId.js';
import {config, inDevMode} from '../../utils.js';
import os from 'os';
import {readFileSync} from 'fs';
import {packageUp} from 'package-up';
const mixpanelTracker = Mixpanel.init('718670ef1c58c0208256c1e408a3d75e');
const distinct_id = getUniqueId() || 'N/A';
const version = await getPackageVersion();
export const track = function () {
//only send tracking information if the user allowed to do so.
@@ -71,5 +73,18 @@ function enrichTrackingObject(trackingObject) {
nodeVersion,
language,
distinct_id,
fredy_version: version
};
}
async function getPackageVersion() {
try {
const packagePath = await packageUp();
const packageJson = readFileSync(packagePath, 'utf8');
const json = JSON.parse(packageJson);
return json.version;
} catch (error) {
console.error('Error reading version from package.json', error);
}
return 'N/A';
}

View File

@@ -69,6 +69,7 @@
"nanoid": "5.0.9",
"node-fetch": "3.3.2",
"node-mailjet": "6.0.6",
"package-up": "^5.0.0",
"puppeteer": "^23.10.4",
"puppeteer-extra": "^3.3.6",
"puppeteer-extra-plugin-stealth": "^2.11.2",

View File

@@ -3545,6 +3545,11 @@ filter-obj@^5.1.0:
resolved "https://registry.npmjs.org/filter-obj/-/filter-obj-5.1.0.tgz"
integrity sha512-qWeTREPoT7I0bifpPUXtxkZJ1XJzxWtfoWWkdVGqa+eCr3SHW/Ocp89o8vLvbUuQnadybJpjOKu4V+RwO6sGng==
find-up-simple@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/find-up-simple/-/find-up-simple-1.0.0.tgz#21d035fde9fdbd56c8f4d2f63f32fd93a1cfc368"
integrity sha512-q7Us7kcjj2VMePAa02hDAF6d+MzsdsAWEwYyOpwUtlerRBkOEPBCRZrAV4XfcSN8fHAgaD0hP7miwoay6DCprw==
find-up@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz"
@@ -5958,6 +5963,13 @@ pac-resolver@^7.0.1:
degenerator "^5.0.0"
netmask "^2.0.2"
package-up@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/package-up/-/package-up-5.0.0.tgz#3facda2aa9248c0b68b3dddfa4c58d22aa3faea2"
integrity sha512-MQEgDUvXCa3sGvqHg3pzHO8e9gqTCMPVrWUko3vPQGntwegmFo52mZb2abIVTjFnUcW0BcPz0D93jV5Cas1DWA==
dependencies:
find-up-simple "^1.0.0"
parent-module@^1.0.0:
version "1.0.1"
resolved "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz"