Class: Intercom::Impression
- Inherits:
-
UserResource
- Object
- UserResource
- Intercom::Impression
- Defined in:
- lib/intercom/impression.rb
Overview
Represents a users interaction with your app (eg page view, or using a particular feature)
An impressions contains user_ip, user_agent and location.
Examples
impression = Intercom::Impression.create(:email => "person@example.com", :location => "/pricing/upgrade",
:user_ip => '1.2.3.4', :user_agent => "my-service-iphone-app-1.2")
The impression response will contain #unread_messages
impression.
You can also create an impression and save it like this:
impression = Intercom::Impression.new
impression.email = "person@example.com"
impression.location = "person@example.com"
....
impression.save
Class Method Summary (collapse)
-
+ (Object) create(params)
Creates a new Impression using params and saves it.
Instance Method Summary (collapse)
-
- (Object) location=(location)
Set the location in your application that this impression occurred.
-
- (Object) save
Records that a user has interacted with your application, including the 'location' within the app they used.
-
- (Object) unread_messages
For convenience, after saving, the unread_messages count will be updated with the number of unread messages for the user for their current location.
-
- (Object) user_agent=(user_agent)
Set the user agent of the user this impression (E.g. their browser user agent, or the name and version of a desktop or phone application).
-
- (Object) user_ip=(user_ip)
Set the ip address of the user for this impression.
Methods inherited from UserResource
#email, #email=, #initialize, #to_hash, #update_from_api_response, #user_id, #user_id=
Methods included from RequiresParameters
Methods included from UnixTimestampUnwrapper
Constructor Details
This class inherits a constructor from Intercom::UserResource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Intercom::UserResource
Class Method Details
+ (Object) create(params)
Creates a new Impression using params and saves it
26 27 28 |
# File 'lib/intercom/impression.rb', line 26 def self.create(params) Impression.new(params).save end |
Instance Method Details
- (Object) location=(location)
Set the location in your application that this impression occurred. E.g. the url in a web app, or perhaps the screen in a desktop or phone application.
45 46 47 |
# File 'lib/intercom/impression.rb', line 45 def location=(location) @attributes["location"] = location end |
- (Object) save
Records that a user has interacted with your application, including the 'location' within the app they used
32 33 34 35 |
# File 'lib/intercom/impression.rb', line 32 def save response = Intercom.post("/v1/users/impressions", to_hash) self.update_from_api_response(response) end |
- (Object) unread_messages
For convenience, after saving, the unread_messages count will be updated with the number of unread messages for the user for their current location.
Remember, Auto Messages (docs.intercom.io/#AutoMessages) can be targeted to only show when a user views a particular page in your application.
59 60 61 |
# File 'lib/intercom/impression.rb', line 59 def @attributes["unread_messages"] end |
- (Object) user_agent=(user_agent)
Set the user agent of the user this impression (E.g. their browser user agent, or the name and version of a desktop or phone application)
51 52 53 |
# File 'lib/intercom/impression.rb', line 51 def user_agent=(user_agent) @attributes["user_agent"] = user_agent end |
- (Object) user_ip=(user_ip)
Set the ip address of the user for this impression
39 40 41 |
# File 'lib/intercom/impression.rb', line 39 def user_ip=(user_ip) @attributes["user_ip"] = user_ip end |