Class: Intercom::Impression

Inherits:
UserResource show all
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.unread_messages

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)

Instance Method Summary (collapse)

Methods inherited from UserResource

#email, #email=, #initialize, #to_hash, #update_from_api_response, #user_id, #user_id=

Methods included from RequiresParameters

#requires_parameters

Methods included from UnixTimestampUnwrapper

#set_time_at, #time_at

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

See Also:



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 unread_messages
  @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