Skip to content

Conversation

alenakhineika
Copy link
Contributor

@alenakhineika alenakhineika commented Jan 14, 2021

Description

Track telemetry events when user decides to edit a document from a code lens and when the edited document is saved to MongoDB.

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added

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)

@alenakhineika alenakhineika requested a review from Anemy January 14, 2021 11:43
Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

nice - good tests too. Couple small comments, not blockers, nice renaming on the telemetry too.

isGenuine: boolean;
dbType: string;
}
};
Copy link
Member

Choose a reason for hiding this comment

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

Another way we could do this is add a typescript definitions file to the data-service itself. While this does help our code it doesn't ensure this can't change in the data-service module. Not too much we can do there though.
I think using the data-service's instance function in our telemetry is a bit overkill - it fetches all of the databases and collection info for example, which we don't use/need. Maybe at some point we update it to be a bit more like mongosh where we're only pulling what we need: https://github.com/mongodb-js/mongosh/blob/master/packages/service-provider-server/src/cli-service-provider.ts#L234 . Not related to this pr but I figure it's good to bring up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, would be nice to have types in data service. But since we were talking about getting rid of data service completely for this project, I put a temporary solution here to fix the linting warning.

} catch (error) {
log.error('TELEMETRY key error', error);
}
this._segmentUserID = storageController.getUserID() || '';
Copy link
Member

Choose a reason for hiding this comment

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

Isn't getUserID always returning a string?

this.track(TelemetryEventTypes.DOCUMENT_UPDATED, { source, success });
}

trackOpenMongoDBDocumentFromPlayground(source: string): void {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can make source here use the DOCUMENT_SOURCE_PLAYGROUND and DOCUMENT_SOURCE_TREEVIEW types

dataService: DataServiceType,
connectionType: ConnectionTypes
): void {
dataService.instance({}, async (error: any, data: any) => {
Copy link
Member

Choose a reason for hiding this comment

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

Since we are doing a lot of things depending on the instance results here - maybe we can promisify this and try catch it. Then if we do end up doing something that breaks it's handled well - maybe we also want to log that error to telemetry.

}
});
} catch (error) {
log.error('TELEMETRY track new connection', error);
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to track the telemetry error here? (We'd probably want to sanitize the error somehow though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Max hasn't requested a telemetry event for failed connections, only for ones that succeeded.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha - I was thinking about creating a telemetry event around letting us know we've missed tracking a connection because we errored parsing the connection instance information, not an event around a connection failing to connect. It's probably something we'd want a bug tracker to report, but since we don't have one it might make sense to report it to telemetry so we're aware if users are adding connections but we aren't properly tracking them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, pls create a ticket to triage it!

Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

👍

@alenakhineika alenakhineika merged commit 5469799 into master Jan 14, 2021
@alenakhineika alenakhineika deleted the VSCODE-224-telemetry-document-edited-from-playground branch January 14, 2021 15:10
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.

2 participants