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

feat: feedback analytics and previously submitted answers #3948

Merged
merged 7 commits into from
Nov 19, 2024

Conversation

jamdelion
Copy link
Contributor

@jamdelion jamdelion commented Nov 13, 2024

What's in this PR?

  • Add _feedback to allow_lists
  • Update submission_services_summary and analytics_summary views to include feedback_score.
  • fix: access previously submitted answers when the user presses back

Verified that feedback_score is an int and displaying in analytics_summary
Screenshot 2024-11-19 at 12 13 32

🎟️ Trello ticket: https://trello.com/c/jEOLoubW/3034-can-we-introduce-in-house-end-of-service-feedback

@jamdelion jamdelion changed the title try again feat: feedback analytics Nov 13, 2024
@jamdelion jamdelion marked this pull request as ready for review November 13, 2024 15:11
Copy link

github-actions bot commented Nov 13, 2024

Removed vultr server and associated DNS entries

@jamdelion jamdelion requested a review from a team November 13, 2024 15:21
((ls.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info,
((ls.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info,
(((ls.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type,
((ls.allow_list_answers -> '_feedback'::text))::text AS feedback
Copy link
Member

Choose a reason for hiding this comment

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

Question: since _feedback is an obejct itself, should the views actually drill down one level further to, for example, expose feedback score as its own column? Otherwise I think we'll hit up against usual "Metabase can't process JSONB types" error !

Score seems like obvious first priority for analytics, I'd leave it up to you if we want to expose other _feedback fields too now/up front or wait to expose them on request later if it comes up!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have attempted to implement this, but wasn't really very sure of it!

Also struggled to test it - eventually realised it was only populating the analytics tables when I finished a flow - is that right? 😅

Copy link
Member

Choose a reason for hiding this comment

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

Full comment below - let's try something like ((ls.allow_list_answers -> '_feedback' -> 'feedbackScore'::int))::int AS feedback_score to extract the view-level column data !

@jamdelion jamdelion changed the title feat: feedback analytics feat: feedback analytics and previously submitted answers Nov 14, 2024
@@ -20,6 +21,8 @@ const ALLOW_LIST = [
"application.information.sensitive",
"application.type",
"drawBoundary.action",
"_feedback",
"_feedback.feedbackScore",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not entirely sure whether _feedback.feedbackScore is needed here, and if it is, whether it is in the right format... The sql file does not have _feedback.feedbackScore in it directly, but seemed to work as it is!

e.g. this is from local hasura, analytics table:
Screenshot 2024-11-14 at 17 06 11

Copy link
Member

@jessicamcinchak jessicamcinchak Nov 15, 2024

Choose a reason for hiding this comment

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

Sorry for confusion here! Here's what I'd expect:

  • only "_feedback" should be included in this list. Dot-separated variables only work when it's the "whole" property name and doesn't require destructuring a passport value, which "_feedback.feedbackScore" would
  • This means that feedback column in the raw analytics table will look exactly like you've posted above - a jsonb object !
  • then in the SQL to generate the view you should be able to do something like ((ls.allow_list_answers -> '_feedback' -> 'feedbackScore'::int))::int AS feedback_score so that what we're exposing to Metabase is the feedback score as an integer (Metabase can't process jsonb! And free-text userComments are nice to track in raw table but aren't very chart-able)

Does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Jess, the int version you put above (and variations I have tried) caused syntax errors "message": "invalid input syntax for type integer: \"feedbackScore\"", - I assume the reason it shouldn't be text is because Metabase can make nice charts with numbers and can't convert from string numbers to actual numbers?

Have added a column for userComment in the table, and I assume that the feedback column (displaying jsonb) is completely redundant then, given that we now have separate columns for feedback_score and user_comment. Figuring out a way to drop that column from the view if so!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-11-18 at 21 02 44

Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Code looks great! Would suggest logging into Vultr & destroying instance & re-running latest failed CI to see if you can clear up errors? Looks like docker-related errors due to editing migrations I'd guess?

((ls.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type,
((ls.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info,
((ls.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info,
((ls.allow_list_answers -> '_feedback') ->> 'feedbackScore'::text)::int AS feedback_score
Copy link
Member

Choose a reason for hiding this comment

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

tricky casting, but works exactly as expected 💯

@jamdelion jamdelion merged commit 3c17075 into main Nov 19, 2024
12 checks passed
@jamdelion jamdelion deleted the jh/analytics-attempt-3 branch November 20, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants