mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 04:02:54 -06:00
33 lines
768 B
TypeScript
33 lines
768 B
TypeScript
import axios from 'axios';
|
|
import fs from 'fs';
|
|
|
|
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
|
|
|
export interface TelemetryData {
|
|
route: string;
|
|
apiVersion: string;
|
|
timestamp: Date;
|
|
}
|
|
|
|
export const sendTelemetry = async (route: string): Promise<void> => {
|
|
const enabled = process.env.TELEMETRY_ENABLED === undefined || process.env.TELEMETRY_ENABLED === 'true';
|
|
|
|
console.log('Telemetry enabled:', enabled);
|
|
if (!enabled) {
|
|
return;
|
|
}
|
|
|
|
const telemetry: TelemetryData = {
|
|
route,
|
|
apiVersion: `${packageJson.version}`,
|
|
timestamp: new Date(),
|
|
};
|
|
|
|
const url = process.env.TELEMETRY_URL || 'https://log.evolution-api.com/telemetry';
|
|
|
|
axios
|
|
.post(url, telemetry)
|
|
.then(() => {})
|
|
.catch(() => {});
|
|
};
|