Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions plugin.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

# name: quipper-monitoring
# name: discourse-quipper-monitoring
# about: Enable site monitoring for sentry and newrelic
# version: 0.0.1
# version: 0.0.2
# authors: Discourse
# required_version: 3.0

Expand Down Expand Up @@ -35,12 +35,32 @@
end

class ::ApplicationController
prepend_before_action :check_headers

def rescue_with_handler(exception)
handle_exception(exception)
super
end

def check_headers
if request.headers['ORIGINAL_FULLPATH'].include?('/l/latest') && request.headers["User-Agent"] == "Quipper/Collab-Discourse 2.0"
sent_headers = request.headers.env.reject { |key| key.to_s.include?('.') }
sentry_message("RequestFromCollabDiscourse", sent_headers.inspect)

if request.headers["Api-Username"].present? && request.headers["Api-Key"].blank?
sentry_message("EmptyApiKey", sent_headers.inspect)
end
end
end

private

def sentry_message(ctx, msg)
if defined?(Sentry)
Sentry.set_tags(context: ctx)
Sentry.capture_message(msg)
end
end

def handle_exception(exception)
fingerprint = [
Expand Down