diff --git a/daft/analytics.py b/daft/analytics.py index 205a2c9398..4944aa2bad 100644 --- a/daft/analytics.py +++ b/daft/analytics.py @@ -9,16 +9,16 @@ import logging import os import platform +import random import time import urllib.error import urllib.request -import uuid from typing import Any, Callable from daft import context _ANALYTICS_CLIENT = None -_WRITE_KEY = "ebFETjqH70OOvtDvrlBC902iljBZGvPU" +_WRITE_KEY = "opL9scJXH6GKdIYgPdA0ncCj8i920LJq" _SEGMENT_BATCH_ENDPOINT = "https://api.segment.io/v1/batch" @@ -33,6 +33,11 @@ class AnalyticsEvent: data: dict[str, Any] +def _get_session_key(): + # Restrict the cardinality of keys to 8000 + return f"anon-{random.randint(1, 8000)}" + + def _build_segment_batch_payload( events: list[AnalyticsEvent], daft_version: str, daft_build_type: str ) -> dict[str, Any]: @@ -86,7 +91,7 @@ def __init__( ) -> None: self._daft_version = daft_version self._daft_build_type = daft_build_type - self._session_key = str(uuid.uuid4()) + self._session_key = _get_session_key() # Function to publish a payload to Segment self._publish = publish_payload_function