debian-mirror-gitlab/app/controllers/groups/email_campaigns_controller.rb

66 lines
1.7 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
class Groups::EmailCampaignsController < Groups::ApplicationController
EMAIL_CAMPAIGNS_SCHEMA_URL = 'iglu:com.gitlab/email_campaigns/jsonschema/1-0-0'
feature_category :navigation
before_action :check_params
def index
track_click
redirect_to redirect_link
end
private
def track_click
2021-04-29 21:17:54 +05:30
if Gitlab.com?
2021-06-08 01:23:25 +05:30
message = Gitlab::Email::Message::InProductMarketing.for(@track).new(group: group, series: @series)
2021-04-29 21:17:54 +05:30
data = {
namespace_id: group.id,
track: @track.to_s,
series: @series,
2021-06-08 01:23:25 +05:30
subject_line: message.subject_line
2021-04-29 21:17:54 +05:30
}
context = SnowplowTracker::SelfDescribingJson.new(EMAIL_CAMPAIGNS_SCHEMA_URL, data)
::Gitlab::Tracking.event(self.class.name, 'click', context: [context])
else
::Users::InProductMarketingEmail.save_cta_click(current_user, @track, @series)
end
2021-03-11 19:13:27 +05:30
end
def redirect_link
case @track
when :create
create_track_url
when :verify
project_pipelines_url(group.projects.first)
when :trial
'https://about.gitlab.com/free-trial/'
when :team
group_group_members_url(group)
end
end
def create_track_url
[
new_project_url,
new_project_url(anchor: 'import_project'),
help_page_url('user/project/repository/repository_mirroring')
][@series]
end
def check_params
@track = params[:track]&.to_sym
@series = params[:series]&.to_i
track_valid = @track.in?(Namespaces::InProductMarketingEmailsService::TRACKS.keys)
series_valid = @series.in?(0..Namespaces::InProductMarketingEmailsService::INTERVAL_DAYS.size - 1)
render_404 unless track_valid && series_valid
end
end