Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spider to influxdb-rails webui request tags #17041

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
11 changes: 10 additions & 1 deletion src/api/app/controllers/webui/webui_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
before_action :setup_view_path
before_action :check_user
before_action :check_anonymous
before_action :check_spider
before_action :set_influxdb_data
Comment on lines 20 to 22
Copy link
Member

@eduardoj eduardoj Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
before_action :check_anonymous
before_action :check_spider
before_action :set_influxdb_data
before_action :check_spider
before_action :set_influxdb_data
before_action :check_anonymous

Otherwise @spider_bot won't be set, and therefore won't be tracked, for pages requiring authentication...

before_action :require_configuration
before_action :current_announcement, unless: -> { request.xhr? }
Expand Down Expand Up @@ -96,7 +97,6 @@
end

def check_user
@spider_bot = request.bot? && Rails.env.production?
User.session = nil # reset old users hanging around

unless WebuiControllerService::UserChecker.new(http_request: request).call
Expand Down Expand Up @@ -274,10 +274,19 @@
ret
end

def check_spider
@spider_bot = if Rails.env.production?
request.bot?

Check warning on line 279 in src/api/app/controllers/webui/webui_controller.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/controllers/webui/webui_controller.rb#L279

Added line #L279 was not covered by tests
else
false
end
end

def set_influxdb_data
InfluxDB::Rails.current.tags = {
beta: User.possibly_nobody.in_beta?,
anonymous: !User.session,
spider: @spider_bot,
interface: :webui
}
end
Expand Down