Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(replay): try 5s rage/dead click timeout for select orgs, using options #77325

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/sentry/options/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,18 @@
default=[],
flags=FLAG_ALLOW_EMPTY | FLAG_AUTOMATOR_MODIFIABLE,
)
register(
"feedback.dead-click.reduced-timeout-org-list",
type=Sequence,
default=[],
flags=FLAG_ALLOW_EMPTY | FLAG_AUTOMATOR_MODIFIABLE,
)
register(
"feedback.dead-click.reduced-timeout-ms",
type=Int,
default=5000,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)


# Extract spans only from a random fraction of transactions.
Expand Down
57 changes: 35 additions & 22 deletions src/sentry/replays/usecases/ingest/dom_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from hashlib import md5
from typing import Any, Literal, TypedDict

from sentry import features
from sentry import features, options
from sentry.conf.types.kafka_definition import Topic
from sentry.models.project import Project
from sentry.replays.usecases.ingest.issue_creation import (
Expand Down Expand Up @@ -401,6 +401,9 @@ def _handle_breadcrumb(
if not isinstance(payload, dict):
return None

reduced_dead_click_timeout = options.get("feedback.dead-click.reduced-timeout-ms")
default_dead_click_timeout = 7000

category = payload.get("category")
if category == "ui.slowClickDetected":
is_timeout_reason = payload["data"].get("endReason") == "timeout"
Expand All @@ -412,28 +415,38 @@ def _handle_breadcrumb(
timeout = payload["data"].get("timeAfterClickMs", 0) or payload["data"].get(
"timeafterclickms", 0
)
if is_timeout_reason and is_target_tagname and timeout >= 7000:
is_rage = (
payload["data"].get("clickCount", 0) or payload["data"].get("clickcount", 0)
) >= 5
click = create_click_event(
payload, replay_id, is_dead=True, is_rage=is_rage, project_id=project_id
if is_timeout_reason and is_target_tagname:
organization = Project.objects.get(id=project_id).organization
dead_click_timeout = (
reduced_dead_click_timeout
if organization.slug in options.get("feedback.dead-click.reduced-timeout-org-list")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not use the org slug because we need to query for it. We have the org_id and the project_id. We could use those with the option directly so you don't need to query anything.

else default_dead_click_timeout
)
if click is not None:
if is_rage:
metrics.incr("replay.rage_click_detected")
if _should_report_rage_click_issue(project_id):
if replay_event is not None:
report_rage_click_issue_with_replay_event(
project_id,
replay_id,
payload["timestamp"],
payload["message"],
payload["data"]["url"],
payload["data"]["node"],
payload["data"]["node"]["attributes"].get("data-sentry-component"),
replay_event,
)

if timeout >= dead_click_timeout:
is_rage = (
payload["data"].get("clickCount", 0) or payload["data"].get("clickcount", 0)
) >= 5
click = create_click_event(
payload, replay_id, is_dead=True, is_rage=is_rage, project_id=project_id
)
if click is not None:
if is_rage:
metrics.incr("replay.rage_click_detected")
if _should_report_rage_click_issue(project_id):
if replay_event is not None:
report_rage_click_issue_with_replay_event(
project_id,
replay_id,
payload["timestamp"],
payload["message"],
payload["data"]["url"],
payload["data"]["node"],
payload["data"]["node"]["attributes"].get(
"data-sentry-component"
),
replay_event,
)
# Log the event for tracking.
log = event["data"].get("payload", {}).copy()
log["project_id"] = project_id
Expand Down
Loading