Download src/utils/sendTelemetry.ts from usofn8n/Evo: direct link, hf CLI and curl.
- Browser
- Download file 852 Bytes
-
https://huggingface.co/spaces/usofn8n/Evo/resolve/main/src/utils/sendTelemetry.ts
- Command line
-
hf download hf://spaces/usofn8n/Evo/src/utils/sendTelemetry.ts
-
curl -L -o sendTelemetry.ts https://huggingface.co/spaces/usofn8n/Evo/resolve/main/src/utils/sendTelemetry.ts
852 Bytes
| import { configService, Telemetry } from '@config/env.config'; | |
| 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 telemetryConfig = configService.get<Telemetry>('TELEMETRY'); | |
| if (!telemetryConfig.ENABLED) { | |
| return; | |
| } | |
| if (route === '/') { | |
| return; | |
| } | |
| const telemetry: TelemetryData = { | |
| route, | |
| apiVersion: `${packageJson.version}`, | |
| timestamp: new Date(), | |
| }; | |
| const url = | |
| telemetryConfig.URL && telemetryConfig.URL !== '' ? telemetryConfig.URL : 'https://log.evolution-api.com/telemetry'; | |
| axios | |
| .post(url, telemetry) | |
| .then(() => {}) | |
| .catch(() => {}); | |
| }; | |