Commit e86fda2c authored by James Lopez's avatar James Lopez

Merge branch '233615-version-app-url-should-be-environment-specific' into 'master'

Version-app url should be environment specific

Closes #233615

See merge request gitlab-org/gitlab!38883
parents 28f4989d f48b05ed
# frozen_string_literal: true
class SubmitUsagePingService
URL = 'https://version.gitlab.com/usage_data'
PRODUCTION_URL = 'https://version.gitlab.com/usage_data'
STAGING_URL = 'https://gitlab-services-version-gitlab-com-staging.gs-staging.gitlab.org/usage_data'
METRICS = %w[leader_issues instance_issues percentage_issues leader_notes instance_notes
percentage_notes leader_milestones instance_milestones percentage_milestones
......@@ -23,7 +24,7 @@ class SubmitUsagePingService
raise SubmissionError.new('Usage data is blank') if payload.blank?
response = Gitlab::HTTP.post(
URL,
url,
body: payload,
allow_local_requests: true,
headers: { 'Content-type' => 'application/json' }
......@@ -45,4 +46,13 @@ class SubmitUsagePingService
metrics.slice(*METRICS)
)
end
# See https://gitlab.com/gitlab-org/gitlab/-/issues/233615 for details
def url
if Rails.env.production?
PRODUCTION_URL
else
STAGING_URL
end
end
end
......@@ -164,7 +164,7 @@ RSpec.describe SubmitUsagePingService do
end
def stub_response(body:, status: 201)
stub_full_request('https://version.gitlab.com/usage_data', method: :post)
stub_full_request(SubmitUsagePingService::STAGING_URL, method: :post)
.to_return(
headers: { 'Content-Type' => 'application/json' },
body: body.to_json,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment