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

Function generateTelemetryGdpr

src/telemetryGenerator.node.ts:676–771  ·  view source on GitHub ↗
(output: TelemetryEntry[])

Source from the content-addressed store, hash-verified

674`;
675
676function generateTelemetryGdpr(output: TelemetryEntry[]) {
677 const file = './src/gdpr.ts';
678 fs.writeFileSync(file, '');
679 fs.appendFileSync(file, gdprHeader);
680 const gdpr = '__GDPR__FRAGMENT__';
681 fs.appendFileSync(file, `/* ${gdpr}\n`);
682 fs.appendFileSync(file, ` "F1" : {\n`);
683 const commonFields = [' "${include}": ['];
684 const fieldListForFile: string[] = [];
685 Object.keys(CommonProperties).forEach((key) => {
686 const entry = (CommonProperties as any)[key] as IPropertyDataMeasurement | IPropertyDataNonMeasurement;
687 const isMeasurement = entry.isMeasurement === true;
688 const jsDocComment = commonPropertyComments.get(key) || '';
689 let comment = (entry.comment || '').split(/\r?\n/).join(' ').trim();
690 comment = `${comment}${comment.length === 0 || comment.endsWith('.') ? '' : '. '}${jsDocComment}`.trim();
691 if (!comment) {
692 console.error(
693 `No comments for common property ${key}, Update CommonPropertyAndMeasureTypeNames in telemetry.ts`
694 );
695 }
696
697 // Do not include `__GDPR__` in the string with JSON comments, else telemetry tool treats this as a valid GDPR annotation.
698 const json = {
699 classification: 'SystemMetaData',
700 purpose: 'FeatureInsight',
701 isMeasurement: isMeasurement,
702 comment: comment
703 };
704 fieldListForFile.push(` "${key}": ${JSON.stringify(json)}`);
705 });
706 commonFields.push(' "${F1}"\n');
707 commonFields.push(' ]');
708 fs.appendFileSync(file, `${fieldListForFile.join(',\n')}\n`);
709 fs.appendFileSync(file, ` }\n`);
710 fs.appendFileSync(file, ` */\n`);
711 fs.appendFileSync(file, '\n');
712
713 output.forEach((item, index) => {
714 // Do not include `__GDPR__` in the string with JSON comments, else telemetry tool treats this as a valid GDPR annotation.
715 const gdpr = '__GDPR__';
716 const header = [
717 `// (${index + 1}). ${item.constantName} (${item.name})`,
718 ...(item.description.trim().length
719 ? item.description.split(/\r?\n/).map((c) => (c.length ? `// ${c}` : '//'))
720 : []),
721 `/* ${gdpr}`,
722 ` "${item.name}" : {`
723 ];
724 const footer = [' }', ' */', '', ''];
725 const properties: Record<string, IPropertyDataNonMeasurement> =
726 'properties' in item.gdpr ? (item.gdpr['properties'] as Record<string, IPropertyDataNonMeasurement>) : {};
727 const measures: Record<string, IPropertyDataMeasurement> =
728 'measures' in item.gdpr ? (item.gdpr['measures'] as Record<string, IPropertyDataMeasurement>) : {};
729 const entries: string[] = [];
730 Object.keys(properties).forEach((key) => {
731 if (key in CommonProperties) {
732 return;
733 }

Callers 1

generateDocumentationFunction · 0.85

Calls 7

joinMethod · 0.80
mapMethod · 0.80
getMethod · 0.65
errorMethod · 0.65
pushMethod · 0.65
forEachMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected