Commit 891c9a11 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'add-snowplow-iglu-registry-application-setting' into 'master'

Add ApplicationSetting snowplow_iglu_registry_url

See merge request gitlab-org/gitlab!18449
parents e97c40bc fd5a0ae7
...@@ -290,6 +290,7 @@ module ApplicationSettingsHelper ...@@ -290,6 +290,7 @@ module ApplicationSettingsHelper
:snowplow_cookie_domain, :snowplow_cookie_domain,
:snowplow_enabled, :snowplow_enabled,
:snowplow_site_id, :snowplow_site_id,
:snowplow_iglu_registry_url,
:push_event_hooks_limit, :push_event_hooks_limit,
:push_event_activities_limit, :push_event_activities_limit,
:custom_http_clone_url_root, :custom_http_clone_url_root,
......
...@@ -104,6 +104,11 @@ class ApplicationSetting < ApplicationRecord ...@@ -104,6 +104,11 @@ class ApplicationSetting < ApplicationRecord
hostname: true, hostname: true,
if: :snowplow_enabled if: :snowplow_enabled
validates :snowplow_iglu_registry_url,
addressable_url: true,
allow_blank: true,
if: :snowplow_enabled
validates :pendo_url, validates :pendo_url,
presence: true, presence: true,
public_url: true, public_url: true,
......
...@@ -129,6 +129,7 @@ module ApplicationSettingImplementation ...@@ -129,6 +129,7 @@ module ApplicationSettingImplementation
snowplow_cookie_domain: nil, snowplow_cookie_domain: nil,
snowplow_enabled: false, snowplow_enabled: false,
snowplow_site_id: nil, snowplow_site_id: nil,
snowplow_iglu_registry_url: nil,
custom_http_clone_url_root: nil, custom_http_clone_url_root: nil,
pendo_enabled: false, pendo_enabled: false,
pendo_url: nil pendo_url: nil
......
...@@ -26,5 +26,8 @@ ...@@ -26,5 +26,8 @@
.form-group .form-group
= f.label :snowplow_cookie_domain, _('Cookie domain'), class: 'label-light' = f.label :snowplow_cookie_domain, _('Cookie domain'), class: 'label-light'
= f.text_field :snowplow_cookie_domain, class: 'form-control' = f.text_field :snowplow_cookie_domain, class: 'form-control'
.form-group
= f.label :snowplow_iglu_registry_url, _('Iglu registry URL (optional)'), class: 'label-light'
= f.text_field :snowplow_iglu_registry_url, class: 'form-control'
= f.submit _('Save changes'), class: 'btn btn-success' = f.submit _('Save changes'), class: 'btn btn-success'
---
title: Add ApplicationSetting for snowplow_iglu_registry_url
merge_request: 18449
author:
type: added
# frozen_string_literal: true
class AddSnowplowIgluRegistryUrlToApplicationSettings < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :application_settings, :snowplow_iglu_registry_url, :string, limit: 255
end
end
...@@ -338,6 +338,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do ...@@ -338,6 +338,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_124116) do
t.boolean "throttle_incident_management_notification_enabled", default: false, null: false t.boolean "throttle_incident_management_notification_enabled", default: false, null: false
t.integer "throttle_incident_management_notification_period_in_seconds", default: 3600 t.integer "throttle_incident_management_notification_period_in_seconds", default: 3600
t.integer "throttle_incident_management_notification_per_period", default: 3600 t.integer "throttle_incident_management_notification_per_period", default: 3600
t.string "snowplow_iglu_registry_url", limit: 255
t.integer "push_event_hooks_limit", default: 3, null: false t.integer "push_event_hooks_limit", default: 3, null: false
t.integer "push_event_activities_limit", default: 3, null: false t.integer "push_event_activities_limit", default: 3, null: false
t.string "custom_http_clone_url_root", limit: 511 t.string "custom_http_clone_url_root", limit: 511
......
...@@ -316,6 +316,7 @@ are listed in the descriptions of the relevant settings. ...@@ -316,6 +316,7 @@ are listed in the descriptions of the relevant settings.
| `snowplow_cookie_domain` | string | no | The Snowplow cookie domain. (e.g. `.gitlab.com`) | | `snowplow_cookie_domain` | string | no | The Snowplow cookie domain. (e.g. `.gitlab.com`) |
| `snowplow_enabled` | boolean | no | Enable snowplow tracking. | | `snowplow_enabled` | boolean | no | Enable snowplow tracking. |
| `snowplow_site_id` | string | no | The Snowplow site name / application id. (e.g. `gitlab`) | | `snowplow_site_id` | string | no | The Snowplow site name / application id. (e.g. `gitlab`) |
| `snowplow_iglu_registry_url` | string | no | The Snowplow base Iglu Schema Registry URL to use for custom context and self describing events'|
| `pendo_url` | string | required by: `pendo_enabled` | The Pendo endpoint url with js snippet. (e.g. `https://cdn.pendo.io/agent/static/your-api-key/pendo.js`) | | `pendo_url` | string | required by: `pendo_enabled` | The Pendo endpoint url with js snippet. (e.g. `https://cdn.pendo.io/agent/static/your-api-key/pendo.js`) |
| `pendo_enabled` | boolean | no | Enable pendo tracking. | | `pendo_enabled` | boolean | no | Enable pendo tracking. |
| `terminal_max_session_time` | integer | no | Maximum time for web terminal websocket connection (in seconds). Set to `0` for unlimited time. | | `terminal_max_session_time` | integer | no | Maximum time for web terminal websocket connection (in seconds). Set to `0` for unlimited time. |
......
...@@ -135,6 +135,7 @@ module API ...@@ -135,6 +135,7 @@ module API
optional :local_markdown_version, type: Integer, desc: 'Local markdown version, increase this value when any cached markdown should be invalidated' optional :local_markdown_version, type: Integer, desc: 'Local markdown version, increase this value when any cached markdown should be invalidated'
optional :allow_local_requests_from_hooks_and_services, type: Boolean, desc: 'Deprecated: Use :allow_local_requests_from_web_hooks_and_services instead. Allow requests to the local network from hooks and services.' # support legacy names, can be removed in v5 optional :allow_local_requests_from_hooks_and_services, type: Boolean, desc: 'Deprecated: Use :allow_local_requests_from_web_hooks_and_services instead. Allow requests to the local network from hooks and services.' # support legacy names, can be removed in v5
optional :snowplow_enabled, type: Grape::API::Boolean, desc: 'Enable Snowplow tracking' optional :snowplow_enabled, type: Grape::API::Boolean, desc: 'Enable Snowplow tracking'
optional :snowplow_iglu_registry_url, type: String, desc: 'The Snowplow base Iglu Schema Registry URL to use for custom context and self describing events'
given snowplow_enabled: ->(val) { val } do given snowplow_enabled: ->(val) { val } do
requires :snowplow_collector_hostname, type: String, desc: 'The Snowplow collector hostname' requires :snowplow_collector_hostname, type: String, desc: 'The Snowplow collector hostname'
optional :snowplow_cookie_domain, type: String, desc: 'The Snowplow cookie domain' optional :snowplow_cookie_domain, type: String, desc: 'The Snowplow cookie domain'
......
...@@ -47,7 +47,8 @@ module Gitlab ...@@ -47,7 +47,8 @@ module Gitlab
cookie_domain: Gitlab::CurrentSettings.snowplow_cookie_domain, cookie_domain: Gitlab::CurrentSettings.snowplow_cookie_domain,
app_id: Gitlab::CurrentSettings.snowplow_site_id, app_id: Gitlab::CurrentSettings.snowplow_site_id,
form_tracking: additional_features, form_tracking: additional_features,
link_click_tracking: additional_features link_click_tracking: additional_features,
iglu_registry_url: Gitlab::CurrentSettings.snowplow_iglu_registry_url
}.transform_keys! { |key| key.to_s.camelize(:lower).to_sym } }.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end end
......
...@@ -8848,6 +8848,9 @@ msgstr "" ...@@ -8848,6 +8848,9 @@ msgstr ""
msgid "If your HTTP repository is not publicly accessible, add your credentials." msgid "If your HTTP repository is not publicly accessible, add your credentials."
msgstr "" msgstr ""
msgid "Iglu registry URL (optional)"
msgstr ""
msgid "ImageDiffViewer|2-up" msgid "ImageDiffViewer|2-up"
msgstr "" msgstr ""
......
...@@ -9,6 +9,7 @@ describe Gitlab::Tracking do ...@@ -9,6 +9,7 @@ describe Gitlab::Tracking do
stub_application_setting(snowplow_collector_hostname: 'gitfoo.com') stub_application_setting(snowplow_collector_hostname: 'gitfoo.com')
stub_application_setting(snowplow_cookie_domain: '.gitfoo.com') stub_application_setting(snowplow_cookie_domain: '.gitfoo.com')
stub_application_setting(snowplow_site_id: '_abc123_') stub_application_setting(snowplow_site_id: '_abc123_')
stub_application_setting(snowplow_iglu_registry_url: 'https://example.org')
end end
describe '.snowplow_options' do describe '.snowplow_options' do
...@@ -19,7 +20,8 @@ describe Gitlab::Tracking do ...@@ -19,7 +20,8 @@ describe Gitlab::Tracking do
cookieDomain: '.gitfoo.com', cookieDomain: '.gitfoo.com',
appId: '_abc123_', appId: '_abc123_',
formTracking: true, formTracking: true,
linkClickTracking: true linkClickTracking: true,
igluRegistryUrl: 'https://example.org'
} }
expect(subject.snowplow_options(nil)).to match(expected_fields) expect(subject.snowplow_options(nil)).to match(expected_fields)
......
...@@ -72,10 +72,14 @@ describe ApplicationSetting do ...@@ -72,10 +72,14 @@ describe ApplicationSetting do
it { is_expected.not_to allow_value(nil).for(:snowplow_collector_hostname) } it { is_expected.not_to allow_value(nil).for(:snowplow_collector_hostname) }
it { is_expected.to allow_value("snowplow.gitlab.com").for(:snowplow_collector_hostname) } it { is_expected.to allow_value("snowplow.gitlab.com").for(:snowplow_collector_hostname) }
it { is_expected.not_to allow_value('/example').for(:snowplow_collector_hostname) } it { is_expected.not_to allow_value('/example').for(:snowplow_collector_hostname) }
it { is_expected.to allow_value('https://example.org').for(:snowplow_iglu_registry_url) }
it { is_expected.not_to allow_value('not-a-url').for(:snowplow_iglu_registry_url) }
it { is_expected.to allow_value(nil).for(:snowplow_iglu_registry_url) }
end end
context 'when snowplow is not enabled' do context 'when snowplow is not enabled' do
it { is_expected.to allow_value(nil).for(:snowplow_collector_hostname) } it { is_expected.to allow_value(nil).for(:snowplow_collector_hostname) }
it { is_expected.to allow_value(nil).for(:snowplow_iglu_registry_url) }
end end
context 'when pendo is enabled' do context 'when pendo is enabled' do
......
...@@ -178,7 +178,8 @@ describe API::Settings, 'Settings' do ...@@ -178,7 +178,8 @@ describe API::Settings, 'Settings' do
snowplow_collector_hostname: "snowplow.example.com", snowplow_collector_hostname: "snowplow.example.com",
snowplow_cookie_domain: ".example.com", snowplow_cookie_domain: ".example.com",
snowplow_enabled: true, snowplow_enabled: true,
snowplow_site_id: "site_id" snowplow_site_id: "site_id",
snowplow_iglu_registry_url: 'https://example.com'
} }
end end
......
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