Skip to content

Commit

Permalink
Merge pull request #49 from MozillaSocial/patch-v4.2.0-mozilla-social-30
Browse files Browse the repository at this point in the history
Revert #36 - "feat(glean):adding proper glean formatted JSON logs..."
  • Loading branch information
toufali authored Oct 31, 2023
2 parents 91d6945 + 87ace54 commit e4f58f0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 312 deletions.
111 changes: 0 additions & 111 deletions .glean/metrics.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
# add instaniated Glean Logger
include Glean
GLEAN = Glean::GleanEventsLogger.new(
app_id: 'moso-mastodon',
app_display_version: Mastodon::Version.to_s,
app_channel: ENV.fetch('RAILS_ENV', 'development'),
logger_options: $stdout
)
# add glean server side logging for controller calls
around_action :emit_glean

# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
Expand Down Expand Up @@ -185,38 +174,4 @@ def respond_with_error(code)
def set_cache_control_defaults
response.cache_control.replace(private: true, no_store: true)
end

private

def emit_glean
yield
ensure
event = {
'user_id' => current_user&.id,
'path' => request.fullpath,
'controller' => controller_name,
'method' => request.method,
'status_code' => response.status,
}
username = current_user&.account&.username
domain = current_user&.account&.domain

handle = nil
unless username.nil?
domain = 'mozilla.social' if domain.nil?
handle = "#{username}@#{domain}"
end

GLEAN.backend_object_update.record(
user_agent: request.user_agent,
ip_address: request.ip,
object_type: 'api_request',
object_state: event.to_json,
identifiers_adjust_device_id: nil,
identifiers_fxa_account_id: nil,
identifiers_mastodon_account_handle: handle,
identifiers_mastodon_account_id: current_user&.account&.id,
identifiers_user_agent: request.user_agent
)
end
end
156 changes: 0 additions & 156 deletions app/lib/glean.rb

This file was deleted.

0 comments on commit e4f58f0

Please sign in to comment.