Commit d321d5d3 authored by Robert Speicher's avatar Robert Speicher

Merge branch '218161-wiki-page-views-usage-ping' into 'master'

Track wiki page views in usage data

See merge request gitlab-org/gitlab!38784
parents 9e6d4635 bc90ba78
......@@ -67,6 +67,8 @@ module WikiActions
@ref = params[:version_id]
@path = page.path
Gitlab::UsageDataCounters::WikiPageCounter.count(:view)
render 'shared/wikis/show'
elsif file_blob
send_blob(wiki.repository, file_blob)
......
---
title: Track wiki page views in usage data
merge_request: 38784
author:
type: changed
......@@ -9,7 +9,7 @@ Please check the ~telemetry [guide](https://docs.gitlab.com/ee/development/telem
MSG
UPDATE_METRICS_DEFINITIONS_MESSAGE = <<~MSG
When adding, changing, or updating metrics, please update the [Usage Statistics definition table](https://docs.gitlab.com/ee/development/telemetry/usage_ping.html#usage-statistics-definitions).
When adding, changing, or updating metrics, please update the [Event dictionary Usage Ping table](https://docs.gitlab.com/ee/development/telemetry/event_dictionary.html#usage-ping).
MSG
......
......@@ -269,9 +269,10 @@ An event dictionary is a single source of truth that outlines what events and pr
| `merge_requests` | `counts` | | | | |
| `merge_requests_users` | `counts` | | | | |
| `notes` | `counts` | | | | |
| `wiki_pages_create` | `counts` | | | | |
| `wiki_pages_update` | `counts` | | | | |
| `wiki_pages_delete` | `counts` | | | | |
| `wiki_pages_view` | `counts` | `create` | | CE+EE | Number of viewed wiki pages |
| `wiki_pages_create` | `counts` | `create` | | CE+EE | Number of created wiki pages |
| `wiki_pages_update` | `counts` | `create` | | CE+EE | Number of updated wiki pages |
| `wiki_pages_delete` | `counts` | `create` | | CE+EE | Number of deleted wiki pages |
| `web_ide_commits` | `counts` | | | | |
| `web_ide_views` | `counts` | | | | |
| `web_ide_merge_requests` | `counts` | | | | |
......
......@@ -2,7 +2,7 @@
module Gitlab::UsageDataCounters
class WikiPageCounter < BaseCounter
KNOWN_EVENTS = %w[create update delete].freeze
KNOWN_EVENTS = %w[view create update delete].freeze
PREFIX = 'wiki_pages'
end
end
......@@ -3,11 +3,13 @@
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::WikiPageCounter do
it_behaves_like 'a redis usage counter', 'Wiki Page', :view
it_behaves_like 'a redis usage counter', 'Wiki Page', :create
it_behaves_like 'a redis usage counter', 'Wiki Page', :update
it_behaves_like 'a redis usage counter', 'Wiki Page', :delete
it_behaves_like 'a redis usage counter with totals', :wiki_pages,
view: 8,
create: 5,
update: 3,
delete: 2
......
......@@ -161,6 +161,14 @@ RSpec.shared_examples 'wiki controller actions' do
expect(assigns(:sidebar_limited)).to be(false)
end
it 'increases the page view counter' do
expect do
subject
expect(response).to have_gitlab_http_status(:ok)
end.to change { Gitlab::UsageDataCounters::WikiPageCounter.read(:view) }.by(1)
end
context 'when page content encoding is invalid' do
it 'sets flash error' do
allow(controller).to receive(:valid_encoding?).and_return(false)
......
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