Skip to content

Commit ea25ebf

Browse files
authored
add startUrl to security scan events (#4151)
1 parent f33c75d commit ea25ebf

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "CodeWhisperer: Add startUrl to security scan telemetry"
4+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mockito = "5.10.0"
2121
mockitoKotlin = "5.2.1"
2222
mockk = "1.13.8"
2323
node-gradle = "7.0.1"
24-
telemetryGenerator = "1.0.190"
24+
telemetryGenerator = "1.0.192"
2525
testLogger = "3.1.0"
2626
testRetry = "1.5.2"
2727
# test-only; platform provides slf4j transitively at runtime. <233, 1.7.36; >=233, 2.0.9

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererCodeCoverageTracker.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispe
3131
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
3232
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererUserGroupSettings
3333
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.TOTAL_SECONDS_IN_MINUTE
34+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getCodeWhispererStartUrl
3435
import software.aws.toolkits.jetbrains.services.codewhisperer.util.runIfIdcConnectionOrTelemetryEnabled
3536
import software.aws.toolkits.telemetry.CodewhispererTelemetry
3637
import java.time.Duration
@@ -245,7 +246,8 @@ abstract class CodeWhispererCodeCoverageTracker(
245246
totalTokensSize,
246247
successCount = myServiceInvocationCount.get(),
247248
codewhispererCustomizationArn = customizationArn,
248-
codewhispererUserGroup = CodeWhispererUserGroupSettings.getInstance().getUserGroup().name
249+
codewhispererUserGroup = CodeWhispererUserGroupSettings.getInstance().getUserGroup().name,
250+
credentialStartUrl = getCodeWhispererStartUrl(project)
249251
)
250252
}
251253
}

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispe
3232
import software.aws.toolkits.jetbrains.services.codewhisperer.service.RequestContext
3333
import software.aws.toolkits.jetbrains.services.codewhisperer.service.ResponseContext
3434
import software.aws.toolkits.jetbrains.services.codewhisperer.settings.CodeWhispererSettings
35+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getCodeWhispererStartUrl
3536
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getConnectionStartUrl
3637
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.getGettingStartedTaskType
3738
import software.aws.toolkits.jetbrains.services.codewhisperer.util.runIfIdcConnectionOrTelemetryEnabled
@@ -330,7 +331,8 @@ class CodeWhispererTelemetryService {
330331
findingId = issue.findingId,
331332
detectorId = issue.detectorId,
332333
ruleId = issue.ruleId,
333-
includesFix = issue.suggestedFixes.isNotEmpty()
334+
includesFix = issue.suggestedFixes.isNotEmpty(),
335+
credentialStartUrl = getCodeWhispererStartUrl(issue.project)
334336
)
335337
}
336338

@@ -341,7 +343,8 @@ class CodeWhispererTelemetryService {
341343
ruleId = issue.ruleId,
342344
component = Component.Hover,
343345
result = result,
344-
reason = reason
346+
reason = reason,
347+
credentialStartUrl = getCodeWhispererStartUrl(issue.project)
345348
)
346349
}
347350

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererUtil.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ object CodeWhispererUtil {
248248
return connection.startUrl
249249
}
250250

251+
fun getCodeWhispererStartUrl(project: Project): String? {
252+
val connection = ToolkitConnectionManager.getInstance(
253+
project
254+
).activeConnectionForFeature(CodeWhispererConnection.getInstance()) as? AwsBearerTokenConnection?
255+
return connection?.startUrl
256+
}
257+
251258
private fun tokenConnection(project: Project) = (
252259
ToolkitConnectionManager
253260
.getInstance(project)

0 commit comments

Comments
 (0)