Skip to content

Commit 0371970

Browse files
authored
telemetry(inline-suggestion): fine tune supplemental context strategy telemetry (#6242)
## Problem Current `supplementalContextStrategy ` only reflect what group the user is in, however by doing this it won't help much on our data analysis. What we need is the context strategy being used so that we know how much % of users have repomap or opentabs and how % of users have empty supplemental context etc. ## Solution --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent f87a94b commit 0371970

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import { isTestFile } from './codeParsingUtil'
1818
import { getFileDistance } from '../../../shared/filesystemUtilities'
1919
import { getOpenFilesInWindow } from '../../../shared/utilities/editorUtilities'
2020
import { getLogger } from '../../../shared/logger/logger'
21-
import { CodeWhispererSupplementalContext, CodeWhispererSupplementalContextItem } from '../../models/model'
21+
import {
22+
CodeWhispererSupplementalContext,
23+
CodeWhispererSupplementalContextItem,
24+
SupplementalContextStrategy,
25+
} from '../../models/model'
2226
import { LspController } from '../../../amazonq/lsp/lspController'
2327
import { waitUntil } from '../../../shared/utilities/timeoutUtils'
2428

@@ -75,14 +79,18 @@ export async function fetchSupplementalContextForSrc(
7579

7680
// opentabs context will use bm25 and users' open tabs to fetch supplemental context
7781
if (supplementalContextConfig === 'opentabs') {
82+
const supContext = (await fetchOpentabsContext(editor, cancellationToken)) ?? []
7883
return {
79-
supplementalContextItems: (await fetchOpentabsContext(editor, cancellationToken)) ?? [],
80-
strategy: 'opentabs',
84+
supplementalContextItems: supContext,
85+
strategy: supContext.length === 0 ? 'Empty' : 'opentabs',
8186
}
8287
}
8388

8489
// codemap will use opentabs context plus repomap if it's present
8590
if (supplementalContextConfig === 'codemap') {
91+
let strategy: SupplementalContextStrategy = 'Empty'
92+
let hasCodemap: boolean = false
93+
let hasOpentabs: boolean = false
8694
const opentabsContextAndCodemap = await waitUntil(
8795
async function () {
8896
const result: CodeWhispererSupplementalContextItem[] = []
@@ -91,20 +99,30 @@ export async function fetchSupplementalContextForSrc(
9199

92100
if (codemap && codemap.length > 0) {
93101
result.push(...codemap)
102+
hasCodemap = true
94103
}
95104

96105
if (opentabsContext && opentabsContext.length > 0) {
97106
result.push(...opentabsContext)
107+
hasOpentabs = true
98108
}
99109

100110
return result
101111
},
102112
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
103113
)
104114

115+
if (hasCodemap) {
116+
strategy = 'codemap'
117+
} else if (hasOpentabs) {
118+
strategy = 'opentabs'
119+
} else {
120+
strategy = 'Empty'
121+
}
122+
105123
return {
106124
supplementalContextItems: opentabsContextAndCodemap ?? [],
107-
strategy: 'codemap',
125+
strategy: strategy,
108126
}
109127
}
110128

@@ -133,9 +151,10 @@ export async function fetchSupplementalContextForSrc(
133151
}
134152
}
135153

154+
const supContext = opentabsContext ?? []
136155
return {
137-
supplementalContextItems: opentabsContext ?? [],
138-
strategy: 'opentabs',
156+
supplementalContextItems: supContext,
157+
strategy: supContext.length === 0 ? 'Empty' : 'opentabs',
139158
}
140159
}
141160

0 commit comments

Comments
 (0)