Commit 6dc228cb authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'add-cta-link-to-survey-responses-page' into 'master'

Add Calendly invite link to survey response page [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!61146
parents 3a779204 677c6329
......@@ -2,20 +2,24 @@
class SurveyResponsesController < ApplicationController
SURVEY_RESPONSE_SCHEMA_URL = 'iglu:com.gitlab/survey_response/jsonschema/1-0-0'
CALENDLY_INVITE_LINK = 'https://calendly.com/mkarampalas/gitlab-user-onboarding-research'
before_action :track_response, only: :index
before_action :set_invite_link, only: :index
skip_before_action :authenticate_user!
feature_category :navigation
def index
track_response if Gitlab.com?
render layout: false
end
private
def track_response
return unless Gitlab.dev_env_or_com?
data = {
survey_id: to_number(params[:survey_id]),
instance_id: to_number(params[:instance_id]),
......@@ -34,4 +38,12 @@ class SurveyResponsesController < ApplicationController
def to_number(param)
param.to_i if param&.match?(/^\d+$/)
end
def set_invite_link
return unless Gitlab.dev_env_or_com?
return unless Gitlab::Utils.to_boolean(params[:show_invite_link])
return unless Feature.enabled?(:calendly_invite_link)
@invite_link = CALENDLY_INVITE_LINK
end
end
......@@ -3,9 +3,12 @@
!!! 5
%html{ lang: I18n.locale }
= render 'layouts/head'
%body.ui-indigo.d-flex.vh-100
%body.ui-indigo.gl-display-flex
= render 'layouts/header/logo_with_title'
.container.pt-6.mw-100.text-center
.mt-9.mb-4= image_tag 'illustrations/subscription-success.svg'
%h2.font-weight-bold= _('Thank you for your feedback!')
%p.pt-1= _('Your response has been recorded.')
.container.gl-pt-8.gl-max-w-full.gl-text-center
.gl-mt-11.gl-mb-6= image_tag 'illustrations/subscription-success.svg'
%h2.gl-font-weight-bold= _('Thank you for your feedback!')
%p.gl-pt-2.gl-mb-0= _('Your response has been recorded.')
- if @invite_link
%p= _('We love speaking to our users. Got more to say about your GitLab experiences?')
%p.gl-pt-3= link_to _("Let's talk!"), @invite_link, target: '_blank', rel: 'noopener noreferrer', class: 'gl-button btn btn-confirm'
---
name: calendly_invite_link
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61146
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/330340
milestone: '13.12'
type: development
group: group::activation
default_enabled: false
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe SurveyResponsesController do
describe 'GET #index' do
subject { get :index, params: params }
let(:params) do
{
survey_id: '1',
instance_id: 'foo',
response: 'bar',
bla: 'bla'
}
end
context 'on GitLab.com' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
it 'tracks a survey_response event', :snowplow do
subject
expect_snowplow_event(
category: described_class.name,
action: 'submit_response',
context: [{ schema: described_class::SURVEY_RESPONSE_SCHEMA_URL, data: { response: 'bar', survey_id: 1 } }]
)
match_snowplow_context_schema(schema_path: 'survey_response_schema', context: { response: 'bar', survey_id: 1, instance_id: 2 } )
end
end
context 'not on GitLab.com' do
it 'does not track a survey_response event', :snowplow do
subject
expect_no_snowplow_event
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Responses' do
it 'shows a friendly message' do
visit survey_responses_path
expect(page).to have_text _('Thank you for your feedback!')
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe SurveyResponsesController do
describe 'GET #index' do
before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(ondotcom)
end
subject(:request) { get survey_responses_path(params) }
let(:ondotcom) { false }
let(:params) do
{
survey_id: '123',
instance_id: 'foo',
response: 'response text',
bla: 'bar',
show_invite_link: 'true'
}
end
describe 'tracking a snowplow event', :snowplow do
it 'does not track a survey_response event' do
request
expect_no_snowplow_event
end
context 'when on GitLab.com' do
let(:ondotcom) { true }
it 'tracks a survey_response event' do
request
expect_snowplow_event(
category: described_class.name,
action: 'submit_response',
context: [
{
schema: described_class::SURVEY_RESPONSE_SCHEMA_URL,
data:
{
survey_id: 123,
response: 'response text'
}
}
]
)
end
end
end
describe 'invite link' do
let(:ondotcom) { true }
let(:feature_flag_enabled) { true }
before do
stub_feature_flags(calendly_invite_link: feature_flag_enabled)
request
end
it { expect(assigns(:invite_link)).to eq(described_class::CALENDLY_INVITE_LINK) }
context 'when not on gitlab.com' do
let(:ondotcom) { false }
it { expect(assigns(:invite_link)).to be_nil }
end
context "when the 'calendly_invite_link' feature flag is disabled" do
let(:feature_flag_enabled) { false }
it { expect(assigns(:invite_link)).to be_nil }
end
context "when the 'invite_link' parameter is not present in the URL" do
let(:params) { }
it { expect(assigns(:invite_link)).to be_nil }
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'survey_responses/index' do
describe 'response page' do
it 'shows a friendly message' do
render
expect(rendered).to have_content(_('Thank you for your feedback!'))
expect(rendered).not_to have_content(_('We love speaking to our users. Got more to say about your GitLab experiences?'))
expect(rendered).not_to have_link(_("Let's talk!"))
end
context 'when invite_link instance variable is set' do
before do
assign(:invite_link, SurveyResponsesController::CALENDLY_INVITE_LINK)
end
it 'shows additional text and an invite link' do
render
expect(rendered).to have_content(_('We love speaking to our users. Got more to say about your GitLab experiences?'))
expect(rendered).to have_link(_("Let's talk!"), href: SurveyResponsesController::CALENDLY_INVITE_LINK)
end
end
end
end
......@@ -19388,6 +19388,9 @@ msgstr ""
msgid "Let's Encrypt is a free, automated, and open certificate authority (CA) that gives digital certificates in order to enable HTTPS (SSL/TLS) for websites. Learn more about Let's Encrypt configuration by following the %{docs_link_start}documentation on GitLab Pages%{docs_link_end}."
msgstr ""
msgid "Let's talk!"
msgstr ""
msgid "License"
msgstr ""
......@@ -36117,6 +36120,9 @@ msgstr ""
msgid "We heard back from your device. You have been authenticated."
msgstr ""
msgid "We love speaking to our users. Got more to say about your GitLab experiences?"
msgstr ""
msgid "We recommend cloud-based mobile authenticator apps such as Authy, Duo Mobile, and LastPass. They can restore access if you lose your hardware device."
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