telemetryUtils.ts ×8

Frontier kind: Joint frontier

unlabeled · c_acd1044f9c5e

2 tests · 10297 LOC · 53 files · introduces 1 test · 50 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges50 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
1641 ranges10297 lines · 53 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.

1 test introduced at this concept.

Introduced code

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

2 files ranked by introduced lines: 50 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/telemetry/common/telemetryUtils.ts 48 introduced LOC · 8 ranges

Open complete file

168
169 export function validateTelemetryData(data?: unknown): { properties: Properties; measurements: Measurements } {
171 > const properties: Properties = {};
172 > const measurements: Measurements = {};
173 >
174 > const flat: Record<string, unknown> = {};
175 > flatten(data, flat);
176 >
177 > for (let prop in flat) {
178 > // enforce property names less than 150 char, take the last 150 char
179 > prop = prop.length > 150 ? prop.substr(prop.length - 149) : prop;
180 > const value = flat[prop];
181 >
182 > if (typeof value === 'number') {
183 > measurements[prop] = value;
184 >
185 > } else if (typeof value === 'boolean') {
186 > measurements[prop] = value ? 1 : 0;
187 >
188 > } else if (typeof value === 'string') {
189 > if (value.length > 8192) {
190 console.warn(`Telemetry property: ${prop} has been trimmed to 8192, the original length is ${value.length}`);
191 }
192 > //enforce property value to be less than 8192 char, take the first 8192 char telemetryUtils.ts
193 > // https://docs.microsoft.com/en-us/azure/azure-monitor/app/api-custom-events-metrics#limits
194 > properties[prop] = value.substring(0, 8191);
195 >
196 > } else if (typeof value !== 'undefined' && value !== null) {
197 properties[prop] = String(value);
198 }
200 >
201 > return {
202 > properties,
203 > measurements
204 > };
205 > }
206
207 interface IRemoteAuthoringConfig {
230 }
231
232 > function flatten(obj: unknown, result: Record<string, unknown>, order: number = 0, prefix?: string): void { telemetryUtils.ts
233 > if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
234 return;
235 }
237 > const source = obj as Record<string, unknown>;
238 > for (const item of Object.getOwnPropertyNames(source)) {
239 > const value = source[item];
240 > const index = prefix ? prefix + item : item;
241 >
242 > if (Array.isArray(value)) {
243 result[index] = safeStringify(value);
244
245 > } else if (value instanceof Date) { telemetryUtils.ts
246 // TODO unsure why this is here and not in _getData
247 result[index] = value.toISOString();
248
249 > } else if (isObject(value)) { telemetryUtils.ts
250 if (order < 2) {
251 flatten(value, result, order + 1, index + '.');
253 result[index] = safeStringify(value);
254 }
255 > } else { telemetryUtils.ts
256 > result[index] = value;
257 > }
258 > }
259 > }
260
261 /**
src/vs/platform/telemetry/common/telemetryLogAppender.ts 2 introduced LOC · 1 range

Open complete file

46
47 log(eventName: string, data: unknown): void {
48 > this.logger.trace(`${this.prefix}telemetry/${eventName}`, validateTelemetryData(data)); telemetryLogAppender.ts
49 > }
50 }
51