MCPcopy Create free account
hub / github.com/Snapchat/Valdi / createLoggers

Function createLoggers

valdi/vscode_debugger/src/telemetry/classification.ts:166–264  ·  view source on GitHub ↗
(sendEvent: (event: Dap.OutputEventParams) => void)

Source from the content-addressed store, hash-verified

164 * invoked when any of the logging functions are called.
165 */
166export const createLoggers = (sendEvent: (event: Dap.OutputEventParams) => void) => {
167 const globalMetrics: Partial<IGlobalMetrics> = {};
168 setJsDebugCommitId(globalMetrics);
169
170 /**
171 * Warning! The naming of this method is required to be exactly `publicLog2`
172 * for the GDPR tooling to automatically detect.
173 */
174 function publicLog2<
175 E extends ClassifiedEvent<T> = never,
176 T extends { [_ in keyof T]: IPropertyData | IGDPRProperty | undefined } = never
177 >(
178 name: string,
179 props: StrictPropertyCheck<
180 E,
181 ClassifiedEvent<T>,
182 'Type of classified event does not match event properties'
183 >,
184 ) {
185 return sendEvent({
186 category: 'telemetry',
187 output: name,
188 data: props,
189 });
190 }
191
192 const dapOperation = (metrics: IRPCMetricsAndErrorsMap) =>
193 publicLog2<
194 IGlobalMetrics & IRPCMetricsAndErrorsMap,
195 IRPCOperationClassification & IGlobalClassification
196 >('js-debug/dap/operation', { ...globalMetrics, ...metrics });
197
198 const cdpOperation = (metrics: IRPCMetricsAndErrorsMap) =>
199 publicLog2<
200 IGlobalMetrics & IRPCMetricsAndErrorsMap,
201 IRPCOperationClassification & IGlobalClassification
202 >('js-debug/cdp/operation', { ...globalMetrics, ...metrics });
203
204 const error = (metrics: IErrorMetrics) =>
205 publicLog2<IGlobalMetrics & IErrorMetrics, IErrorClassification & IGlobalClassification>(
206 'js-debug/error',
207 { ...globalMetrics, ...metrics },
208 );
209
210 const browserVersion = (metrics: IBrowserVersionMetrics) => {
211 globalMetrics.browser =
212 (metrics.targetProject || metrics.targetProject) + '/' + metrics.targetVersion;
213
214 publicLog2<
215 IGlobalMetrics & IBrowserVersionMetrics,
216 IBrowserVersionClassification & IGlobalClassification
217 >('js-debug/browserVersion', { ...globalMetrics, ...metrics });
218 };
219
220 const breakpointStats = (metrics: IBreakpointMetrics) =>
221 publicLog2<
222 IGlobalMetrics & IBreakpointMetrics,
223 IBreakpointClassification & IGlobalClassification

Callers 1

Calls 1

setJsDebugCommitIdFunction · 0.85

Tested by

no test coverage detected