     return if ($(e.target).closest(
                  '.favorites2-collection-list-container'
               ).length > 0 and not $(e.target).hasClass('.modal-close'))
-    track.funnel 'Set Management: Open menu - dismiss'
+    analytics.track 'Set Management: Open menu - dismiss'
 
 # Hover on work
 $(document).on 'mouseenter', '.artwork-item', ->
   hoverTimeout = setTimeout ->
     hoverTimeout = null
-    track.funnel 'Set Management: Hover on work'
+    analytics.track 'Set Management: Hover on work'
   , 300
 
 # Click remove
 $(document).on 'click', '.artwork-item-remove', ->
   clickedSaveControl = true
-  track.click 'Set Management: Click remove'
+  analytics.track 'Set Management: Click remove'
 
 # Click favicon
 $(document).on 'click', '.overlay-button-save, .circle-icon-button-save', (e) ->
   clickedSaveControl = true
-  track.funnel 'Set Management: Click favicon'
+  analytics.track 'Set Management: Click favicon'
   if $(e.target).closest('.save-controls-one-btn-container').length
     listenForMenuDismiss()
   if $(e.target).closest('.save-controls-two-btn-container').length
-    track.funnel 'Set Management: Successful save'
+    analytics.track 'Set Management: Successful save'
 
 # Click set stack
 $(document).on 'click', ('.save-controls-two-btn-add-to-collection, ' +
                          '.circle-icon-button-add'), ->
   clickedSaveControl = true
   openedMenu = true
-  track.funnel 'Set Management: Click set stack'
+  analytics.track 'Set Management: Click set stack'
   listenForMenuDismiss()
 
 # Dismiss
 $(document).on 'mouseleave', '.artwork-item', (e) ->
   return clearTimeout(hoverTimeout) if hoverTimeout
   unless clickedSaveControl
-    track.funnel 'Set Management: Hover on work - dismiss'
+    analytics.track 'Set Management: Hover on work - dismiss'
   clickedSaveControl = false
 
 # Work saved to My Favs
 $(document).on 'click', ('.save-controls-drop-down-container ' +
                          '.overlay-button-save, .circle-icon-button-save'), ->
   return unless MODE is 'drop down'
-  track.funnel 'Set Management: Work Saved to My Favs'
-  track.funnel 'Set Management: Successful save'
+  analytics.track 'Set Management: Work Saved to My Favs'
+  analytics.track 'Set Management: Successful save'
   listenForMenuDismiss()
 
 # Added to set X

# See: http://cl.ly/image/3q040w1J2I2y/o
#

{ track } = analytics = require '../../../lib/analytics.coffee'
Cookies = require 'cookies-js'
mediator = require '../../../lib/mediator.coffee'

MODE = Cookies.get('save-controls') or analytics.getProperty('ab:save:controls')

# Funnel 1 (NUX Onboarding modal to new set made)
# ------------------------------------------------------------------------------

# NUX modal
mediator.on 'modal:opened', ({ view }) ->
  return unless view.$el.html().match('favorites2-onboarding-modal')?
  analytics.track 'Set Management: NUX modal'

# Click
$(document).on 'click', '.favorites2-onboarding-modal a', ->
  analytics.track 'Set Management: NUX modal - click'

# Dismiss
mediator.on 'modal:closed', ({ view }) ->
  return unless view.$el.html().match('favorites2-onboarding-modal')?
  analytics.track 'Set Management: NUX modal - dismiss'

# Click create new set
$(document).on 'click', '.favorites2-new-collection', ->
  analytics.track 'Set Management: Click create new set'

# New set made
onNewSet = (e) ->
  return if e.keyCode and e.keyCode isnt 13
  analytics.track 'Set Management: New set made'
$(document).on 'keyup', '.favorites2-edit-modal input', onNewSet
$(document).on 'click', '.favorites2-edit-modal-save', onNewSet

