diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 643993d035e..152d7baad49 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -133,6 +133,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController :signup_enabled, :sentry_dsn, :sentry_enabled, + :clientside_sentry_dsn, + :clientside_sentry_enabled, :send_user_confirmation_email, :shared_runners_enabled, :shared_runners_text, diff --git a/app/helpers/sentry_helper.rb b/app/helpers/sentry_helper.rb index 4b07f71bcea..8e80f83ae61 100644 --- a/app/helpers/sentry_helper.rb +++ b/app/helpers/sentry_helper.rb @@ -7,13 +7,9 @@ module SentryHelper Gitlab::Sentry.context(current_user) end - def sentry_dsn_public - sentry_dsn = ApplicationSetting.current.sentry_dsn - - return unless sentry_dsn - - uri = URI.parse(sentry_dsn) - uri.password = nil - uri.to_s + def clientside_sentry_enabled? + current_application_settings.clientside_sentry_enabled end + + delegate :clientside_sentry_dsn, to: :current_application_settings end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index dd1a6922968..4a1e7d6e59e 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -60,6 +60,10 @@ class ApplicationSetting < ActiveRecord::Base presence: true, if: :sentry_enabled + validates :clientside_sentry_dsn, + presence: true, + if: :clientside_sentry_enabled + validates :akismet_api_key, presence: true, if: :akismet_enabled diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 0dc1103eece..5cc99e0833f 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -411,6 +411,21 @@ .col-sm-10 = f.text_field :sentry_dsn, class: 'form-control' + .form-group + .col-sm-offset-2.col-sm-10 + .checkbox + = f.label :clientside_sentry_enabled do + = f.check_box :clientside_sentry_enabled + Enable Clientside Sentry + .help-block + Sentry can also be used for reporting and logging clientside exceptions. + %a{ href: 'https://sentry.io/for/javascript/', target: '_blank', rel: 'noopener noreferrer' } https://sentry.io/for/javascript/ + + .form-group + = f.label :sentry_dsn, 'Sentry DSN', class: 'control-label col-sm-2' + .col-sm-10 + = f.text_field :sentry_dsn, class: 'form-control' + %fieldset %legend Repository Storage .form-group diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 8aef5cbdc04..1579afa6461 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -33,7 +33,7 @@ = webpack_bundle_tag "runtime" = webpack_bundle_tag "common" = webpack_bundle_tag "main" - = webpack_bundle_tag "raven" if sentry_enabled? + = webpack_bundle_tag "raven" if clientside_sentry_enabled? - if content_for?(:page_specific_javascripts) = yield :page_specific_javascripts diff --git a/config/application.rb b/config/application.rb index f2ecc4ce77c..0ab8a24a5df 100644 --- a/config/application.rb +++ b/config/application.rb @@ -55,6 +55,7 @@ module Gitlab # - Webhook URLs (:hook) # - GitLab-shell secret token (:secret_token) # - Sentry DSN (:sentry_dsn) + # - Clientside Sentry DSN (:clientside_sentry_dsn) # - Deploy keys (:key) config.filter_parameters += %i( authentication_token @@ -71,6 +72,7 @@ module Gitlab runners_token secret_token sentry_dsn + clientside_sentry_dsn variables ) diff --git a/db/schema.rb b/db/schema.rb index ff00951d5f6..592f1c253ea 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170424142900) do +ActiveRecord::Schema.define(version: 20170426175636) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -63,7 +63,6 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.boolean "shared_runners_enabled", default: true, null: false t.integer "max_artifacts_size", default: 100, null: false t.string "runners_registration_token" - t.integer "max_pages_size", default: 100, null: false t.boolean "require_two_factor_authentication", default: false t.integer "two_factor_grace_period", default: 48 t.boolean "metrics_enabled", default: false @@ -112,15 +111,16 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" + t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false t.string "default_artifacts_expire_in", default: "0", null: false t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false - t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" + t.integer "cached_markdown_version" end create_table "audit_events", force: :cascade do |t| @@ -731,8 +731,8 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.integer "visibility_level", default: 20, null: false t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" - t.text "description_html" t.boolean "lfs_enabled" + t.text "description_html" t.integer "parent_id" t.boolean "require_two_factor_authentication", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false @@ -965,9 +965,9 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" - t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" + t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.integer "cached_markdown_version" end @@ -1070,7 +1070,6 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.string "line_code" t.string "note_type" t.text "position" - t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree @@ -1320,10 +1319,10 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" - t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false + t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree diff --git a/lib/api/settings.rb b/lib/api/settings.rb index d01c7f2703b..82f513c984e 100644 --- a/lib/api/settings.rb +++ b/lib/api/settings.rb @@ -58,6 +58,7 @@ module API :restricted_visibility_levels, :send_user_confirmation_email, :sentry_enabled, + :clientside_sentry_enabled, :session_expire_delay, :shared_runners_enabled, :sidekiq_throttling_enabled, @@ -138,6 +139,10 @@ module API given sentry_enabled: ->(val) { val } do requires :sentry_dsn, type: String, desc: 'Sentry Data Source Name' end + optional :clientside_sentry_enabled, type: Boolean, desc: 'Sentry can also be used for reporting and logging clientside exceptions. https://sentry.io/for/javascript/' + given clientside_sentry_enabled: ->(val) { val } do + requires :clientside_sentry_dsn, type: String, desc: 'Clientside Sentry Data Source Name' + end optional :repository_storage, type: String, desc: 'Storage paths for new projects' optional :repository_checks_enabled, type: Boolean, desc: "GitLab will periodically run 'git fsck' in all project and wiki repositories to look for silent disk corruption issues." optional :koding_enabled, type: Boolean, desc: 'Enable Koding' diff --git a/lib/api/v3/settings.rb b/lib/api/v3/settings.rb index 748d6b97d4f..67a85e13d8c 100644 --- a/lib/api/v3/settings.rb +++ b/lib/api/v3/settings.rb @@ -89,6 +89,10 @@ module API given sentry_enabled: ->(val) { val } do requires :sentry_dsn, type: String, desc: 'Sentry Data Source Name' end + optional :clientside_sentry_enabled, type: Boolean, desc: 'Sentry can also be used for reporting and logging clientside exceptions. https://sentry.io/for/javascript/' + given clientside_sentry_enabled: ->(val) { val } do + requires :clientside_sentry_dsn, type: String, desc: 'Clientside Sentry Data Source Name' + end optional :repository_storage, type: String, desc: 'Storage paths for new projects' optional :repository_checks_enabled, type: Boolean, desc: "GitLab will periodically run 'git fsck' in all project and wiki repositories to look for silent disk corruption issues." optional :koding_enabled, type: Boolean, desc: 'Enable Koding' @@ -120,7 +124,7 @@ module API :home_page_url, :after_sign_out_path, :sign_in_text, :help_page_text, :shared_runners_enabled, :max_artifacts_size, :max_pages_size, :container_registry_token_expire_delay, :metrics_enabled, :sidekiq_throttling_enabled, :recaptcha_enabled, - :akismet_enabled, :admin_notification_email, :sentry_enabled, + :akismet_enabled, :admin_notification_email, :sentry_enabled, :clientside_sentry_enabled, :repository_storage, :repository_checks_enabled, :koding_enabled, :plantuml_enabled, :version_check_enabled, :email_author_in_body, :html_emails_enabled, :housekeeping_enabled, :terminal_max_session_time diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb index 4de504e9bf9..a8a2715e848 100644 --- a/lib/gitlab/gon_helper.rb +++ b/lib/gitlab/gon_helper.rb @@ -12,7 +12,7 @@ module Gitlab gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class gon.katex_css_url = ActionController::Base.helpers.asset_path('katex.css') gon.katex_js_url = ActionController::Base.helpers.asset_path('katex.js') - gon.sentry_dsn = sentry_dsn_public if sentry_enabled? + gon.sentry_dsn = Gitlab.config.clientside_sentry_dsn if clientside_sentry_enabled? gon.gitlab_url = Gitlab.config.gitlab.url gon.is_production = Rails.env.production?