Skip to content

Commit ae617b7

Browse files
committed
Using NullTelemetryService instead of mock
1 parent d9ccb7e commit ae617b7

File tree

1 file changed

+3
-53
lines changed

1 file changed

+3
-53
lines changed

src/vs/platform/extensionManagement/test/common/extensionGalleryService.test.ts

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ import product from 'vs/platform/product/common/product';
2121
import { IProductService } from 'vs/platform/product/common/productService';
2222
import { resolveMarketplaceHeaders } from 'vs/platform/externalServices/common/marketplace';
2323
import { InMemoryStorageService, IStorageService } from 'vs/platform/storage/common/storage';
24-
import { ITelemetryInfo, ITelemetryService, TelemetryConfiguration, TelemetryLevel, TELEMETRY_SETTING_ID } from 'vs/platform/telemetry/common/telemetry';
24+
import { ITelemetryService, TelemetryConfiguration, TELEMETRY_SETTING_ID } from 'vs/platform/telemetry/common/telemetry';
2525
import { TargetPlatform } from 'vs/platform/extensions/common/extensions';
26-
import { ClassifiedEvent, GDPRClassification, StrictPropertyCheck } from 'vs/platform/telemetry/common/gdprTypings';
27-
import { staticObservableValue } from 'vs/base/common/observableValue';
28-
import { Emitter, Event } from 'vs/base/common/event';
26+
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
2927

3028
class EnvironmentServiceMock extends mock<IEnvironmentService>() {
3129
override readonly serviceMachineIdResource: URI;
@@ -51,7 +49,7 @@ suite('Extension Gallery Service', () => {
5149
configurationService = new TestConfigurationService({ [TELEMETRY_SETTING_ID]: TelemetryConfiguration.ON });
5250
configurationService.updateValue(TELEMETRY_SETTING_ID, TelemetryConfiguration.ON);
5351
productService = { _serviceBrand: undefined, ...product, enableTelemetry: true };
54-
telemetryService = new MockTelemetryService();
52+
telemetryService = NullTelemetryService;
5553
});
5654

5755
teardown(() => disposables.clear());
@@ -158,51 +156,3 @@ suite('Extension Gallery Service', () => {
158156
return { version, targetPlatform } as IRawGalleryExtensionVersion;
159157
}
160158
});
161-
162-
class MockTelemetryService implements ITelemetryService {
163-
public _serviceBrand: undefined;
164-
public telemetryLevel = staticObservableValue(TelemetryLevel.USAGE);
165-
public sendErrorTelemetry = true;
166-
167-
public events: any[] = [];
168-
169-
private readonly emitter = new Emitter<any>();
170-
171-
public get eventLogged(): Event<any> {
172-
return this.emitter.event;
173-
}
174-
175-
public setEnabled(value: boolean): void {
176-
}
177-
178-
public setExperimentProperty(name: string, value: string): void {
179-
}
180-
181-
public publicLog(eventName: string, data?: any): Promise<void> {
182-
const event = { name: eventName, data: data };
183-
this.events.push(event);
184-
this.emitter.fire(event);
185-
return Promise.resolve();
186-
}
187-
188-
public publicLog2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data?: StrictPropertyCheck<T, E>) {
189-
return this.publicLog(eventName, data as any);
190-
}
191-
192-
public publicLogError(eventName: string, data?: any): Promise<void> {
193-
return this.publicLog(eventName, data);
194-
}
195-
196-
public publicLogError2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data?: StrictPropertyCheck<T, E>) {
197-
return this.publicLogError(eventName, data as any);
198-
}
199-
200-
public getTelemetryInfo(): Promise<ITelemetryInfo> {
201-
return Promise.resolve({
202-
instanceId: 'someValue.instanceId',
203-
sessionId: 'someValue.sessionId',
204-
machineId: 'someValue.machineId',
205-
firstSessionDate: 'someValue.firstSessionDate'
206-
});
207-
}
208-
}

0 commit comments

Comments
 (0)