Skip to content

Commit

Permalink
Trim quotes on event properties (#1852)
Browse files Browse the repository at this point in the history
* addquote trimmer

* fix tests

* remove unnecessary check
  • Loading branch information
EDsCODE authored Oct 13, 2020
1 parent 1336203 commit 72fe8fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ee/clickhouse/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ def get_id(self, event):

def get_properties(self, event):
if len(event) >= 10 and event[8] and event[9]:
return dict(zip(event[8], event[9]))
prop_vals = [res.strip('"') for res in event[9]]
return dict(zip(event[8], prop_vals))
else:
return json.loads(event[2])
props = json.loads(event[2])
unpadded = {key: value.strip('"') for key, value in props.items()}
return unpadded

def get_event(self, event):
return event[1]
Expand Down
4 changes: 2 additions & 2 deletions ee/clickhouse/test/test_process_event_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def test_ip_capture(self) -> None:
)

events = get_events()
self.assertEqual(events[0]["properties"]["$ip"], '"11.12.13.14"')
self.assertEqual(events[0]["properties"]["$ip"], "11.12.13.14")

def test_ip_override(self) -> None:
user = self._create_user("tim")
Expand All @@ -284,7 +284,7 @@ def test_ip_override(self) -> None:
)

event = get_events()[0]
self.assertEqual(event["properties"]["$ip"], '"1.0.0.1"')
self.assertEqual(event["properties"]["$ip"], "1.0.0.1")

def test_anonymized_ip_capture(self) -> None:
self.team.anonymize_ips = True
Expand Down

0 comments on commit 72fe8fd

Please sign in to comment.