Commit 6213f056 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'slack_service_usage_data' into 'master'

Log individual user usage of Slack service [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!54347
parents f8fe86e5 9f8d3b34
......@@ -97,9 +97,12 @@ class ChatNotificationService < Service
opts[:channel] = channels if channels.present?
opts[:username] = username if username
return false unless notify(message, opts)
if notify(message, opts)
log_usage(event_type, user_id_from_hook_data(data))
return true
end
true
false
end
def event_channel_names
......@@ -120,6 +123,10 @@ class ChatNotificationService < Service
private
def log_usage(_, _)
# Implement in child class
end
def labels_to_be_notified_list
return [] if labels_to_be_notified.nil?
......@@ -136,6 +143,10 @@ class ChatNotificationService < Service
(labels_to_be_notified_list & label_titles).any?
end
def user_id_from_hook_data(data)
data.dig(:user, :id) || data[:user_id]
end
# every notifier must implement this independently
def notify(message, opts)
raise NotImplementedError
......
......@@ -2,6 +2,12 @@
class SlackService < ChatNotificationService
include SlackMattermost::Notifier
extend ::Gitlab::Utils::Override
SUPPORTED_EVENTS_FOR_USAGE_LOG = %w[
push issue confidential_issue merge_request note confidential_note
tag_push wiki_page deployment
].freeze
prop_accessor EVENT_CHANNEL['alert']
......@@ -37,4 +43,15 @@ class SlackService < ChatNotificationService
super
end
override :log_usage
def log_usage(event, user_id)
return unless user_id
return unless SUPPORTED_EVENTS_FOR_USAGE_LOG.include?(event)
key = "i_ecosystem_slack_service_#{event}_notification"
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(key, values: user_id)
end
end
---
title: Log individual user usage of Slack service
merge_request: 54347
author:
type: changed
---
name: usage_data_track_ecosystem_slack_service
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/322588
milestone: '13.10'
type: development
group: group::ecosystem
default_enabled: false
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_issue_notification_monthly
description: Calculated unique users to trigger a Slack message by performing an action on an issue by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_push_notification_monthly
description: Calculated unique users to trigger a Slack message by performing a Git push by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_deployment_notification_monthly
description: Calculated unique users to trigger a Slack message by performing a deployment by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_wiki_page_notification_monthly
description: Calculated unique users to trigger a Slack message by performing an action on a wiki page by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_merge_request_notification_monthly
description: Calculated unique users to trigger a Slack message by performing an action on a merge request by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_note_notification_monthly
description: Calculated unique users to trigger a Slack message by creating a note by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_tag_push_notification_monthly
description: Calculated unique users to trigger a Slack message by performing a tag push by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_note_notification_monthly
description: Calculated unique users to trigger a Slack message by creating a confidential note by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_issue_notification_monthly
description: Calculated unique users to trigger a Slack message by performing an action on a confidential issue by month
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 28d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_issue_notification_weekly
description: Calculated unique users to trigger a Slack message by performing an action on an issue by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_push_notification_weekly
description: Calculated unique users to trigger a Slack message by performing a Git push by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_deployment_notification_weekly
description: Calculated unique users to trigger a Slack message by performing a deployment by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_wiki_page_notification_weekly
description: Calculated unique users to trigger a Slack message by performing an action on a wiki page by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_merge_request_notification_weekly
description: Calculated unique users to trigger a Slack message by performing an action on a merge request by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_note_notification_weekly
description: Calculated unique users to trigger a Slack message by creating a note by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_tag_push_notification_weekly
description: Calculated unique users to trigger a Slack message by performing a tag push by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_note_notification_weekly
description: Calculated unique users to trigger a Slack message by creating a confidential note by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_issue_notification_weekly
description: Calculated unique users to trigger a Slack message by performing an action on a confidential issue by week
product_section: dev
product_stage: create
product_group: group::ecosystem
product_category: integrations
value_type: number
status: implemented
milestone: "13.10"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54347
time_frame: 7d
data_source: redis_hll
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
......@@ -9524,6 +9524,222 @@ Status: `data_available`
Tiers:
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_issue_notification_monthly`
Calculated unique users to trigger a Slack message by performing an action on a confidential issue by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303152233_i_ecosystem_slack_service_confidential_issue_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_issue_notification_weekly`
Calculated unique users to trigger a Slack message by performing an action on a confidential issue by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302104814_i_ecosystem_slack_service_confidential_issue_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_note_notification_monthly`
Calculated unique users to trigger a Slack message by creating a confidential note by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303152144_i_ecosystem_slack_service_confidential_note_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_confidential_note_notification_weekly`
Calculated unique users to trigger a Slack message by creating a confidential note by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302104556_i_ecosystem_slack_service_confidential_note_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_deployment_notification_monthly`
Calculated unique users to trigger a Slack message by performing a deployment by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303150912_i_ecosystem_slack_service_deployment_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_deployment_notification_weekly`
Calculated unique users to trigger a Slack message by performing a deployment by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302103755_i_ecosystem_slack_service_deployment_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_issue_notification_monthly`
Calculated unique users to trigger a Slack message by performing an action on an issue by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303150507_i_ecosystem_slack_service_issue_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_issue_notification_weekly`
Calculated unique users to trigger a Slack message by performing an action on an issue by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302103002_i_ecosystem_slack_service_issue_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_merge_request_notification_monthly`
Calculated unique users to trigger a Slack message by performing an action on a merge request by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303151831_i_ecosystem_slack_service_merge_request_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_merge_request_notification_weekly`
Calculated unique users to trigger a Slack message by performing an action on a merge request by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302104007_i_ecosystem_slack_service_merge_request_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_note_notification_monthly`
Calculated unique users to trigger a Slack message by creating a note by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303151946_i_ecosystem_slack_service_note_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_note_notification_weekly`
Calculated unique users to trigger a Slack message by creating a note by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302104047_i_ecosystem_slack_service_note_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_push_notification_monthly`
Calculated unique users to trigger a Slack message by performing a Git push by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303150654_i_ecosystem_slack_service_push_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_push_notification_weekly`
Calculated unique users to trigger a Slack message by performing a Git push by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302103629_i_ecosystem_slack_service_push_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_tag_push_notification_monthly`
Calculated unique users to trigger a Slack message by performing a tag push by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303152049_i_ecosystem_slack_service_tag_push_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_tag_push_notification_weekly`
Calculated unique users to trigger a Slack message by performing a tag push by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302104144_i_ecosystem_slack_service_tag_push_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_wiki_page_notification_monthly`
Calculated unique users to trigger a Slack message by performing an action on a wiki page by month
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210303151609_i_ecosystem_slack_service_wiki_page_notification_monthly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ecosystem.i_ecosystem_slack_service_wiki_page_notification_weekly`
Calculated unique users to trigger a Slack message by performing an action on a wiki page by week
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_7d/20210302103907_i_ecosystem_slack_service_wiki_page_notification_weekly.yml)
Group: `group::ecosystem`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `redis_hll_counters.ide_edit.g_edit_by_sfe_monthly`
Missing description
......
......@@ -20,3 +20,49 @@
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_jira_service
- name: i_ecosystem_slack_service_issue_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_push_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_deployment_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_wiki_page_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_merge_request_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_note_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_tag_push_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_confidential_note_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
- name: i_ecosystem_slack_service_confidential_issue_notification
category: ecosystem
redis_slot: ecosystem
aggregation: weekly
feature_flag: usage_data_track_ecosystem_slack_service
......@@ -4,4 +4,116 @@ require 'spec_helper'
RSpec.describe SlackService do
it_behaves_like "slack or mattermost notifications", 'Slack'
describe '#execute' do
before do
stub_request(:post, "https://slack.service.url/")
end
let_it_be(:slack_service) { create(:slack_service, branches_to_be_notified: 'all') }
it 'uses only known events', :aggregate_failures do
described_class::SUPPORTED_EVENTS_FOR_USAGE_LOG.each do |action|
expect(Gitlab::UsageDataCounters::HLLRedisCounter.known_event?("i_ecosystem_slack_service_#{action}_notification")).to be true
end
end
context 'hook data includes a user object' do
let_it_be(:user) { create_default(:user) }
let_it_be(:project) { create_default(:project, :repository, :wiki_repo) }
shared_examples 'increases the usage data counter' do |event_name|
it 'increases the usage data counter' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(event_name, values: user.id).and_call_original
slack_service.execute(data)
end
end
context 'event is not supported for usage log' do
let_it_be(:pipeline) { create(:ci_pipeline) }
let(:data) { Gitlab::DataBuilder::Pipeline.build(pipeline) }
it 'does not increase the usage data counter' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event).with('i_ecosystem_slack_service_pipeline_notification', values: user.id)
slack_service.execute(data)
end
end
context 'issue notification' do
let_it_be(:issue) { create(:issue) }
let(:data) { issue.to_hook_data(user) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_issue_notification'
end
context 'push notification' do
let(:data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_push_notification'
end
context 'deployment notification' do
let_it_be(:deployment) { create(:deployment, user: user) }
let(:data) { Gitlab::DataBuilder::Deployment.build(deployment) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_deployment_notification'
end
context 'wiki_page notification' do
let_it_be(:wiki_page) { create(:wiki_page, wiki: project.wiki, message: 'user created page: Awesome wiki_page') }
let(:data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_wiki_page_notification'
end
context 'merge_request notification' do
let_it_be(:merge_request) { create(:merge_request) }
let(:data) { merge_request.to_hook_data(user) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_merge_request_notification'
end
context 'note notification' do
let_it_be(:issue_note) { create(:note_on_issue, note: 'issue note') }
let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_note_notification'
end
context 'tag_push notification' do
let(:oldrev) { Gitlab::Git::BLANK_SHA }
let(:newrev) { '8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b' } # gitlab-test: git rev-parse refs/tags/v1.1.0
let(:ref) { 'refs/tags/v1.1.0' }
let(:data) { Git::TagHooksService.new(project, user, change: { oldrev: oldrev, newrev: newrev, ref: ref }).send(:push_data) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_tag_push_notification'
end
context 'confidential note notification' do
let_it_be(:confidential_issue_note) { create(:note_on_issue, note: 'issue note', confidential: true) }
let(:data) { Gitlab::DataBuilder::Note.build(confidential_issue_note, user) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_confidential_note_notification'
end
context 'confidential issue notification' do
let_it_be(:issue) { create(:issue, confidential: true) }
let(:data) { issue.to_hook_data(user) }
it_behaves_like 'increases the usage data counter', 'i_ecosystem_slack_service_confidential_issue_notification'
end
end
context 'hook data does not include a user' do
let(:data) { Gitlab::DataBuilder::Pipeline.build(create(:ci_pipeline)) }
it 'does not increase the usage data counter' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
slack_service.execute(data)
end
end
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