-
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
refactor: store analytics_logs allow_list_answers from arrays of objects to object #2945
refactor: store analytics_logs allow_list_answers from arrays of objects to object #2945
Conversation
- Align the data structure of the `allow_list_answers` to the `submission_services_summary` - Filter out null answer values from getAnswers - Return null when no allow_list_answers found
- Convert from an array of objects to a single object - Currently we have no records in prod where the [allow_list_answers is longer than 1](https://metabase.editor.planx.uk/question/354-number-of-analytics-logs-with-allow-list-answers-greater-than-1) so we can use this to convert - Update the `analytics_summary` db view to handle the change to the data structure
5d2cec6
to
48cb555
Compare
- Assumption that only one passport variable was set at a time and that it was defined by the flow was proven wrong - Therefore node_fn was not accurate and the tracking of it unnecessary as the associated passport key is stored in the allow_list_answers object
🤖 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.
Small comment on some possible TypeScript tidy ups but looking good!
if (!nodeFn || !ALLOW_LIST.includes(nodeFn)) return []; | ||
const nodeFn: string | undefined = data?.fn || data?.val; | ||
|
||
if (!nodeFn || !ALLOW_LIST.includes(nodeFn as AllowListKey)) return; |
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.
if (!nodeFn || !ALLOW_LIST.includes(nodeFn as AllowListKey)) return; | |
const isAllowListKey = (nodeFn: string): nodeFn is AllowListKey => { | |
return (ALLOW_LIST as readonly string[]).includes(nodeFn); | |
}; | |
if (!nodeFn || !isAllowListKey(nodeFn)) return; |
If we add a type guard here instead of just .includes()
we'll get type narrowing and can drop the casting to AllowListKey
on line 526.
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 much neater solution 🙌
I wasn't happy with the type casting but I couldn't figure out an improvement, I'll keep this pattern in mind going forward 😊
Should be sorted here: 9bccce1
const filteredEntries = Object.entries(dataSetByNode) | ||
.filter( | ||
([key, value]) => | ||
ALLOW_LIST.includes(key as AllowListKey) && Boolean(value), |
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.
See previous comment on using a type guard (is
function) - we can probably use one here to avoid casting twice.
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.
Should also be sorted by: 9bccce1
- As per: #2945 (comment) - As per: #2945 (comment) Co-authored-by: Dafydd Llŷr Pearson <[email protected]>
What
allow_list_answers
as an objectgetAnswers
to filter outnull
answerValues
to avoid storingnull
values: https://metabase.editor.planx.uk/question/353-null-allow-list-valuesallow_list_answers
> 1 none of our ALLOW_LIST actually gets set by the same node: https://metabase.editor.planx.uk/question/354-number-of-analytics-logs-with-allow-list-answers-greater-than-1analytics_summary
to handle the change in data structure ofallow_list_answers
node_fn
from trackingWhy
allow_list_answers
as an array is harder to work withlowcal_sessions
null
values from some edge case nodesFollow Up
null
being stored inallow_list_answers
it doesn't cleanup historical data which will be done in a follow up PR.analytics_logs
andanalytics_summary
on.dev
it looks like the data was updated as expected 🥳