Commit 31a384b4 authored by Thong Kuah's avatar Thong Kuah

Merge branch '13201-rename-snowplow_collector_uri-to-snowplow_collector_hostname' into 'master'

Rename snowplow_collector_uri to snowplow_collector_hostname

Closes #13201

See merge request gitlab-org/gitlab-ee!14963
parents 8507897f 842e0f06
# frozen_string_literal: true
class RenameApplicationSettingsSnowplowCollectorUriColumn < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
rename_column_concurrently :application_settings, :snowplow_collector_uri, :snowplow_collector_hostname
end
def down
cleanup_concurrent_column_rename :application_settings, :snowplow_collector_hostname, :snowplow_collector_uri
end
end
# frozen_string_literal: true
class CleanupApplicationSettingsSnowplowCollectorUriRename < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
cleanup_concurrent_column_rename :application_settings, :snowplow_collector_uri, :snowplow_collector_hostname
end
def down
rename_column_concurrently :application_settings, :snowplow_collector_hostname, :snowplow_collector_uri
end
end
......@@ -195,7 +195,7 @@ ActiveRecord::Schema.define(version: 2019_08_02_235445) do
t.boolean "pseudonymizer_enabled", default: false, null: false
t.boolean "hide_third_party_offers", default: false, null: false
t.boolean "snowplow_enabled", default: false, null: false
t.string "snowplow_collector_uri"
t.string "snowplow_collector_hostname"
t.string "snowplow_site_id"
t.string "snowplow_cookie_domain"
t.boolean "instance_statistics_visibility_private", default: false, null: false
......
......@@ -45,7 +45,7 @@ module EE
:slack_app_id,
:slack_app_secret,
:slack_app_verification_token,
:snowplow_collector_uri,
:snowplow_collector_hostname,
:snowplow_cookie_domain,
:snowplow_enabled,
:snowplow_site_id
......
......@@ -59,8 +59,9 @@ module EE
allow_blank: true,
length: { maximum: EMAIL_ADDITIONAL_TEXT_CHARACTER_LIMIT }
validates :snowplow_collector_uri,
validates :snowplow_collector_hostname,
presence: true,
hostname: true,
if: :snowplow_enabled
validates :geo_node_allowed_ips, length: { maximum: 255 }, presence: true
......@@ -94,7 +95,7 @@ module EE
slack_app_id: nil,
slack_app_secret: nil,
slack_app_verification_token: nil,
snowplow_collector_uri: nil,
snowplow_collector_hostname: nil,
snowplow_cookie_domain: nil,
snowplow_enabled: false,
snowplow_site_id: nil,
......
......@@ -18,8 +18,8 @@
= f.label :snowplow_enabled, class: 'form-check-label' do
Enable Snowplow
.form-group
= f.label :snowplow_collector_uri, 'Collector URI', class: 'label-light'
= f.text_field :snowplow_collector_uri, class: 'form-control', placeholder: 'snowplow.example.com'
= f.label :snowplow_collector_hostname, 'Collector Hostname', class: 'label-light'
= f.text_field :snowplow_collector_hostname, class: 'form-control', placeholder: 'snowplow.example.com'
.form-group
= f.label :snowplow_site_id, class: 'label-light' do
Site ID
......
......@@ -7,7 +7,7 @@
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","#{asset_url('snowplow/sp.js')}","snowplow"));
window.snowplow('newTracker', '#{Gitlab::SnowplowTracker::NAMESPACE}', '#{Gitlab::CurrentSettings.snowplow_collector_uri}', {
window.snowplow('newTracker', '#{Gitlab::SnowplowTracker::NAMESPACE}', '#{Gitlab::CurrentSettings.snowplow_collector_hostname}', {
appId: '#{Gitlab::CurrentSettings.snowplow_site_id}',
cookieDomain: '#{Gitlab::CurrentSettings.snowplow_cookie_domain}',
userFingerprint: false,
......
---
title: Rename snowplow_collector_uri to snowplow_collector_hostname
merge_request: 14963
author:
type: changed
......@@ -38,7 +38,7 @@ module EE
optional :snowplow_enabled, type: Grape::API::Boolean, desc: 'Enable Snowplow'
given snowplow_enabled: ->(val) { val } do
requires :snowplow_collector_uri, type: String, desc: 'Snowplow Collector URI'
requires :snowplow_collector_hostname, type: String, desc: 'Snowplow Collector Hostname'
optional :snowplow_cookie_domain, type: String, desc: 'Snowplow cookie domain'
optional :snowplow_site_id, type: String, desc: 'Snowplow Site/Application ID'
end
......
......@@ -24,7 +24,7 @@ module Gitlab
end
def emitter
::SnowplowTracker::Emitter.new(Gitlab::CurrentSettings.snowplow_collector_uri)
::SnowplowTracker::Emitter.new(Gitlab::CurrentSettings.snowplow_collector_hostname)
end
def enabled?
......
......@@ -23,7 +23,7 @@ describe Gitlab::SnowplowTracker do
before do
stub_application_setting(snowplow_enabled: true)
stub_application_setting(snowplow_site_id: 'awesome gitlab')
stub_application_setting(snowplow_collector_uri: 'url.com')
stub_application_setting(snowplow_collector_hostname: 'url.com')
end
it 'tracks the event' do
......
......@@ -18,7 +18,7 @@ describe API::Settings, 'EE Settings' do
put api("/application/settings", admin),
params: {
help_text: 'Help text',
snowplow_collector_uri: 'https://snowplow.example.com',
snowplow_collector_hostname: 'snowplow.example.com',
snowplow_cookie_domain: '.example.com',
snowplow_enabled: true,
snowplow_site_id: 'site_id',
......@@ -27,7 +27,7 @@ describe API::Settings, 'EE Settings' do
expect(response).to have_gitlab_http_status(200)
expect(json_response['help_text']).to eq('Help text')
expect(json_response['snowplow_collector_uri']).to eq('https://snowplow.example.com')
expect(json_response['snowplow_collector_hostname']).to eq('snowplow.example.com')
expect(json_response['snowplow_cookie_domain']).to eq('.example.com')
expect(json_response['snowplow_enabled']).to be_truthy
expect(json_response['snowplow_site_id']).to eq('site_id')
......@@ -156,12 +156,12 @@ describe API::Settings, 'EE Settings' do
it_behaves_like 'settings for licensed features'
end
context "missing snowplow_collector_uri value when snowplow_enabled is true" do
context "missing snowplow_collector_hostname value when snowplow_enabled is true" do
it "returns a blank parameter error message" do
put api("/application/settings", admin), params: { snowplow_enabled: true }
expect(response).to have_gitlab_http_status(400)
expect(json_response['error']).to eq('snowplow_collector_uri is missing')
expect(json_response['error']).to eq('snowplow_collector_hostname is missing')
end
end
end
......@@ -11,7 +11,7 @@ describe 'layouts/_head' do
before do
allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
allow(Gitlab::CurrentSettings).to receive(:snowplow_enabled?).and_return(true)
allow(Gitlab::CurrentSettings).to receive(:snowplow_collector_uri).and_return('www.snow.plow')
allow(Gitlab::CurrentSettings).to receive(:snowplow_collector_hostname).and_return('www.snow.plow')
end
it 'add a snowplow script tag with asset host' do
......
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