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

feat(nav): add analytics tracking #80512

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

natemoo-re
Copy link
Member

Adds trackAnalytics call for primary nav items on the new sidebar

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 9, 2024
Comment on lines +40 to +43
/**
* A unique identifier string, used as a key for analytics
*/
id: string;
Copy link
Member

Choose a reason for hiding this comment

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

If there a reasonable chance (and from experience, I would probably say that there is), then I would rather namespace this under analytics object. It's not much of a difference, but it gives you more flexibility and isolation of the analytics and item concept (you'd just access it via item.analytics.id)

Copy link
Member

Choose a reason for hiding this comment

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

On a separate note, you could apply inversion of control here, and define this as a callback function, so that if someone needs to extend anything, they don't need to go through the item definition and add fields, bloating the struct

Comment on lines +138 to +145
function SidebarLink({
children,
item,
onClick,
}: SidebarItemProps & {
children: React.ReactNode;
onClick: React.HTMLAttributes<HTMLAnchorElement>['onClick'];
}) {
Copy link
Member

Choose a reason for hiding this comment

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

The type intersection here is a big no-no :D

I recommend pretty much everyone to read the typescript performance docs to understand exactly why.

In summary, TS is unfortunately not very good at intersecting types - the larger the type, the more the compiles struggles (afaik there is also no type caching here, so the more instances you have, the slower things get). These HTMLAttributes types, while seemingly harmless, are actually absolute massive, as they contain all enumerable html attributes, including the entire CSS definition.

A bit of historical context, but about 3 years back when we joined Sentry, things were so bad that making a simple type change took the lsp more than a second to process... You would make a change and it literally took one second or more for the changes to reflect in your IDE.

We basically halved the time and iirc memory usage of the type checker, mostly by removing intersections like these. There is a PR where I did the initial exploration, and then if you search for ref(tsc), there is a bunch of PRs like this one where you can see the impact of these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants