You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: visit_properties.rb
    path of file: ./repos/ahoy/lib/ahoy
    
    the code of the file until where you have to start completion: require "cgi"
require "device_detector"
require "uri"

module Ahoy
  class VisitProperties
    attr_reader :request, :params, :referrer, :landing_page

    def initialize(request, api:)
      @request = request
      @params = request.params
      @referrer = api ? params["referrer"] : request.referer
      @landing_page = api ? params["landing_page"] : request.original_ur
    
    def utm_properties
      landing_params = {}
      begin
        landing_uri = URI.parse(landing_page)
        # could also use Rack::Utils.parse_nested_query
        landing_params = CGI.parse(landing_uri.query) if landing_uri
      rescue
        # do nothing
      end

      props = {}
      %w(utm_source utm_medium utm_term utm_content utm_campaign).each do |name|
        props[name.to_sym] = params[name] || landing_params[name].try(:first)
      end
      props
    end