aboutsummaryrefslogtreecommitdiff
path: root/src/client/javascript/analytics.js
blob: 821aef82f91d3fb0dad9cea803aefe3ba1aa8ae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* global ga */

const self = {}

self.send = {}

self.send.search = function (selectedUser, favorite) {
  const hitType = 'event'

  const eventCategory = favorite ? 'search fav' : 'search'


  let eventAction
  switch (selectedUser.type) {
    case 'c':
      eventAction = 'Class'
      break
    case 't':
      eventAction = 'Teacher'
      break
    case 'r':
      eventAction = 'Room'
      break
    case 's':
      eventAction = 'Student'
      break
  }

  const eventLabel = selectedUser.value

  ga(function () {
    ga('send', { hitType, eventCategory, eventAction, eventLabel })
  })
}

module.exports = self