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

intercom_custom_data helper not working #269

Open alfmatos opened 7 years ago

alfmatos commented 7 years ago

Hi,

I've setup a project with intercom-ruby and intercom-rails. The ruby part is for events, everything else is intercom-rails. However, custom data attributes using the helper do not show up on the intercom dashboard.

intercom_custom_data.user[:reports] = 5

I've tried using the key as a string "app_activated_at", and several other options, but nothing seems to work. A couple of things:

But then nothing happens, even though the usual attributes get updated correctly.

Version info

Expected behavior

Expected to use the helper and it would update the remote custom data attributes.

Actual behavior

No attributes get updatedm and no error is raised anywhere

Steps to reproduce

  1. Add the helper calls to a controller
  2. Call the controller method
  3. Nothing gets updated
alfmatos commented 7 years ago

After further investigating, it seems that the helper des not work when followed by a redirect. Putting the helper on the index works, as it just render the index view. Putting it on a create/destroy does not, since it renders a redirect.

This works:

  def index
    intercom_custom_data.user["reports"] = 10
  end

This does not:

  def create
    @report  = Report.new
    if @report.save
      intercom_custom_data.user["reports"] = 5
      format.html { redirect_to PATH, notice: 'NOTICE' }
    end
  end