|
@@ -21,6 +21,15 @@ SegmentList = typing.Iterable[typing.Dict[str, typing.Any]]
|
|
|
RRWebNode = typing.Dict[str, typing.Any]
|
|
|
|
|
|
|
|
|
+def sec(timestamp: datetime.datetime):
|
|
|
+ # sentry data inside rrweb is recorded in seconds
|
|
|
+ return int(timestamp.timestamp())
|
|
|
+
|
|
|
+
|
|
|
+def ms(timestamp: datetime.datetime):
|
|
|
+ return int(timestamp.timestamp()) * 1000
|
|
|
+
|
|
|
+
|
|
|
def assert_expected_response(
|
|
|
response: typing.Dict[str, typing.Any], expected_response: typing.Dict[str, typing.Any]
|
|
|
) -> None:
|
|
@@ -115,7 +124,7 @@ def mock_replay(
|
|
|
|
|
|
return {
|
|
|
"type": "replay_event",
|
|
|
- "start_time": int(timestamp.timestamp()),
|
|
|
+ "start_time": sec(timestamp),
|
|
|
"replay_id": replay_id,
|
|
|
"project_id": project_id,
|
|
|
"retention_days": 30,
|
|
@@ -137,9 +146,9 @@ def mock_replay(
|
|
|
),
|
|
|
"dist": kwargs.pop("dist", "abc123"),
|
|
|
"platform": kwargs.pop("platform", "javascript"),
|
|
|
- "timestamp": int(timestamp.timestamp()),
|
|
|
+ "timestamp": sec(timestamp),
|
|
|
"replay_start_timestamp": kwargs.pop(
|
|
|
- "replay_start_timestamp", int(timestamp.timestamp())
|
|
|
+ "replay_start_timestamp", sec(timestamp)
|
|
|
),
|
|
|
"environment": kwargs.pop("environment", "production"),
|
|
|
"release": kwargs.pop("release", "version@1.3"),
|
|
@@ -197,16 +206,16 @@ def mock_segment_init(
|
|
|
return [
|
|
|
{
|
|
|
"type": EventType.DomContentLoaded,
|
|
|
- "timestamp": int(timestamp.timestamp()),
|
|
|
+ "timestamp": ms(timestamp), # rrweb timestamps are in ms
|
|
|
},
|
|
|
{
|
|
|
"type": EventType.Load,
|
|
|
- "timestamp": int(timestamp.timestamp()),
|
|
|
+ "timestamp": ms(timestamp), # rrweb timestamps are in ms
|
|
|
},
|
|
|
{
|
|
|
"type": EventType.Meta,
|
|
|
"data": {"href": href, "width": width, "height": height},
|
|
|
- "timestamp": int(timestamp.timestamp()),
|
|
|
+ "timestamp": ms(timestamp), # rrweb timestamps are in ms
|
|
|
},
|
|
|
]
|
|
|
|
|
@@ -223,11 +232,12 @@ def mock_segment_fullsnapshot(timestamp: datetime.datetime, bodyChildNodes) -> S
|
|
|
tagName="html",
|
|
|
childNodes=[bodyNode],
|
|
|
)
|
|
|
+
|
|
|
return [
|
|
|
{
|
|
|
"type": EventType.FullSnapshot,
|
|
|
"data": {
|
|
|
- "timestamp": int(timestamp.timestamp()),
|
|
|
+ "timestamp": ms(timestamp), # rrweb timestamps are in ms
|
|
|
"node": {
|
|
|
"type": EventType.DomContentLoaded,
|
|
|
"childNodes": [htmlNode],
|
|
@@ -241,11 +251,11 @@ def mock_segment_console(timestamp: datetime.datetime) -> SegmentList:
|
|
|
return [
|
|
|
{
|
|
|
"type": EventType.Custom,
|
|
|
- "timestamp": int(timestamp.timestamp()),
|
|
|
+ "timestamp": ms(timestamp), # rrweb timestamps are in ms
|
|
|
"data": {
|
|
|
"tag": "breadcrumb",
|
|
|
"payload": {
|
|
|
- "timestamp": int(timestamp.timestamp()) / 1000,
|
|
|
+ "timestamp": sec(timestamp), # sentry data inside rrweb is in seconds
|
|
|
"type": "default",
|
|
|
"category": "console",
|
|
|
"data": {
|
|
@@ -266,7 +276,7 @@ def mock_segment_breadcrumb(timestamp: datetime.datetime, payload) -> SegmentLis
|
|
|
return [
|
|
|
{
|
|
|
"type": 5,
|
|
|
- "timestamp": int(timestamp.timestamp()),
|
|
|
+ "timestamp": ms(timestamp), # rrweb timestamps are in ms
|
|
|
"data": {
|
|
|
"tag": "breadcrumb",
|
|
|
"payload": payload,
|
|
@@ -281,7 +291,7 @@ def mock_segment_nagivation(
|
|
|
return mock_segment_breadcrumb(
|
|
|
timestamp,
|
|
|
{
|
|
|
- "timestamp": int(timestamp.timestamp()) / 1000,
|
|
|
+ "timestamp": sec(timestamp), # sentry data inside rrweb is in seconds
|
|
|
"type": "default",
|
|
|
"category": "navigation",
|
|
|
"data": {"from": hrefFrom, "to": hrefTo},
|