Skip to content

Commit df7be50

Browse files
authored
telemetry: emit aws_expandExplorerNode #3712
Emit aws_expandExplorerNode when a service node in AWS Explorer is expanded. aws/aws-toolkit-common@0b80eea
1 parent 6a27e29 commit df7be50

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/awsexplorer/activation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export async function activate(args: {
5656
folder: element.element.folder,
5757
})
5858
}
59+
if (element.element.serviceId) {
60+
telemetry.aws_expandExplorerNode.emit({ serviceType: element.element.serviceId })
61+
}
5962
})
6063
globals.context.subscriptions.push(view)
6164

src/awsexplorer/regionNode.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,20 @@ import { Ec2ParentNode } from '../ec2/explorer/ec2ParentNode'
3030
import { DevSettings } from '../shared/settings'
3131
import { Ec2Client } from '../shared/clients/ec2Client'
3232

33-
const serviceCandidates = [
33+
interface ServiceNode {
34+
allRegions?: boolean
35+
serviceId: string
36+
/**
37+
* Decides if the node should be shown. Example:
38+
* ```
39+
* when: () => DevSettings.instance.isDevMode()
40+
* ```
41+
*/
42+
when?: () => boolean
43+
createFn: (regionCode: string, partitionId: string) => any
44+
}
45+
46+
const serviceCandidates: ServiceNode[] = [
3447
{
3548
serviceId: 'apigateway',
3649
createFn: (regionCode: string, partitionId: string) => new ApiGatewayNode(partitionId, regionCode),
@@ -85,6 +98,11 @@ const serviceCandidates = [
8598
serviceId: 'ssm',
8699
createFn: (regionCode: string) => new SsmDocumentNode(regionCode),
87100
},
101+
{
102+
allRegions: true,
103+
serviceId: 'cloudcontrol',
104+
createFn: (regionCode: string) => new ResourcesNode(regionCode),
105+
},
88106
]
89107

90108
/**
@@ -119,14 +137,14 @@ export class RegionNode extends AWSTreeNodeBase {
119137
if (service.when !== undefined && !service.when()) {
120138
continue
121139
}
122-
if (this.regionProvider.isServiceInRegion(service.serviceId, this.regionCode)) {
140+
if (service.allRegions || this.regionProvider.isServiceInRegion(service.serviceId, this.regionCode)) {
123141
const node = service.createFn(this.regionCode, partitionId)
124142
if (node !== undefined) {
143+
node.serviceId = service.serviceId
125144
childNodes.push(node)
126145
}
127146
}
128147
}
129-
childNodes.push(new ResourcesNode(this.regionCode))
130148

131149
return this.sortNodes(childNodes)
132150
}

src/shared/treeview/nodes/awsTreeNodeBase.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { isCloud9 } from '../../extensionUtilities'
88

99
export abstract class AWSTreeNodeBase extends TreeItem {
1010
public readonly regionCode?: string
11+
/** Service id as defined in the service model. May be undefined for child nodes. */
12+
public serviceId: string | undefined
1113

1214
public constructor(label: string, collapsibleState?: TreeItemCollapsibleState) {
1315
super(label, collapsibleState)

0 commit comments

Comments
 (0)