Spaces:
Runtime error
Runtime error
Download src/utils/sendTelemetry.ts from oex2003/evolution-api: direct link, hf CLI and curl.
- Browser
- Download file 841 Bytes
-
https://huggingface.co/spaces/oex2003/evolution-api/resolve/refs%2Fpr%2F1/src/utils/sendTelemetry.ts
- Command line
-
hf download hf://spaces/oex2003/evolution-api@refs/pr/1/src/utils/sendTelemetry.ts
-
curl -L -o sendTelemetry.ts https://huggingface.co/spaces/oex2003/evolution-api/resolve/refs%2Fpr%2F1/src/utils/sendTelemetry.ts
841 Bytes
| 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'; | |
| if (!enabled) { | |
| return; | |
| } | |
| if (route === '/') { | |
| return; | |
| } | |
| const telemetry: TelemetryData = { | |
| route, | |
| apiVersion: `${packageJson.version}`, | |
| timestamp: new Date(), | |
| }; | |
| const url = | |
| process.env.TELEMETRY_URL && process.env.TELEMETRY_URL !== '' | |
| ? process.env.TELEMETRY_URL | |
| : 'https://log.evolution-api.com/telemetry'; | |
| axios | |
| .post(url, telemetry) | |
| .then(() => {}) | |
| .catch(() => {}); | |
| }; | |