Skip to content

Commit

Permalink
[CHORE] Update segment logging to use restricted set of IDs (#1870)
Browse files Browse the repository at this point in the history
* Uses a new segment workspace
* Update ID to restrict it to a set of 8000 unique IDs

---------

Co-authored-by: Jay Chia <[email protected]@users.noreply.github.com>
  • Loading branch information
jaychia and Jay Chia authored Feb 12, 2024
1 parent 8565272 commit fe92fe9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions daft/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand All @@ -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]:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fe92fe9

Please sign in to comment.