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
6 changes: 3 additions & 3 deletions src/client/activation/extensionSurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export class ExtensionSurveyPrompt implements IExtensionSingleActivationService
return false;
}

let feedbackDisabled = false;
let feedbackEnabled = true;

const telemetryConfig = this.workspace.getConfiguration('telemetry');
if (telemetryConfig) {
feedbackDisabled = telemetryConfig.get<boolean>('disableFeedback', false);
feedbackEnabled = telemetryConfig.get<boolean>('feedback.enabled', true);
}

if (feedbackDisabled) {
if (!feedbackEnabled) {
return false;
}

Expand Down
25 changes: 21 additions & 4 deletions src/test/activation/extensionSurvey.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,38 @@ suite('Extension survey prompt - shouldShowBanner()', () => {
}
random.verifyAll();
});
test('Returns false if telemetry.disableFeedback is enabled', async () => {
test('Returns true if telemetry.feedback.enabled is enabled', async () => {
disableSurveyForTime.setup((d) => d.value).returns(() => false);
doNotShowAgain.setup((d) => d.value).returns(() => false);

const telemetryConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
workspaceService.setup((w) => w.getConfiguration('telemetry')).returns(() => telemetryConfig.object);
telemetryConfig
.setup((t) => t.get(TypeMoq.It.isValue('disableFeedback'), TypeMoq.It.isValue(false)))
.setup((t) => t.get(TypeMoq.It.isValue('feedback.enabled'), TypeMoq.It.isValue(true)))
.returns(() => true);

const result = extensionSurveyPrompt.shouldShowBanner();

expect(result).to.equal(false, 'Banner should not be shown when telemetry.disableFeedback is true');
expect(result).to.equal(true, 'Banner should be shown when telemetry.feedback.enabled is true');
workspaceService.verify((w) => w.getConfiguration('telemetry'), TypeMoq.Times.once());
telemetryConfig.verify((t) => t.get('disableFeedback', false), TypeMoq.Times.once());
telemetryConfig.verify((t) => t.get('feedback.enabled', true), TypeMoq.Times.once());
});

test('Returns false if telemetry.feedback.enabled is disabled', async () => {
disableSurveyForTime.setup((d) => d.value).returns(() => false);
doNotShowAgain.setup((d) => d.value).returns(() => false);

const telemetryConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
workspaceService.setup((w) => w.getConfiguration('telemetry')).returns(() => telemetryConfig.object);
telemetryConfig
.setup((t) => t.get(TypeMoq.It.isValue('feedback.enabled'), TypeMoq.It.isValue(true)))
.returns(() => false);

const result = extensionSurveyPrompt.shouldShowBanner();

expect(result).to.equal(false, 'Banner should not be shown when feedback.enabled is false');
workspaceService.verify((w) => w.getConfiguration('telemetry'), TypeMoq.Times.once());
telemetryConfig.verify((t) => t.get('feedback.enabled', true), TypeMoq.Times.once());
});

test('Returns true if user is in the random sampling', async () => {
Expand Down