Commit 20f656cc authored by Luke Bennett's avatar Luke Bennett

Add instance level analytics

Adds instance-level cycle analytics and productivity analytics
under a feature flag.
parent 31dd8f64
......@@ -110,6 +110,12 @@ Rails.application.routes.draw do
draw :jira_connect
end
Gitlab.ee do
constraints(::Constraints::FeatureConstrainer.new(:analytics)) do
draw :analytics
end
end
if ENV['GITLAB_CHAOS_SECRET'] || Rails.env.development?
resource :chaos, only: [] do
get :leakmem
......@@ -119,6 +125,13 @@ Rails.application.routes.draw do
get :kill
end
end
if ENV['GITLAB_ENABLE_CHAOS_ENDPOINTS']
get '/chaos/leakmem' => 'chaos#leakmem'
get '/chaos/cpuspin' => 'chaos#cpuspin'
get '/chaos/sleep' => 'chaos#sleep'
get '/chaos/kill' => 'chaos#kill'
end
end
concern :clusterable do
......
# frozen_string_literal: true
class Analytics::ApplicationController < ApplicationController
layout 'analytics'
end
# frozen_string_literal: true
class Analytics::CycleAnalyticsController < Analytics::ApplicationController
end
# frozen_string_literal: true
class Analytics::ProductivityAnalyticsController < Analytics::ApplicationController
end
- page_title _('Analytics')
- header_title _('Analytics'), analytics_root_path
- nav 'analytics'
- @left_sidebar = true
= render template: 'layouts/application'
.nav-sidebar{ class: ("sidebar-collapsed-desktop" if collapsed_sidebar?) }
.nav-sidebar-inner-scroll
.context-header
= link_to analytics_root_path, title: _('Analytics') do
.avatar-container.s40.settings-avatar
= sprite_icon('log', size: 24)
.sidebar-context-title= _('Analytics')
%ul.sidebar-top-level-items
= nav_link(controller: :productivity_analytics) do
= link_to analytics_productivity_analytics_path, class: 'qa-sidebar-productivity-analytics' do
.nav-icon-container
= sprite_icon('comment')
%span.nav-item-name
= _('Productivity Analytics')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: :productivity_analytics, html_options: { class: "fly-out-top-item qa-sidebar-productivity-analytics-fly-out" } ) do
= link_to analytics_productivity_analytics_path do
%strong.fly-out-top-item-name
= _('Productivity Analytics')
= nav_link(controller: :cycle_analytics) do
= link_to analytics_cycle_analytics_path, class: 'qa-sidebar-cycle-analytics' do
.nav-icon-container
= sprite_icon('repeat')
%span.nav-item-name
= _('Cycle Analytics')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: :cycle_analytics, html_options: { class: "fly-out-top-item qa-sidebar-cycle-analytics-fly-out" } ) do
= link_to analytics_cycle_analytics_path do
%strong.fly-out-top-item-name
= _('Cycle Analytics')
= render 'shared/sidebar_toggle_button'
---
title: Add instance level analytics
merge_request: 14173
author:
type: added
# frozen_string_literal: true
namespace :analytics do
root to: redirect('-/analytics/productivity_analytics')
resource :productivity_analytics, only: :show
resource :cycle_analytics, only: :show
end
# frozen_string_literal: true
require 'spec_helper'
describe Analytics::CycleAnalyticsController do
let(:user) { create(:user) }
before do
sign_in(user)
end
describe 'GET show' do
it 'renders `show` template' do
get :show
expect(response).to render_template :show
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Analytics::ProductivityAnalyticsController do
let(:user) { create(:user) }
before do
sign_in(user)
end
describe 'GET show' do
it 'renders `show` template' do
get :show
expect(response).to render_template :show
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'Analytics' do
include RSpec::Rails::RequestExampleGroup
include Warden::Test::Helpers
let(:user) { create(:user) }
it "redirects to productivity_analytics" do
expect(get('/-/analytics')).to redirect_to('/-/analytics/productivity_analytics')
end
context ':analytics feature is disabled' do
before do
stub_feature_flags(analytics: false)
end
it 'redirects to sign_in if user is not authenticated' do
expect(get('/-/analytics')).to redirect_to('/users/sign_in')
end
it 'returns 404 if user is authenticated' do
login_as(user)
expect(get('/-/analytics')).to eq(404)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'layouts/nav/sidebar/_analytics' do
it_behaves_like 'has nav sidebar'
context 'top-level items' do
before do
render
end
it 'has `Analytics` link' do
expect(rendered).to have_content('Analytics')
expect(rendered).to include(analytics_root_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#log">/)
end
it 'has `Productivity Analytics` link' do
expect(rendered).to have_content('Productivity Analytics')
expect(rendered).to include(analytics_productivity_analytics_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#comment">/)
end
it 'has `Cycle Analytics` link' do
expect(rendered).to have_content('Cycle Analytics')
expect(rendered).to include(analytics_cycle_analytics_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#repeat">/)
end
end
end
......@@ -10308,6 +10308,9 @@ msgstr ""
msgid "Proceed"
msgstr ""
msgid "Productivity Analytics"
msgstr ""
msgid "Profile"
msgstr ""
......
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