Module: Land::Action

Extended by:
ActiveSupport::Concern
Defined in:
lib/land/action.rb

Instance Method Summary collapse

Instance Method Details

#track_with_land!Object

Use @land to avoid conflicts in controller namespace



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/land/action.rb', line 10

def track_with_land!
  yield && return if untracked?

  begin
    @land = Tracker.for(self)
    @land.track
  rescue => e
    begin
      Rails.logger.error e

      if defined?(NewRelic::Agent) && NewRelic::Agent.respond_to?(:notice_error)
        NewRelic::Agent.notice_error(e)
      end
    rescue
      # eat this error
    end
  end

  begin
    yield
  rescue => e
    @land.status = ActionDispatch::ExceptionWrapper.status_code_for_exception(e.class.name)
    raise e
  ensure
    begin
      @land.save
    rescue => e
      begin
        Rails.logger.error e

        if defined?(NewRelic::Agent) && NewRelic::Agent.respond_to?(:notice_error)
          NewRelic::Agent.notice_error(e)
        end
      rescue
        # bubble controller error, not this one
      end
    end
  end
end

#untracked?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/land/action.rb', line 50

def untracked?
  untracked_path? || untracked_ip?
end

#untracked_ip?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/land/action.rb', line 58

def untracked_ip?
  Land.config.untracked_ips.include? request.remote_ip
end

#untracked_path?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/land/action.rb', line 54

def untracked_path?
  Land.config.untracked_paths.include? request.fullpath
end