-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ed8f14
commit be5ef77
Showing
7 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import threading | ||
import uuid | ||
from enum import Enum | ||
from typing import cast | ||
|
||
import requests | ||
|
||
from danswer.configs.app_configs import DISABLE_TELEMETRY | ||
from danswer.dynamic_configs import get_dynamic_config_store | ||
from danswer.dynamic_configs.interface import ConfigNotFoundError | ||
|
||
CUSTOMER_UUID_KEY = "customer_uuid" | ||
DANSWER_TELEMETRY_ENDPOINT = "https://telemetry.danswer.ai/anonymous_telemetry" | ||
|
||
|
||
class RecordType(str, Enum): | ||
VERSION = "version" | ||
SIGN_UP = "sign_up" | ||
LATENCY = "latency" | ||
FAILURE = "failure" | ||
|
||
|
||
def get_or_generate_uuid() -> str: | ||
kv_store = get_dynamic_config_store() | ||
try: | ||
return cast(str, kv_store.load(CUSTOMER_UUID_KEY)) | ||
except ConfigNotFoundError: | ||
customer_id = str(uuid.uuid4()) | ||
kv_store.store(CUSTOMER_UUID_KEY, customer_id) | ||
return customer_id | ||
|
||
|
||
def optional_telemetry(record_type: RecordType, data: dict) -> None: | ||
if DISABLE_TELEMETRY: | ||
return | ||
|
||
try: | ||
|
||
def telemetry_logic() -> None: | ||
payload = { | ||
"data": data, | ||
"record": record_type, | ||
"customer_uuid": get_or_generate_uuid(), | ||
} | ||
requests.post( | ||
DANSWER_TELEMETRY_ENDPOINT, | ||
headers={"Content-Type": "application/json"}, | ||
json=payload, | ||
) | ||
|
||
# Run in separate thread to have minimal overhead in main flows | ||
thread = threading.Thread(target=telemetry_logic, daemon=True) | ||
thread.start() | ||
except Exception: | ||
# Should never interfere with normal functions of Danswer | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
be5ef77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
internal-search – ./
internal-search-git-main-danswer.vercel.app
internal-search.vercel.app
internal-search-danswer.vercel.app
www.danswer.dev
danswer.dev