2021-02-01 15:08:56 +00:00
|
|
|
# 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-19 15:09:08 +00:00
|
|
|
if Gitlab.com?
|
2021-05-19 09:10:19 +00:00
|
|
|
message = Gitlab::Email::Message::InProductMarketing.for(@track).new(group: group, user: current_user, series: @series)
|
2021-05-14 00:11:05 +00:00
|
|
|
|
2021-04-19 15:09:08 +00:00
|
|
|
data = {
|
|
|
|
namespace_id: group.id,
|
|
|
|
track: @track.to_s,
|
|
|
|
series: @series,
|
2021-05-14 00:11:05 +00:00
|
|
|
subject_line: message.subject_line
|
2021-04-19 15:09:08 +00:00
|
|
|
}
|
|
|
|
context = SnowplowTracker::SelfDescribingJson.new(EMAIL_CAMPAIGNS_SCHEMA_URL, data)
|
2021-02-01 15:08:56 +00:00
|
|
|
|
2021-06-02 03:09:51 +00:00
|
|
|
::Gitlab::Tracking.event(self.class.name, 'click', context: [context], user: current_user, namespace: group)
|
2021-04-19 15:09:08 +00:00
|
|
|
else
|
|
|
|
::Users::InProductMarketingEmail.save_cta_click(current_user, @track, @series)
|
|
|
|
end
|
2021-02-01 15:08:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def redirect_link
|
|
|
|
case @track
|
|
|
|
when :create
|
|
|
|
create_track_url
|
|
|
|
when :verify
|
|
|
|
project_pipelines_url(group.projects.first)
|
2021-08-03 12:09:42 +00:00
|
|
|
when :trial, :trial_short
|
2021-02-01 15:08:56 +00:00
|
|
|
'https://about.gitlab.com/free-trial/'
|
2021-07-28 15:09:57 +00:00
|
|
|
when :team, :team_short
|
2021-02-01 15:08:56 +00:00
|
|
|
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)
|
2021-05-19 09:10:19 +00:00
|
|
|
return render_404 unless track_valid
|
2021-02-01 15:08:56 +00:00
|
|
|
|
2021-05-19 09:10:19 +00:00
|
|
|
series_valid = @series.in?(0..Namespaces::InProductMarketingEmailsService::TRACKS[@track][:interval_days].size - 1)
|
|
|
|
render_404 unless series_valid
|
2021-02-01 15:08:56 +00:00
|
|
|
end
|
|
|
|
end
|