Skip to content

Commit

Permalink
chore(feedback): add extra source tags to create_feedback_issue metri…
Browse files Browse the repository at this point in the history
…cs (#76742)

referrer: identifies the pipeline feedback was ingested/shimmed from.
See the enum + architecture doc
client_source: "source" field optionally sent in new feedback envelopes.
This is user/SDK-defined, current examples are "widget" vs "api".
  • Loading branch information
aliu39 committed Aug 29, 2024
1 parent fa2fcd9 commit 5522b80
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/sentry/feedback/usecases/create_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,44 @@ def should_filter_feedback(event, project_id, source: FeedbackCreationSource):
):
metrics.incr(
"feedback.create_feedback_issue.filtered",
tags={"reason": "missing_context"},
tags={
"reason": "missing_context",
"referrer": source.value,
},
)
return True

if event["contexts"]["feedback"]["message"] == UNREAL_FEEDBACK_UNATTENDED_MESSAGE:
metrics.incr(
"feedback.create_feedback_issue.filtered",
tags={"reason": "unreal.unattended"},
tags={
"reason": "unreal.unattended",
"referrer": source.value,
},
)
return True

if event["contexts"]["feedback"]["message"].strip() == "":
metrics.incr("feedback.create_feedback_issue.filtered", tags={"reason": "empty"})
metrics.incr(
"feedback.create_feedback_issue.filtered",
tags={
"reason": "empty",
"referrer": source.value,
},
)
return True

return False


def create_feedback_issue(event, project_id: int, source: FeedbackCreationSource):
metrics.incr("feedback.create_feedback_issue.entered")
metrics.incr(
"feedback.create_feedback_issue.entered",
tags={
"referrer": source.value,
"client_source": get_path(event, "contexts", "feedback", "source"),
},
)

if should_filter_feedback(event, project_id, source):
return
Expand All @@ -200,7 +218,11 @@ def create_feedback_issue(event, project_id: int, source: FeedbackCreationSource
logger.exception("Error checking if message is spam")
metrics.incr(
"feedback.create_feedback_issue.spam_detection",
tags={"is_spam": is_message_spam},
tags={
"is_spam": is_message_spam,
"referrer": source.value,
"client_source": event["contexts"]["feedback"].get("source"),
},
sample_rate=1.0,
)

Expand Down Expand Up @@ -345,7 +367,11 @@ def shim_to_feedback(
feedback_event["tags"] = [list(item) for item in event.tags]

else:
metrics.incr("feedback.user_report.missing_event", sample_rate=1.0)
metrics.incr(
"feedback.user_report.missing_event",
sample_rate=1.0,
tags={"referrer": source.value},
)

feedback_event["timestamp"] = datetime.utcnow().timestamp()
feedback_event["platform"] = "other"
Expand Down

0 comments on commit 5522b80

Please sign in to comment.