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

Autocomplete: add items to CompletionEvent with tree-sitter fields for analytics #1144

Merged
merged 4 commits into from
Sep 22, 2023

Conversation

valerybugakov
Copy link
Member

@valerybugakov valerybugakov commented Sep 22, 2023

Context

Test plan

Updated unit tests + CI.

@valerybugakov valerybugakov requested a review from a team September 22, 2023 06:37
@valerybugakov valerybugakov self-assigned this Sep 22, 2023
Comment on lines +53 to 70
// Information about each completion item received per one completion event
items: CompletionItemInfo[]
}

export interface ItemPostProcesssingInfo {
// Number of ERROR nodes found in the completion insert text after pasting
// it into the document and parsing this range with tree-sitter.
parseErrorCount?: number
// Number of lines truncated for multiline completions.
lineTruncatedCount?: number
// The truncation approach used.
truncatedWith?: 'tree-sitter' | 'indentation'
}

interface CompletionItemInfo extends ItemPostProcesssingInfo {
lineCount: number
charCount: number
}
Copy link
Member Author

Choose a reason for hiding this comment

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

These fields are added to CompletionEvent

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -103,7 +124,7 @@ export function networkRequestStarted(id: string, contextSummary: ContextSummary
}
}

export function loaded(id: string): void {
export function loaded(id: string, items: InlineCompletionItemWithAnalytics[]): void {
Copy link
Member Author

Choose a reason for hiding this comment

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

New analytics info is added to the existing events here.

Comment on lines 27 to +30
export function processInlineCompletions(
items: InlineCompletionItem[],
params: ProcessInlineCompletionsParams
): InlineCompletionItem[] {
): InlineCompletionItemWithAnalytics[] {
Copy link
Member Author

Choose a reason for hiding this comment

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

processInlineCompletions now returns all the information required for logging. Another way to implement it is to pass the logId here and sprinkle log calls throughout the internal logic, but I found that it makes it harder to test the whole pipeline, so the approach where processInlineCompletions is a pure function.

Base automatically changed from vb/tree-sitter-analytics-prep to main September 22, 2023 07:34
Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

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

Noice

vscode/src/completions/logger.ts Outdated Show resolved Hide resolved
@@ -120,7 +155,7 @@ export function loaded(id: string): void {
//
// For statistics logging we start a timeout matching the READ_TIMEOUT_MS so we can increment the
// suggested completion count as soon as we count it as such.
export function suggested(id: string, source: string, completion: InlineCompletionItem): void {
export function suggested(id: string, source: InlineCompletionsResultSource, completion: InlineCompletionItem): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the source move into the InlineCompletionItem too?

Copy link
Member Author

@valerybugakov valerybugakov Sep 22, 2023

Choose a reason for hiding this comment

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

The InlineCompletionItem type is compliant with vscode.InlineCompletionItem and the vscode one doesn't have the source field. I'm not sure why we use an alias instead of vscode.InlineCompletionItem directly (I support it because of compatibility issues with non-VS-Code environments).

vscode/src/completions/logger.ts Outdated Show resolved Hide resolved
vscode/src/completions/inline-completion-item-provider.ts Outdated Show resolved Hide resolved
import { ProviderConfig } from './providers/provider'
import { RequestManager, RequestParams } from './request-manager'
import { ProvideInlineCompletionItemsTracer, ProvideInlineCompletionsItemTraceData } from './tracer'
import { InlineCompletionItem } from './types'

interface AutocompleteResult extends vscode.InlineCompletionList {
completionEvent?: CompletionEvent
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also have items?

Copy link
Member Author

@valerybugakov valerybugakov Sep 22, 2023

Choose a reason for hiding this comment

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

Yep, extends vscode.InlineCompletionList handles this part

Copy link
Contributor

Choose a reason for hiding this comment

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

Duh 🦭

@@ -15,7 +15,7 @@ import type * as vscode from 'vscode'
// at Object.<anonymous> (/snapshot/dist/agent.js)
// at Module._compile (pkg/prelude/bootstrap.js:1926:22)
// </VERY IMPORTANT>
import type { InlineCompletionItemProvider } from '../../vscode/src/completions/vscodeInlineCompletionItemProvider'
import type { InlineCompletionItemProvider } from '../../vscode/src/completions/inline-completion-item-provider'
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh no this will take some time to get used too 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

Trying to be consistent with filenames, most of the things are kebab-case and we do not prefix modules in the vscode package with vscode 😛

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah not saying it doesn't make sense 🙈

@valerybugakov valerybugakov merged commit d9a5873 into main Sep 22, 2023
11 checks passed
@valerybugakov valerybugakov deleted the vb/tree-sitter-analytics-fields branch September 22, 2023 12:18
valerybugakov added a commit that referenced this pull request Sep 25, 2023
philipp-spiess pushed a commit that referenced this pull request Sep 26, 2023
…s for analytics (#1144)

Adds information about completion items to the `CompletionEvent` we
send to our analytics platforms.
philipp-spiess pushed a commit that referenced this pull request Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants