Skip to content

fix(feedback): update_user_reports to shim feedback - #68317

Merged
JoshFerge merged 4 commits into
masterfrom
jferg/feedback-shim-adjust
Apr 17, 2024
Merged

JoshFerge merged 4 commits into
masterfrom
jferg/feedback-shim-adjust

Conversation

@JoshFerge

Copy link
Copy Markdown
Contributor
  • In places where we previously created feedbacks, we now only do so if an event exists at the time.
  • In update_userreports, create the feedback via shim there, where the event exists.

We were seeing lots of customer issues where the environment wasn't being set correctly. This should fix the issue.

Note, after this change, user reports that never receive an associated event will no longer be ingested / shown in the platform. This is the behavior prior to the recent feedback changes. Because of missing environments, these events end up causing more confusion than they are worth, so I think it makes sense to not show them.

@JoshFerge
JoshFerge requested a review from a team as a code owner April 4, 2024 23:16
@JoshFerge
JoshFerge requested a review from a team April 4, 2024 23:16
@JoshFerge

Copy link
Copy Markdown
Contributor Author

will follow up with tests tomorrow

@aliu39

aliu39 commented Apr 5, 2024

Copy link
Copy Markdown
Member

Do we expect shim_to_feedback to ever be called with event=None after this change? If not, could we remove this case in that fx?

@aliu39

aliu39 commented Apr 5, 2024

Copy link
Copy Markdown
Member

Because of missing environments, these events end up causing more confusion than they are worth, so I think it makes sense to not show them.

By "events" do you mean userreport + resulting feedback? I.e. "user reports without an associated event are missing an environment"

if features.has(
"organizations:user-feedback-ingest", project.organization, actor=None
):
shim_to_feedback(

@aliu39 aliu39 Apr 5, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When is this task ran and what's the purpose of calling shim_to_feedback here, vs save_userreport? If it's called in both, won't this create duplicate feedbacks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if you look at the above:

user_reports = UserReport.objects.filter(
        group_id__isnull=True,
        environment_id__isnull=True,
        date_added__gte=start,
        date_added__lte=end,
    )

this is the key -- we're only going to call shim_to_feedback on user reports which haven't already been shimmed, as there was no event associated with them, so no duplication.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we just use event_id__isnull instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

don't think it really matters too much -- they should all return equivalent results unless i'm missing something

@aliu39 aliu39 Apr 5, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if it doesn't matter for functionality, i'd prefer event_id=null. from a reader's perspective, event_id__isnull makes it clear that we're filtering on user reports with missing events. Although environment and group = null is correlated with event = null right now, the relationship isn't clear and it might not always be the case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@aliu3ntry i think that is a fair point -- my only counter is that this PR is not changing this line, and i'd rather not introduce changes that aren't needed. i could add a comment explaining if that makes sense to you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see, that's fair. Yes a comment would be good

@aliu39 aliu39 Apr 8, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Taking a second look, I think event_id__isnull would've been wrong... we use event_id's to lookup the associated events, and in the UserReport model this field isn't nullable. Thank you for adding the comment!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right, totally that makes sense -- the event_id is added regardless if the event exists or not.

shim_to_feedback(
report, event, project, FeedbackCreationSource.USER_REPORT_ENVELOPE
)
report.update(group_id=event.group_id, environment_id=event.get_environment().id)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we update these fields before creating the feedback? I.e. move it above line 68

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i don't think it really matters, what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought shim_to_feedback used these fields -- didn't look closely enough, my bad

@JoshFerge

Copy link
Copy Markdown
Contributor Author

this case

yes, we can remove the case. i'd want to do that in a follow up PR to ensure that metric drops to 0.

@JoshFerge

Copy link
Copy Markdown
Contributor Author

Because of missing environments, these events end up causing more confusion than they are worth, so I think it makes sense to not show them.

By "events" do you mean userreport + resulting feedback? I.e. "user reports without an associated event are missing an environment"

yes, exactly.

@codecov

codecov Bot commented Apr 5, 2024 •

Copy link
Copy Markdown

Bundle Report

Changes will decrease total bundle size by 2.23kB ⬇️

Bundle name Size Change
sentry-webpack-bundle-array-push 26.15MB 2.23kB ⬇️

@ryan953

ryan953 commented Apr 6, 2024

Copy link
Copy Markdown
Member

This looks related to #68179

@JoshFerge
JoshFerge merged commit 5b2d59a into master Apr 17, 2024
@JoshFerge
JoshFerge deleted the jferg/feedback-shim-adjust branch April 17, 2024 17:59
@github-actions github-actions Bot locked and limited conversation to collaborators May 3, 2024

This branch was successfully deployed

1 active deployment
Preview — 1d5adc73 Deployed Apr 5, 2024 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants