Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Retrieve and display a customization name when a customization is overridden in an AB test"
}
8 changes: 5 additions & 3 deletions packages/core/src/codewhisperer/util/customizationUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { showMessageWithUrl } from '../../shared/utilities/messages'
import { parse } from '@aws-sdk/util-arn-parser'
import { Commands } from '../../shared/vscode/commands2'
import { vsCodeState } from '../models/model'
import { FeatureConfigProvider } from '../../shared/featureConfig'
import { FeatureConfigProvider, Features } from '../../shared/featureConfig'

/**
*
Expand Down Expand Up @@ -108,15 +108,17 @@ export const getSelectedCustomization = (): Customization => {
const result = selectedCustomizationArr[AuthUtil.instance.conn.label] || baseCustomization

// A/B case
const arnOverride = FeatureConfigProvider.instance.getCustomizationArnOverride()
const customizationFeature = FeatureConfigProvider.getFeature(Features.customizationArnOverride)
const arnOverride = customizationFeature?.value.stringValue
const customizationOverrideName = customizationFeature?.variation
if (arnOverride === undefined || arnOverride === '') {
return result
} else {
// A trick to prioritize arn from A/B over user's currently selected(for request and telemetry)
// but still shows customization info of user's currently selected.
return {
arn: arnOverride,
name: result.name,
name: customizationOverrideName,
description: result.description,
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/shared/featureConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ListFeatureEvaluationsRequest,
ListFeatureEvaluationsResponse,
} from '../codewhisperer/client/codewhispereruserclient'
import * as vscode from 'vscode'
import { codeWhispererClient as client } from '../codewhisperer/client/codewhisperer'
import { AuthUtil } from '../codewhisperer/util/authUtil'
import { getLogger } from './logger'
Expand Down Expand Up @@ -152,6 +153,8 @@ export class FeatureConfigProvider {
)
this.featureConfigs.delete(Features.customizationArnOverride)
}

await vscode.commands.executeCommand('aws.amazonq.refreshStatusBar')
}
}
if (Auth.instance.isInternalAmazonUser()) {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/test/fake/mockFeatureConfigData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ export const mockFeatureConfigsData: FeatureEvaluation[] = [
variation: 'TREATMENT',
value: { stringValue: 'testValue' },
},
{
feature: 'customizationArnOverride',
variation: 'customizationName',
value: { stringValue: 'customizationARN' },
},
]
20 changes: 19 additions & 1 deletion packages/core/src/test/shared/featureConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('FeatureConfigProvider', () => {
it('test getFeatureConfigsTelemetry will return expected string', async () => {
assert.strictEqual(
FeatureConfigProvider.instance.getFeatureConfigsTelemetry(),
`{testFeature: TREATMENT, featureA: CONTROL, featureB: TREATMENT}`
`{testFeature: TREATMENT, featureA: CONTROL, featureB: TREATMENT, customizationArnOverride: customizationName}`
)
})

Expand Down Expand Up @@ -77,6 +77,13 @@ describe('FeatureConfigProvider', () => {
},
variation: 'TREATMENT',
},
customizationArnOverride: {
name: 'customizationArnOverride',
value: {
stringValue: 'customizationARN',
},
variation: 'customizationName',
},
}

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

it('should retrieve customization override values', async () => {
assert.strictEqual(
FeatureConfigProvider.getFeature(Features.customizationArnOverride)?.value.stringValue,
'customizationARN'
)
assert.strictEqual(
FeatureConfigProvider.getFeature(Features.customizationArnOverride)?.variation,
'customizationName'
)
})

describe('getProjectContextGroup', function () {
beforeEach(function () {
sinon.restore()
Expand Down
Loading