Skip to content

Commit 6c60bea

Browse files
authored
Update telemetry (#2604)
1 parent fd2b509 commit 6c60bea

File tree

14 files changed

+45
-22
lines changed

14 files changed

+45
-22
lines changed

core/src/software/aws/toolkits/core/credentials/CredentialProviderFactory.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ interface CredentialProviderFactory {
1515
*/
1616
val id: String
1717

18+
/**
19+
* ID used to indicate where credentials are stored or retrieved from
20+
*/
21+
val credentialSourceId: CredentialSourceId
22+
1823
/**
1924
* Invoked on creation of the factory to update the credential system with what [CredentialIdentifier] this factory
2025
* is capable of creating. The provided [credentialLoadCallback] is capable of being invoked multiple times in the case that

core/src/software/aws/toolkits/core/credentials/ToolkitCredentialsProvider.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ enum class CredentialType {
1414
SsoProfile
1515
}
1616

17+
enum class CredentialSourceId {
18+
SharedCredentials,
19+
SdkStore,
20+
Ec2,
21+
EnvVars
22+
}
23+
1724
/**
1825
* Represents a possible credential provider that can be used within the toolkit.
1926
*

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ awsSdkVersion=2.16.36
1616
coroutinesVersion=1.3.3
1717
detektVersion=1.16.0
1818
jacksonVersion=2.11.1
19-
telemetryVersion=0.0.96
19+
telemetryVersion=1.0.3
2020
commonsMarkVersion=0.17.1
2121
jgitVersion=5.11.0.202103091610-r
2222

jetbrains-core/src/software/aws/toolkits/jetbrains/core/credentials/ChangeConnectionSettingsMenu.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ internal class ChangeRegionAction(private val region: AwsRegion) : ToggleAction(
169169
)
170170
}
171171

172-
AwsTelemetry.setRegion(
173-
regionId = region.id
174-
)
172+
AwsTelemetry.setRegion(e.project)
175173
}
176174
}
177175
}

jetbrains-core/src/software/aws/toolkits/jetbrains/core/credentials/CredentialManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ class DefaultCredentialManager : CredentialManager() {
130130
removeProvider(it)
131131
count.decrementAndGet()
132132
}
133-
AwsTelemetry.loadCredentials(credentialSourceId = providerFactory.id, value = count.get().toDouble())
133+
AwsTelemetry.loadCredentials(
134+
credentialSourceId = providerFactory.credentialSourceId.toTelemetryCredentialSourceId(),
135+
value = count.get().toDouble()
136+
)
134137
}
135138
}
136139
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.aws.toolkits.jetbrains.core.credentials
5+
6+
import software.aws.toolkits.core.credentials.CredentialSourceId
7+
import software.aws.toolkits.telemetry.CredentialSourceId as TelemetryCredentialSourceId
8+
9+
fun CredentialSourceId?.toTelemetryCredentialSourceId(): TelemetryCredentialSourceId = when (this) {
10+
CredentialSourceId.SharedCredentials -> TelemetryCredentialSourceId.SharedCredentials
11+
CredentialSourceId.SdkStore -> TelemetryCredentialSourceId.SdkStore
12+
CredentialSourceId.Ec2 -> TelemetryCredentialSourceId.Ec2
13+
CredentialSourceId.EnvVars -> TelemetryCredentialSourceId.EnvVars
14+
else -> TelemetryCredentialSourceId.Other
15+
}

jetbrains-core/src/software/aws/toolkits/jetbrains/core/credentials/profiles/ProfileCredentialProviderFactory.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import software.aws.toolkits.core.ToolkitClientManager
2323
import software.aws.toolkits.core.credentials.CredentialIdentifier
2424
import software.aws.toolkits.core.credentials.CredentialIdentifierBase
2525
import software.aws.toolkits.core.credentials.CredentialProviderFactory
26+
import software.aws.toolkits.core.credentials.CredentialSourceId
2627
import software.aws.toolkits.core.credentials.CredentialType
2728
import software.aws.toolkits.core.credentials.CredentialsChangeEvent
2829
import software.aws.toolkits.core.credentials.CredentialsChangeListener
@@ -86,6 +87,7 @@ class ProfileCredentialProviderFactory(private val ssoCache: SsoCache = diskCach
8687
private val profileHolder = ProfileHolder()
8788

8889
override val id = PROFILE_FACTORY_ID
90+
override val credentialSourceId: CredentialSourceId = CredentialSourceId.SharedCredentials
8991

9092
override fun setUp(credentialLoadCallback: CredentialsChangeListener) {
9193
// Load the initial data, then start the background watcher

jetbrains-core/src/software/aws/toolkits/jetbrains/services/ecr/actions/DeleteTagAction.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DeleteTagAction : ExplorerNodeAction<EcrTagNode>(message("ecr.delete.tag.a
4949
)
5050

5151
if (response != Messages.OK) {
52-
EcrTelemetry.deleteTags(project, Result.Cancelled, selected.size.toDouble())
52+
EcrTelemetry.deleteTags(project = project, result = Result.Cancelled, value = selected.size.toDouble())
5353
return
5454
}
5555

@@ -78,14 +78,14 @@ class DeleteTagAction : ExplorerNodeAction<EcrTagNode>(message("ecr.delete.tag.a
7878
content = message("ecr.delete.tag.succeeded", selected.size, repositoryName)
7979
)
8080
project.refreshAwsTree(EcrResources.listTags(repositoryName))
81-
EcrTelemetry.deleteTags(project, Result.Succeeded, selected.size.toDouble())
81+
EcrTelemetry.deleteTags(project = project, result = Result.Succeeded, value = selected.size.toDouble())
8282
} catch (e: Exception) {
8383
LOG.error(e) { "Exception thrown while trying to delete ${selected.size} tags" }
8484
notifyError(
8585
project = project,
8686
content = message("ecr.delete.tag.failed", selected.size, repositoryName)
8787
)
88-
EcrTelemetry.deleteTags(project, Result.Failed, selected.size.toDouble())
88+
EcrTelemetry.deleteTags(project = project, result = Result.Failed, value = selected.size.toDouble())
8989
}
9090
}
9191
}

jetbrains-core/src/software/aws/toolkits/jetbrains/services/ecr/actions/PushToRepositoryAction.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import software.amazon.awssdk.services.ecr.EcrClient
4545
import software.aws.toolkits.core.utils.error
4646
import software.aws.toolkits.core.utils.getLogger
4747
import software.aws.toolkits.jetbrains.core.awsClient
48-
import software.aws.toolkits.jetbrains.core.credentials.activeRegion
4948
import software.aws.toolkits.jetbrains.core.explorer.ExplorerDataKeys
5049
import software.aws.toolkits.jetbrains.services.ecr.DockerRunConfiguration
5150
import software.aws.toolkits.jetbrains.services.ecr.DockerfileEcrPushRequest
@@ -91,7 +90,7 @@ class PushToRepositoryAction :
9190

9291
if (!result) {
9392
// user cancelled; noop
94-
EcrTelemetry.deployImage(project, Result.Cancelled, project.activeRegion().id)
93+
EcrTelemetry.deployImage(project, Result.Cancelled)
9594
return
9695
}
9796

@@ -124,7 +123,6 @@ class PushToRepositoryAction :
124123
EcrTelemetry.deployImage(
125124
project,
126125
result,
127-
regionId = project.activeRegion().id,
128126
ecrDeploySource = type
129127
)
130128
}

jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/upload/CreateFunctionDialog.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import org.jetbrains.annotations.TestOnly
1313
import software.amazon.awssdk.services.lambda.model.PackageType
1414
import software.amazon.awssdk.services.lambda.model.Runtime
1515
import software.aws.toolkits.core.lambda.validOrNull
16-
import software.aws.toolkits.jetbrains.core.credentials.activeRegion
1716
import software.aws.toolkits.jetbrains.core.explorer.refreshAwsTree
1817
import software.aws.toolkits.jetbrains.core.help.HelpIds
1918
import software.aws.toolkits.jetbrains.services.lambda.Lambda.findPsiElementsForHandler
@@ -73,7 +72,6 @@ class CreateFunctionDialog(private val project: Project, private val initialRunt
7372
LambdaTelemetry.deploy(
7473
project,
7574
result = Result.Cancelled,
76-
regionId = project.activeRegion().id,
7775
lambdaPackageType = LambdaPackageType.from(view.configSettings.packageType().toString()),
7876
initialDeploy = true
7977
)
@@ -106,11 +104,9 @@ class CreateFunctionDialog(private val project: Project, private val initialRunt
106104
LambdaTelemetry.deploy(
107105
project,
108106
result = Result.Succeeded,
109-
regionId = project.activeRegion().id,
110107
lambdaPackageType = packageType,
111108
initialDeploy = true
112109
)
113-
114110
project.refreshAwsTree(LambdaResources.LIST_FUNCTIONS)
115111
}
116112

@@ -119,7 +115,6 @@ class CreateFunctionDialog(private val project: Project, private val initialRunt
119115
LambdaTelemetry.deploy(
120116
project,
121117
result = Result.Failed,
122-
regionId = project.activeRegion().id,
123118
lambdaPackageType = packageType,
124119
initialDeploy = true
125120
)

0 commit comments

Comments
 (0)