diff --git a/src/telemetry/requirements.txt b/src/telemetry/requirements.txt index 405599c4..fd38fb64 100644 --- a/src/telemetry/requirements.txt +++ b/src/telemetry/requirements.txt @@ -1,2 +1,3 @@ uvicorn fastapi +requests diff --git a/src/telemetry/telemetry.py b/src/telemetry/telemetry.py index f2c0ccbf..bb05bc8e 100644 --- a/src/telemetry/telemetry.py +++ b/src/telemetry/telemetry.py @@ -7,6 +7,7 @@ from typing import Dict, List from fastapi import FastAPI from fastapi import HTTPException import sqlite3 +import requests import uvicorn @@ -25,6 +26,15 @@ def v1_telemetry(telemetry_data: List[Dict[str, str]]): logger.error(error_message) raise HTTPException(status_code=500, detail=error_message) + # POST request to new khoj telemetry server + try: + requests.post("https://telemetry.khoj.dev/v1/telemetry", json=telemetry_data) + except Exception as e: + raise HTTPException( + status_code=500, + detail="Could not POST equest to new khoj telemetry server. Contact developer to get this fixed.", + ) + # Insert recieved telemetry data into SQLite db logger.info(f"Insert row into telemetry table at {sqlfile}: {telemetry_data}") with sqlite3.connect(sqlfile) as conn: