MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / sanitizeProperties

Function sanitizeProperties

src/platform/telemetry/index.ts:88–108  ·  view source on GitHub ↗
(eventName: string, data: Record<string, any>)

Source from the content-addressed store, hash-verified

86}
87
88function sanitizeProperties(eventName: string, data: Record<string, any>) {
89 let customProperties: Record<string, string> = {};
90 Object.getOwnPropertyNames(data).forEach((prop) => {
91 if (data[prop] === undefined || data[prop] === null) {
92 return;
93 }
94 try {
95 // If there are any errors in serializing one property, ignore that and move on.
96 // Else nothing will be sent.
97 customProperties[prop] =
98 typeof data[prop] === 'string'
99 ? data[prop]
100 : typeof data[prop] === 'object'
101 ? 'object'
102 : data[prop].toString();
103 } catch (ex) {
104 logger.error(`Failed to serialize ${prop} for ${eventName}`, ex);
105 }
106 });
107 return customProperties;
108}
109
110/**
111 * Send this & subsequent telemetry only after this promise has been resolved.

Callers 1

Calls 3

toStringMethod · 0.65
errorMethod · 0.65
forEachMethod · 0.45

Tested by

no test coverage detected