| 75 | |
| 76 | |
| 77 | def send_telemetry(event_name: str, user_id, additional_properties: dict = {}): |
| 78 | if os.getenv("TELEMETRY_DISABLED"): |
| 79 | return |
| 80 | |
| 81 | env = os.getenv("ENV") |
| 82 | if env in ["test", "dev"]: |
| 83 | return |
| 84 | |
| 85 | current_time = datetime.now(timezone.utc) |
| 86 | payload = { |
| 87 | "anonymous_id": str(get_anonymous_id()), |
| 88 | "event_name": event_name, |
| 89 | "user_properties": { |
| 90 | "user_id": str(user_id), |
| 91 | }, |
| 92 | "properties": { |
| 93 | "time": current_time.strftime("%m/%d/%Y"), |
| 94 | "user_id": str(user_id), |
| 95 | **additional_properties, |
| 96 | }, |
| 97 | } |
| 98 | |
| 99 | response = requests.post(proxy_url, json=payload) |
| 100 | |
| 101 | if response.status_code != 200: |
| 102 | print(f"Error sending telemetry through proxy: {response.status_code}") |
| 103 | |
| 104 | |
| 105 | def get_file_content_hash(file_obj: Union[str, BinaryIO]) -> str: |