-
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
Mh/metadata types update #2805
Mh/metadata types update #2805
Conversation
Removed vultr server and associated DNS entries |
@@ -0,0 +1,49 @@ | |||
DROP VIEW public.analytics_summary; |
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.
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 created my branch off of Daf's but when I created the PR I didn't notice I was pointing at main
I'll get that sorted 👍
trackHelpClick: (metadata?: HelpClickMetadata) => Promise<void>; | ||
trackNextStepsLinkClick: (metadata?: SelectedUrlsMetadata) => Promise<void>; | ||
trackHelpClick: (metadata?: Metadata) => Promise<void>; | ||
trackNextStepsLinkClick: (metadata?: Metadata) => Promise<void>; |
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.
It seems that this change means the type is less desscriptive/meaningful rather than more - I'm not sure I understand?
If trackHelpClick
has type HelpClickMetadata
then it already is valid Metadata
right? But with this update, I could incorrectly pass trackHelpClick({ "back": { ...metadata } })
and I don't think it wouldn't get caught, right?
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 I understand Daf's intention with adding Metadata
I think it's nice to make clear the expected content that could be written to the metadata
jsonb column which could have anything written to it but we're setting our expectations which I really like and could see the value of. I was associating all functions which write to the column with Metadata
so that it's clear it'll be one of the types it's composed of.
Although, as you say it does mean we're not enforcing the types on the functions which as you say is less descriptive.
I've updated my PR to expand on the Metadata
but the new type never gets used anywhere preserving the more explicit types on the functions 🤔
Rather than go with this approach it would maybe be best to remove the Metadata
type?
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.
In my mind this distinction is:
- specific types like
HelpClickMetadata
should be used to restrict the arguments passed to methods liketrackHelpClick
- the broad union type
Metadata
should be used to define what the GraphQL requests (mutations and queries alike) for this JSONB column expect
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 definitely agree with that @jessicamcinchak although the bit I'm not sure on is whether we can actually assign the Metadata
type to the GraphQL request, is that what you're suggesting?
With trackHelpClick
I think the function is associated with HelpClickMetadata
but there's no where to add Metadata
as I understand it although I think I might be missing something.
async function trackHelpClick(metadata?: HelpClickMetadata) {
if (shouldSkipTracking()) return;
await publicClient.mutate({
mutation: gql`
mutation UpdateHasClickedHelp($id: bigint!, $metadata: jsonb = {}) {
update_analytics_logs_by_pk(
pk_columns: { id: $id }
_set: { has_clicked_help: true }
_append: { metadata: $metadata }
) {
id
}
}
`,
variables: {
id: lastVisibleNodeAnalyticsLogId,
metadata,
},
});
}
Or would you suggest we maintain the Metadata
but just have it in the file not being called but serving as a marker?
I'm a little bamboozled I think but it would be good to fix this PR / close it as I fear I'm wasting your time with this.
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.
As discussed I'll leave the Metadata
type in the file with a comment explaining it describes that the mutation which write to metadata
will have payload which can be described by one of the options in the union.
ea8d12d
to
a191a43
Compare
177eadc
to
18b8332
Compare
a191a43
to
2cc43a0
Compare
fa49004
to
6f103e9
Compare
…e metadata column
6f103e9
to
8df4c1e
Compare
id?: string; | ||
type?: string | null; | ||
title?: string; |
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.
These have to be optional as some change events we can't access the target nodeId
so we only track change: {}
What
analytics_summary
view #2798Why
Metadata
type