提交 293b1a4e 编写于 作者: J Johannes Rieken

stats - send telemetry event about bundle size and file count in extensions

上级 69e7247e
......@@ -327,13 +327,15 @@ function packageTask(platform, arch, opts) {
.pipe(rename('bin/' + product.applicationName)));
}
// submit all stats that have been collected during
// the build phase
if (opts.stats) {
result.on('end', () => require('./lib/stats').submitAllStats());
}
return result.pipe(vfs.dest(destination));
return result.pipe(es.through(undefined, function () {
// submit all stats that have been collected during the build phase
if (!opts.stats) {
return this.emit('end');
}
const { submitAllStats } = require('./lib/stats');
submitAllStats(product).then(() => this.emit('end')).catch(() => this.emit('end'));
})).pipe(vfs.dest(destination));
};
}
......
......@@ -6,6 +6,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
var es = require("event-stream");
var util = require("gulp-util");
var appInsights = require("applicationinsights");
var Entry = /** @class */ (function () {
function Entry(name, totalCount, totalSize) {
this.name = name;
......@@ -70,10 +71,9 @@ function createStatsStream(group, log) {
});
}
exports.createStatsStream = createStatsStream;
function submitAllStats() {
function submitAllStats(productJson) {
var sorted = [];
// move entries for single files to the
// front
// move entries for single files to the front
_entries.forEach(function (value) {
if (value.totalCount === 1) {
sorted.unshift(value);
......@@ -82,11 +82,32 @@ function submitAllStats() {
sorted.push(value);
}
});
// todo@ramya/joh - send the data as telemetry event
// so that it can be stored in the datawarehouse
// print to console
for (var _i = 0, sorted_1 = sorted; _i < sorted_1.length; _i++) {
var entry = sorted_1[_i];
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();
}
return new Promise(function (resolve) {
var measurements = Object.create(null);
for (var _i = 0, sorted_2 = sorted; _i < sorted_2.length; _i++) {
var entry = sorted_2[_i];
measurements[entry.name + ".size"] = entry.totalSize;
measurements[entry.name + ".count"] = entry.totalCount;
}
appInsights.setup(productJson.aiConfig.asimovKey)
.setAutoCollectConsole(false)
.setAutoCollectExceptions(false)
.setAutoCollectPerformance(false)
.setAutoCollectRequests(false)
.start();
appInsights.defaultClient.config.endpointUrl = 'https://vortex.data.microsoft.com/collect/v1';
appInsights.defaultClient.trackEvent("bundleStats", undefined, measurements);
appInsights.defaultClient.sendPendingData(function () { return resolve(); });
});
}
exports.submitAllStats = submitAllStats;
......@@ -8,6 +8,7 @@
import * as es from 'event-stream';
import * as util from 'gulp-util';
import * as File from 'vinyl';
import * as appInsights from 'applicationinsights';
class Entry {
constructor(readonly name: string, public totalCount: number, public totalSize: number) { }
......@@ -72,10 +73,10 @@ export function createStatsStream(group: string, log?: boolean): es.ThroughStrea
});
}
export function submitAllStats(): void {
export function submitAllStats(productJson: any): Promise<void> {
let sorted: Entry[] = [];
// move entries for single files to the
// front
// move entries for single files to the front
_entries.forEach(value => {
if (value.totalCount === 1) {
sorted.unshift(value);
......@@ -83,9 +84,36 @@ export function submitAllStats(): void {
sorted.push(value);
}
});
// todo@ramya/joh - send the data as telemetry event
// so that it can be stored in the datawarehouse
// 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();
}
return new Promise(resolve => {
const measurements = Object.create(null);
for (const entry of sorted) {
measurements[`${entry.name}.size`] = entry.totalSize;
measurements[`${entry.name}.count`] = entry.totalCount;
}
appInsights.setup(productJson.aiConfig.asimovKey)
.setAutoCollectConsole(false)
.setAutoCollectExceptions(false)
.setAutoCollectPerformance(false)
.setAutoCollectRequests(false)
.start();
appInsights.defaultClient.config.endpointUrl = 'https://vortex.data.microsoft.com/collect/v1';
appInsights.defaultClient.trackEvent(`bundleStats`, undefined, measurements);
appInsights.defaultClient.sendPendingData(() => resolve());
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册