intercom / intercom-rails

The easiest way to install Intercom in a Rails app.
https://developers.intercom.io/reference
MIT License
280 stars 106 forks source link

New signed up users are not added to intercom until after they log-in #300

Closed samiggapps closed 6 years ago

samiggapps commented 6 years ago

Expected behavior

I would expect that after a user has signed up they are created as a user on the intercom platform, irrelevant of them logging in. (unless someone can justify why this should be the desired behavior)

Actual behavior

After a user signs up they are not created as a user on the intercom platform. Only once they have logged in are they created as a user on intercom.

IntercomRails.config do |config|
  # == Intercom app_id
  #
  config.app_id = ENV["INTERCOM_APP_ID"]

  # == Intercom session_duration
  #
  # config.session_duration = 300000
  # == Intercom secret key
  # This is required to enable Identity Verification, you can find it on your Setup
  # guide in the "Identity Verification" step.
  #
  config.api_secret = ENV["INTERCOM_SECRET_KEY"]

  # == Enabled Environments
  # Which environments is auto inclusion of the Javascript enabled for
  #
  config.enabled_environments = ["staging", "production"]

  # == Current user method/variable
  # The method/variable that contains the logged in user in your controllers.
  # If it is `current_user` or `@user`, then you can ignore this
  #
  # config.user.current = Proc.new { current_user }
  # config.user.current = [Proc.new { current_user }]

  # == Include for logged out Users
  # If set to true, include the Intercom messenger on all pages, regardless of whether
  # The user model class (set below) is present.
  config.include_for_logged_out_users = true

  # == User model class
  # The class which defines your user model
  #
  config.user.model = Proc.new { User }

  # == Lead/custom attributes for non-signed up users
  # Pass additional attributes to for potential leads or
  # non-signed up users as an an array.
  # Any attribute contained in config.user.lead_attributes can be used
  # as custom attribute in the application.
  # config.user.lead_attributes = %w(ref_data utm_source)

  # == Exclude users
  # A Proc that given a user returns true if the user should be excluded
  # from imports and Javascript inclusion, false otherwise.
  #
  config.user.exclude_if = Proc.new { |current_user| current_user.super_admin? }

  # == User Custom Data
  # A hash of additional data you wish to send about your users.
  # You can provide either a method name which will be sent to the current
  # user object, or a Proc which will be passed the current user.
  #
  config.user.custom_data = {
    :role => Proc.new { |current_user| current_user.role },
    :is_confirmed => Proc.new { |current_user| current_user.confirmed? },
    :number_of_submissions => Proc.new { |current_user| current_user.candidate_profile.submissions.count if current_user.candidate? },
    :sign_in_count => Proc.new { |current_user| current_user.sign_in_count },
    :first_name => Proc.new { |current_user| 
      if current_user.candidate? 
        current_user.candidate_profile.first_name
      elsif current_user.company_user?  
        current_user.company_user_profile.first_name
      end 
    },
    :last_name => Proc.new { |current_user| 
      if current_user.candidate? 
        current_user.candidate_profile.last_name
      elsif current_user.company_user?  
        current_user.company_user_profile.last_name
      end  
    }
  }

  # == Current company method/variable
  # The method/variable that contains the current company for the current user,
  # in your controllers. 'Companies' are generic groupings of users, so this
  # could be a company, app or group.
  #
  # config.company.current = Proc.new { current_company }
  #
  # Or if you are using devise you can just use the following config
  #
  config.company.current = Proc.new { current_user.company }

  # == Exclude company
  # A Proc that given a company returns true if the company should be excluded
  # from imports and Javascript inclusion, false otherwise.
  #
  # config.company.exclude_if = Proc.new { |app| app.subdomain == 'demo' }

  # == Company Custom Data
  # A hash of additional data you wish to send about a company.
  # This works the same as User custom data above.
  #
  config.company.custom_data = {
    :number_of_talent_fit_projects => Proc.new { |company| company.talent_fit_projects.count },
  }

  # == Company Plan name
  # This is the name of the plan a company is currently paying (or not paying) for.
  # e.g. Messaging, Free, Pro, etc.
  #
  # config.company.plan = Proc.new { |current_company| current_company.plan.name }

  # == Company Monthly Spend
  # This is the amount the company spends each month on your app. If your company
  # has a plan, it will set the 'total value' of that plan appropriately.
  #
  # config.company.monthly_spend = Proc.new { |current_company| current_company.plan.price }
  # config.company.monthly_spend = Proc.new { |current_company| (current_company.plan.price - current_company.subscription.discount) }

  # == Custom Style
  # By default, Intercom will add a button that opens the messenger to
  # the page. If you'd like to use your own link to open the messenger,
  # uncomment this line and clicks on any element with id 'Intercom' will
  # open the messenger.
  #
  config.inbox.style = :custom
  #
  # If you'd like to use your own link activator CSS selector
  # uncomment this line and clicks on any element that matches the query will
  # open the messenger
  # config.inbox.custom_activator = '.intercom'
  #
  # If you'd like to hide default launcher button uncomment this line
  # config.hide_default_launcher = true
end
samiggapps commented 6 years ago

After doing some more digging this is not an issue with this gem, this is the way intercom is built to work. I would love someone to comment and explain why intercom works in this way, but not an issue with this Gem. Closing issue.