Skip to content

Commit 9267d0c

Browse files
committed
fix(analytics): make naming, formatting, and consistency better
1 parent 5ae5cb0 commit 9267d0c

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

analytics/events.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
"use strict";
22

3-
const makeEvent = (category) => (eventDetails) => ({
3+
const event = (category) => (action, details) => ({
44
category: category,
5-
action: eventDetails.action,
6-
label: eventDetails.label || undefined,
7-
value: eventDetails.value || undefined
5+
action: action,
6+
label: details.label,
7+
value: details.value
88
});
99

10-
const buildEvent = makeEvent("build");
11-
const configEvent = makeEvent("options");
10+
const onBuild = event("build");
11+
const onConfig = event("options");
12+
13+
exports.event = event;
14+
exports.onBuild = onBuild;
15+
exports.onConfig = onConfig;
1216

13-
exports.makeEvent = makeEvent;
14-
exports.buildEvent = buildEvent;
15-
exports.configEvent = configEvent;

bin/webpack.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
341341
var compiler;
342342
try {
343343
insightReporter.trackEvent(
344-
insightEvents.configEvent({
345-
action: "options-collected",
344+
insightEvents.onConfig("options-collected", {
346345
label: JSON.stringify(options),
347346
value: 1
348347
})
@@ -374,8 +373,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
374373
}
375374

376375
insightReporter.trackEvent(
377-
insightEvents.buildEvent({
378-
action: "build-end",
376+
insightEvents.onBuild("build-end", {
379377
label: "compiler build end",
380378
value: 9999
381379
})
@@ -411,8 +409,7 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => {
411409
console.log("\nWebpack is watching the files…\n");
412410
} else
413411
insightReporter.trackEvent(
414-
insightEvents.buildEvent({
415-
action: "build-start",
412+
insightEvents.onBuild("build-start", {
416413
label: "compiler build start",
417414
value: 2
418415
})

0 commit comments

Comments
 (0)