|
6 | 6 | import * as assert from 'assert'
|
7 | 7 | import { Memento, ConfigurationTarget } from 'vscode'
|
8 | 8 | import { Settings } from '../../../shared/settings'
|
9 |
| -import { convertLegacy, getClientId, TelemetryConfig } from '../../../shared/telemetry/util' |
| 9 | +import { convertLegacy, getClientId, getUserAgent, TelemetryConfig } from '../../../shared/telemetry/util' |
| 10 | +import { extensionVersion } from '../../../shared/vscode/env' |
10 | 11 | import { FakeMemento } from '../../fakeExtensionContext'
|
11 | 12 |
|
12 | 13 | describe('TelemetryConfig', function () {
|
@@ -157,3 +158,22 @@ describe('getClientId', function () {
|
157 | 158 | assert.strictEqual(clientId, '11111111-1111-1111-1111-111111111111')
|
158 | 159 | })
|
159 | 160 | })
|
| 161 | + |
| 162 | +describe('getUserAgent', function () { |
| 163 | + it('includes product name and version', async function () { |
| 164 | + const userAgent = await getUserAgent() |
| 165 | + const lastPair = userAgent.split(' ')[0] |
| 166 | + assert.ok(lastPair?.startsWith(`AWS-Toolkit-For-VSCode/${extensionVersion}`)) |
| 167 | + }) |
| 168 | + |
| 169 | + it('omits `ClientId` by default', async function () { |
| 170 | + const userAgent = await getUserAgent() |
| 171 | + assert.ok(!userAgent.includes('ClientId')) |
| 172 | + }) |
| 173 | + |
| 174 | + it('includes `ClientId` at the end if opted in', async function () { |
| 175 | + const userAgent = await getUserAgent({ includeClientId: true }) |
| 176 | + const lastPair = userAgent.split(' ').pop() |
| 177 | + assert.ok(lastPair?.startsWith('ClientId/')) |
| 178 | + }) |
| 179 | +}) |
0 commit comments