Skip to content

Commit 4823f7d

Browse files
authored
Merge pull request #810 from hayemaxi/auth-telem
VSC telemetry updates
2 parents 310b8e2 + fb04184 commit 4823f7d

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

telemetry/definitions/commonDefinitions.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,16 @@
15891589
],
15901590
"description": "The type of an SQS Queue"
15911591
},
1592+
{
1593+
"name": "ssoRegistrationClientId",
1594+
"type": "string",
1595+
"description": "The client ID of an SSO registration."
1596+
},
1597+
{
1598+
"name": "ssoRegistrationExpiresAt",
1599+
"type": "string",
1600+
"description": "Date/time that an SSO client registration expires."
1601+
},
15921602
{
15931603
"name": "successCount",
15941604
"type": "int",
@@ -2450,6 +2460,14 @@
24502460
},
24512461
{
24522462
"type": "source"
2463+
},
2464+
{
2465+
"type": "ssoRegistrationClientId",
2466+
"required": false
2467+
},
2468+
{
2469+
"type": "ssoRegistrationExpiresAt",
2470+
"required": false
24532471
}
24542472
]
24552473
},
@@ -2524,9 +2542,21 @@
25242542
"type": "authStatus",
25252543
"required": true
25262544
},
2545+
{
2546+
"type": "credentialStartUrl",
2547+
"required": false
2548+
},
25272549
{
25282550
"type": "source",
25292551
"required": true
2552+
},
2553+
{
2554+
"type": "ssoRegistrationClientId",
2555+
"required": false
2556+
},
2557+
{
2558+
"type": "ssoRegistrationExpiresAt",
2559+
"required": false
25302560
}
25312561
],
25322562
"passive": true
@@ -2650,6 +2680,14 @@
26502680
},
26512681
{
26522682
"type": "source"
2683+
},
2684+
{
2685+
"type": "ssoRegistrationClientId",
2686+
"required": false
2687+
},
2688+
{
2689+
"type": "ssoRegistrationExpiresAt",
2690+
"required": false
26532691
}
26542692
]
26552693
},
@@ -2720,6 +2758,10 @@
27202758
"type": "credentialSourceId",
27212759
"required": false
27222760
},
2761+
{
2762+
"type": "credentialStartUrl",
2763+
"required": false
2764+
},
27232765
{
27242766
"type": "credentialType",
27252767
"required": false
@@ -2742,6 +2784,14 @@
27422784
{
27432785
"type": "sessionDuration",
27442786
"required": false
2787+
},
2788+
{
2789+
"type": "ssoRegistrationClientId",
2790+
"required": false
2791+
},
2792+
{
2793+
"type": "ssoRegistrationExpiresAt",
2794+
"required": false
27452795
}
27462796
]
27472797
},

telemetry/vscode/src/generate.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ function getTypeOrThrow(types: MetadataType[] = [], name: string) {
122122

123123
const baseName = 'MetricBase'
124124

125+
/**
126+
* Fields set automatically by the telemetry client (thus application code
127+
* normally shouldn't set these because the value will be overridden).
128+
*/
125129
const commonMetadata = [
126130
'awsAccount',
127131
'awsRegion',
@@ -132,7 +136,13 @@ const commonMetadata = [
132136
'requestId',
133137
'requestServiceType',
134138
'result',
135-
]
139+
] as const
140+
141+
/**
142+
* These fields will also be set by the telemetry client, but the caller might
143+
* know better, so they won't be overridden if specified in `.record()` calls.
144+
*/
145+
const optionalMetadata: typeof commonMetadata[number][] = ['awsRegion']
136146

137147
const passive: PropertySignatureStructure = {
138148
isReadonly: true,
@@ -183,7 +193,7 @@ const header = `
183193
`.trimStart()
184194

185195
function getMetricMetadata(metric: Metric) {
186-
return metric.metadata?.filter(m => !commonMetadata.includes(m.type)) ?? []
196+
return metric.metadata?.filter(m => !commonMetadata.includes(m.type as typeof commonMetadata[number])) ?? []
187197
}
188198

189199
function generateMetadataProperty(metadata: MetricMetadataType): PropertySignatureStructure {
@@ -351,7 +361,7 @@ function generateFile(telemetryJson: MetricDefinitionRoot, dest: string) {
351361
isExported: true,
352362
name: 'Metadata',
353363
typeParameters: [`T extends ${baseName}`],
354-
type: `Partial<Omit<T, keyof ${baseName}>>`,
364+
type: `Partial<Omit<T, keyof ${baseName}> | Partial<Pick<${baseName}, ${optionalMetadata.map(v => `'${v}'`).join(' | ')}>>>`,
355365
kind: StructureKind.TypeAlias,
356366
}
357367

telemetry/vscode/test/resources/generatorOutput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const definitions: Record<string, MetricDefinition> = {
114114
passive_passive: { unit: 'None', passive: true, requiredMetadata: [] },
115115
}
116116

117-
export type Metadata<T extends MetricBase> = Partial<Omit<T, keyof MetricBase>>
117+
export type Metadata<T extends MetricBase> = Partial<Omit<T, keyof MetricBase> | Partial<Pick<MetricBase, 'awsRegion'>>>
118118

119119
export interface Metric<T extends MetricBase = MetricBase> {
120120
readonly name: string

telemetry/vscode/test/resources/generatorOverrideOutput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const definitions: Record<string, MetricDefinition> = {
8585
metadata_hasResult: { unit: 'None', passive: false, requiredMetadata: [] },
8686
}
8787

88-
export type Metadata<T extends MetricBase> = Partial<Omit<T, keyof MetricBase>>
88+
export type Metadata<T extends MetricBase> = Partial<Omit<T, keyof MetricBase> | Partial<Pick<MetricBase, 'awsRegion'>>>
8989

9090
export interface Metric<T extends MetricBase = MetricBase> {
9191
readonly name: string

0 commit comments

Comments
 (0)