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
5 changes: 5 additions & 0 deletions packages/core/src/shared/telemetry/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,15 @@ export function withTelemetryContext(opts: TelemetryContextArgs) {
* Used to identify the q client info and send the respective origin parameter from LSP to invoke Maestro service at CW API level
*
* Returns default value of vscode appName or AmazonQ-For-SMUS-CE in case of a sagemaker unified studio environment
* Returns default value of vscode appName
* OR AmazonQ-For-SMUS-CE in case of SMUS
* OR AmazonQ-For-SMAI-CE in case of SMAI
*/
export function getClientName(): string {
if (isSageMaker('SMUS')) {
return 'AmazonQ-For-SMUS-CE'
} else if (isSageMaker('SMAI')) {
return 'AmazonQ-For-SMAI-CE'
}
return env.appName
}
16 changes: 15 additions & 1 deletion packages/core/src/test/shared/telemetry/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,29 @@ describe('getClientName', function () {
assert.ok(isSageMakerStub.calledOnceWith('SMUS'))
})

it('returns "AmazonQ-For-SMAI-CE" when in SMAI environment', function () {
isSageMakerStub.withArgs('SMUS').returns(false)
isSageMakerStub.withArgs('SMAI').returns(true)
sandbox.stub(vscode.env, 'appName').value('SageMaker Code Editor')

const result = getClientName()

assert.strictEqual(result, 'AmazonQ-For-SMAI-CE')
assert.ok(isSageMakerStub.calledWith('SMUS'))
assert.ok(isSageMakerStub.calledWith('SMAI'))
})

it('returns vscode app name when not in SMUS environment', function () {
const mockAppName = 'Visual Studio Code'
isSageMakerStub.withArgs('SMUS').returns(false)
isSageMakerStub.withArgs('SMAI').returns(false)
sandbox.stub(vscode.env, 'appName').value(mockAppName)

const result = getClientName()

assert.strictEqual(result, mockAppName)
assert.ok(isSageMakerStub.calledOnceWith('SMUS'))
assert.ok(isSageMakerStub.calledWith('SMUS'))
assert.ok(isSageMakerStub.calledWith('SMAI'))
})

it('handles undefined app name gracefully', function () {
Expand Down
Loading