build/lib/stats.ts/submitAllStats
export function submitAllStats(productJson: any, commit: string): Promise<boolean> {
	const appInsights = require('applicationinsights') as typeof import('applicationinsights');

	const sorted: Entry[] = [];
	// move entries for single files to the front
	_entries.forEach(value => {
		if (value.totalCount === 1) {
			sorted.unshift(value);
		} else {
			sorted.push(value);
		}
	});

	// print to console
	for (const entry of sorted) {
		console.log(entry.toString(true));
	}

	// send data as telementry event when the
	// product is configured to send telemetry
	if (!productJson || !productJson.aiConfig || typeof productJson.aiConfig.asimovKey !== 'string') {
		return Promise.resolve(false);
	}

	return new Promise(resolve => {
		try {

			const sizes: any = {};
			const counts: any = {};
			for (const entry of sorted) {
				sizes[entry.name] = entry.totalSize;
				counts[entry.name] = entry.totalCount;
			}

			appInsights.setup(productJson.aiConfig.asimovKey)
				.setAutoCollectConsole(false)
				.setAutoCollectExceptions(false)
				.setAutoCollectPerformance(false)
				.setAutoCollectRequests(false)
				.setAutoCollectDependencies(false)
				.setAutoDependencyCorrelation(false)
				.start();

			appInsights.defaultClient.config.endpointUrl = 'https://vortex.data.microsoft.com/collect/v1';

			/* __GDPR__
				"monacoworkbench/packagemetrics" : {
					"commit" : {"classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
					"size" : {"classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
					"count" : {"classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
				}
			*/
			appInsights.defaultClient.trackEvent({
				name: 'monacoworkbench/packagemetrics',
				properties: { commit, size: JSON.stringify(sizes), count: JSON.stringify(counts) }
			});


			appInsights.defaultClient.flush({
				callback: () => {
					appInsights.dispose();
					resolve(true);
				}
			});

		} catch (err) {
			console.error('ERROR sending build stats as telemetry event!');
			console.error(err);
			resolve(false);
		}
	});

}