README.mdown in intercom-rails-0.2.24 vs README.mdown in intercom-rails-0.2.25

- old
+ new

@@ -15,17 +15,17 @@ ``` bundle install ``` -Take note of your `app_id` from [here](https://www.intercom.io/apps/api_keys) and generate a config file: +Take note of your `app_id` from [here](https://app.intercom.io/apps/api_keys) and generate a config file: ``` rails generate intercom:config YOUR-APP-ID ``` -To make installing Intercom as easy as possible, where possible a `<script>` tag **will be automatically inserted before the closing `</body>` tag**. For most Rails apps, **you won't need to do any extra config**. Having trouble? Check out troubleshooting below. +To make installing Intercom as easy as possible, where possible a `<script>` tag **will be automatically inserted before the closing `</body>` tag**. For most Rails apps, **you won't need to do any extra config**. Having trouble? Check out troubleshooting below. ### Disabling automatic insertion To disable automatic insertion for a particular controller or action you can: @@ -53,29 +53,31 @@ ```ruby config.api_secret = '123456' ``` -### Custom Data -Custom data lets you associate any data, specific to your app, with a user in Intercom. For custom data variables you want updated on every request set them in `config/initializers/intercom.rb`. +### User Custom data attributes +You can associate any attributes, specific to your app, with a user in Intercom. +For custom data attributes you want updated on every request set them in `config/initializers/intercom.rb`, the latest value will be sent to Intercom on each page visit. -You can give either a: +Configure what attributes will be sent using either a: * `Proc` which will be passed the current user object - * Or, a method which will be sent to the current user object - -to generate the values of the custom data: + * Or, a method which will be sent to the current user object +e.g. + ```ruby config.user.custom_data = { :plan => Proc.new { |user| user.plan.name }, :is_paid => Proc.new { |user| user.plan.present? }, :email_verified => :email_verified? } ``` -In some situations you'll want to set some custom data specific to a request. You can do this using the `intercom_custom_data` helper available in your controllers: +In some situations you'll want to set some custom data attribute specific to a request. +You can do this using the `intercom_custom_data` helper available in your controllers: ```ruby class AppsController < ActionController::Base def activate intercom_custom_data.user[:app_activated_at] = Time.now @@ -87,13 +89,34 @@ ... end end ``` -Attributes must be accessible in order to sync with intercom. Additionally, attriutes ending in "_at" will be parsed as times. +Attributes must be accessible in order to sync with intercom. +Additionally, attributes ending in "_at" will be parsed as times. +### Companies +By default, Intercom treats all Users as unrelated individuals. If for example you know users are part of a company, you can group them as such. + +Read more about it here http://docs.intercom.io/configuring-Intercom/grouping-users-by-company + +Basic usage is as follows - in `config/initializers/intercom.rb` + +```ruby +config.company.current = Proc.new { current_company } +``` + +and like with Users, you can set custom attribute on companies too: + +```ruby +config.company.custom_data = { + :number_of_messages => Proc.new { |app| app.messages.count }, + :is_interesting => :is_interesting? +} +``` + ### Inbox Intercom includes an inbox which allows a user to read their past conversations with your app, and start new conversations. It's hidden by default, you can include a link to open it by adding a line to `config/initializers/intercom.rb`: To use the default link style, which requires no extra config and includes a small question mark icon in the bottom right corner of your app: @@ -115,17 +138,17 @@ You can read more about configuring the Inbox within Intercom (Config menu -> Inbox Link). ### Environments -By default Intercom will be automatically inserted in all Rails environments. If you would like to specify the environments in which Intercom should be inserted, you can do so as follows: +By default Intercom will be automatically inserted in development and production Rails environments. If you would like to specify the environments in which Intercom should be inserted, you can do so as follows: ```ruby config.enabled_environments = ["production"] ``` -### Manually Inserting the Intercom Javascript +### Manually Inserting the Intercom Javascript Some situations may require manually inserting the Intercom script tag. If you simply wish to place the Intercom javascript in a different place within the page or, on a page without a closing `</body>` tag: ```erb <%= intercom_script_tag %> @@ -171,13 +194,28 @@ rake intercom:import ``` Any custom data defined in `config/initializers/intercom.rb` will also be sent. +## Running tests/specs + +specs should run on a clean clone of this repo, using the following commands. (developed against ruby 2.1.2 and 1.9.3) + +``` +bundle install +bundle exec rake spec +or +bundle exec rspec spec/ +``` + ## Contributors - Dr Nic Williams (@drnic) - provided a rails generator for adding the Intercom javascript tag into your layout. - Alexander Chaychuk (@sashich) - fixed bug in user detection when users not persisted (e.g. new session view with devise). ## License + +intercom-rails is released under the [MIT License](http://www.opensource.org/licenses/MIT). + +## Copyright Copyright (c) 2011-2012 Intercom, Inc. All rights reserved.