Class: ThinkFeelDoEngine::Reports::UserAgent

Inherits:
Object
  • Object
show all
Defined in:
app/models/think_feel_do_engine/reports/user_agent.rb

Overview

Scenario: a Participant accesses the site with a unique user agent.

Class Method Summary collapse

Class Method Details

.allObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/think_feel_do_engine/reports/user_agent.rb', line 12

def self.all
  Participant.not_moderator.select(:id, :study_id).map do |participant|
    user_agents = EventCapture::Event
                  .where(participant_id: participant.id)
                  .map { |event| event.payload["ua"] }
                  .uniq

    user_agents.map do |agent|
      ua = UserAgentParser.parse(agent)
      next if ua.family == "Other" && ua.version.to_s == ""

      {
        participant_id: participant.study_id,
        user_agent_family: ua.family,
        user_agent_version: ua.version.to_s,
        user_agent_os: ua.os.to_s
      }
    end
  end.flatten.compact
end

.columnsObject



8
9
10
# File 'app/models/think_feel_do_engine/reports/user_agent.rb', line 8

def self.columns
  %w( participant_id user_agent_family user_agent_version user_agent_os )
end