fix(analytics): make naming, formatting, and consistency better

This commit is contained in:
Sean Larkin 2017-11-03 09:07:58 -07:00
parent 5ae5cb08ee
commit 9267d0c498
2 changed files with 13 additions and 15 deletions

View File

@ -1,15 +1,16 @@
"use strict";
const makeEvent = (category) => (eventDetails) => ({
const event = (category) => (action, details) => ({
category: category,
action: eventDetails.action,
label: eventDetails.label || undefined,
value: eventDetails.value || undefined
action: action,
label: details.label,
value: details.value
});
const buildEvent = makeEvent("build");
const configEvent = makeEvent("options");
const onBuild = event("build");
const onConfig = event("options");
exports.event = event;
exports.onBuild = onBuild;
exports.onConfig = onConfig;
exports.makeEvent = makeEvent;
exports.buildEvent = buildEvent;
exports.configEvent = configEvent;

View File

@ -341,8 +341,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
var compiler;
try {
insightReporter.trackEvent(
insightEvents.configEvent({
action: "options-collected",
insightEvents.onConfig("options-collected", {
label: JSON.stringify(options),
value: 1
})
@ -374,8 +373,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
}
insightReporter.trackEvent(
insightEvents.buildEvent({
action: "build-end",
insightEvents.onBuild("build-end", {
label: "compiler build end",
value: 9999
})
@ -411,8 +409,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
console.log("\nWebpack is watching the files…\n");
} else
insightReporter.trackEvent(
insightEvents.buildEvent({
action: "build-start",
insightEvents.onBuild("build-start", {
label: "compiler build start",
value: 2
})