@@ -121,6 +121,7 @@ export class RecommendationHandler {
121
121
let nextToken = ''
122
122
let errorCode = ''
123
123
let req : codewhispererClient . ListRecommendationsRequest | codewhispererClient . GenerateRecommendationsRequest
124
+ let shouldRecordServiceInvocation = false
124
125
125
126
if ( pagination ) {
126
127
req = EditorContext . buildListRecommendationRequest ( editor as vscode . TextEditor , this . nextToken )
@@ -141,6 +142,7 @@ export class RecommendationHandler {
141
142
const codewhispererPromise = pagination
142
143
? client . listRecommendations ( req )
143
144
: client . generateRecommendations ( req )
145
+ shouldRecordServiceInvocation = true
144
146
const resp = await this . getServerResponse (
145
147
triggerType ,
146
148
config . isManualTriggerEnabled ,
@@ -217,24 +219,25 @@ export class RecommendationHandler {
217
219
recommendation . forEach ( ( item , index ) => {
218
220
getLogger ( ) . verbose ( `[${ index } ]\n${ item . content . trimRight ( ) } ` )
219
221
} )
220
-
221
- telemetry . recordCodewhispererServiceInvocation ( {
222
- codewhispererRequestId : requestId ? requestId : undefined ,
223
- codewhispererSessionId : sessionId ? sessionId : undefined ,
224
- codewhispererLastSuggestionIndex : this . recommendations . length - 1 ,
225
- codewhispererTriggerType : triggerType ,
226
- codewhispererAutomatedTriggerType : autoTriggerType ,
227
- codewhispererCompletionType :
228
- invocationResult == 'Succeeded' ? TelemetryHelper . instance . completionType : undefined ,
229
- result : invocationResult ,
230
- duration : latency ? latency : 0 ,
231
- codewhispererLineNumber : this . startPos . line ? this . startPos . line : 0 ,
232
- codewhispererCursorOffset : TelemetryHelper . instance . cursorOffset
233
- ? TelemetryHelper . instance . cursorOffset
234
- : 0 ,
235
- codewhispererLanguage : languageContext . language ,
236
- reason : reason ? reason . substring ( 0 , 200 ) : undefined ,
237
- } )
222
+ if ( shouldRecordServiceInvocation ) {
223
+ telemetry . recordCodewhispererServiceInvocation ( {
224
+ codewhispererRequestId : requestId ? requestId : undefined ,
225
+ codewhispererSessionId : sessionId ? sessionId : undefined ,
226
+ codewhispererLastSuggestionIndex : this . recommendations . length - 1 ,
227
+ codewhispererTriggerType : triggerType ,
228
+ codewhispererAutomatedTriggerType : autoTriggerType ,
229
+ codewhispererCompletionType :
230
+ invocationResult == 'Succeeded' ? TelemetryHelper . instance . completionType : undefined ,
231
+ result : invocationResult ,
232
+ duration : latency ? latency : 0 ,
233
+ codewhispererLineNumber : this . startPos . line ? this . startPos . line : 0 ,
234
+ codewhispererCursorOffset : TelemetryHelper . instance . cursorOffset
235
+ ? TelemetryHelper . instance . cursorOffset
236
+ : 0 ,
237
+ codewhispererLanguage : languageContext . language ,
238
+ reason : reason ? reason . substring ( 0 , 200 ) : undefined ,
239
+ } )
240
+ }
238
241
recommendation = recommendation . filter ( r => r . content . length > 0 )
239
242
240
243
if ( config . isIncludeSuggestionsWithCodeReferencesEnabled === false ) {
0 commit comments