Class: UsageReportingJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/usage_reporting_job.rb

Instance Method Summary collapse

Instance Method Details

#perform ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/jobs/usage_reporting_job.rb', line 4

def perform
  # If there's no ID, don't send
  return unless SiteSettings.anonymous_usage_id
  # Get the endpoint
  uri = URI.parse(UsageReport.endpoint)
  # Prepare the report
  data = UsageReport.generate
  # Tell the user what we're doing
  Rails.logger.info("Sending anonymous usage report to #{uri}: #{data}")
  # Send
  headers = {
    "Content-Type": "application/json",
    "User-Agent": "Manyfold::UsageReportingJob"
  }
  Net::HTTP.post(uri, data, headers)
end