diff --git a/docs/events.md b/docs/events.md new file mode 100644 index 0000000..e6869c4 --- /dev/null +++ b/docs/events.md @@ -0,0 +1,36 @@ +# Events specification + +This document specifies all the data (along with the format) which gets send from the Welcome package to the GitHub analytics pipeline. This document follows the same format and nomenclature than the [Atom Core Events spec](https://github.com/atom/metrics/blob/master/docs/events.md). + +## Counters + +Currently the Welcome package does not log any counter event. + +## Timing events + +Currently the Welcome package does not log any timing event. + +## Standard events + +#### Welcome package shown + +* **eventType**: `welcome-v1` +* **metadata** + + | field | value | + |-------|-------| + | `ea` | `show-on-initial-load` + + +#### Click on links + +* **eventType**: `welcome-v1` +* **metadata** + + | field | value | + |-------|-------| + | `ea` | link that was clicked + +(There are many potential values for the `ea` param, e.g: `clicked-welcome-atom-docs-link`,`clicked-welcome-atom-org-link`, `clicked-project-cta`, `clicked-init-script-cta`, ...). + + diff --git a/lib/reporter-proxy.js b/lib/reporter-proxy.js index e97ad04..e779c7e 100644 --- a/lib/reporter-proxy.js +++ b/lib/reporter-proxy.js @@ -4,20 +4,22 @@ export default class ReporterProxy { constructor () { this.reporter = null this.queue = [] + this.eventType = 'welcome-v1' } setReporter (reporter) { this.reporter = reporter let customEvent + while ((customEvent = this.queue.shift())) { - this.reporter.addCustomEvent(customEvent.category, customEvent) + this.reporter.addCustomEvent(this.eventType, customEvent) } } sendEvent (action, label, value) { - const event = { action, label, value, category: 'welcome-v1' } + const event = { ea: action, el: label, ev: value } if (this.reporter) { - this.reporter.addCustomEvent(event.category, event) + this.reporter.addCustomEvent(this.eventType, event) } else { this.queue.push([event]) } diff --git a/test/welcome.test.js b/test/welcome.test.js index c989479..872e6eb 100644 --- a/test/welcome.test.js +++ b/test/welcome.test.js @@ -127,13 +127,13 @@ describe('Welcome', () => { const reporter1 = {addCustomEvent (category, event) { this.reportedEvents.push(event) }, reportedEvents: []} const reporter2 = {addCustomEvent (category, event) { this.reportedEvents.push(event) }, reportedEvents: []} - welcomePackage.reporterProxy.sendEvent('foo', 'bar', 'baz') - welcomePackage.reporterProxy.sendEvent('foo2', 'bar2', 'baz2') + welcomePackage.reporterProxy.sendEvent('foo', 'bar', 10) + welcomePackage.reporterProxy.sendEvent('foo2', 'bar2', 60) welcomePackage.reporterProxy.setReporter(reporter1) assert.deepEqual(reporter1.reportedEvents, [ - [{category: 'welcome-v1', action: 'foo', label: 'bar', value: 'baz'}], - [{category: 'welcome-v1', action: 'foo2', label: 'bar2', value: 'baz2'}] + [{category: 'welcome-v1', ea: 'foo', el: 'bar', ev: 10}], + [{category: 'welcome-v1', ea: 'foo2', el: 'bar2', ev: 60}] ]) welcomePackage.consumeReporter(reporter2)