def extract_custom( self, output: MutableMapping[str, Any], event: InsertEvent, metadata: KafkaMessageMetadata, ) -> None: data = event.get("data", {}) output["message"] = _unicodify(event["message"]) # USER REQUEST GEO user = data.get("user", data.get("sentry.interfaces.User", None)) or {} extract_user(output, user) geo = user.get("geo", None) or {} self.extract_geo(output, geo) request = data.get("request", data.get("sentry.interfaces.Http", None)) or {} http_data: MutableMapping[str, Any] = {} extract_http(http_data, request) output["http_method"] = http_data["http_method"] output["http_referer"] = http_data["http_referer"] output["primary_hash"] = _hashify(event["primary_hash"]) output["hierarchical_hashes"] = list( _hashify(x) for x in data.get("hierarchical_hashes") or ()) output["culprit"] = _unicodify(data.get("culprit", None)) output["type"] = _unicodify(data.get("type", None)) output["title"] = _unicodify(data.get("title", None))
def extract_custom( self, output: MutableMapping[str, Any], event: InsertEvent, metadata: KafkaMessageMetadata, ) -> None: data = event.get("data", {}) user_dict = data.get("user", data.get("sentry.interfaces.User", None)) or {} user_data: MutableMapping[str, Any] = {} extract_user(user_data, user_dict) output["user_name"] = user_data["username"] output["user_id"] = user_data["user_id"] output["user_email"] = user_data["email"] ip_address = _ensure_valid_ip(user_data["ip_address"]) if ip_address: if ip_address.version == 4: output["ip_address_v4"] = str(ip_address) elif ip_address.version == 6: output["ip_address_v6"] = str(ip_address) contexts: MutableMapping[str, Any] = _as_dict_safe( data.get("contexts", None)) geo = user_dict.get("geo", {}) if "geo" not in contexts and isinstance(geo, dict): contexts["geo"] = geo request = data.get("request", data.get("sentry.interfaces.Http", None)) or {} http_data: MutableMapping[str, Any] = {} extract_http(http_data, request) output["http_method"] = http_data["http_method"] output["http_referer"] = http_data["http_referer"] # _as_dict_safe may not return a reference to the entry in the data # dictionary in some cases. data["contexts"] = contexts output["message"] = _unicodify(event["message"]) output["primary_hash"] = str(uuid.UUID(_hashify( event["primary_hash"]))) output["hierarchical_hashes"] = list( str(uuid.UUID(_hashify(x))) for x in data.get("hierarchical_hashes") or ()) output["culprit"] = _unicodify(data.get("culprit", "")) output["type"] = _unicodify(data.get("type", "")) output["title"] = _unicodify(data.get("title", ""))
def extract_custom( self, output: MutableMapping[str, Any], event: InsertEvent, metadata: KafkaMessageMetadata, ) -> None: data = event.get("data", {}) output["message"] = _unicodify(event["message"]) # USER REQUEST GEO user = data.get("user", data.get("sentry.interfaces.User", None)) or {} extract_user(output, user) geo = user.get("geo", None) or {} self.extract_geo(output, geo) request = data.get("request", data.get("sentry.interfaces.Http", None)) or {} http_data: MutableMapping[str, Any] = {} extract_http(http_data, request) output["http_method"] = http_data["http_method"] output["http_referer"] = http_data["http_referer"]