Commit 184ae277 authored by Alex Buijs's avatar Alex Buijs

Add survey responses landing page

For in-app message surveys, add
a landing page for tracking responses
parent baa0c3d7
...@@ -129,6 +129,9 @@ Rails.application.routes.draw do ...@@ -129,6 +129,9 @@ Rails.application.routes.draw do
scope '/push_from_secondary/:geo_node_id' do scope '/push_from_secondary/:geo_node_id' do
draw :git_http draw :git_http
end end
# Used for survey responses
resources :survey_responses, only: :index
end end
if ENV['GITLAB_CHAOS_SECRET'] || Rails.env.development? || Rails.env.test? if ENV['GITLAB_CHAOS_SECRET'] || Rails.env.development? || Rails.env.test?
......
# frozen_string_literal: true
class SurveyResponsesController < ApplicationController
include Gitlab::Tracking::ControllerConcern
SURVEY_RESPONSE_SCHEMA_URL = 'iglu:com.gitlab/survey_response/jsonschema/1-0-0'
skip_before_action :authenticate_user!
def index
track_response if Gitlab.com?
render layout: false
end
private
def track_response
data = {
survey_id: to_number(params[:survey_id]),
instance_id: to_number(params[:instance_id]),
user_id: to_number(params[:user_id]),
email: params[:email],
name: params[:name],
username: params[:username],
response: params[:response]
}.compact
track_self_describing_event(SURVEY_RESPONSE_SCHEMA_URL, data)
end
def to_number(param)
param.to_i if param&.match?(/^\d+$/)
end
end
- page_title _('Survey Response')
!!! 5
%html{ lang: I18n.locale }
= render 'layouts/head'
%body.ui-indigo.d-flex.vh-100
= 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.')
---
title: Survey Responses landing page
merge_request: 29951
author:
type: added
# frozen_string_literal: true
require 'spec_helper'
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' do
expect(controller).to receive(:track_self_describing_event).with(
SurveyResponsesController::SURVEY_RESPONSE_SCHEMA_URL,
survey_id: 1,
response: 'bar'
)
subject
end
end
context 'not on GitLab.com' do
it 'does not track a survey_response event' do
expect(controller).not_to receive(:track_self_describing_event)
subject
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
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
...@@ -20429,6 +20429,9 @@ msgstr "" ...@@ -20429,6 +20429,9 @@ msgstr ""
msgid "Support page URL" msgid "Support page URL"
msgstr "" msgstr ""
msgid "Survey Response"
msgstr ""
msgid "Switch branch/tag" msgid "Switch branch/tag"
msgstr "" msgstr ""
...@@ -20710,6 +20713,9 @@ msgstr "" ...@@ -20710,6 +20713,9 @@ msgstr ""
msgid "Thank you for signing up for your free trial! You will get additional instructions in your inbox shortly." msgid "Thank you for signing up for your free trial! You will get additional instructions in your inbox shortly."
msgstr "" msgstr ""
msgid "Thank you for your feedback!"
msgstr ""
msgid "Thank you for your report. A GitLab administrator will look into it shortly." msgid "Thank you for your report. A GitLab administrator will look into it shortly."
msgstr "" msgstr ""
...@@ -24693,6 +24699,9 @@ msgstr "" ...@@ -24693,6 +24699,9 @@ msgstr ""
msgid "Your request for access has been queued for review." msgid "Your request for access has been queued for review."
msgstr "" msgstr ""
msgid "Your response has been recorded."
msgstr ""
msgid "Your search didn't match any commits." msgid "Your search didn't match any commits."
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