intercom / intercom-rails

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

Error: invalid filter name app_id #338

Closed rassom closed 3 years ago

rassom commented 3 years ago

I'm using Rails's built-in CSP, so cannot use the instructions provided for the Twitter Secure Headers gem (https://github.com/intercom/intercom-rails#automatic-insertion).

When using the manual insertion method instead (https://github.com/intercom/intercom-rails#manual-insertion) to make Intercom work with CSP - content security policy - , I get the error: intercom rails invalid filter name app_id

Any ideas why the intercom rails invalid filter name app_iderror is happening?

Version info

rassom commented 3 years ago

@arindambarman-intercom Any chance you could take a look at this? Thanks 🙏

arindambarman-intercom commented 3 years ago

Hey @rassom sorry missed this earlier. Can you share your integration script? From the error message itself it looks like it is unrelated to CSP. Also can paste the stacktrace?

rassom commented 3 years ago

Hey @arindambarman-intercom,

Thanks for replying.

Found out that the error was caused by (invalid) HAML syntax.

Invalid syntax:

- if logged_in?
  = intercom_script_tag({                         
      :app_id => 'your-app-id',                   
      :user_id => current_user.id,               
      :email => current_user.email,              
      :name => current_user.name,                 
      :created_at => current_user.created_at      
    }, {                                          
      :secret => 'your-apps-api-secret',          
      :widget => {:activator => '#Intercom'},     
      :nonce => get_nonce_from_your_csp_framework 
    })        

Valid syntax:

- if logged_in?
  = intercom_script_tag({                         |
      :app_id => 'your-app-id',                   |
      :user_id => current_user.id,                |
      :email => current_user.email,               |
      :name => current_user.name,                 |
      :created_at => current_user.created_at      |
    }, {                                          |
      :secret => 'your-apps-api-secret',          |
      :widget => {:activator => '#Intercom'},     |
      :nonce => get_nonce_from_your_csp_framework |
    })                                            |

So all good and working now.

Sorry for the inconvenience and have a great weekend.

Best wishes, Rasmus