Skip to content

Conversation

@nirinchev
Copy link
Contributor

Description

This is a refactoring of the telemetry service to more closely tie the event type with its properties.

  • All telemetry events now contain their own type, which makes it impossible to supply the wrong combination of type/properties.
  • Added some basic documentation of the events and their properties.
  • Removed Keytar Secrets Migration Failed as it wasn't ever reported.

There should be no functional changes and all events should continue to be reported exactly as before. This is laying the groundwork for the telemetry changes we've been discussing, but those are not included in this PR.

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

@nirinchev nirinchev requested review from alenakhineika and gagik and removed request for gagik January 22, 2025 17:01
@nirinchev nirinchev changed the title chore(telemetry): refactor telemetry types chore(telemetry): refactor telemetry types VSCODE-672 Jan 22, 2025
Copy link
Contributor

@gagik gagik left a comment

Choose a reason for hiding this comment

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

This is great; previous way of adding a new event for telemetry required a lot of boilerplate so this is a really nice change

export * from './telemetryEvents';

export { TelemetryService };
export default TelemetryService;
Copy link
Contributor

@gagik gagik Jan 23, 2025

Choose a reason for hiding this comment

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

this is a more controversial preference thing but can we consider not using default exports (and maybe even banning them eventually...)? I know TelemetryService was actually mainly being used as a default export and we have a lot in the codebase.

I think benefits of avoiding defaults are quite minor especially since IDEs have gotten better but minor boosts still exist (also consistency as I don't really see why sometimes we have default and sometimes named exports). Strongest argument other than that might be:

Default exports are also refactoring hostile. If I rename the named exported members in a module, then any usage will be renamed, too (provided you are using an IDE that can apply this refactoring). With default exports, this isn’t possible.

https://www.lloydatkinson.net/posts/2022/default-exports-in-javascript-modules-are-terrible/
https://cichocinski.dev/blog/using-default-exports-makes-javascript-harder

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'd not be opposed to that - the only reason I reexported it as default was to avoid changing a bunch of places where we were importing it from telemetry/telemetryService.

Copy link
Contributor

@gagik gagik Jan 23, 2025

Choose a reason for hiding this comment

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

Yeah that makes sense, it may be worth leaving for a different time and dealing with default exports more globally later if we decide to do so

@nirinchev nirinchev merged commit 0816d1c into main Jan 23, 2025
6 checks passed
@nirinchev nirinchev deleted the ni/telemetry branch January 23, 2025 12:11
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