Skip to content

Commit 582b970

Browse files
committed
added Compute Env to Post metrics
1 parent ea875fc commit 582b970

File tree

5 files changed

+77
-26
lines changed

5 files changed

+77
-26
lines changed

package-lock.json

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4270,7 +4270,7 @@
42704270
},
42714271
"devDependencies": {
42724272
"@aws-sdk/types": "^3.13.1",
4273-
"@aws-toolkits/telemetry": "^1.0.176",
4273+
"@aws-toolkits/telemetry": "^1.0.180",
42744274
"@aws/fully-qualified-names": "^2.1.1",
42754275
"@cspotcode/source-map-support": "^0.8.1",
42764276
"@sinonjs/fake-timers": "^10.0.2",

src/shared/telemetry/service-2.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@
6464
"type":"string",
6565
"max":2000
6666
},
67+
"ComputeEnv":{
68+
"type":"string",
69+
"enum":[
70+
"cloud9",
71+
"cloud9-codecatalyst",
72+
"cloud9-ec2",
73+
"codecatalyst",
74+
"ec2",
75+
"local",
76+
"sagemaker",
77+
"ssh",
78+
"test",
79+
"web",
80+
"wsl",
81+
"other"
82+
]
83+
},
6784
"Datapoint":{
6885
"type":"double",
6986
"min":0
@@ -169,6 +186,7 @@
169186
"AWSProductVersion":{"shape":"AWSProductVersion"},
170187
"OS":{"shape":"Value"},
171188
"OSVersion":{"shape":"Value"},
189+
"CommputeEnv": {"shape":"ComputeEnv"},
172190
"ParentProduct":{"shape":"Value"},
173191
"ParentProductVersion":{"shape":"Value"},
174192
"Metadata":{"shape":"Metadata"},
@@ -190,6 +208,7 @@
190208
"ClientID":{"shape":"ClientID"},
191209
"OS":{"shape":"Value"},
192210
"OSVersion":{"shape":"Value"},
211+
"CommputeEnv": {"shape":"ComputeEnv"},
193212
"ParentProduct":{"shape":"Value"},
194213
"ParentProductVersion":{"shape":"Value"},
195214
"MetricData":{"shape":"MetricData"}

src/shared/telemetry/telemetryClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ServiceConfigurationOptions } from 'aws-sdk/lib/service'
1717
import globals from '../extensionGlobals'
1818
import { DevSettings } from '../settings'
1919
import { ClassToInterfaceType } from '../utilities/tsUtils'
20+
import { getComputeEnvType } from './util'
2021

2122
export const accountMetadataKey = 'awsAccount'
2223
export const regionKey = 'awsRegion'
@@ -91,6 +92,7 @@ export class DefaultTelemetryClient implements TelemetryClient {
9192
ClientID: this.clientId,
9293
OS: os.platform(),
9394
OSVersion: os.release(),
95+
CommputeEnv: getComputeEnvType(),
9496
ParentProduct: vscode.env.appName,
9597
ParentProductVersion: vscode.version,
9698
MetricData: batch,
@@ -117,6 +119,7 @@ export class DefaultTelemetryClient implements TelemetryClient {
117119
AWSProductVersion: extensionVersion,
118120
OS: os.platform(),
119121
OSVersion: os.release(),
122+
CommputeEnv: getComputeEnvType(),
120123
ParentProduct: vscode.env.appName,
121124
ParentProductVersion: vscode.version,
122125
Comment: feedback.comment,

src/shared/telemetry/util.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { mapMetadata } from './telemetryLogger'
1515
import { Result } from './telemetry.gen'
1616
import { MetricDatum } from './clienttelemetry'
1717
import { isValidationExemptMetric } from './exemptMetrics'
18+
import { isCloud9, isSageMaker, isCn } from '../../shared/extensionUtilities'
19+
import { isInDevEnv } from '../../codecatalyst/utils'
1820

1921
const legacySettingsTelemetryValueDisable = 'Disable'
2022
const legacySettingsTelemetryValueEnable = 'Enable'
@@ -90,6 +92,33 @@ export async function getUserAgent(
9092
return pairs.join(' ')
9193
}
9294

95+
// Although this is similair to getEnvType() in authUtil files, added new.
96+
// auth util can be upadate to get ComputeEnv
97+
98+
export function getComputeEnvType() {
99+
// Compute ENV could be one of the following
100+
// "cloud9"|"cloud9-codecatalyst"|"cloud9-ec2"|"codecatalyst"|"ec2"|"local"|"sagemaker"|"ssh"|"test"|"web"|"wsl"|"other"|string;
101+
102+
if (isCloud9('classic')) return 'cloud9'
103+
104+
if (isCloud9('codecatalyst')) return 'cloud9-codecatalyst'
105+
106+
if (isInDevEnv()) return 'codecatalyst' // should it be codecatalyst devEnv?
107+
108+
if (isCn()) return 'amazon-cloud9' // name better
109+
110+
if (isSageMaker()) return 'sagemaker'
111+
112+
if (env.remoteName == 'ssh-remote' && !isInDevEnv()) return 'ec2'
113+
114+
if (isAutomation()) return 'test'
115+
116+
if (!env.remoteName)
117+
// use isDevenvVscode instead?
118+
return 'local'
119+
else return 'other'
120+
}
121+
93122
/**
94123
* Validates that emitted telemetry metrics
95124
* 1. contain a result property and

0 commit comments

Comments
 (0)