 _ = require 'underscore'
 _s = require 'underscore.string'
 qs = require 'qs'
+Q = require 'bluebird-q'
 Backbone = require 'backbone'
 PersonalizeState = require './state.coffee'
 mediator = require '../../../../lib/mediator.coffee'

  # Init the personalize flow
  else
    user.approximateLocation success: -> user.save()
    new PersonalizeRouter user: user, reonboarding: reonboarding?, force: force
    Backbone.history.start pushState: true
    require('./analytics.coffee')(user)


    @$el.attr 'data-state', 'loading'

    Q.all [
      $.post('/artsy-primer/set-sailthru')
    ]
    .then =>
      Q.all [
        @user.save()
        $.post('/flash', message: 'Thank you. Please expect your personalized portfolio in the next 2 business days.')
      ]
    .finally =>
      location.assign @redirectLocation()

module.exports.init = ->
