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: logger.rb
    path of file: ./repos/annict/app/lib/annict
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Annict
  class Logger
    ACTIONS = {
      GRAPHQL_API_REQUEST: "graphql_api.request",
      REST_API_REQUEST: "rest_api.request"
    }.freeze

    attr_writer :page_category

    def initialize(request, user)
      @request = request
      @user = user
    end

    def log(type, action, metadata =
    
    def build_metadata(action, metadata = {})
      metadata.merge(
        action: ACTIONS.fetch(action),
        page_category: @page_category,
        request: {
          path: @request.path,
          params: @request.params.slice(:work_id, :episode_id)
        },
        viewer: {
          type: @user.present? ? "user" : "guest"
        },
        user: {
          id: @user&.id,
          username: @user&.username
        }
      )
    end