Skip to content

Commit b81dd43

Browse files
committed
update scope
1 parent 880ab84 commit b81dd43

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

packages/core/src/codewhisperer/util/diagnosticsUtil.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,23 @@ export function getDiagnosticsType(message: string): string {
8585
return 'OTHER'
8686
}
8787

88+
/**
89+
* Generates a unique MD5 hash key for a VS Code diagnostic object.
90+
*
91+
* @param diagnostic - A VS Code Diagnostic object containing information about a code diagnostic
92+
* @returns A 32-character hexadecimal MD5 hash string that uniquely identifies the diagnostic
93+
*
94+
* @description
95+
* Creates a deterministic hash by combining the diagnostic's message, severity, code, and source.
96+
* This hash can be used as a unique identifier for deduplication or tracking purposes.
97+
* Note: range is not in the hashed string because a diagnostic can move and its range can change within the editor
98+
*/
8899
function getDiagnosticKey(diagnostic: vscode.Diagnostic): string {
89100
const jsonStr = JSON.stringify({
90101
message: diagnostic.message,
91102
severity: diagnostic.severity,
92103
code: diagnostic.code,
93104
source: diagnostic.source,
94-
range: {
95-
start: {
96-
line: diagnostic.range.start.line,
97-
character: diagnostic.range.start.character,
98-
},
99-
end: {
100-
line: diagnostic.range.end.line,
101-
character: diagnostic.range.end.character,
102-
},
103-
},
104105
})
105106

106107
return crypto.createHash('md5').update(jsonStr).digest('hex')

packages/core/src/codewhisperer/util/telemetryHelper.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { CodeAnalysisScope as CodeAnalysisScopeClientSide } from '../models/cons
3131
import { Session } from '../../amazonqTest/chat/session/session'
3232
import { sleep } from '../../shared/utilities/timeoutUtils'
3333
import { getDiagnosticsDifferences, getDiagnosticsOfCurrentFile, toIdeDiagnostics } from './diagnosticsUtil'
34+
import { Auth } from '../../auth'
3435

3536
export class TelemetryHelper {
3637
// Some variables for client component latency
@@ -457,7 +458,7 @@ export class TelemetryHelper {
457458
)
458459
})
459460

460-
if (userTriggerDecisionEvent.suggestionState === 'ACCEPT') {
461+
if (userTriggerDecisionEvent.suggestionState === 'ACCEPT' && Auth.instance.isInternalAmazonUser()) {
461462
// wait 1 seconds for the user installed 3rd party LSP
462463
// to update its diagnostics.
463464
void sleep(1000).then(() => {
@@ -469,10 +470,10 @@ export class TelemetryHelper {
469470
userTriggerDecisionEvent.removedIdeDiagnostics = diagnosticDiff.removed.map((it) =>
470471
toIdeDiagnostics(it)
471472
)
472-
sendEvent()
473+
void sendEvent()
473474
})
474475
} else {
475-
sendEvent()
476+
void sendEvent()
476477
}
477478
}
478479

packages/core/src/codewhispererChat/controllers/chat/telemetryHelper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
getDiagnosticsOfCurrentFile,
5454
toIdeDiagnostics,
5555
} from '../../../codewhisperer/util/diagnosticsUtil'
56+
import { Auth } from '../../../auth'
5657

5758
export function logSendTelemetryEventFailure(error: any) {
5859
let requestId: string | undefined
@@ -374,7 +375,7 @@ export class CWCTelemetryHelper {
374375
}
375376
telemetry.amazonq_interactWithMessage.emit({ ...event, ...additionalContextInfo })
376377

377-
let interactWithMessageEvent: CodeWhispererUserClient.ChatInteractWithMessageEvent = {
378+
const interactWithMessageEvent: CodeWhispererUserClient.ChatInteractWithMessageEvent = {
378379
conversationId: event.cwsprChatConversationId,
379380
messageId: event.cwsprChatMessageId,
380381
interactionType: this.getCWClientTelemetryInteractionType(event.cwsprChatInteractionType),
@@ -386,7 +387,7 @@ export class CWCTelemetryHelper {
386387
?.cwsprChatHasProjectContext,
387388
customizationArn: undefinedIfEmpty(getSelectedCustomization().arn),
388389
}
389-
if (interactWithMessageEvent.interactionType === 'INSERT_AT_CURSOR') {
390+
if (interactWithMessageEvent.interactionType === 'INSERT_AT_CURSOR' && Auth.instance.isInternalAmazonUser()) {
390391
// wait 1 seconds for the user installed 3rd party LSP
391392
// to update its diagnostics.
392393
void sleep(1000).then(() => {

0 commit comments

Comments
 (0)