Fix initialization for pro

This commit is contained in:
Piotr Sarnacki 2015-01-06 18:14:19 +01:00
parent f566d601ee
commit 35b059e783

View File

@ -47,6 +47,12 @@ unless window.TravisApplication
@tailing = new Travis.Tailing($(window), '#tail', '#log') @tailing = new Travis.Tailing($(window), '#tail', '#log')
@toTop = new Travis.ToTop($(window), '.to-top', '#log-container') @toTop = new Travis.ToTop($(window), '.to-top', '#log-container')
@on 'user:signed_in', (user) ->
Travis.onUserUpdate(user)
@on 'user:synced', (user) ->
Travis.onUserUpdate(user)
reset: -> reset: ->
@_super.apply(this, arguments) @_super.apply(this, arguments)
@get('modelClasses').forEach (klass) -> @get('modelClasses').forEach (klass) ->
@ -144,46 +150,37 @@ unless window.TravisApplication
currentDate: -> currentDate: ->
new Date() new Date()
)
onUserUpdate: (user) -> onUserUpdate: (user) ->
if Travis.config.pro if Travis.config.pro
@identifyCustomer(user) @identifyCustomer(user)
@subscribePusher(user) @subscribePusher(user)
@setupCharm(user) @setupCharm(user)
subscribePusher: (user) -> subscribePusher: (user) ->
channels = user.channels channels = user.channels
channels = channels.map (channel) -> channels = channels.map (channel) ->
if channel.match /^private-/ if channel.match /^private-/
channel channel
else else
"private-#{channel}" "private-#{channel}"
Travis.pusher.subscribeAll(channels) Travis.pusher.subscribeAll(channels)
setupCharm: (user) -> setupCharm: (user) ->
$.extend window.__CHARM, $.extend window.__CHARM,
customer: user.login, customer: user.login,
customer_id: user.id, customer_id: user.id,
email: user.email
displayCharm: ->
__CHARM.show()
identifyCustomer: (user) ->
if _cio && _cio.identify
_cio.identify
id: user.id
email: user.email email: user.email
name: user.name
created_at: (Date.parse(user.created_at) / 1000) || null
login: user.login
@on 'user:signed_in', (user) -> displayCharm: ->
Travis.onUserUpdate(user) __CHARM.show()
@on 'user:synced', (user) ->
Travis.onUserUpdate(user)
@_super.apply this, arguments
identifyCustomer: (user) ->
if _cio && _cio.identify
_cio.identify
id: user.id
email: user.email
name: user.name
created_at: (Date.parse(user.created_at) / 1000) || null
login: user.login
)