telemetryService.ts ×9

Frontier kind: Code frontier

unlabeled · c_3114d2062b20

2 tests · 19809 LOC · 91 files · introduces 0 tests · 113 LOC · 5 files

Introduces — evidence that enters the hierarchy at this concept

Code
20 ranges113 lines · 5 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2749 ranges19809 lines · 91 files · Browse complete extent
All tests (intent)
2 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

5 files ranked by introduced lines: 113 introduced LOC across 20 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/telemetry/common/telemetryService.ts 54 introduced LOC · 9 ranges

Open complete file

76
77 constructor(
78 > config: ITelemetryServiceConfig, telemetryService.ts
79 > @IConfigurationService private _configurationService: IConfigurationService,
80 > @IProductService private _productService: IProductService
81 > ) {
82 > this._appenders = config.appenders;
83 > this._commonProperties = config.commonProperties ?? Object.create(null);
84 >
85 > this.sessionId = this._commonProperties['sessionID'] as string;
86 > this.machineId = this._commonProperties['common.machineId'] as string;
87 > this.sqmId = this._commonProperties['common.sqmId'] as string;
88 > this.devDeviceId = this._commonProperties['common.devDeviceId'] as string;
89 > this.firstSessionDate = this._commonProperties['common.firstSessionDate'] as string;
90 > this.msftInternal = this._commonProperties['common.msftInternal'] as boolean | undefined;
91 >
92 > this._piiPaths = config.piiPaths || [];
93 > this._telemetryLevel = TelemetryLevel.USAGE;
94 > this._sendErrorTelemetry = !!config.sendErrorTelemetry;
95 > this._meteredConnectionService = config.meteredConnectionService;
96 >
97 > // static cleanup pattern for: `vscode-file:///DANGEROUS/PATH/resources/app/Useful/Information`
98 > this._cleanupPatterns = [/(vscode-)?file:\/\/.*?\/resources\/app\//gi];
99 >
100 > for (const piiPath of this._piiPaths) {
101 > this._cleanupPatterns.push(new RegExp(escapeRegExpCharacters(piiPath), 'gi'));
102 >
103 > if (piiPath.indexOf('\\') >= 0) {
104 this._cleanupPatterns.push(new RegExp(escapeRegExpCharacters(piiPath.replace(/\\/g, '/')), 'gi'));
105 }
107 >
108 > this._updateTelemetryLevel();
109 > this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
110 // Check on the telemetry settings and update the state if changed
111 const affectsTelemetryConfig =
116 this._updateTelemetryLevel();
117 }
118 > })); telemetryService.ts
119 >
120 > // Buffer events until experiment properties are set (or timeout expires).
121 > // This ensures early events include experiment context when available.
122 > if (config.waitForExperimentProperties) {
123 this._flushTimeout = setTimeout(() => this._flushPendingEvents(), TelemetryService.BUFFER_FLUSH_TIMEOUT);
124 > } else { telemetryService.ts
125 > this._isExperimentPropertySet = true;
126 > }
127 > }
128
129 setExperimentProperty(name: string, value: string): void {
141
142 private _flushPendingEvents(): void {
143 > if (this._isExperimentPropertySet) { telemetryService.ts
144 > return;
145 > }
146
147 this._isExperimentPropertySet = true;
157 }
158 this._pendingEvents = [];
160
161 private _updateTelemetryLevel(): void {
162 > let level = getTelemetryLevel(this._configurationService); telemetryService.ts
163 > const collectableTelemetry = this._productService.enabledTelemetryLevels;
164 > // Also ensure that error telemetry is respecting the product configuration for collectable telemetry
165 > if (collectableTelemetry) {
166 this._sendErrorTelemetry = this.sendErrorTelemetry ? collectableTelemetry.error : false;
167 // Make sure the telemetry level from the service is the minimum of the config and product
169 level = Math.min(level, maxCollectableTelemetryLevel);
170 }
172 > this._telemetryLevel = level;
173 > }
174
175 get sendErrorTelemetry(): boolean {
182
183 dispose(): void {
184 > // Flush any remaining pending events before disposing telemetryService.ts
185 > this._flushPendingEvents();
186 > this._disposables.dispose();
187 > }
188
189 private _log(eventName: string, eventLevel: TelemetryLevel, data?: ITelemetryData) {
src/vs/platform/agentHost/node/agentHostTelemetryService.ts 41 introduced LOC · 4 ranges

Open complete file

221 }
222
223 > export async function createAgentHostTelemetryService(options: IAgentHostTelemetryServiceOptions): Promise<IAgentHostTelemetryService> { agentHostTelemetryService.ts
224 > const { environmentService, productService, fileService, loggerService, logService, disposables } = options;
225 > if (options.disableTelemetry || !loggerService || !supportsTelemetry(productService, environmentService)) {
226 return disposables.add(new AgentHostTelemetryService(NullTelemetryService));
227 }
229 > const configurationService = disposables.add(new ConfigurationService(joinPath(environmentService.appSettingsHome, 'settings.json'), fileService, new NullPolicyService(), logService));
230 > await configurationService.initialize();
231 >
232 > const appenders: ITelemetryAppender[] = [
233 > disposables.add(new TelemetryLogAppender('', false, loggerService, environmentService, productService)),
234 > ];
235 > const internalTelemetry = isInternalTelemetry(productService, configurationService);
236 > const loggingOnly = isLoggingOnly(productService, environmentService);
237 > if (!loggingOnly && productService.aiConfig?.ariaKey) {
238 const collectorAppender = new OneDataSystemAppender(options.requestService, internalTelemetry, 'monacoworkbench', null, productService.aiConfig.ariaKey);
239 disposables.add(toDisposable(() => { void collectorAppender.flush(); }));
240 appenders.push(collectorAppender);
241 }
243 > // Prefer the host-forwarded identifiers (see `agentHostTelemetryEnv`) so the
244 > // agent host reports the same persisted machineId/sqmId/devDeviceId as the
245 > // workbench. Fall back to computing them live when not provided (e.g. the
246 > // remote/server agent host, which does not forward them).
247 > const [machineId, sqmId, devDeviceId] = await Promise.all([
248 > process.env[AgentHostMachineIdEnvKey] || getMachineId(error => logService.error(error)),
249 > process.env[AgentHostSqmIdEnvKey] || getSqmMachineId(error => logService.error(error)),
250 > process.env[AgentHostDevDeviceIdEnvKey] || getDevDeviceId(error => logService.error(error)),
251 > ]);
252 >
253 > const commonProperties = resolveCommonProperties(release(), hostname(), process.arch, productService.commit, productService.version, machineId, sqmId, devDeviceId, internalTelemetry, productService.date);
254 >
255 > const telemetryService = new TelemetryService({
256 > appenders,
257 > sendErrorTelemetry: true,
258 > commonProperties,
259 > piiPaths: getPiiPathsFromEnvironment(environmentService),
260 > }, configurationService, productService);
261 >
262 > const extensionVersion = loggingOnly ? undefined : await resolveCopilotExtensionVersion(environmentService, fileService, logService);
263 > const internalSender = loggingOnly ? undefined : disposables.add(new AgentHostInternalTelemetrySender({ requestService: options.requestService, commonProperties, extensionVersion }));
264 > const restricted = loggingOnly ? undefined : new AgentHostRestrictedTelemetrySender(commonProperties, logService, undefined, internalSender, options.fetchFn);
265 >
266 > return disposables.add(new AgentHostTelemetryService(telemetryService, restricted));
267 > }
src/vs/platform/log/common/log.ts 8 introduced LOC · 4 ranges

Open complete file

716
717 private getLoggerEntry(resourceOrId: URI | string): LoggerEntry | undefined {
718 > if (isString(resourceOrId)) { log.ts
719 > return [...this._loggers.values()].find(logger => logger.info.id === resourceOrId);
720 > }
721 return this._loggers.get(resourceOrId);
722 > } log.ts
723
724 getLogger(resourceOrId: URI | string): ILogger | undefined {
725 > return this.getLoggerEntry(resourceOrId)?.logger; log.ts
726 > }
727
728 createLogger(idOrResource: URI | string, options?: ILoggerOptions): ILogger {
864 }
865 protected override doCreateLogger(resource: URI, logLevel: LogLevel, options?: ILoggerOptions): ILogger {
866 > return new NullLogger(); log.ts
867 > }
868 }
869
src/vs/platform/telemetry/common/telemetryUtils.ts 6 introduced LOC · 2 ranges

Open complete file

266 */
267 export function isInternalTelemetry(productService: IProductService, configService: IConfigurationService) {
268 > const msftInternalDomains = productService.msftInternalDomains || []; telemetryUtils.ts
269 > const internalTesting = configService.getValue<boolean>('telemetry.internalTesting');
270 > return verifyMicrosoftInternalDomain(msftInternalDomains) || internalTesting;
271 > }
272
273 interface IPathEnvironment {
280
281 export function getPiiPathsFromEnvironment(paths: IPathEnvironment): string[] {
282 > return [paths.appRoot, paths.extensionsPath, paths.userHome.fsPath, paths.tmpDir.fsPath, paths.userDataPath]; telemetryUtils.ts
283 > }
284
285 //#region Telemetry Cleaning
src/vs/platform/telemetry/common/commonProperties.ts 4 introduced LOC · 1 range

Open complete file

99
100 export function verifyMicrosoftInternalDomain(domainList: readonly string[]): boolean {
101 > const userDnsDomain = env['USERDNSDOMAIN']; commonProperties.ts
102 > if (!userDnsDomain) {
103 > return false;
104 > }
105
106 const domain = userDnsDomain.toLowerCase();