mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-03 12:23:02 +01:00
Make old telemetry server forward requests to new server
This commit is contained in:
parent
f6ceb22373
commit
d13db2e666
2 changed files with 11 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
|||
uvicorn
|
||||
fastapi
|
||||
requests
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue