Skip to content

Commit be31826

Browse files
committed
Using AB variation value as customization name when overridden
1 parent 3d46b7b commit be31826

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
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": "Uses AB variation as the name for overridden customizations"
4+
}

packages/core/src/codewhisperer/util/customizationUtil.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,15 @@ export const getSelectedCustomization = (): Customization => {
109109

110110
// A/B case
111111
const arnOverride = FeatureConfigProvider.instance.getCustomizationArnOverride()
112+
const customizationOverrideName = FeatureConfigProvider.instance.getCustomizationArnOverrideName()
112113
if (arnOverride === undefined || arnOverride === '') {
113114
return result
114115
} else {
115116
// A trick to prioritize arn from A/B over user's currently selected(for request and telemetry)
116117
// but still shows customization info of user's currently selected.
117118
return {
118119
arn: arnOverride,
119-
name: result.name,
120+
name: customizationOverrideName,
120121
description: result.description,
121122
}
122123
}

packages/core/src/shared/featureConfig.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ListFeatureEvaluationsRequest,
1010
ListFeatureEvaluationsResponse,
1111
} from '../codewhisperer/client/codewhispereruserclient'
12+
import * as vscode from 'vscode'
1213
import { codeWhispererClient as client } from '../codewhisperer/client/codewhisperer'
1314
import { AuthUtil } from '../codewhisperer/util/authUtil'
1415
import { getLogger } from './logger'
@@ -152,6 +153,8 @@ export class FeatureConfigProvider {
152153
)
153154
this.featureConfigs.delete(Features.customizationArnOverride)
154155
}
156+
157+
await vscode.commands.executeCommand('aws.amazonq.refreshStatusBar')
155158
}
156159
}
157160
if (Auth.instance.isInternalAmazonUser()) {
@@ -195,12 +198,22 @@ export class FeatureConfigProvider {
195198
return this.getFeatureValueForKey(Features.customizationArnOverride).stringValue
196199
}
197200

201+
getCustomizationArnOverrideName(): string | undefined {
202+
return this.getFeatureVariationForKey(Features.customizationArnOverride)
203+
}
204+
198205
// Get the feature value for the given key.
199206
// In case of a misconfiguration, it will return a default feature value of Boolean true.
200207
private getFeatureValueForKey(name: FeatureName): FeatureValue {
201208
return this.featureConfigs.get(name)?.value ?? featureDefinitions.get(name)?.value ?? { boolValue: true }
202209
}
203210

211+
// Get the feature variation for the given key.
212+
// In case of a misconfiguration, it will return an empty string
213+
private getFeatureVariationForKey(name: FeatureName): string {
214+
return this.featureConfigs.get(name)?.variation ?? featureDefinitions.get(name)?.variation ?? ''
215+
}
216+
204217
/**
205218
* Map of feature configurations.
206219
*

packages/core/src/test/fake/mockFeatureConfigData.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ export const mockFeatureConfigsData: FeatureEvaluation[] = [
2121
variation: 'TREATMENT',
2222
value: { stringValue: 'testValue' },
2323
},
24+
{
25+
feature: 'customizationArnOverride',
26+
variation: 'customizationName',
27+
value: { stringValue: 'customizationARN' },
28+
},
2429
]

packages/core/src/test/shared/featureConfig.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('FeatureConfigProvider', () => {
4848
it('test getFeatureConfigsTelemetry will return expected string', async () => {
4949
assert.strictEqual(
5050
FeatureConfigProvider.instance.getFeatureConfigsTelemetry(),
51-
`{testFeature: TREATMENT, featureA: CONTROL, featureB: TREATMENT}`
51+
`{testFeature: TREATMENT, featureA: CONTROL, featureB: TREATMENT, customizationArnOverride: customizationName}`
5252
)
5353
})
5454

@@ -77,6 +77,13 @@ describe('FeatureConfigProvider', () => {
7777
},
7878
variation: 'TREATMENT',
7979
},
80+
customizationArnOverride: {
81+
name: 'customizationArnOverride',
82+
value: {
83+
stringValue: 'customizationARN',
84+
},
85+
variation: 'customizationName',
86+
},
8087
}
8188

8289
assert.deepStrictEqual(Object.fromEntries(featureConfigs), expectedFeatureConfigs)
@@ -95,6 +102,11 @@ describe('FeatureConfigProvider', () => {
95102
assert.strictEqual(FeatureConfigProvider.isEnabled('feature-does-not-exist' as FeatureName), false)
96103
})
97104

105+
it('should retrieve customization override values', async () => {
106+
assert.strictEqual(FeatureConfigProvider.instance.getCustomizationArnOverrideName(), 'customizationName')
107+
assert.strictEqual(FeatureConfigProvider.instance.getCustomizationArnOverride(), 'customizationARN')
108+
})
109+
98110
describe('getProjectContextGroup', function () {
99111
beforeEach(function () {
100112
sinon.restore()

0 commit comments

Comments
 (0)