Skip to content
This repository has been archived by the owner on Aug 12, 2019. It is now read-only.

Commit

Permalink
Fix field names used by the welcome package metric events
Browse files Browse the repository at this point in the history
  • Loading branch information
rafeca committed Mar 21, 2019
1 parent d670323 commit fc3422b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
36 changes: 36 additions & 0 deletions 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`, ...).


8 changes: 5 additions & 3 deletions lib/reporter-proxy.js
Expand Up @@ -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])
}
Expand Down
8 changes: 4 additions & 4 deletions test/welcome.test.js
Expand Up @@ -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)
Expand Down

0 comments on commit fc3422b

Please sign in to comment.