Skip to content

Commit

Permalink
feat(replays): Add click_is_dead and click_is_rage columns (#4470)
Browse files Browse the repository at this point in the history
* Add is_dead and is_rage columns

* Safely extract keys

* Revert "Safely extract keys"

This reverts commit eeeea85.
  • Loading branch information
cmanallen committed Jul 14, 2023
1 parent 1df9407 commit fe6e66c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions snuba/datasets/configuration/replays/entities/replays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ schema:
{ name: click_testid, type: String, args: {} },
{ name: click_aria_label, type: String, args: {} },
{ name: click_title, type: String, args: {} },
{ name: click_is_dead, type: UInt, args: { size: 8 } },
{ name: click_is_rage, type: UInt, args: { size: 8 } },
{ name: retention_days, type: UInt, args: { size: 16 } },
{ name: partition, type: UInt, args: { size: 16 } },
{ name: offset, type: UInt, args: { size: 64 } },
Expand Down
2 changes: 2 additions & 0 deletions snuba/datasets/configuration/replays/storages/replays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ schema:
{ name: click_testid, type: String, args: {} },
{ name: click_aria_label, type: String, args: {} },
{ name: click_title, type: String, args: {} },
{ name: click_is_dead, type: UInt, args: { size: 8 } },
{ name: click_is_rage, type: UInt, args: { size: 8 } },
{ name: retention_days, type: UInt, args: { size: 16 } },
{ name: partition, type: UInt, args: { size: 16 } },
{ name: offset, type: UInt, args: { size: 64 } },
Expand Down
10 changes: 10 additions & 0 deletions snuba/datasets/processors/replays_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ def process_replay_actions(
"click_testid": to_string(click["testid"])[:64],
"click_aria_label": to_string(click["aria_label"])[:64],
"click_title": to_string(click["title"])[:64],
"click_is_dead": to_uint1(click["is_dead"]),
"click_is_rage": to_uint1(click["is_rage"]),
}
for click in payload["clicks"][:MAX_CLICK_EVENTS]
]
Expand Down Expand Up @@ -294,6 +296,14 @@ def to_datetime(value: Any) -> datetime:
return _timestamp_to_datetime(_collapse_or_err(_collapse_uint32, int(value)))


def to_uint1(value: Any) -> int:
int_value = int(value)
if int_value == 0 or int_value == 1:
return int_value
else:
raise ValueError("Value must be 0 or 1")


def to_uint16(value: Any) -> int:
return _collapse_or_err(_collapse_uint16, int(value))

Expand Down
4 changes: 4 additions & 0 deletions tests/datasets/test_replays_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ def test_replay_actions(self) -> None:
"text": "text",
"timestamp": int(now.timestamp()),
"event_hash": "df3c3aa2daae465e89f1169e49139827",
"is_dead": 0,
"is_rage": 1,
}
],
}
Expand Down Expand Up @@ -746,3 +748,5 @@ def test_replay_actions(self) -> None:
assert row["click_alt"] == ""
assert row["click_testid"] == ""
assert row["click_title"] == ""
assert row["click_is_dead"] == 0
assert row["click_is_rage"] == 1

0 comments on commit fe6e66c

Please sign in to comment.