regen-network / rnd-dev-team

RND Dev Team issue management (DEPRECATED)
0 stars 0 forks source link

Refactor web-components to not have direct dependency on tracking code #1400

Open wgwz opened 1 year ago

wgwz commented 1 year ago

Is your feature request related to a problem? Please describe.

We want to reduce the number of side effects in web-components, specifically, we don't want to be directly dependent on tracking code in web-components. This task is move tracking calls into regen-web specific components, or to find a way to pass tracking code through props.

Additional context (optional)

See this convo in PR #1551 for more context.


For Admin Use

blushi commented 1 year ago

Also see https://github.com/regen-network/regen-web/pull/1551#discussion_r1021386380 that would avoid importing tracking types into web-components

wgwz commented 1 year ago

There are only two places where web-components is dependent on tracking code:

$ rg 'track<' web-components 
web-components/src/components/cards/ProjectCard/ProjectCard.tsx
236:                      track<'buy1', Buy1Event>('buy1', {

web-components/src/components/form/CreateSellOrderForm.tsx
92:        track<'sell2', Sell2Event>('sell2', {

I.e. in the case of ProjectCard the track call could be moved to this higher-level component:

https://github.com/regen-network/regen-web/blob/kyle/1341-improving-tracking-metadata/web-registry/src/pages/Projects/Projects.tsx#L101-L104

Similarly the track call in CreateSellOrderForm can be moved into this higher-level component:

https://github.com/regen-network/regen-web/blob/kyle/1341-improving-tracking-metadata/web-registry/src/pages/Dashboard/MyEcocredits/MyEcocredits.tsx#L454

TL;DR I don't think we necessarily have to refactor the track function to make web-components independent of tracking code.