Skip to content

Commit

Permalink
feat(surveys): Improved survey creation flow (#17902)
Browse files Browse the repository at this point in the history
* create edit survey components for feature flagging

* visual type picker

* organization

* move previews into tooltips

* targeting

* sync preview and accordion

* better presentation view

* Update UI snapshots for `chromium` (2)

* fix migration file lint

* Update UI snapshots for `chromium` (2)

* make collapse panel header easier to see

* label question index

* more fixes

* update

* surveys new creation flow flag

* fix linter spacing

* form appearance file

* Update UI snapshots for `chromium` (2)

* fix

* fix

* Update UI snapshots for `chromium` (2)

* fix targeting

* fix cypress tests

* black

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Li Yi Yu <[email protected]>
Co-authored-by: Neil Kakkar <[email protected]>
  • Loading branch information
4 people authored Oct 16, 2023
1 parent e94ea2a commit 27e183b
Show file tree
Hide file tree
Showing 26 changed files with 1,899 additions and 768 deletions.
4 changes: 4 additions & 0 deletions cypress/e2e/surveys.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ describe('Surveys', () => {
cy.get('[data-attr="survey-preview"]').find('form').find('.ratings-number').should('have.length', 5)

// add targeting filters
cy.get('.LemonCollapsePanel').contains('Targeting').click()
cy.contains('All users').click()
cy.get('.Popover__content').contains('Users who match').click()
cy.contains('Add user targeting').click()

// select the first property
Expand Down Expand Up @@ -156,6 +159,7 @@ describe('Surveys', () => {
cy.get('.Popover__content').contains('Edit').click()

// remove user targeting properties
cy.get('.LemonCollapsePanel').contains('Targeting').click()
cy.contains('Remove all user properties').click()

// save
Expand Down
1 change: 1 addition & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ beforeEach(() => {
decideResponse({
// set feature flags here e.g.
// 'toolbar-launch-side-action': true,
'surveys-new-creation-flow': true,
'surveys-results-visualizations': true,
'auto-redirect': true,
notebooks: true,
Expand Down
6 changes: 0 additions & 6 deletions ee/clickhouse/views/test/test_clickhouse_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def test_creating_updating_basic_experiment(self):
self.assertEqual(experiment.end_date.strftime("%Y-%m-%dT%H:%M"), end_date)

def test_adding_behavioral_cohort_filter_to_experiment_fails(self):

cohort = Cohort.objects.create(
team=self.team,
filters={
Expand Down Expand Up @@ -739,7 +738,6 @@ def test_creating_experiment_with_group_aggregation_parameter(self):
self.assertEqual(created_ff.filters["aggregation_group_type_index"], 0)

def test_used_in_experiment_is_populated_correctly_for_feature_flag_list(self) -> None:

ff_key = "a-b-test"
response = self.client.post(
f"/api/projects/{self.team.id}/experiments/",
Expand Down Expand Up @@ -945,7 +943,6 @@ def test_create_experiment_updates_feature_flag_cache(self):
class ClickhouseTestFunnelExperimentResults(ClickhouseTestMixin, APILicensedTest):
@snapshot_clickhouse_queries
def test_experiment_flow_with_event_results(self):

journeys_for(
{
"person1": [
Expand Down Expand Up @@ -1031,7 +1028,6 @@ def test_experiment_flow_with_event_results(self):

@snapshot_clickhouse_queries
def test_experiment_flow_with_event_results_with_hogql_aggregation(self):

journeys_for(
{
"person1": [
Expand Down Expand Up @@ -1150,7 +1146,6 @@ def test_experiment_flow_with_event_results_with_hogql_aggregation(self):
self.assertAlmostEqual(response_data["expected_loss"], 1, places=2)

def test_experiment_flow_with_event_results_cached(self):

journeys_for(
{
"person1": [
Expand Down Expand Up @@ -1248,7 +1243,6 @@ def test_experiment_flow_with_event_results_cached(self):

@snapshot_clickhouse_queries
def test_experiment_flow_with_event_results_and_events_out_of_time_range_timezones(self):

journeys_for(
{
"person1": [
Expand Down
1 change: 1 addition & 0 deletions ee/session_recordings/session_recording_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

MINIMUM_AGE_FOR_RECORDING = timedelta(hours=24)


# TODO rename this...
def save_recording_with_new_content(recording: SessionRecording, content: str) -> str:
if not settings.OBJECT_STORAGE_ENABLED:
Expand Down
Binary file modified frontend/__snapshots__/scenes-app-surveys--new-survey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export const FEATURE_FLAGS = {
WEBHOOKS_DENYLIST: 'webhooks-denylist', // owner: #team-pipeline
SURVEYS_MULTIPLE_QUESTIONS: 'surveys-multiple-questions', // owner: @liyiy
SURVEYS_RESULTS_VISUALIZATIONS: 'surveys-results-visualizations', // owner: @jurajmajerik
SURVEYS_NEW_CREATION_FLOW: 'surveys-new-creation-flow', // owner: @liyiy
CONSOLE_RECORDING_SEARCH: 'console-recording-search', // owner: #team-monitoring
PERSONS_HOGQL_QUERY: 'persons-hogql-query', // owner: @mariusandra
} as const
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/scenes/notebooks/Nodes/NotebookNodeSurvey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ const Component = ({ attributes }: NotebookNodeProps<NotebookNodeSurveyAttribute
? survey.questions[0].link
: undefined
}
readOnly={true}
onAppearanceChange={() => {}}
/>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/scenes/surveys/EditSurvey.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.presentation-preview .CodeSnippet__actions {
display: none;
}

.SurveyForm {
.LemonCollapsePanel__header {
background: var(--border-light);
}
}
969 changes: 969 additions & 0 deletions frontend/src/scenes/surveys/EditSurveyNew.tsx

Large diffs are not rendered by default.

547 changes: 547 additions & 0 deletions frontend/src/scenes/surveys/EditSurveyOld.tsx

Large diffs are not rendered by default.

569 changes: 11 additions & 558 deletions frontend/src/scenes/surveys/Survey.tsx

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions frontend/src/scenes/surveys/SurveyAPIEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function SurveyAPIEditor({ survey }: { survey: Survey | NewSurvey }): JSX
id: survey.id,
name: survey.name,
description: survey.description,
type: survey.type,
type: 'api',
linked_flag_key: survey.linked_flag ? survey.linked_flag.key : null,
targeting_flag_key: survey.targeting_flag ? survey.targeting_flag.key : null,
questions: survey.questions,
Expand All @@ -18,11 +18,8 @@ export function SurveyAPIEditor({ survey }: { survey: Survey | NewSurvey }): JSX
}

return (
<div className="flex flex-col">
<h4 className="text-center">API survey response</h4>
<CodeSnippet wrap language={Language.JSON}>
{JSON.stringify(apiSurvey, null, 2)}
</CodeSnippet>
</div>
<CodeSnippet wrap language={Language.JSON}>
{JSON.stringify(apiSurvey, null, 2)}
</CodeSnippet>
)
}
Loading

0 comments on commit 27e183b

Please sign in to comment.