Skip to content

Commit 0f96791

Browse files
committed
Change format of json post, simplify logic
1 parent 7d44657 commit 0f96791

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/webhint-theme/source/js/telemetry/telemetry.js

+14-17
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
"use strict";
22
(function () {
33
const activityKey = 'webhint-activity';
4+
const productKey = 'webhint-online-scanner';
45
const storage = window.localStorage;
56
const telemetryApiEndpoint = 'http://localhost:7071/api/webhint-telemetry-ingress-api';
6-
let nameKey = '';
77
let sendTimeout = null;
88
let telemetryQueue = [];
99
let options = {
1010
batchDelay: 15000,
1111
defaultProperties: {},
12-
enabled: false,
13-
instrumentationKey: '8ef2b55b-2ce9-4c33-a09a-2c3ef605c97d',
1412
};
1513

1614
const post = async (url, data) => {
@@ -29,7 +27,11 @@
2927
clearTimeout(sendTimeout);
3028
sendTimeout = null;
3129
}
32-
const data = JSON.stringify(telemetryQueue);
30+
const data = JSON.stringify({
31+
product: productKey,
32+
data: telemetryQueue
33+
});
34+
3335
telemetryQueue = [];
3436
try {
3537
post(telemetryApiEndpoint, data)
@@ -45,19 +47,14 @@
4547
};
4648

4749
const track = async (type, data) => {
48-
telemetryQueue.push({
49-
data: {
50-
baseData: {
51-
name: data.name,
52-
properties: Object.assign(Object.assign({}, options.defaultProperties), data.properties),
53-
ver: 2
54-
},
55-
baseType: `${type}Data`
56-
},
57-
iKey: options.instrumentationKey,
58-
name: `Microsoft.ApplicationInsights.${nameKey}.${type}`,
59-
time: new Date().toISOString()
60-
});
50+
telemetryQueue.push(
51+
{
52+
name: data.name,
53+
properties: Object.assign(Object.assign({}, options.defaultProperties), data.properties),
54+
ver: 2,
55+
type: `${type}Data`
56+
}
57+
);
6158
if (!options.batchDelay) {
6259
await sendTelemetry();
6360
}

0 commit comments

Comments
 (0)