-
Notifications
You must be signed in to change notification settings - Fork 2
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: track allow list answers #2597
Conversation
🤖 Hasura Change Summary compared a subset of table metadata including permissions: Updated Tables (1)
|
Removed vultr server and associated DNS entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few quick comments - can't currently test the pizza as I'm getting CORS issues - I suspect it just needs a rebase as this was something I broke when working on auth before Christmas I think! 👍
@@ -410,6 +421,50 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({ | |||
} | |||
} | |||
|
|||
async function updateLastVisibleNodeLogWithAllowListAnswers(nodeId: string) { | |||
if (shouldTrackAnalytics && lastVisibleNodeAnalyticsLogId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'm not exactly sure how, but it would be nice to handle this repeated condition throughout this provider. Even if we just reverse it and make it a guard clause I think it would be a bit more readable / meaningful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great shout, I think theres a lot of nesting in the file which can make it a bit harder to parse.
I've added more guard clauses and tried to see if I could update the conditionals to be slightly more readable.
It's on this commit and it would be great to get your opinion on the changes: 7bb5ac8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice and a good improvement - more readable for sure 👍
What do you think about a change along these lines -
function trackEvent(event: MyEnumOfEventTypes): void {
skipUpdateIfNotTracking();
switch (event) {
case "helpClick":
// Handle helpClick event
break;
case "nextStepsLinkClick":
// Handle nextStepsLinkClick event
break;
// Add more cases as needed
default:
// Handle default case or throw an error
break;
}
}
The benefits I'd see of this would be -
- You can't miss the guard clause
skipUpdateIfNotTracking()
when adding a new event - It's a bit more self documenting - when we come back and add a new event type it should be a simpler pattern to follow (add event enum, add case in this controller function)
- We could drop the "child" functions like
trackHelpClick()
from thecreateContext
type definition and only expost the "parent"trackEvent()
controller.
Super happy for the response to be "not worth it", just wanted to run the idea by you. This could also be a small refactor on a follow up PR! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really interesting suggestion! I'd noticed there was quite a lot of very similar patterns and something like this could potentially resolve that. Some of the events have specific requirements for further info but I'm sure this could be managed as well.
As this piece of work has been on the burner for a long time I think I'd opt to as you say leave it for now and potentially follow up with a refactor PR in the future. I feel like I'm almost too close to the analyticsProvider
file and a bit of time away from it could really help to refactor with fresh eyes
...lanx.uk/migrations/1703169856492_alter_table_public_analytics_logs_add_column_node_fn/up.sql
Outdated
Show resolved
Hide resolved
Thank you very much for the review, I'll have a look at the comments now. Strangely with testing on the pizza I wasn't seeing any CORS issues before the holidays and it still seems to be working for me 🤔 I'll double check once I've pushed commits and rebased though. |
Ah sorry about this - there's certainly a chance I had a local cookie or something else going on - tried again and it works a charm for me now! Will take another look very shortly 👍 |
Thanks for checking again @DafyddLlyr, absolutely no rush as I have some local setup issues to squash before I rebase and update as per your comments. As the testing is quite laborious it might be worth waiting until the branch is updated rather than having to do it twice 😅 |
- As per: #2597 (comment) - Update definition to use uppercase variable name and declare as const for consistency and more thorough type defintion
3e131e4
to
393e17b
Compare
- As per: #2597 (comment) - Update definition to use uppercase variable name and declare as const for consistency and more thorough type defintion
- As per: #2597 (comment) - Reduce nesting by refactoring to use guard clauses - Abstract commonly used guard clause into it's own function.
393e17b
to
7bb5ac8
Compare
- The passport variable a node can relate to is stored either on the `fn` or the `val` of the node. - Begin tracking this to support allow list work - These allowlist answers will always be an empty array when the log is created - Added update permission as on breadcrumb changes the record will be updated if the logs node_fn is in the allow_list
- When breadcrumbs change and the user has answered a question check if it's in the allow list and if so store - Update permission to allow us to select the node_id - This allows us to ensure that we'll only track allow list answers against the correct nodes
- As per: #2597 (comment) - Update definition to use uppercase variable name and declare as const for consistency and more thorough type defintion
- As per: #2597 (comment) - Reduce nesting by refactoring to use guard clauses - Abstract commonly used guard clause into it's own function.
7bb5ac8
to
612fa87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look great! Once small comment on abstracting away a few things but it's non-blocking 👌
- As per: #2597 (comment) - Consolidating individual tracking event functions into a single function with a case statement - Step towards clearer organisation and documentation of analyticsProvider
- As per: #2597 (comment) - Consolidating individual tracking event functions into a single function with a case statement - Step towards clearer organisation and documentation of analyticsProvider
- As per: #2597 (comment) - Consolidating individual tracking event functions into a single function with a case statement - Step towards clearer organisation and documentation of analyticsProvider
- As per: #2597 (comment) - Consolidating individual tracking event functions into a single function with a case statement - Step towards clearer organisation and documentation of analyticsProvider Co-authored-by: Dafydd Llŷr Pearson <[email protected]>
- As per: #2597 (comment) - Consolidating individual tracking event functions into a single function with a case statement - Step towards clearer organisation and documentation of analyticsProvider Co-authored-by: Dafydd Llŷr Pearson <[email protected]>
What
node_fn
inanalytics_log
table to tie together nodes and the passport variables they relate toallow_list_answers
inanalytics
when a user directly answers a questionWhy
node_fn
makes it easier to reason about how nodes can affect the passport.allow_list_answers
Note