Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Made sectionName optional #28

Closed
wants to merge 3 commits into from
Closed

Conversation

rhystmills
Copy link

@rhystmills rhystmills commented Feb 8, 2021

What does this change?

This PR makes the sectionName property in the Targeting type optional.

The sectionName property in the Targeting type doesn't appear in the ReaderRevenueBanner payload on DCR (which, based on testing, doesn't seem to be under type control currently: once we resolve the type discrepancies we can change this), and is optionally an empty string in SlotBodyEnd.

A related PR is the removal of the ophanComponentId property from the tracking type.

N.b. this PR formerly added isSensitive as a prop, but it's not actually used on the platform so I will remove it there instead.

This value is optional in ReaderRevenueEpic and doesn't appear in ReaderRevenueBanner
@rhystmills rhystmills changed the title Made sectionName optional Made sectionName optional and add isSensitive optional property Feb 8, 2021
Copy link
Member

@tjmw tjmw left a comment

Choose a reason for hiding this comment

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

I left a couple of comments on the Targeting type changes made here. I'm not 100% on their usage though.

@tomrf1 I think your input here would be valuable, it you have a moment to look at these changes?

@@ -27,10 +27,11 @@ export type WeeklyArticleHistory = WeeklyArticleLog[];

export type Targeting = {
contentType: string;
sectionName: string;
sectionName?: string;
Copy link
Member

Choose a reason for hiding this comment

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

Interestingly this is required for epic targeting according to the type definition here, though like you say not required by banner targeting here.

So it's true that the net result if we were to combine the types is that it's optional, though I think that doesn't quite reflect the reality. I wonder if a better place to end up would be to split this type into two (one for the epic, one for the banner) like support-dotcom-components does. Not suggesting you have to take on that refactoring here though! Also interesting to think about how to reduce the duplication here and in support-dotcom-components (these types should always be aligned I think).

In the meantime perhaps making this optional as you've done is the most pragmatic way forward.

Copy link
Author

Choose a reason for hiding this comment

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

Splitting the two sounds like a good decision to me.

If the 'canonical' types are in support-dotcom-components, could we just import them from there?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like this Targeting definition is only used by the epic (SlotBodyEnd) - is that right?
What does automat-client give us?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, it's enforced (not particularly explicitly) by the use of getBodyEnd from automat-client, which uses the Metadata type which includes Targeting and Tracking.

Copy link
Author

@rhystmills rhystmills Feb 9, 2021

Choose a reason for hiding this comment

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

From testing, I don't think ReaderRevenueBanner has any type control at all (you can change any of the properties without a complaint from Typescript) - I think ideally it would use the types from elsewhere though - the problem at the moment is that the types it includes aren't included in the definitions from automat-client. From what Tom W says, perhaps there are more canonical types in support-dotcom-components?

Perhaps both DCR and automat-client should be importing types from there?

Copy link
Member

@tjmw tjmw Feb 9, 2021

Choose a reason for hiding this comment

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

What does automat-client give us?

Reminding myself by looking over the repo. It looks like the main things are:

  • type definitions (though as we're discovering, it seems like this is a bit over-simplified and perhaps it'd be better if we could somehow share the type definitions from support-dotcom-components).
  • a thin wrapper around fetch for the end of article api call (getBodyEnd)
  • some shared libs around views retrieving and storing message views (stored in local storage)

So it seems like if we wanted we could move towards embracing automat-client more. For example getBanner which is the equivalent of getBodyEnd is currently implemented directly in ReaderRevenueBanner. Perhaps we want to move that to the client. But then if that's not been a pain point, maybe automat-client isn't pulling its weight in terms of usefulness to warrant having this additional lib.

I do think sharing the type definitions in support-dotcom-components is the way to go. Perhaps there's a way to achieve that with a monorepo approach, where the support-dotcom-components repo also includes an NPM lib (which could replace automat-client). It seems like there might be less friction that way.

types.ts Outdated Show resolved Hide resolved
@rhystmills rhystmills changed the title Made sectionName optional and add isSensitive optional property Made sectionName optional Feb 9, 2021
@rhystmills rhystmills closed this Apr 19, 2021
@shtukas shtukas deleted the rm-optional-sectionName branch February 6, 2023 15:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants