Commit 677c6329 authored by Alex Buijs's avatar Alex Buijs Committed by Kushal Pandya

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

parent 3c832e79
...@@ -2,20 +2,24 @@ ...@@ -2,20 +2,24 @@
class SurveyResponsesController < ApplicationController class SurveyResponsesController < ApplicationController
SURVEY_RESPONSE_SCHEMA_URL = 'iglu:com.gitlab/survey_response/jsonschema/1-0-0' 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! skip_before_action :authenticate_user!
feature_category :navigation feature_category :navigation
def index def index
track_response if Gitlab.com?
render layout: false render layout: false
end end
private private
def track_response def track_response
return unless Gitlab.dev_env_or_com?
data = { data = {
survey_id: to_number(params[:survey_id]), survey_id: to_number(params[:survey_id]),
instance_id: to_number(params[:instance_id]), instance_id: to_number(params[:instance_id]),
...@@ -34,4 +38,12 @@ class SurveyResponsesController < ApplicationController ...@@ -34,4 +38,12 @@ class SurveyResponsesController < ApplicationController
def to_number(param) def to_number(param)
param.to_i if param&.match?(/^\d+$/) param.to_i if param&.match?(/^\d+$/)
end 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 end
...@@ -3,9 +3,12 @@ ...@@ -3,9 +3,12 @@
!!! 5 !!! 5
%html{ lang: I18n.locale } %html{ lang: I18n.locale }
= render 'layouts/head' = render 'layouts/head'
%body.ui-indigo.d-flex.vh-100 %body.ui-indigo.gl-display-flex
= render 'layouts/header/logo_with_title' = render 'layouts/header/logo_with_title'
.container.pt-6.mw-100.text-center .container.gl-pt-8.gl-max-w-full.gl-text-center
.mt-9.mb-4= image_tag 'illustrations/subscription-success.svg' .gl-mt-11.gl-mb-6= image_tag 'illustrations/subscription-success.svg'
%h2.font-weight-bold= _('Thank you for your feedback!') %h2.gl-font-weight-bold= _('Thank you for your feedback!')
%p.pt-1= _('Your response has been recorded.') %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
...@@ -19385,6 +19385,9 @@ msgstr "" ...@@ -19385,6 +19385,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}." 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 "" msgstr ""
msgid "Let's talk!"
msgstr ""
msgid "License" msgid "License"
msgstr "" msgstr ""
...@@ -36096,6 +36099,9 @@ msgstr "" ...@@ -36096,6 +36099,9 @@ msgstr ""
msgid "We heard back from your device. You have been authenticated." msgid "We heard back from your device. You have been authenticated."
msgstr "" 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." 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 "" 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