def _create_session_recording_event(team_id, distinct_id, session_id, timestamp, window_id="", has_full_snapshot=True): create_session_recording_event( uuid=uuid4(), team_id=team_id, distinct_id=distinct_id, timestamp=timestamp, session_id=session_id, window_id=window_id, snapshot_data={"timestamp": timestamp.timestamp(), "has_full_snapshot": has_full_snapshot,}, )
def process_event_ee( distinct_id: str, ip: str, site_url: str, data: dict, team_id: int, now: datetime.datetime, sent_at: Optional[datetime.datetime], event_uuid: UUIDT, ) -> None: timer = statsd.Timer("%s_posthog_cloud" % (settings.STATSD_PREFIX, )) timer.start() properties = data.get("properties", {}) if data.get("$set"): properties["$set"] = data["$set"] if data.get("$set_once"): properties["$set_once"] = data["$set_once"] person_uuid = UUIDT() ts = handle_timestamp(data, now, sent_at) handle_identify_or_alias(data["event"], properties, distinct_id, team_id) if data["event"] == "$snapshot": create_session_recording_event( uuid=event_uuid, team_id=team_id, distinct_id=distinct_id, session_id=properties["$session_id"], snapshot_data=properties["$snapshot_data"], timestamp=ts, ) return _capture_ee( event_uuid=event_uuid, person_uuid=person_uuid, ip=ip, site_url=site_url, team_id=team_id, event=data["event"], distinct_id=distinct_id, properties=properties, timestamp=ts, ) timer.stop("process_event_ee")
def process_event_ee( distinct_id: str, ip: str, site_url: str, data: dict, team_id: int, now: str, sent_at: Optional[str], ) -> None: properties = data.get("properties", {}) if data.get("$set"): properties["$set"] = data["$set"] person_uuid = UUIDT() event_uuid = UUIDT() ts = handle_timestamp(data, now, sent_at) handle_identify_or_alias(data["event"], properties, distinct_id, team_id) if data["event"] == "$snapshot": create_session_recording_event( uuid=event_uuid, team_id=team_id, distinct_id=distinct_id, session_id=properties["$session_id"], snapshot_data=properties["$snapshot_data"], timestamp=ts, ) return _capture_ee( event_uuid=event_uuid, person_uuid=person_uuid, ip=ip, site_url=site_url, team_id=team_id, event=data["event"], distinct_id=distinct_id, properties=properties, timestamp=ts, )
def _create_session_recording_event(**kwargs): create_session_recording_event( uuid=uuid4(), **kwargs, )
def bulk_create_session_recording_events(events: List[Dict], **kw): for data in events: create_session_recording_event(**data, **kw, uuid=uuid4())