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

chore(telemetry): telemetry improvements VSCODE-673 #914

Merged
merged 6 commits into from
Jan 29, 2025

Conversation

nirinchev
Copy link
Contributor

@nirinchev nirinchev commented Jan 23, 2025

Description

This addresses the requested improvements tracked in this document.

  • Add new Side Panel Opened event when the extension side panel is activated
  • Add new Section Expanded event when a section is expanded in the connections tree view
  • Update Command Run with source: command_bar | shortcut
  • Update Playground Code Executed to include the type of the command when it's other
  • Update Playground Created, add source_details

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@nirinchev nirinchev requested a review from gagik January 23, 2025 14:23
@nirinchev nirinchev self-assigned this Jan 23, 2025
@nirinchev nirinchev changed the title chore(telemetry): telemetry improvements chore(telemetry): telemetry improvements VSCODE-673 Jan 23, 2025
src/connectionController.ts Outdated Show resolved Hide resolved
@nirinchev nirinchev requested a review from gagik January 24, 2025 17:13
@nirinchev nirinchev marked this pull request as ready for review January 24, 2025 17:13
});

if (!event.element.onDidExpand) {
if (!treeItem.onDidExpand) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do I understand correctly that if we do not have an onDidExpand set then we also don't end up calling _onTreeItemUpdate? Seems to be the legacy behavior so not an issue for this PR, more of not sure why this is fully returning here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems to be the case - I don't know if this is incorrect and a lurking bug or there's a deeper meaning to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this part handles three elements that don't have children. I might be mistaken, maybe Rhys knows better.

@nirinchev nirinchev requested a review from gagik January 28, 2025 07:50
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.

Looks good! Just minor non-blocking comment

src/telemetry/telemetryEvents.ts Outdated Show resolved Hide resolved
/**
* Reported when a tree item from the collection explorer is expanded.
*/
export class TreeItemExpandedTelemetryEvent implements TelemetryEventBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

though here this seems better as section is too vague... which maybe says more about the name of the type.

I don't mind leaving it as is

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 think I'd prefer to leave this as - I know there's a discrepancy between the class name and the event name, but I feel it's fine as those are intended to be consumed by different audiences.


export default class HelpExplorer {
_treeController: HelpTree;
_treeView?: vscode.TreeView<vscode.TreeItem>;

constructor() {
constructor(private _telemetryService: TelemetryService) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need _telemetryService in the constructor?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is meant to be a shortcut for passing it as an argument in the constructor and defining/setting it as a property of the class object which is then used in its method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to inject the telemetry service and I think it's better to do it via the ctor rather than as an argument to activateHelpTreeView like it was previously. I think that way is cleaner architecturally as I see it as a dependency we set once for the lifetime of the controller. Obviously, there's not a huge difference with the HelpExplorer because it's a fairly minimalistic class, but if you consider a more complex controller that has multiple methods which need to log some telemetry events, it becomes much easier to reason about how the dependencies are satisfied.


export default class PlaygroundsExplorer {
private _treeController: PlaygroundsTree;
private _treeView?: vscode.TreeView<vscode.TreeItem>;

constructor() {
constructor(private _telemetryService: TelemetryService) {
Copy link
Contributor

@alenakhineika alenakhineika Jan 28, 2025

Choose a reason for hiding this comment

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

Same here. Doesn't seem we use _telemetryService in the constructor.

* Reported when a tree item from the collection explorer is expanded.
*/
export class TreeItemExpandedTelemetryEvent implements TelemetryEventBase {
type = 'Section Expanded';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is Section a tree item? If yes, maybe Tree Item Expanded would be more transparent than Section Expanded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the name Amanda suggested and I am inclined to keep it because the fact those are tree items is an implementation detail of the code and not terminology that non-engineers necessarily use when describing the connection tree.

@@ -189,4 +191,12 @@ export class TelemetryService {
new ParticipantResponseFailedTelemetryEvent(command, errorName, errorCode)
);
}

trackTreeViewActivated: () => void = throttle(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why to we want to throttle here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to the way the extension works, there's no integration point we can use to be notified that the side panel is opened, which is why we're piggy-backing on the tree visibility event. However, since we have 3 trees in the side panel (connections, playgrounds, help), that event would get fired 3 times every time we open the sidepanel. Rather than deal with this in post-processing, I figured throttling would be a reasonable way to reduce the noise.

@nirinchev nirinchev merged commit 390d75b into main Jan 29, 2025
9 checks passed
@nirinchev nirinchev deleted the ni/telemetry-additions branch January 29, 2025 12:56
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