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

Mh/metadata types update #2805

Merged
merged 1 commit into from
Feb 26, 2024
Merged

Mh/metadata types update #2805

merged 1 commit into from
Feb 26, 2024

Conversation

Mike-Heneghan
Copy link
Contributor

What

Why

  • I'm not sure but I think this expands on the logic of implementing the Metadata type

Copy link

github-actions bot commented Feb 19, 2024

Removed vultr server and associated DNS entries

@@ -0,0 +1,49 @@
DROP VIEW public.analytics_summary;
Copy link
Member

Choose a reason for hiding this comment

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

I was surprised to see a migration here - but it looks to be the same migration from #2798, right? If you change your base branch to Daf's branch it may display a more meaningful comparison of changes, then if #2798 merges first it should automatically switch to main again & rebase ?

Copy link
Contributor Author

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>;
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

@jessicamcinchak jessicamcinchak Feb 20, 2024

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 like trackHelpClick
  • the broad union type Metadata should be used to define what the GraphQL requests (mutations and queries alike) for this JSONB column expect

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@Mike-Heneghan Mike-Heneghan changed the base branch from main to dp/unfold-metadata-columns February 20, 2024 09:23
@Mike-Heneghan Mike-Heneghan force-pushed the mh/metadata-types-update branch from ea8d12d to a191a43 Compare February 20, 2024 16:58
@Mike-Heneghan Mike-Heneghan force-pushed the dp/unfold-metadata-columns branch from 177eadc to 18b8332 Compare February 21, 2024 11:01
@Mike-Heneghan Mike-Heneghan force-pushed the mh/metadata-types-update branch from a191a43 to 2cc43a0 Compare February 21, 2024 11:06
@Mike-Heneghan Mike-Heneghan changed the base branch from dp/unfold-metadata-columns to main February 21, 2024 12:17
@Mike-Heneghan Mike-Heneghan force-pushed the mh/metadata-types-update branch 2 times, most recently from fa49004 to 6f103e9 Compare February 21, 2024 17:32
@Mike-Heneghan Mike-Heneghan force-pushed the mh/metadata-types-update branch from 6f103e9 to 8df4c1e Compare February 21, 2024 17:55
Comment on lines +50 to +52
id?: string;
type?: string | null;
title?: string;
Copy link
Contributor Author

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: {}

@Mike-Heneghan Mike-Heneghan requested a review from a team February 21, 2024 17:57
@Mike-Heneghan Mike-Heneghan merged commit 3d9cc81 into main Feb 26, 2024
12 checks passed
@Mike-Heneghan Mike-Heneghan deleted the mh/metadata-types-update branch March 14, 2024 12:20
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.

3 participants