def _capture_ee( event_uuid: UUID, person_uuid: UUID, ip: str, site_url: str, team_id: int, event: str, distinct_id: str, properties: Dict, timestamp: datetime.datetime, ) -> None: elements = properties.get("$elements") elements_list = [] if elements: del properties["$elements"] elements_list = [ Element( text=el["$el_text"][0:400] if el.get("$el_text") else None, tag_name=el["tag_name"], href=el["attr__href"][0:2048] if el.get("attr__href") else None, attr_class=el["attr__class"].split(" ") if el.get("attr__class") else None, attr_id=el.get("attr__id"), nth_child=el.get("nth_child"), nth_of_type=el.get("nth_of_type"), attributes={key: value for key, value in el.items() if key.startswith("attr__")}, ) for index, el in enumerate(elements) ] team = Team.objects.only("slack_incoming_webhook", "event_names", "event_properties", "anonymize_ips").get( pk=team_id ) if not team.anonymize_ips and "$ip" not in properties: properties["$ip"] = ip store_names_and_properties(team=team, event=event, properties=properties) # determine/create elements elements_hash = create_elements(event_uuid=event_uuid, elements=elements_list, team=team) # # determine create events create_event( event_uuid=event_uuid, event=event, properties=properties, timestamp=timestamp, team=team, elements_hash=elements_hash, distinct_id=distinct_id, ) emit_omni_person( event_uuid=event_uuid, uuid=person_uuid, team_id=team_id, distinct_id=distinct_id, timestamp=timestamp, properties=properties, )
def _capture_ee( event_uuid: UUID, person_uuid: UUID, ip: str, site_url: str, team_id: int, event: str, distinct_id: str, properties: Dict, timestamp: datetime.datetime, ) -> None: elements = properties.get("$elements") elements_list = [] if elements: del properties["$elements"] elements_list = [ Element( text=el["$el_text"][0:400] if el.get("$el_text") else None, tag_name=el["tag_name"], href=el["attr__href"][0:2048] if el.get("attr__href") else None, attr_class=el["attr__class"].split(" ") if el.get("attr__class") else None, attr_id=el.get("attr__id"), nth_child=el.get("nth_child"), nth_of_type=el.get("nth_of_type"), attributes={key: value for key, value in el.items() if key.startswith("attr__")}, ) for index, el in enumerate(elements) ] team = Team.objects.select_related("organization").get(pk=team_id) if not team.anonymize_ips and "$ip" not in properties: properties["$ip"] = ip event = sanitize_event_name(event) _add_missing_feature_flags(properties, team, distinct_id) store_names_and_properties(team=team, event=event, properties=properties) if not Person.objects.distinct_ids_exist(team_id=team_id, distinct_ids=[str(distinct_id)]): # Catch race condition where in between getting and creating, # another request already created this user try: Person.objects.create(team_id=team_id, distinct_ids=[str(distinct_id)]) except IntegrityError: pass # # determine create events create_event( event_uuid=event_uuid, event=event, properties=properties, timestamp=timestamp, team=team, distinct_id=distinct_id, elements=elements_list, site_url=site_url, )